/* --- General Styles --- */
html,
body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: Arial, sans-serif;
    background-color: #121213;
    color: var(--ti-dark-grey);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

body #bmc-wbtn {
    height: 48px !important;
    width: 48px !important;
}

/* Header */

.game-header {
    text-align: center;
    padding: 5px;
}

.header-text {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--ti-dark-grey);
    text-transform: uppercase;
    letter-spacing: 3px;
    position: relative;
    display: inline-block;
}

.header-text.animate {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.sub-header {
    font-size: 1rem;
    color: var(--ti-light-grey);
    /* Soft white-gray color */
    margin-top: -10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
        /* Normal size */
    }

    15% {
        transform: scale(1.4);
        /* First pulse (boink) */
    }

    40% {
        transform: scale(1.2);
        /* Second, stronger pulse (boink) */
    }

    60% {
        transform: scale(1.4);
        /* After the second pulse, return to a smaller boink */
    }

    85% {
        transform: scale(1);
        /* Return to normal size, ready for the next cycle */
    }
}

.game-container {
    text-align: center;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    margin-top: -50px;
}

/* --- Board --- */
#board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

#board div {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    border: 1px solid var(--ti-dark-grey);
    text-transform: uppercase;
    background-color: #edede9;
    color: var(--ti-dark-grey);
}

/* --- Keyboard --- */
.keyboard-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Keyboard rows */
.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Individual key */
.key {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #FFF;
    background-color: var(--ti-dark-grey);
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.key-wide {
    width: 80px;
}

.key:hover {
    background-color: var(--ti-light-grey);
}

.key:active {
    transform: scale(0.95);
}


/* --- Feedback Colors --- */
#board div.correct,
.key.correct {
    background-color: #8ac926;
}

#board div.present,
.key.present {
    background-color: #f48c06;
}

#board div.absent,
.key.absent {
    background-color: #adb5bd;
}

#board div.lie,
.key.lie {
    background: linear-gradient(to right, #8ac926 33.33%, #f48c06 33.33%, #f48c06 66.66%, #adb5bd 66.66%);
}

/* Guesses effect */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-10px);
    }

    40%,
    80% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.5s;
}

@keyframes colorChange {
    0% {
        background-color: #8ac926;
        /* Green */
    }

    100% {
        background-color: #ffca3a;
        /* Yellow */
    }
}

.celebrate {
    animation: colorChange 0.2s ease-in-out;
}

/* Modal Background */
.modal {
    display: none;
    /* Initially hidden */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease-in-out;
}

/* Modal Content */
.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 400px;
    margin: 0 20px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.modal-content.left {
    text-align: left;
}

.modal-content .left {
    text-align: left;
    color: var(--ti-light-grey);
    text-transform: uppercase;
}

/* Show the modal */
.modal.show {
    display: flex;
    opacity: 1;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

/* Button Styling */
.modal button {
    margin-top: 10px;
    padding: 10px 20px;
    background-color: var(--ti-yellow);
    border: none;
    border-radius: 15px;
    color: var(--ti-dark-grey);
    cursor: pointer;
}

.modal button:hover {
    background-color: var(--ti-dark-grey);
    color: var(--ti-yellow);
}

/* Make leaderboard link yellow like buttons */
#endModal .modal-message a,
#endModal .modal-content a {
    color: var(--ti-yellow);
    font-weight: bold;
}

#endModal .modal-message a:hover,
#endModal .modal-content a:hover {
    color: #e0a800;
    text-decoration: none;
}

