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

/* ── Dark / Matrix theme (default) ── */
:root,
[data-theme="dark"] {
    --bg: #000000;
    --surface: #0a0a0a;
    --surface-2: #111111;
    --text: #00ff41;
    --text-dim: #1a6b2a;
    --text-bright: #33ff66;
    --pin-bg: #050505;
    --pin-border: #0d3b15;
    --pin-locked-bg: #0a1a0a;
    --correct: #00ff41;
    --hot: #ff2020;
    --warm: #cc8800;
    --cold: #2080cc;
    --frozen: #3050aa;
    --hot-glow: rgba(255,32,32,0.6);
    --warm-glow: rgba(204,136,0,0.5);
    --cold-glow: rgba(32,128,204,0.4);
    --frozen-glow: rgba(48,80,170,0.4);
    --glow: rgba(0, 255, 65, 0.15);
    --glow-strong: rgba(0, 255, 65, 0.3);
    --font: 'Courier New', 'Lucida Console', 'Monaco', monospace;
    --radius: 0px;
    --fuse-text: #000000;
    --overlay-bg: rgba(0, 0, 0, 0.94);
    --fuse-hi: linear-gradient(90deg, #00cc33, #00ff41);
    --fuse-mid: linear-gradient(90deg, #cc8800, #ffaa00);
    --fuse-low: linear-gradient(90deg, #cc2020, #ff2020);
}

/* ── Light / Classic theme ── */
[data-theme="light"] {
    --bg: #f4efe8;
    --surface: #ffffff;
    --surface-2: #eae4dc;
    --text: #2c2016;
    --text-dim: #907e6f;
    --text-bright: #1a0e04;
    --pin-bg: #ffffff;
    --pin-border: #cfc6ba;
    --pin-locked-bg: #e4ddd4;
    --correct: #2a8a48;
    --hot: #cc3333;
    --warm: #cc8800;
    --cold: #3366aa;
    --frozen: #5566aa;
    --hot-glow: rgba(204,51,51,0.45);
    --warm-glow: rgba(204,136,0,0.35);
    --cold-glow: rgba(51,102,170,0.3);
    --frozen-glow: rgba(85,102,170,0.25);
    --glow: rgba(44, 32, 20, 0.06);
    --glow-strong: rgba(44, 32, 20, 0.12);
    --font: 'Baskerville', 'Georgia', 'Times New Roman', serif;
    --radius: 6px;
    --fuse-text: #ffffff;
    --overlay-bg: rgba(255, 255, 255, 0.90);
    --fuse-hi: linear-gradient(90deg, #22a44e, #34c464);
    --fuse-mid: linear-gradient(90deg, #d4900a, #eab830);
    --fuse-low: linear-gradient(90deg, #c43030, #e04444);
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    overscroll-behavior: none;
}

/* Theme Toggle */
#theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    height: 28px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    z-index: 200;
    text-transform: uppercase;
}

#theme-toggle:hover {
    border-color: var(--text);
    color: var(--text);
    box-shadow: 0 0 12px var(--glow);
}

#theme-toggle:active {
    transform: scale(0.97);
}

/* Beta Banner */
#beta-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 200;
}

#beta-tag {
    height: 32px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    font-size: 10px;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-dim);
}

#beta-copy {
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--text-dim);
    opacity: 0.5;
}

#beta-banner a {
    height: 32px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    font-size: 10px;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: 2px;
    color: var(--text-dim);
    text-decoration: none;
    transition: all 0.15s;
}

#beta-banner a:hover {
    border-color: var(--text);
    color: var(--text);
    box-shadow: 0 0 12px var(--glow);
}

#beta-banner a:active {
    transform: scale(0.97);
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    gap: 28px;
}

/* Progress Bar */
#progress-bar {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#progress-label {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 3px;
    color: var(--text-dim);
    text-transform: uppercase;
}

#progress-track {
    width: 100%;
    height: 2px;
    background: var(--surface-2);
    border-radius: var(--radius);
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: var(--text);
    border-radius: var(--radius);
    transition: width 0.5s ease;
    box-shadow: 0 0 8px var(--glow-strong);
}

#progress-detail {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-dim);
    opacity: 0.4;
}

/* Level Up Message */
#level-up-msg {
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 3px;
    color: var(--text);
    text-align: center;
    text-shadow: 0 0 20px var(--glow-strong);
    animation: fadeIn 0.5s ease, pulse 2s ease-in-out infinite;
}

/* Fuse Bar */
#fuse-bar {
    width: 100%;
    max-width: 520px;
    height: 28px;
    background: var(--surface);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--pin-border);
}

#fuse-fill {
    height: 100%;
    width: 100%;
    background: var(--text);
    border-radius: var(--radius);
    transition: width 0.05s linear;
    box-shadow: 0 0 10px var(--glow);
}

#fuse-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 400;
    color: var(--fuse-text);
    letter-spacing: 2px;
}

/* Lock Container */
#lock-container {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    max-width: 95vw;
}

/* Pin */
.pin {
    width: clamp(45px, calc(90vw / var(--pin-count, 5) - 10px), 76px);
    height: 148px;
    flex-shrink: 1;
    background: var(--pin-bg);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s, transform 0.2s;
    cursor: pointer;
    overflow: hidden;
}

