@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: #f0fdf4;
    background-image: url('../img/background2.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== GLOBAL CONTROLS (menu/result - wood style) ===== */
.global-controls {
    position: fixed;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 200;
}

.global-controls .ctrl-btn {
    width: 44px;
    height: 44px;
    padding: 6px;
}

.global-controls .ctrl-btn svg {
    width: 24px;
    height: 24px;
}

.global-controls.hidden {
    display: none;
}

/* ===== MENU CARD ===== */
.menu-frame {
    background: #8B5A2B;
    padding: 12px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    max-width: 420px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 24px);
    border: 4px solid #5C3A21;
    position: relative;
}

.menu-inner {
    background: #FDF5E6;
    padding: 24px;
    border-radius: 16px;
    border: 2px solid #DEB887;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
}

.menu-logo {
    width: 100%;
    height: auto;
    margin-bottom: 16px;
}

.menu-desc {
    color: #5C3A21;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
}

/* ===== DIFFICULTY BUTTONS ===== */
.diff-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
    width: 100%;
}

.diff-btn {
    flex: 1 1 30%;
    min-width: 30%;
    padding: 8px 4px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.diff-btn.easy { background: #16a34a; }
.diff-btn.medium { background: #65a30d; }
.diff-btn.advanced { background: #eab308; }
.diff-btn.hard { background: #f97316; }
.diff-btn.extreme { background: #dc2626; }

.diff-btn:hover {
    opacity: 1;
    filter: brightness(1.1);
}

.diff-btn:not(.active) {
    opacity: 0.8;
}

.diff-btn.active {
    opacity: 1;
    filter: brightness(1.1);
    box-shadow: 0 0 0 2px #FDF5E6, 0 0 0 4px #8B5A2B;
}

.diff-info {
    background: #E8D8B7;
    color: #5C3A21;
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 16px;
    width: 100%;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #D4C4A1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

/* ===== PRIMARY BUTTON ===== */
.btn-start {
    width: 100%;
    padding: 12px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-start:hover {
    filter: brightness(1.1);
}

.btn-online {
    width: 100%;
    padding: 10px;
    background: #8B5A2B;
    color: #FDF5E6;
    border: 3px solid #5C3A21;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.btn-online:hover { filter: brightness(1.15); }
.btn-online svg { stroke: #facc15; }

.btn-stats {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: #8B5A2B;
    border: 2px solid #DEB887;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}

.btn-stats:hover { background: #E8D8B7; }
.btn-stats svg { stroke: #8B5A2B; }

/* ===== STATS OVERLAY ===== */
.stats-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    animation: statsIn 0.25s ease-out;
    overflow-y: auto;
    padding: 16px;
}

.stats-overlay.visible {
    display: flex;
}

@keyframes statsIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.stats-frame {
    max-width: 480px;
    width: 100%;
}

.stats-section {
    width: 100%;
    margin-bottom: 16px;
}

.stats-subtitle {
    font-size: 14px;
    font-weight: 800;
    color: #8B5A2B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 2px solid #DEB887;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.stats-table th {
    background: #E8D8B7;
    color: #5C3A21;
    font-weight: 700;
    padding: 6px 8px;
    text-align: center;
    font-size: 11px;
    text-transform: uppercase;
}

.stats-table th:first-child {
    text-align: left;
    border-radius: 6px 0 0 0;
}

.stats-table th:last-child {
    border-radius: 0 6px 0 0;
}

.stats-table td {
    padding: 6px 8px;
    text-align: center;
    color: #5C3A21;
    border-bottom: 1px solid #E8D8B7;
    font-weight: 500;
}

.stats-table td:first-child {
    text-align: left;
    font-weight: 700;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table .best-time {
    color: #16a34a;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.stats-table .no-data {
    color: #c4a882;
}

.stats-online-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.stats-online-item {
    background: #E8D8B7;
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    border: 1px solid #D4C4A1;
}

.stats-online-value {
    font-size: 24px;
    font-weight: 900;
    font-family: 'Kalam', cursive;
    color: #5C3A21;
}

.stats-online-label {
    font-size: 10px;
    font-weight: 700;
    color: #8B5A2B;
    text-transform: uppercase;
}

.stats-online-item.wins .stats-online-value { color: #16a34a; }
.stats-online-item.losses .stats-online-value { color: #dc2626; }
.stats-online-item.draws .stats-online-value { color: #eab308; }

.stats-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.btn-stats-reset {
    flex: 1;
    padding: 10px;
    background: transparent;
    color: #dc2626;
    border: 2px solid #dc2626;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-stats-reset:hover {
    background: #dc2626;
    color: #fff;
}

.btn-stats-close {
    flex: 1;
    padding: 10px;
    background: #16a34a;
    color: #fff;
    border: 2px solid transparent;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-stats-close:hover {
    filter: brightness(1.1);
}

/* Stats Reset Overlay */
.stats-reset-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    z-index: 10;
    animation: fadeIn 0.2s;
}

.stats-reset-dialog {
    background: #FDF5E6;
    padding: 24px;
    border-radius: 12px;
    border: 3px solid #dc2626;
    text-align: center;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.stats-reset-dialog p {
    color: #5C3A21;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 24px;
}

.stats-reset-actions {
    display: flex;
    gap: 12px;
}

.btn-stats-cancel {
    flex: 1;
    padding: 10px;
    background: #8B5A2B;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.btn-stats-confirm {
    flex: 1;
    padding: 10px;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.btn-stats-cancel:hover, .btn-stats-confirm:hover {
    filter: brightness(1.15);
}

.btn-start svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* ===== GAME SCREEN ===== */
#game-screen.visible {
    justify-content: flex-start;
    align-items: stretch;
}

/* ===== TOP BAR ===== */
.top-bar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 0;
    z-index: 10;
    flex-shrink: 0;
    width: 100%;
}

@media (min-width: 640px) {
    .top-bar { padding: 8px 32px 0; }
}

.timer-box {
    background: #8B5A2B;
    border: 4px solid #5C3A21;
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

.timer-text {
    color: #facc15;
    font-size: 24px;
    font-weight: 700;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.target-box {
    background: #FDF5E6;
    border: 4px solid #5C3A21;
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-width: 140px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.target-label {
    font-size: 11px;
    font-weight: 700;
    color: #5C3A21;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.target-number {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Kalam', cursive;
    color: #dc2626;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.controls {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ctrl-btn {
    background: #8B5A2B;
    border: 4px solid #5C3A21;
    border-radius: 9999px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.ctrl-btn:hover {
    filter: brightness(1.1);
}

.ctrl-btn:active {
    transform: scale(0.95);
}

.ctrl-btn svg {
    width: 28px;
    height: 28px;
    stroke-width: 3;
}

.ctrl-btn.restart svg { color: #a4c639; }
.ctrl-btn.home svg { color: #facc15; }
.ctrl-btn.music svg { color: #22d3ee; }
.ctrl-btn.sfx svg { color: #a3e635; }
.ctrl-btn.lang svg { color: #facc15; }
.ctrl-btn.lang { width: auto; padding: 8px 12px; gap: 4px; }
.lang-label {
    color: #facc15;
    font-weight: 800;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ===== GAME BOARD ===== */
.game-board {
    position: relative;
    flex: 1;
    overflow: hidden;
    margin: 0 16px 16px;
    border-radius: 24px;
    border: 4px solid #5C3A21;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    background-color: #FDF5E6;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 39px,
        rgba(92,58,33,0.05) 39px,
        rgba(92,58,33,0.05) 40px
    );
    transition: background-color 0.2s;
    user-select: none;
    -webkit-user-select: none;
    min-height: 0;
    width: auto;
}

.game-board.penalty {
    background-color: #f87171;
    background-image: none;
}

/* ===== NUMBER ITEMS ===== */
.number-item {
    position: absolute;
    cursor: pointer;
    font-family: 'Kalam', cursive;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.3s;
}

.number-item.found {
    pointer-events: none;
}

.number-value {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    position: relative;
}

.number-circle {
    position: absolute;
    inset: 0;
    border: 3px solid #ef4444;
    border-radius: 45% 55% 40% 60% / 55% 45% 60% 40%;
    opacity: 0;
    transform: scale(1.5);
    transition: all 0.3s ease-out;
    pointer-events: none;
    z-index: 20;
}

.number-item.found .number-circle {
    opacity: 1;
    transform: scale(1);
}

/* Colored circles per player */
.number-item.found-p0 .number-circle { border-color: #ef4444; opacity: 1; transform: scale(1); }
.number-item.found-p1 .number-circle { border-color: #22c55e; opacity: 1; transform: scale(1); }
.number-item.found-p2 .number-circle { border-color: #3b82f6; opacity: 1; transform: scale(1); }
.number-item.found-p3 .number-circle { border-color: #f59e0b; opacity: 1; transform: scale(1); }
.number-item.found-p4 .number-circle { border-color: #a855f7; opacity: 1; transform: scale(1); }
.number-item.found-p5 .number-circle { border-color: #06b6d4; opacity: 1; transform: scale(1); }

/* ===== COUNTDOWN OVERLAY ===== */
.countdown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.countdown-number {
    font-size: 120px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 60px rgba(22, 163, 74, 0.4);
    animation: countdown-pulse 0.8s ease-out;
    font-family: 'Kalam', cursive;
}

@keyframes countdown-pulse {
    0% {
        transform: scale(2);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== GAME OVER SCREEN ===== */
.result-frame {
    background: #8B5A2B;
    padding: 12px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    max-width: 420px;
    width: calc(100% - 32px);
    border: 4px solid #5C3A21;
    position: relative;
}

.result-inner {
    background: #FDF5E6;
    padding: 32px;
    border-radius: 16px;
    border: 2px solid #DEB887;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.trophy-icon {
    color: #eab308;
    margin-bottom: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.trophy-icon svg {
    width: 80px;
    height: 80px;
}

.result-title {
    font-size: 36px;
    font-weight: 800;
    color: #4A7C2A;
    margin-bottom: 8px;
}

.result-subtitle {
    color: #5C3A21;
    font-weight: 500;
    margin-bottom: 24px;
}

.time-result-box {
    background: #E8D8B7;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    width: 100%;
    border: 1px solid #D4C4A1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.time-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #8B5A2B;
    margin-bottom: 4px;
}

.time-value {
    font-size: 48px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 800;
    color: #4A7C2A;
    text-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.result-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-replay {
    width: 100%;
    padding: 16px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-replay:hover { filter: brightness(1.1); }

.btn-menu-back {
    width: 100%;
    padding: 10px;
    background: #f97316;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-menu-back:hover { filter: brightness(1.1); }

/* ===== SCORE BOX (online, n-player) ===== */
.score-box {
    background: #8B5A2B;
    border: 4px solid #5C3A21;
    border-radius: 12px;
    padding: 4px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 2px;
    justify-content: center;
    white-space: nowrap;
}

.score-entry {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(253,245,230,0.1);
    cursor: default;
}

.score-entry.is-me {
    background: rgba(253,245,230,0.25);
}

.score-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.score-name {
    font-size: 10px;
    font-weight: 700;
    color: #FDF5E6;
    text-transform: uppercase;
    white-space: nowrap;
}

.score-val {
    font-size: 18px;
    font-weight: 800;
    font-family: 'Kalam', cursive;
    color: #FDF5E6;
}

/* ===== TOAST NOTIFICATION ===== */
.game-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(92, 58, 33, 0.95);
    color: #FDF5E6;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.game-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== RESULT SCREEN ===== */
.result-frame {
    background: #8B5A2B;
    padding: 12px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    max-width: 420px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 24px);
    border: 4px solid #5C3A21;
}

.result-inner {
    background: #FDF5E6;
    padding: 28px 24px;
    border-radius: 16px;
    border: 2px solid #DEB887;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
}

.trophy-icon {
    color: #d4a017;
    margin-bottom: 4px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.result-title {
    font-family: 'Kalam', cursive;
    font-size: 32px;
    font-weight: 700;
    color: #5C3A21;
    margin-bottom: 4px;
}

.result-subtitle {
    font-size: 14px;
    color: #8B5A2B;
    margin-bottom: 16px;
}

.time-result-box {
    background: rgba(139, 90, 43, 0.08);
    border: 2px solid #DEB887;
    border-radius: 14px;
    padding: 16px 24px;
    margin-bottom: 20px;
    width: 100%;
}

.time-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #8B5A2B;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.time-value {
    font-family: 'Kalam', cursive;
    font-size: 42px;
    font-weight: 700;
    color: #5C3A21;
}

/* ===== ONLINE RANKING (result) ===== */
.online-ranking {
    width: 100%;
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 4px;
    background: rgba(139, 90, 43, 0.06);
    border: 1px solid transparent;
}

.ranking-row.is-me {
    background: rgba(139, 90, 43, 0.12);
    border-color: #DEB887;
}

.ranking-row:first-child {
    background: rgba(234, 179, 8, 0.12);
    border-color: #eab308;
}

.ranking-pos {
    font-family: 'Kalam', cursive;
    font-size: 22px;
    font-weight: 700;
    color: #8B5A2B;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.ranking-row:first-child .ranking-pos {
    color: #eab308;
}

.ranking-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ranking-name {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: #5C3A21;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-score {
    font-family: 'Kalam', cursive;
    font-size: 26px;
    font-weight: 700;
    color: #5C3A21;
    flex-shrink: 0;
}

.ranking-row:first-child .ranking-score {
    color: #eab308;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* ===== LOBBY ===== */
.lobby-frame {
    max-width: 440px;
    max-height: calc(100vh - 24px);
}

.lobby-title {
    font-size: 24px;
    font-weight: 800;
    color: #5C3A21;
    margin-bottom: 8px;
}

.lobby-desc {
    font-size: 13px;
    color: #8B5A2B;
    margin-bottom: 20px;
    line-height: 1.4;
}

.lobby-buttons-row {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-bottom: 16px;
}

.btn-gold {
    flex: 1;
    padding: 18px 12px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-gold:hover {
    filter: brightness(1.1);
}

.btn-gold:active {
    transform: scale(0.98);
}

/* ===== PLAYER COUNT SELECTOR ===== */
.player-count-section {
    width: 100%;
    margin-bottom: 16px;
}

.player-count-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #5C3A21;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.player-count-btns {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.pc-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 3px solid #DEB887;
    background: #E8D8B7;
    color: #5C3A21;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Kalam', cursive;
}

.pc-btn:hover {
    border-color: #8B5A2B;
    background: #DEB887;
}

.pc-btn.active {
    background: #8B5A2B;
    color: #facc15;
    border-color: #5C3A21;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== WAITING COUNTDOWN ===== */
.waiting-countdown {
    background: #E8D8B7;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid #D4C4A1;
    font-size: 14px;
    font-weight: 700;
    color: #5C3A21;
    margin-bottom: 12px;
    text-align: center;
}

.waiting-countdown-value {
    font-family: 'Kalam', cursive;
    font-size: 22px;
    font-weight: 700;
    color: #dc2626;
    margin: 0 4px;
}

/* ===== WAITING PLAYER LIST ===== */
.waiting-player-list {
    width: 100%;
    margin-bottom: 12px;
}

.waiting-player-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #E8D8B7;
    border-radius: 8px;
    margin-bottom: 4px;
    border: 1px solid #D4C4A1;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.waiting-player-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.waiting-player-name {
    font-size: 14px;
    font-weight: 700;
    color: #5C3A21;
}

.lobby-name-row {
    width: 100%;
    text-align: left;
    margin-bottom: 12px;
}

.lobby-name-row label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #5C3A21;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.lobby-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #DEB887;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #5C3A21;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.lobby-input:focus {
    border-color: #8B5A2B;
}

.lobby-divider {
    width: 100%;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #8B5A2B;
    text-transform: uppercase;
    margin: 16px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lobby-divider::before,
.lobby-divider::after {
    content: '';
    flex: 1;
    height: 2px;
    background: #DEB887;
}

.room-list {
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.room-list-empty {
    text-align: center;
    color: #aaa;
    font-size: 14px;
    padding: 16px;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #E8D8B7;
    border-radius: 10px;
    margin-bottom: 6px;
    border: 1px solid #D4C4A1;
}

.room-host {
    font-weight: 700;
    color: #5C3A21;
}

.room-players {
    font-size: 12px;
    font-weight: 600;
    color: #8B5A2B;
    background: rgba(139, 90, 43, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

.room-join-btn {
    padding: 6px 16px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: filter 0.2s;
}

.room-join-btn:hover { filter: brightness(1.1); }

.connection-status {
    font-size: 12px;
    color: #8B5A2B;
    margin-top: 8px;
    min-height: 18px;
}

/* Waiting */
.waiting-spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #DEB887;
    border-top-color: #8B5A2B;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 16px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.waiting-text {
    font-size: 16px;
    font-weight: 700;
    color: #5C3A21;
    margin-bottom: 12px;
}

.room-code-display {
    background: #E8D8B7;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #D4C4A1;
    text-align: center;
}

.room-code-value {
    display: block;
    font-size: 28px;
    font-weight: 900;
    color: #8B5A2B;
    letter-spacing: 0.15em;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 4px;
}

/* Checkbox */
.lobby-checkbox-row {
    width: 100%;
    margin-bottom: 12px;
}

.lobby-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #5C3A21;
    cursor: pointer;
}

.lobby-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #8B5A2B;
    cursor: pointer;
}

/* Invite Link */
.invite-link-display {
    margin-top: 12px;
    width: 100%;
}

.invite-link-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #DEB887;
    border-radius: 8px;
    font-size: 12px;
    color: #5C3A21;
    background: #fff;
    margin-bottom: 8px;
    outline: none;
}

.copy-invite-btn {
    width: 100%;
    padding: 10px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: filter 0.2s;
}

.copy-invite-btn:hover { filter: brightness(1.1); }


/* ===== SVG ICON HELPERS ===== */
.icon { display: inline-flex; align-items: center; }

/* ===== RESPONSIVE / MOBILE ===== */

/* Scrollable screens on small heights (portrait phones) */
@media (max-height: 700px) {
    .screen.visible {
        justify-content: flex-start;
        overflow-y: auto;
        padding: 16px 0;
    }

    #game-screen.visible {
        overflow: hidden;
        padding: 0;
    }

    .menu-frame, .result-frame {
        margin: auto;
    }

    .menu-logo {
        margin-bottom: 12px;
    }

    .menu-desc {
        margin-bottom: 12px;
        font-size: 12px;
    }

    .diff-info {
        margin-bottom: 16px;
        padding: 8px;
        font-size: 12px;
    }

    .btn-start {
        padding: 12px;
        font-size: 18px;
    }

    .btn-online {
        padding: 10px;
        font-size: 16px;
    }

    .result-inner {
        padding: 20px;
    }

    .trophy-icon svg {
        width: 50px;
        height: 50px;
    }

    .trophy-icon {
        margin-bottom: 12px;
    }

    .result-title {
        font-size: 28px;
    }

    .time-result-box {
        padding: 16px;
        margin-bottom: 20px;
    }

    .time-value {
        font-size: 36px;
    }
}

/* Small screens (phones) */
@media (max-width: 480px) {
    .top-bar {
        height: auto;
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 8px 4px;
    }

    .timer-box {
        padding: 4px 10px;
        min-width: 70px;
        border-width: 3px;
    }

    .timer-text {
        font-size: 18px;
    }

    .target-box {
        padding: 4px 10px;
        min-width: auto;
        gap: 6px;
        border-width: 3px;
    }

    .target-label {
        font-size: 9px;
    }

    .target-number {
        font-size: 22px;
    }

    .score-box {
        padding: 3px 6px;
        gap: 4px;
        border-width: 3px;
        max-width: 280px;
    }

    .score-name {
        font-size: 9px;
        max-width: 36px;
    }

    .score-val {
        font-size: 15px;
    }

    .score-dot {
        width: 6px;
        height: 6px;
    }

    .score-entry {
        padding: 1px 4px;
        gap: 2px;
    }

    .controls {
        gap: 4px;
    }

    .ctrl-btn {
        width: 36px;
        height: 36px;
        border-width: 3px;
        padding: 5px;
    }

    .ctrl-btn svg {
        width: 20px;
        height: 20px;
    }

    .ctrl-btn.lang {
        padding: 5px 8px;
    }

    .lang-label {
        font-size: 12px;
    }

    .game-board {
        margin: 0 6px 6px;
        border-radius: 16px;
        border-width: 3px;
    }

    .menu-frame {
        padding: 8px;
        border-width: 3px;
        border-radius: 18px;
    }

    .menu-inner {
        padding: 16px;
        border-radius: 12px;
    }

    .diff-btn {
        padding: 6px 2px;
        font-size: 12px;
        border-radius: 8px;
    }

    .btn-start {
        padding: 12px;
        font-size: 18px;
        border-radius: 12px;
    }

    .btn-online {
        padding: 10px;
        font-size: 16px;
        border-radius: 12px;
    }

    .btn-gold {
        padding: 10px 6px;
        font-size: 14px;
        border-radius: 12px;
    }

    .countdown-number {
        font-size: 80px;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .menu-inner { padding: 12px; }

    .top-bar { padding: 4px 6px 2px; }

    .timer-box { padding: 3px 8px; min-width: 60px; }
    .timer-text { font-size: 16px; }

    .target-box { padding: 3px 8px; }
    .target-label { font-size: 8px; }
    .target-number { font-size: 20px; }

    .ctrl-btn { width: 32px; height: 32px; }
    .ctrl-btn svg { width: 18px; height: 18px; }

    .game-board { margin: 0 4px 4px; border-radius: 12px; }

    .diff-btn { font-size: 11px; min-width: 28%; }

    .menu-logo { margin-bottom: 8px; }
    .menu-desc { font-size: 11px; margin-bottom: 8px; }
    .diff-info { font-size: 11px; padding: 6px; margin-bottom: 12px; }
}

/* Desktop larger screens */
@media (min-width: 640px) {
    .diff-btn { font-size: 16px; }
    .top-bar { padding: 8px 32px 0; }
}

/* Short viewport (landscape phones, small windows) */
@media (max-height: 500px) {
    /* Menu */
    .menu-inner { padding: 12px 16px; }
    .menu-logo { margin-bottom: 6px; max-height: 60px; object-fit: contain; }
    .menu-desc { font-size: 11px; margin-bottom: 6px; }
    .diff-grid { gap: 4px; margin-bottom: 6px; }
    .diff-btn { padding: 5px 4px; font-size: 12px; }
    .diff-info { padding: 6px; margin-bottom: 8px; font-size: 11px; }
    .btn-start { padding: 8px; font-size: 14px; }
    .btn-online { padding: 6px; font-size: 13px; margin-top: 4px; }
    .btn-stats { padding: 4px; font-size: 12px; margin-top: 4px; }

    /* Lobby */
    .lobby-title { font-size: 18px; margin-bottom: 4px; }
    .lobby-desc { font-size: 11px; margin-bottom: 8px; }
    .btn-gold { padding: 10px 8px; font-size: 13px; }
    .player-count-section { margin-bottom: 8px; }
    .pc-btn { width: 36px; height: 36px; font-size: 15px; }
    .lobby-buttons-row { margin-bottom: 8px; gap: 8px; }

    /* Result */
    .result-inner { padding: 16px 14px; }
    .trophy-icon svg { width: 50px; height: 50px; }
    .result-title { font-size: 24px; }
    .result-subtitle { margin-bottom: 8px; font-size: 12px; }
    .time-result-box { padding: 10px 16px; margin-bottom: 12px; }
    .time-value { font-size: 32px; }
    .btn-replay { padding: 10px; font-size: 16px; }
    .btn-menu-back { padding: 7px; font-size: 13px; }
    .ranking-row { padding: 5px 10px; }

    /* Stats */
    .stats-section { margin-bottom: 8px; }
    .stats-subtitle { font-size: 12px; margin-bottom: 4px; }
    .stats-table { font-size: 11px; }
    .stats-table th { padding: 4px 6px; font-size: 10px; }
    .stats-table td { padding: 4px 6px; }
    .stats-online-item { padding: 6px 4px; }
    .stats-online-value { font-size: 20px; }
    .stats-online-label { font-size: 9px; }
    .stats-online-grid { gap: 4px; }
    .btn-stats-reset, .btn-stats-close { padding: 7px; font-size: 12px; }
    .stats-reset-dialog { padding: 16px; }
    .stats-reset-dialog p { font-size: 14px; margin-bottom: 16px; }
}

@media (max-height: 380px) {
    /* Menu */
    .menu-inner { padding: 8px 12px; }
    .menu-logo { max-height: 40px; margin-bottom: 4px; }
    .menu-desc { display: none; }
    .diff-grid { gap: 3px; margin-bottom: 4px; }
    .diff-btn { padding: 4px 3px; font-size: 11px; border-radius: 8px; }
    .diff-info { padding: 4px; margin-bottom: 6px; font-size: 10px; }
    .btn-start { padding: 6px; font-size: 13px; border-radius: 10px; }
    .btn-online { padding: 5px; font-size: 12px; margin-top: 3px; }
    .btn-stats { padding: 3px; font-size: 11px; margin-top: 3px; }

    /* Lobby */
    .lobby-title { font-size: 16px; margin-bottom: 2px; }
    .lobby-desc { display: none; }
    .btn-gold { padding: 8px 6px; font-size: 12px; border-radius: 8px; }
    .player-count-section { margin-bottom: 4px; }
    .player-count-label { font-size: 10px; margin-bottom: 4px; }
    .pc-btn { width: 32px; height: 32px; font-size: 14px; border-radius: 8px; }
    .lobby-buttons-row { margin-bottom: 4px; gap: 6px; }
    .waiting-countdown { padding: 4px 10px; font-size: 12px; }

    /* Result */
    .result-inner { padding: 10px 10px; }
    .trophy-icon { margin-bottom: 0; }
    .trophy-icon svg { width: 36px; height: 36px; }
    .result-title { font-size: 20px; margin-bottom: 2px; }
    .result-subtitle { margin-bottom: 4px; font-size: 11px; }
    .time-result-box { padding: 6px 10px; margin-bottom: 8px; }
    .time-value { font-size: 26px; }
    .btn-replay { padding: 7px; font-size: 14px; border-radius: 10px; }
    .btn-menu-back { padding: 5px; font-size: 12px; }
    .result-buttons { gap: 6px; }
    .ranking-row { padding: 4px 8px; font-size: 13px; }

    /* Stats */
    .stats-section { margin-bottom: 4px; }
    .stats-subtitle { font-size: 11px; margin-bottom: 2px; padding-bottom: 2px; }
    .stats-table { font-size: 10px; }
    .stats-table th { padding: 3px 4px; font-size: 9px; }
    .stats-table td { padding: 3px 4px; }
    .stats-online-grid { gap: 3px; }
    .stats-online-item { padding: 4px 3px; border-radius: 6px; }
    .stats-online-value { font-size: 16px; }
    .stats-online-label { font-size: 8px; }
    .btn-stats-reset, .btn-stats-close { padding: 5px; font-size: 11px; border-radius: 8px; }
    .stats-buttons { margin-top: 2px; gap: 6px; }
    .stats-reset-dialog { padding: 12px; }
    .stats-reset-dialog p { font-size: 13px; margin-bottom: 12px; }
}
