* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(45deg, #1a5276 0%, #2e86c1 40%, #48c9b0 75%, #58d68d 100%);
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: white;
    overflow-x: hidden;
    padding: 1rem;
}

.game-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 500px;
    width: 100%;
    text-align: center;
    position: relative;
}

.header {
    position: relative;
    z-index: 20;
    flex-shrink: 0;
}

.title {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 255, 255, 0.3); }
    to { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 255, 255, 0.5); }
}

.navigation {
    margin-bottom: 0.8rem;
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-button {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    font-size: 0.75rem;
    backdrop-filter: blur(5px);
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: white;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.new-game-button,
.share-button,
.control-button {
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    touch-action: manipulation;
    flex: 1;
    min-width: 0;
    max-width: 120px;
}

.new-game-button {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
}

.share-button {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
}

.control-button {
    background: linear-gradient(45deg, #8e44ad, #9b59b6);
}

.new-game-button:active,
.share-button:active,
.control-button:active {
    transform: scale(0.95);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.game-mode-selector {
    position: relative;
    z-index: 1;
    margin-bottom: 0.8rem;
    display: flex;
    gap: 0.4rem;
    justify-content: center;
}

.mode-button {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.3);
    touch-action: manipulation;
}

.mode-button.active {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.mode-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.game-content {
    position: relative;
    z-index: 1;
}

.game-info {
    position: relative;
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.guess-count {
    font-size: 0.9rem;
    font-weight: bold;
    color: #ffeb3b;
}

.closest-distance {
    font-size: 0.8rem;
    color: #e0e0e0;
    font-weight: bold;
}

.message {
    position: relative;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.6rem;
    margin-bottom: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
}

.message.success {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
    animation: pulse 0.5s ease-in-out;
}

.message.error {
    background: rgba(244, 67, 54, 0.3);
    border-color: rgba(244, 67, 54, 0.5);
    animation: shake 0.5s ease-in-out;
}

.message.info {
    background: rgba(255, 193, 7, 0.3);
    border-color: rgba(255, 193, 7, 0.5);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Guess input with autocomplete suggestions */
.guess-input-section {
    position: relative;
    z-index: 30;
    margin-bottom: 0.8rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    gap: 0.4rem;
}

#guessInput {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0.9rem;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

#guessInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#guessInput:focus {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.22);
}

#guessButton {
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    background: linear-gradient(45deg, #2980b9, #3498db);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

#guessButton:active {
    transform: scale(0.95);
}

.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: rgba(20, 35, 50, 0.96);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    max-height: 216px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    text-align: left;
}

.suggestion-item {
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.15s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background: rgba(46, 204, 113, 0.25);
}

/* The 3D globe */
.globe-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    aspect-ratio: 1 / 0.95;
    margin-bottom: 0.8rem;
    border-radius: 12px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 42%, rgba(10, 35, 60, 0.55), rgba(5, 15, 30, 0.75));
    border: 1px solid rgba(255, 255, 255, 0.2);
    touch-action: none;
}

.globe-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.globe-wrap canvas:active {
    cursor: grabbing;
}

.globe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    animation: loadingPulse 1.2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Guess chips list (closest first) */
.guess-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
    max-height: 130px;
    overflow-y: auto;
    padding: 0.1rem;
}

.guess-chip {
    padding: 0.35rem 0.6rem;
    border-radius: 14px;
    font-size: 0.72rem;
    font-weight: bold;
    border: 1px solid rgba(0, 0, 0, 0.25);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

/* Bottom stats */
.bottom-section {
    flex-shrink: 0;
}

.stats {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 70px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffd700;
}

.stat-label {
    font-size: 0.65rem;
    color: #e0e0e0;
    margin-top: 0.25rem;
}

/* Stats Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #2c2c2e;
    color: #fff;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    position: relative;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.modal-close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.distribution-grid {
    display: grid;
    gap: 8px;
    margin-top: 15px;
    text-align: left;
}

.dist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

.dist-item > span {
    min-width: 22px;
    text-align: right;
}

.dist-bar {
    background-color: #4a4a4c;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: right;
    min-width: 25px;
    transition: width 0.5s ease-in-out;
}

.dist-bar.highlight {
    background-color: #538d4e; /* Green for the current game's guess count */
}

/* Mobile-specific optimizations */
@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .game-container {
        border-radius: 0;
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 0.8rem;
    }

    .title {
        font-size: 1.6rem;
        margin-bottom: 0.4rem;
    }

    .navigation {
        margin-bottom: 0.6rem;
        gap: 0.3rem;
    }

    .nav-button {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .button-container {
        gap: 0.3rem;
        margin-bottom: 0.6rem;
    }

    .new-game-button,
    .share-button,
    .control-button {
        padding: 0.5rem 0.6rem;
        font-size: 0.65rem;
        border-radius: 12px;
        letter-spacing: 0.3px;
        max-width: 100px;
    }

    .game-mode-selector {
        margin-bottom: 0.6rem;
        gap: 0.3rem;
    }

    .mode-button {
        padding: 0.35rem 0.7rem;
        font-size: 0.75rem;
    }

    .game-info {
        margin-bottom: 0.6rem;
        padding: 0.5rem;
    }

    .guess-count {
        font-size: 0.85rem;
    }

    .closest-distance {
        font-size: 0.75rem;
    }

    .message {
        font-size: 0.8rem;
        padding: 0.5rem;
        margin-bottom: 0.6rem;
        min-height: 35px;
    }

    #guessInput {
        padding: 0.6rem 0.8rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    #guessButton {
        padding: 0.6rem 0.8rem;
        font-size: 0.7rem;
    }

    .guess-chips {
        max-height: 110px;
        gap: 0.3rem;
    }

    .guess-chip {
        font-size: 0.68rem;
        padding: 0.3rem 0.5rem;
    }

    .stats {
        gap: 0.6rem;
    }

    .stat-item {
        padding: 0.35rem 0.5rem;
        min-width: 65px;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .game-container {
        padding: 0.6rem;
    }

    .title {
        font-size: 1.4rem;
    }

    .new-game-button,
    .share-button,
    .control-button {
        padding: 0.45rem 0.5rem;
        font-size: 0.6rem;
        max-width: 85px;
    }

    .stats-grid {
        gap: 10px;
    }
}


/* ============================================================
   Kit A header (shared brand with the home hub)
   ============================================================ */

@font-face {
    font-family: 'Righteous';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/assets/fonts/righteous.woff2') format('woff2');
}

@font-face {
    font-family: 'Silkscreen';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/assets/fonts/silkscreen-700.woff2') format('woff2');
}

.nav-mini {
    display: flex;
    width: max-content;
    align-items: center;
    gap: 5px;
    background: linear-gradient(90deg, #ffb700, #ffd700);
    border: none;
    border-radius: 999px;
    padding: 7px 13px 7px 9px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #241a3d;
    text-decoration: none;
    margin-bottom: 0.6rem;
    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
}

.nav-mini svg path {
    stroke: #241a3d;
}

.nav-mini:hover {
    background: linear-gradient(90deg, #ffc61a, #ffe14d);
}

.lockup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    margin-bottom: 0.9rem;
}

.badge {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    flex: none;
}

.lockup-text {
    text-align: left;
}

.game-name {
    font-family: 'Righteous', 'Arial Rounded MT Bold', Arial, sans-serif;
    font-size: 23px;
    font-weight: 400;
    letter-spacing: 1.5px;
    line-height: 1;
    margin: 0;
    animation: none;
    text-shadow: 1px 2px 5px rgba(0, 0, 0, 0.45);
}

.game-tag {
    font-family: 'Silkscreen', 'Courier New', monospace;
    font-weight: 700;
    font-size: 8px;
    letter-spacing: 2px;
    margin-top: 3px;
    color: #ffe36e;
}

/* Unified action pills: one glass shape, a color dot per action */
.new-game-button,
.share-button,
.control-button,
.definition-button,
.game-button {
    border: none;
    border-radius: 999px;
    color: #ffffff;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    max-width: none;
}

.share-button { background: linear-gradient(45deg, #27ae60, #2ecc71); }
.control-button { background: linear-gradient(45deg, #8e44ad, #b06ee0); }
.new-game-button { background: linear-gradient(45deg, #d94a3a, #ff7a6e); }
.definition-button { background: linear-gradient(45deg, #3d8fe8, #5aa9ff); }
.game-button { background: linear-gradient(45deg, #e08e1f, #f2a33c); }

/* Segmented mode control, gold active */
.game-mode-selector {
    display: flex;
    background: rgba(10, 10, 25, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 0.8rem;
}

.mode-button,
.difficulty-button {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 999px;
    padding: 8px 4px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.8);
    box-shadow: none;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.2s ease, color 0.2s ease;
}

.mode-button:hover,
.difficulty-button:hover {
    transform: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.1);
}

.mode-button.active,
.difficulty-button.active {
    background: linear-gradient(90deg, #ffb700, #ffd700);
    color: #241a3d;
    box-shadow: none;
}

.mode-button.active:hover,
.difficulty-button.active:hover {
    background: linear-gradient(90deg, #ffb700, #ffd700);
}

/* Tap-to-identify pin and popup */
.globe-pin {
    position: absolute;
    z-index: 40;
    transform: translate(-50%, -100%);
    pointer-events: none;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

.globe-pop {
    position: absolute;
    z-index: 41;
    transform: translate(-50%, -100%);
    display: flex;
    align-items: center;
    gap: 9px;
    background: rgba(10, 10, 25, 0.94);
    border: 1px solid rgba(255, 215, 0, 0.5);
    border-radius: 12px;
    padding: 8px 9px 8px 13px;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.globe-pop-text {
    text-align: left;
}

.globe-pop-name {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
}

.globe-pop-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 1px;
}

.globe-pop-guess {
    background: linear-gradient(90deg, #ffb700, #ffd700);
    border: none;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #241a3d;
    cursor: pointer;
    touch-action: manipulation;
}

.globe-pop-guess:active {
    transform: scale(0.95);
}

.globe-pop-close {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    width: 26px;
    height: 26px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    touch-action: manipulation;
    flex: none;
}

/* First-time hint: countries are tappable */
.globe-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 39;
    background: rgba(10, 10, 25, 0.85);
    border: 1px solid rgba(255, 215, 0, 0.45);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 11.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    pointer-events: none;
    animation: hintPulse 2.4s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .globe-hint {
        animation: none;
    }
}