.pin.active {
    transform: scale(1.06);
    border-color: var(--text-dim);
    box-shadow: 0 0 20px var(--glow), inset 0 0 10px var(--glow);
}

.pin.upcoming {
    opacity: 0.25;
}

.pin.locked {
    background: var(--pin-locked-bg);
    border-color: var(--text);
    box-shadow: 0 0 15px var(--glow-strong);
    opacity: 1;
}

.pin-letter {
    font-size: 38px;
    font-weight: 400;
    line-height: 1;
    color: var(--text);
    transition: color 0.1s;
    text-shadow: 0 0 8px var(--glow);
}

.pin-letter-adjacent {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-dim);
    opacity: 0.3;
    line-height: 1;
    height: 24px;
}

.pin-letter-prev {
    margin-bottom: 10px;
}

.pin-letter-next {
    margin-top: 10px;
}

.pin.locked .pin-letter {
    color: var(--text-bright);
    text-shadow: 0 0 15px var(--glow-strong);
}

.pin.locked .pin-letter-adjacent {
    opacity: 0;
}

/* Nudge */
#nudge-prompt {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-style: normal;
    color: var(--text-dim);
    letter-spacing: 2px;
    animation: pulse 1.5s ease-in-out infinite;
    pointer-events: none;
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* Commit Button */
#commit-btn {
    width: 200px;
    height: 48px;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 6px;
    cursor: pointer;
    transition: all 0.15s;
    text-shadow: 0 0 10px var(--glow);
}

#commit-btn:hover {
    border-color: var(--text);
    box-shadow: 0 0 20px var(--glow);
    transform: scale(1.02);
}

#commit-btn:active {
    transform: scale(0.97);
    background: var(--bg);
}

/* How to Play Button */
#how-to-play-btn {
    height: 32px;
    padding: 0 16px;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.15s;
    animation: fadeIn 0.8s ease;
}

#how-to-play-btn:hover {
    border-color: var(--text);
    color: var(--text);
    box-shadow: 0 0 12px var(--glow);
}

#how-to-play-btn:active {
    transform: scale(0.97);
}

/* How to Play Overlay */
#how-to-play-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    animation: fadeIn 0.3s ease;
}

#how-to-play-box {
    max-width: 400px;
    padding: 36px;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    text-align: left;
}

#how-to-play-box h2 {
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--text);
    margin-bottom: 24px;
    text-align: center;
    text-shadow: 0 0 15px var(--glow);
}

#how-to-play-box p {
    font-size: 12px;
    line-height: 1.8;
    color: var(--text-dim);
    margin-bottom: 14px;
}

#how-to-play-box b {
    color: var(--text);
}

#how-to-play-close {
    display: block;
    width: 100%;
    height: 40px;
    margin-top: 24px;
    background: var(--surface);
    border: 1px solid var(--pin-border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

#how-to-play-close:hover {
    border-color: var(--text);
    box-shadow: 0 0 12px var(--glow);
}

#how-to-play-close:active {
    transform: scale(0.97);
}

/* Results Overlay */
#results-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

#results-title {
    font-size: 28px;
    font-weight: 400;
    letter-spacing: 8px;
}

.result-win {
    color: var(--text);
    text-shadow: 0 0 30px var(--glow-strong);
}

.result-lose {
    color: var(--hot);
    text-shadow: 0 0 30px rgba(255, 32, 32, 0.3);
}

#results-word {
    font-size: 24px;
    font-weight: 400;
    letter-spacing: 14px;
    color: var(--text);
    text-shadow: 0 0 10px var(--glow);
}

#results-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 240px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    letter-spacing: 1px;
}

.stat-label {
    color: var(--text-dim);
}

.stat-value {
    font-weight: 400;
    color: var(--text);
}

#results-score {
    font-size: 20px;
    font-weight: 400;
    color: var(--text);
    letter-spacing: 3px;
    margin-top: 10px;
    text-shadow: 0 0 15px var(--glow);
}

#play-again-btn {
    width: 200px;
    height: 48px;
    background: var(--surface);
    border: 1px solid var(--text);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 4px;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 16px;
    box-shadow: 0 0 10px var(--glow);
}

#play-again-btn:hover {
    background: var(--surface-2);
    box-shadow: 0 0 25px var(--glow-strong);
    transform: scale(1.02);
}

#play-again-btn:active {
    transform: scale(0.97);
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0) scale(1.06); }
    20% { transform: translateX(-8px) scale(1.06); }
    40% { transform: translateX(8px) scale(1.06); }
    60% { transform: translateX(-5px) scale(1.06); }
    80% { transform: translateX(5px) scale(1.06); }
}

.pin.shake {
    animation: shake 0.4s ease;
}

@keyframes flashCorrect {
    0% { background-color: rgba(0, 255, 65, 0.3); }
    100% { background-color: var(--pin-locked-bg); }
}

.pin.flash-correct {
    animation: flashCorrect 0.5s ease;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

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

/* Responsive */
@media (max-width: 500px) {
    .pin {
        height: 120px;
    }
    .pin-letter {
        font-size: 28px;
    }
    .pin-letter-adjacent {
        font-size: 13px;
    }
    #lock-container {
        gap: 6px;
    }
    #commit-btn, #play-again-btn {
        width: 160px;
        height: 42px;
        font-size: 12px;
    }
    #results-title {
        font-size: 22px;
    }
    #results-word {
        letter-spacing: 8px;
    }
}
