* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #050A1E;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

/* ── Screens ── */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: opacity 0.5s ease;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ── Start Screen ── */
#startScreen {
    gap: 20px;
}

.game-title {
    font-size: clamp(36px, 6vw, 60px);
    font-weight: 900;
    color: #00D4FF;
    letter-spacing: 6px;
    text-shadow: 0 0 10px #00D4FF,
    0 0 30px #0088FF,
    0 0 60px #004499;
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% {
        text-shadow: 0 0 10px #00D4FF, 0 0 30px #0088FF, 0 0 60px #004499;
    }
    50% {
        text-shadow: 0 0 20px #00EEFF, 0 0 50px #00AAFF, 0 0 100px #0066FF;
    }
}

.game-subtitle {
    font-size: 15px;
    color: #6699BB;
    letter-spacing: 3px;
}

.diff-row {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.diff-btn {
    padding: 9px 22px;
    border: 1.5px solid #00D4FF33;
    border-radius: 8px;
    background: #00D4FF08;
    color: #5599AA;
    font-family: inherit;
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover, .diff-btn.active {
    border-color: #00D4FF;
    background: #00D4FF1A;
    color: #00D4FF;
    box-shadow: 0 0 14px #00D4FF44;
}

.start-btn {
    margin-top: 4px;
    padding: 14px 56px;
    background: linear-gradient(135deg, #0077DD, #00D4FF);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 5px;
    cursor: pointer;
    box-shadow: 0 0 28px #00AAFF55;
    transition: all 0.2s;
}

.start-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 0 44px #00CCFFAA;
}

.rules-box {
    max-width: 420px;
    padding: 16px 24px;
    background: #001833AA;
    border: 1px solid #00D4FF22;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.9;
    color: #5599BB;
    backdrop-filter: blur(10px);
}

.rules-box ol {
    padding-left: 20px;
}

.rules-box .hl-green {
    color: #00FF99;
}

.rules-box .hl-red {
    color: #FF5555;
}

.rules-box .hl-yellow {
    color: #FFD700;
}

/* ── HUD ── */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: none;
    align-items: center;
    padding: 10px 20px;
    gap: 16px;
    z-index: 10;
    background: linear-gradient(to bottom, #050A1Ecc 60%, transparent);
}

.stat-chip {
    background: #00D4FF0D;
    border: 1px solid #00D4FF22;
    border-radius: 8px;
    padding: 5px 14px;
    text-align: center;
    min-width: 64px;
}

.stat-chip .lbl {
    display: block;
    font-size: 9px;
    color: #00D4FF66;
    letter-spacing: 2px;
}

.stat-chip .val {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #00D4FF;
}

.prog-wrap {
    flex: 1;
}

.prog-track {
    height: 5px;
    background: #00D4FF22;
    border-radius: 3px;
    overflow: hidden;
}

.prog-fill {
    height: 100%;
    background: linear-gradient(90deg, #0077DD, #00D4FF);
    border-radius: 3px;
    box-shadow: 0 0 8px #00AAFF;
    transition: width 0.35s ease;
}

.prog-lbl {
    font-size: 11px;
    color: #336688;
    margin-top: 3px;
    text-align: right;
}

/* ── Word Display ── */
#wordDisplay {
    position: absolute;
    z-index: 8;
    display: none;
    gap: 0;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    pointer-events: none;
    transform: translateX(-50%);
    padding: 4px 14px 5px;
    background: #050A1E99;
    border: 1px solid #00D4FF33;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.lt {
    color: #2E6080;
    transition: color 0.06s;
}

.lt.ok {
    color: #00FF99;
    text-shadow: 0 0 6px #00FF99;
}

.lt.bad {
    color: #FF4444;
    text-shadow: 0 0 6px #FF4444;
    animation: jitter 0.1s;
}

@keyframes jitter {
    0%, 100% {
        transform: translateX(0);
    }
    33% {
        transform: translateX(-2px);
    }
    66% {
        transform: translateX(2px);
    }
}

/* ── Transition Overlay ── */
#transBg {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #001A4499 0%, #050A1EEE 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#transBg.show {
    opacity: 1;
    pointer-events: all;
}

.trans-title {
    font-size: clamp(40px, 8vw, 72px);
    font-weight: 900;
    letter-spacing: 8px;
    animation: transGlow 0.8s ease-in-out infinite alternate;
}

.trans-title.cyan {
    color: #00D4FF;
}

.trans-title.gold {
    color: #FFD700;
}

.trans-title.red {
    color: #FF5555;
}

@keyframes transGlow {
    from {
        text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
    }
    to {
        text-shadow: 0 0 40px currentColor, 0 0 80px currentColor, 0 0 120px currentColor;
    }
}

.trans-sub {
    font-size: 16px;
    color: #88AACC;
    letter-spacing: 3px;
    margin-top: 10px;
}

.countdown {
    font-size: 96px;
    font-weight: 900;
    color: #00D4FF;
    text-shadow: 0 0 40px #00AAFF, 0 0 80px #0066FF;
    margin-top: 16px;
    animation: cdPop 1s ease-out forwards;
}

@keyframes cdPop {
    0% {
        transform: scale(1.6);
        opacity: 0;
    }
    30% {
        transform: scale(1.0);
        opacity: 1;
    }
    80% {
        transform: scale(1.0);
        opacity: 1;
    }
    100% {
        transform: scale(0.6);
        opacity: 0;
    }
}

/* ── End Screen ── */
#endScreen {
    gap: 18px;
}