/* banner  */
.banner {
    background-color: white;
    opacity: 80%;
    color: var(--ti-dark-grey);
    text-align: center;
    padding: 0.5rem;
    font-size: 1.0rem;
    position: fixed;
    top: 0;
    max-width: 100%;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* Hidden state */
.banner.hide {
    opacity: 0;
    visibility: hidden;
}

.big-emoji {
    font-style: normal;
    font-size: 1.5rem;
}

/* footer */
.footer {
    bottom: 0;
    width: 100%;
    color: var(--ti-light-grey);
    text-align: center;
    padding: 15px;
    font-size: 0.8rem;
}

.footer a {
    color: var(--ti-light-grey);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Score chart */
.chart {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 100%;
    height: 200px;
    padding: 10px;
}

/* Wrapper for each bar to hold the label on the left */
.bar-container {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

/* Label on the left */
.label {
    width: 40px;
    text-align: right;
    margin-right: 10px;
    font-weight: bold;
}

/* Style for each bar */
.bar {
    width: 0;
    /* Start with 0 width */
    height: 15px;
    /* Reduced bar height */
    background-color: var(--ti-yellow);
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    color: var(--ti-dark-grey);
    padding-right: 2px;
    box-sizing: border-box;
    transition: width 0.5s ease-in-out;
}

/* Stats */
.stats {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-item {
    text-align: center;
}

.stat-item .value {
    font-size: 30px;
    font-weight: bold;
    color: var(--ti-yellow)
}

.stat-item .label {
    font-size: 10px;
    color: gray;
}

/* modes */
.mode-tabs {
    display: flex;
    overflow: hidden;
    font-family: sans-serif;
    background-color: var(--ti-yellow);
    max-width: 50%;
    margin: 10px auto;
}

.mode-tab {
    flex: 1;
    padding: 6px 10px;
    border: 1.5px solid #333;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: #333;
    transition: background-color 0.2s;
}

.mode-tab.active {
    background-color: var(--ti-dark-grey);
    color: var(--ti-yellow);
}

.mode-tab:disabled {
    cursor: not-allowed;
    opacity: 0.75;
}

.mode-tab:focus {
    outline: none;
}

/* caution banner */
.caution-banner {
    background-color: #f44336;
    /* Red background */
    color: white;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 4px;
    width: auto;
    margin: 10px auto;
    text-align: center;
}

.caution-text {
    font-weight: bold;
}

/* global statistics */
.global-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
    margin: 0.7em 0 0.5em 0;
    padding: 1em 0.5em 0.7em 0.5em;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

.global-stats-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 1.5em;
}

.global-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.global-stat-label {
    font-size: 12px;
    color: gray;
    font-weight: 600;
}

.global-stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--ti-yellow);
    border-radius: 5px;
    padding: 0.13em 0.7em;
    margin-top: 0.08em;
    min-width: 2.2em;
    text-align: center;
}

.global-stats-note {
    text-align: center;
    font-size: 0.98em;
    color: #3a4a5a;
    margin-top: 0.5em;
    margin-bottom: 0.2em;
    font-style: italic;
    letter-spacing: 0.01em;
    opacity: 0.7;
}

.global-stats-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    font-weight: 500;
    color: #222;
}

.global-stats-summary-main {
    color: var(--ti-yellow);
    font-size: 1.5em;
    font-weight: bold;
    margin: 0 0.2em;
}

.global-stats-summary-label {
    color: #666;
    font-size: 0.98em;
    margin: 0 0.1em;
}

.outage-banner {
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    background: var(--ti-dark-grey);
    color: var(--ti-yellow);
    text-align: center;
    font-weight: 600;
    padding: 12px 0;
    font-size: 1.1em;
}

.leaderboard-row {
    display: flex;
    gap: 32px;
    justify-content: center;
    margin-bottom: 24px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.leaderboard-panel {
    flex: 1 1 320px;
    min-width: 350px;
    max-width: 450px;
    background: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.leaderboard-title {
    text-align: center;
    font-size: 1.28em;
    font-weight: 700;
    margin-bottom: 12px;
    color: #555;
    letter-spacing: 0.5px;
}

.leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f7f7fa;
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 10px 18px;
    box-shadow: 0 1px 4px #0001;
    transition: box-shadow 0.2s;
}

.leaderboard-item.top {
    background: #ede7f6;
    box-shadow: 0 2px 8px #b39ddb44;
    font-weight: 600;
}

.leaderboard-name {
    font-size: 1.08em;
    color: #333;
    font-weight: 500;
}

.leaderboard-score {
    font-size: 1.05em;
    color: #888;
    font-weight: 400;
}

.rank-badge {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-weight: 700;
    font-size: 1em;
    margin-right: 10px;
    color: #fff;
}

.rank-1 {
    background: #ffd600;
    color: #bfa100;
}

.rank-2 {
    background: #bdbdbd;
    color: #757575;
}

.rank-3 {
    background: #ff8a65;
    color: #fff;
}

.rank-other {
    background: #e0e0e0;
    color: #888;
}


@media (max-width: 1200px) {
    .leaderboard-row {
        gap: 16px;
        max-width: 98vw;
    }

    .leaderboard-panel {
        max-width: 99vw;
    }
}

@media (max-width: 900px) {
    .leaderboard-row {
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
    }

    .leaderboard-panel {
        max-width: 100%;
    }
}

/* User Info and Username Form */
#current-user-info {
    margin: 18px 0 0 0;
    text-align: center;
    font-size: 1.em;
    color: #555;
}

#username-form {
    margin: 10px auto 0 auto;
    display: flex;
    justify-content: center;
    gap: 8px;
    align-items: center;
    max-width: 400px;
}

#username-input {
    padding: 7px 14px;
    border-radius: 7px;
    border: 1.5px solid #b39ddb;
    font-size: 1.08em;
    width: 210px;
    outline: none;
    transition: border 0.2s;
}

#username-form button {
    padding: 7px 20px;
    border-radius: 7px;
    border: none;
    background: black;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-size: 1.08em;
    box-shadow: 0 1px 4px #b39ddb22;
    transition: background 0.2s;
}