body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1rem;
    background: radial-gradient(circle at top right, #1e1b4b, var(--background));
    overflow-x: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 1.25rem auto;
}

.back-btn {
    background: transparent;
    border: none;
    padding: 0.3rem 0;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}
.back-btn:hover { color: var(--text); }

.hud {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--surface-glass);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--surface-border);
    font-weight: 700;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}
.hud-score  { color: #3b82f6; }
.hud-combo  { color: #f97316; }
.hud-lives  { color: #ef4444; }
.hud-best   { color: #f59e0b; }

.game-container {
    flex: 1;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.4s ease forwards;
}
.screen.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

h1 {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.4rem;
    text-align: center;
    line-height: 1.1;
}
h1 .title-emoji {
    -webkit-text-fill-color: initial;
    background: none;
}
.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    text-align: center;
    max-width: 520px;
}

/* ── Mode menu (fallback when no ?mode= in URL) ── */
.mode-groups { width: 100%; max-width: 720px; }

.mode-group-title {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin: 1.25rem 0 0.6rem 0;
}
.mode-group-title:first-of-type { margin-top: 0; }

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
    margin-bottom: 0.5rem;
}

.mode-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.1rem 1rem;
    cursor: pointer;
    text-align: left;
    color: var(--text);
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: all 0.2s ease;
}
.mode-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(139, 92, 246, 0.18);
}
.mode-card .mode-title { font-size: 1.02rem; font-weight: 800; }
.mode-card .mode-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.mode-card .mode-best {
    margin-top: 0.3rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #f59e0b;
    font-variant-numeric: tabular-nums;
}
.mode-card.mode-hangul       { border-left: 4px solid #8b5cf6; }
.mode-card.mode-beginner     { border-left: 4px solid #10b981; }
.mode-card.mode-intermediate { border-left: 4px solid #f59e0b; }
.mode-card.mode-advanced     { border-left: 4px solid #ef4444; }

.controls-hint {
    margin-top: 1.75rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
}

/* ── Prompt banner ── */
.prompt-banner {
    width: 100%;
    max-width: 520px;
    background: var(--surface-glass);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.1rem;
    text-align: center;
    margin-bottom: 1rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
.prompt-context {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.2rem;
}
.prompt-main {
    font-size: 1.9rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1.15;
}

/* ── Mole board ── */
.mole-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    touch-action: manipulation;
}

.hole {
    position: relative;
    aspect-ratio: 1 / 0.92;
    overflow: hidden;
    border-radius: 0 0 50% 50% / 0 0 28% 28%;
    background:
        radial-gradient(ellipse 80% 55% at 50% 118%, #0b0b12 0 55%, transparent 60%),
        linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.18));
}

/* The dirt rim drawn in FRONT of the mole so it appears to emerge from the ground */
.hole::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -14%;
    width: 116%;
    height: 46%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: linear-gradient(180deg, #5b3a1d 0%, #432a14 60%, #2e1c0d 100%);
    box-shadow: inset 0 6px 10px rgba(0,0,0,0.45), 0 -3px 6px rgba(0,0,0,0.3);
    z-index: 3;
    pointer-events: none;
}

.mole {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 8%;
    margin: 0 auto;
    height: 74%;
    border: none;
    border-radius: 46% 46% 38% 38%;
    background: linear-gradient(180deg, #a78bfa 0%, #8b5cf6 70%, #7c3aed 100%);
    color: #fff;
    font-family: var(--font-kr);
    font-weight: 800;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.4rem 0.3rem 0.5rem;
    line-height: 1.1;
    word-break: keep-all;
    transform: translateY(125%);
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
    box-shadow: inset 0 -8px 10px rgba(0,0,0,0.22), inset 0 6px 8px rgba(255,255,255,0.18);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.mole.up { transform: translateY(0); }

/* little ears + eyes so it reads as a critter */
.mole::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 22%;
    right: 22%;
    height: 16%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 50%, #1f2937 0 22%, transparent 26%),
        radial-gradient(circle at 70% 50%, #1f2937 0 22%, transparent 26%);
    opacity: 0.85;
    pointer-events: none;
}

.mole.correct {
    background: linear-gradient(180deg, #34d399 0%, #10b981 70%, #059669 100%);
    animation: bonk 0.35s ease;
}
.mole.wrong {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 70%, #dc2626 100%);
    animation: wobble 0.4s ease;
}
.mole.reveal {
    background: linear-gradient(180deg, #34d399 0%, #10b981 70%, #059669 100%);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.6), inset 0 -8px 10px rgba(0,0,0,0.22);
}

@keyframes bonk {
    0% { transform: translateY(0) scale(1); }
    40% { transform: translateY(14%) scale(0.86, 1.12); }
    100% { transform: translateY(0) scale(1); }
}
@keyframes wobble {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(0) rotate(-5deg); }
    75% { transform: translateY(0) rotate(5deg); }
}

/* floating combo splash */
.combo-splash {
    position: absolute;
    left: 50%;
    top: -10px;
    transform: translateX(-50%);
    font-weight: 900;
    font-size: 1.1rem;
    color: #f97316;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 6;
    animation: floatUp 0.7s ease forwards;
}
@keyframes floatUp {
    0% { opacity: 0; transform: translate(-50%, 6px) scale(0.7); }
    30% { opacity: 1; transform: translate(-50%, -6px) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -28px) scale(1); }
}

/* ── Game over ── */
#screen-gameover { padding-top: 3rem; text-align: center; align-items: center; }
.gameover-icon { font-size: 5rem; margin-bottom: 0.5rem; }
#gameover-title { font-size: 2rem; margin-bottom: 0.5rem; }
#gameover-message {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
    white-space: pre-line;
}
.gameover-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; }

.primary-btn, .secondary-btn {
    border: none;
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: var(--font-ui);
    transition: transform 0.2s, background 0.2s;
}
.primary-btn { background: var(--primary); color: white; }
.primary-btn:hover { transform: scale(1.05); background: var(--accent); }
.secondary-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--surface-border);
}
.secondary-btn:hover { background: rgba(255, 255, 255, 0.06); }

@media (max-width: 480px) {
    h1 { font-size: 2.2rem; }
    .prompt-main { font-size: 1.5rem; }
    .mole { font-size: 1rem; }
    .mole-board { gap: 0.45rem; }
}