.end-title {
    font-size: clamp(28px, 5vw, 48px);
    font-weight: 900;
    letter-spacing: 4px;
}

.end-title.win {
    color: #FFD700;
    text-shadow: 0 0 20px #FFD700, 0 0 50px #FF8800;
}

.end-title.lose {
    color: #FF5555;
    text-shadow: 0 0 20px #FF5555, 0 0 50px #AA0000;
}

.end-sub {
    font-size: 14px;
    letter-spacing: 1px;
    color: #88AACC;
    margin-top: -6px;
    text-align: center;
}

#endScreen.lv1 .stat-card {
    border-color: #36cfc955;
    background: #36cfc915;
}

#endScreen.lv1 .stat-card .cv {
    color: #36cfc9;
}

#endScreen.lv2 .stat-card {
    border-color: #4f86ff55;
    background: #4f86ff15;
}

#endScreen.lv2 .stat-card .cv {
    color: #4f86ff;
}

#endScreen.lv3 .stat-card {
    border-color: #b37dff55;
    background: #b37dff15;
}

#endScreen.lv3 .stat-card .cv {
    color: #b37dff;
}

.stats-row {
    display: flex;
    gap: 16px;
}

.stat-card {
    background: #00D4FF0D;
    border: 1px solid #00D4FF33;
    border-radius: 14px;
    padding: 18px 28px;
    text-align: center;
    min-width: 100px;
}

.stat-card .cl {
    color: #336688;
    letter-spacing: 2px;
    font-weight: bold;
}

.stat-card .cv {
    font-size: 34px;
    font-weight: bold;
    color: #00D4FF;
    margin-top: 4px;
}

.action-row {
    display: flex;
    gap: 14px;
}

.action-btn {
    padding: 12px 36px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn.primary {
    background: linear-gradient(135deg, #0055AA, #0099FF);
    color: #fff;
    box-shadow: 0 0 20px #0077FF55;
}

.action-btn.primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 32px #0099FFAA;
}

.action-btn.secondary {
    background: #001833;
    color: #5599BB;
    border: 1px solid #005588;
}

.action-btn.secondary:hover {
    color: #00D4FF;
    border-color: #00D4FF;
}

/* ── Message bar ── */
#msgBar {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9;
    font-size: 13px;
    color: #5599BB;
    letter-spacing: 1px;
    padding: 5px 20px;
    background: #050A1E99;
    border: 1px solid #00D4FF22;
    border-radius: 20px;
    transition: opacity 0.6s;
    white-space: nowrap;
}