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

:root {
    --bg: #0e1228;
    --bg-mid: #151b3a;
    --bg-card: rgba(22, 33, 62, 0.72);
    --bg-cell: #143a6b;
    --bg-cell-hover: #1c508f;
    --bg-cell-active: #ff3d68;
    --text: #f4f6ff;
    --text-dim: #9aa3c7;
    --accent: #ff3d68;
    --accent-2: #ff8a5c;
    --accent-hover: #ff6b88;
    --success: #3dff9a;
    --danger: #ff5c5c;
    --gold: #ffd24a;
    --cyan: #5ce1ff;
    --radius: 16px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --glow: 0 0 28px rgba(255, 61, 104, 0.45);
    --font: 'Trebuchet MS', 'Segoe UI', Candara, 'Gill Sans', sans-serif;
    --font-display: 'Segoe UI Black', 'Arial Black', 'Trebuchet MS', Impact, sans-serif;
}

html, body {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font);
    color: var(--text);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    background:
        radial-gradient(1200px 700px at 10% -10%, rgba(255, 61, 104, 0.28), transparent 55%),
        radial-gradient(900px 600px at 110% 10%, rgba(92, 225, 255, 0.18), transparent 50%),
        radial-gradient(700px 500px at 50% 110%, rgba(255, 210, 74, 0.12), transparent 45%),
        linear-gradient(165deg, var(--bg) 0%, var(--bg-mid) 55%, #101632 100%);
    background-attachment: fixed;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.35;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    padding: 14px 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hidden { display: none !important; }

header {
    text-align: center;
    margin-bottom: 14px;
    animation: brandIn 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

@keyframes brandIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

header h1,
.brand {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 9vw, 3.4rem);
    letter-spacing: 0.02em;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
}

.brand-word {
    background: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 55%, var(--gold) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 18px rgba(255, 61, 104, 0.35));
}

.brand-puzzle {
    color: var(--text);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.privacy-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--success);
    background: rgba(61, 255, 154, 0.1);
    border: 1px solid rgba(61, 255, 154, 0.28);
    animation: fadeUp 0.8s 0.15s both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.made-with {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 14px;
    opacity: 0.9;
}

.made-with a {
    color: var(--cyan);
    text-decoration: none;
    border-bottom: 1px solid rgba(92, 225, 255, 0.35);
}

.made-with a:hover {
    color: #fff;
}

#menu-screen,
#result-screen,
#highscore-screen {
    width: 100%;
    max-width: 520px;
    animation: screenIn 0.45s ease both;
}

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

.card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    width: 100%;
}

.card h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    margin-bottom: 10px;
}

.card h2::after {
    content: '';
    display: block;
    width: 42px;
    height: 3px;
    margin-top: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
}

.card > p {
    color: var(--text-dim);
    font-size: 0.92rem;
    line-height: 1.45;
}

.card a {
    color: var(--cyan);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid rgba(92, 225, 255, 0.35);
}

.card ul {
    padding-left: 18px;
    margin-top: 8px;
}

.card li {
    margin-bottom: 6px;
    color: var(--text-dim);
    line-height: 1.4;
    font-size: 0.88rem;
}

.privacy-info {
    margin-top: 8px;
    padding: 14px;
    border: 1px solid rgba(61, 255, 154, 0.28);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(61, 255, 154, 0.08), rgba(92, 225, 255, 0.04));
    width: 100%;
}

.privacy-info h3 {
    color: var(--success);
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.privacy-info p {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.45;
}

.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
    margin-bottom: 10px;
}

.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #ff5c3a 55%, var(--accent-2) 100%);
    color: #fff;
    box-shadow: var(--glow), 0 8px 20px rgba(255, 61, 104, 0.28);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
    box-shadow: 0 0 36px rgba(255, 61, 104, 0.55), 0 10px 24px rgba(255, 61, 104, 0.35);
}

.btn-secondary {
    background: rgba(20, 58, 107, 0.75);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-cell-hover);
}

.dict-status {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: center;
    min-height: 1em;
    margin-bottom: 10px;
}

.dict-status.error {
    color: var(--gold);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(255, 92, 92, 0.55);
    font-size: 0.85rem;
    padding: 12px;
    letter-spacing: 0.03em;
}

.btn-danger:hover {
    background: rgba(255, 92, 92, 0.12);
}

/* ── Mode Selection ── */
.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-btn {
    position: relative;
    overflow: hidden;
    background: rgba(15, 40, 80, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    color: var(--text);
    text-align: center;
    font-family: inherit;
}

.mode-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(255, 61, 104, 0.22), transparent 60%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mode-btn > * { position: relative; z-index: 1; }

.mode-btn:hover {
    background: rgba(28, 80, 143, 0.55);
    transform: translateY(-2px);
}

.mode-btn.active {
    border-color: rgba(255, 61, 104, 0.7);
    background: linear-gradient(180deg, rgba(255, 61, 104, 0.32), rgba(255, 61, 104, 0.08));
    box-shadow: inset 0 0 0 1px rgba(255, 61, 104, 0.35), 0 8px 24px rgba(255, 61, 104, 0.2);
    transform: translateY(-2px) scale(1.02);
}

.mode-btn.active::before { opacity: 1; }

.mode-hint {
    margin: 12px 0 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-2);
    text-align: center;
}

.mode-icon {
    font-size: 1.7rem;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.mode-name {
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.03em;
}

.mode-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.3;
}

/* ── Level Display ── */
.level-card {
    text-align: center;
}

.level-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.level-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.level-number {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 900;
    background: linear-gradient(180deg, var(--gold), #ff9f1a);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 0 12px rgba(255, 210, 74, 0.35));
}

.level-grid-size {
    font-size: 0.8rem;
    color: var(--cyan);
    margin-bottom: 10px;
    font-weight: 600;
}

.level-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.level-stepper {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(14, 18, 40, 0.85);
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    border: 1px solid rgba(255, 255, 255, 0.16);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.15s ease, transform 0.12s ease;
}

.level-stepper:active {
    background: var(--bg-cell-active);
    color: #fff;
    transform: scale(0.94);
}

#level-slider {
    flex: 1;
    min-width: 0;
    height: 34px;
    accent-color: var(--accent);
    touch-action: manipulation;
    cursor: pointer;
}

.xp-bar-container {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    height: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.xp-bar {
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--gold));
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
    box-shadow: 0 0 16px rgba(255, 61, 104, 0.45);
}

.xp-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* ── Game HUD ── */
.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hud-item {
    text-align: center;
    min-width: 70px;
}

.hud-center {
    flex: 1;
}

.hud-label {
    display: block;
    font-size: 0.62rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.hud-value {
    display: block;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1.1;
}

.hud-mode-tag {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 999px;
    margin-top: 4px;
    letter-spacing: 0.04em;
    box-shadow: 0 4px 14px rgba(255, 61, 104, 0.35);
}

.btn-quit {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(14, 18, 40, 0.85);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.btn-quit:active {
    background: var(--bg-cell-active);
    color: #fff;
}

#timer.warning {
    color: var(--danger);
    animation: pulseWarn 0.9s ease infinite;
}

@keyframes pulseWarn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ── Rush bar ── */
.rush-bar {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 999px;
    height: 18px;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.rush-fill {
    background: linear-gradient(90deg, var(--success), var(--cyan), var(--accent));
    height: 100%;
    width: 50%;
    border-radius: 999px;
    transition: width 0.3s;
    box-shadow: 0 0 16px rgba(61, 255, 154, 0.35);
}

.rush-text {
    position: absolute;
    inset: 0;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* ── Challenge bar ── */
.challenge-bar {
    width: 100%;
    text-align: center;
    background: linear-gradient(135deg, rgba(255, 210, 74, 0.15), rgba(255, 61, 104, 0.12));
    border: 1px solid rgba(255, 210, 74, 0.28);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 8px;
    font-weight: 800;
    color: var(--gold);
    font-size: 0.9rem;
    letter-spacing: 0.03em;
}

/* ── Grid ── */
#grid-container {
    position: relative;
    width: min(94vw, 78vh);
    height: min(94vw, 78vh);
    margin: 0 auto 8px;
    touch-action: none;
    cursor: pointer;
    filter: drop-shadow(0 16px 40px rgba(0, 0, 0, 0.45));
}

.path-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.path-svg line {
    stroke: #ff6b88;
    stroke-width: 7;
    stroke-linecap: round;
    opacity: 0.75;
    filter: drop-shadow(0 0 6px rgba(255, 61, 104, 0.8));
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2.5%;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 5;
}

.grid.size-5 { grid-template-columns: repeat(5, 1fr); }
.grid.size-6 { grid-template-columns: repeat(6, 1fr); }

.cell {
    background: linear-gradient(160deg, #1a4d8c 0%, var(--bg-cell) 55%, #0d2d55 100%);
    border-radius: 18%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 9vw, 3.4rem);
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.12s, transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    position: relative;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 14px rgba(0, 0, 0, 0.28);
}

.grid.size-5 .cell { font-size: clamp(1.4rem, 7vw, 2.8rem); }
.grid.size-6 .cell { font-size: clamp(1.1rem, 5.6vw, 2.3rem); }

.cell .letter { margin: auto; }

.cell.bonus {
    border: 2px solid rgba(255, 255, 255, 0.45);
}

.cell.bonus .bonus-label {
    position: absolute;
    top: 3px;
    right: 4px;
    font-family: var(--font);
    font-size: clamp(0.45rem, 2vw, 0.65rem);
    font-weight: 800;
    letter-spacing: 0.03em;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.cell.bonus-dl { background: linear-gradient(135deg, #3dff9a, #1f9d56); }
.cell.bonus-tl { background: linear-gradient(135deg, #5ce1ff, #2763b0); }
.cell.bonus-dw { background: linear-gradient(135deg, #ffd24a, #d98a00); }
.cell.bonus-tw { background: linear-gradient(135deg, #ff3d68, #bd2e33); }

.cell:active {
    background: var(--bg-cell-active) !important;
    transform: scale(1.12) !important;
    box-shadow: 0 0 28px rgba(255, 61, 104, 0.85) !important;
    border-color: #fff !important;
}

.cell.pulse {
    background: var(--bg-cell-active);
    transform: scale(1.12);
    box-shadow: 0 0 28px rgba(255, 61, 104, 0.85);
    border-color: rgba(255, 255, 255, 0.55);
}

.cell.selected {
    background: linear-gradient(160deg, #ff5c88, var(--bg-cell-active) 60%, #c91845);
    transform: scale(1.08);
    box-shadow: 0 0 22px rgba(255, 61, 104, 0.7);
    z-index: 1;
    border-color: rgba(255, 255, 255, 0.45);
}

.cell.flash-error {
    background: var(--danger) !important;
    animation: shake 0.3s ease;
}

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

/* ── Current word ── */
.word-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.current-word {
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 7vw, 2.3rem);
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    min-height: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(120deg, var(--accent), var(--accent-2), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 10px rgba(255, 61, 104, 0.35));
}

.word-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.word-actions button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, opacity 0.2s;
}

.word-actions button:active {
    transform: scale(0.92);
}

#btn-word-submit {
    background: linear-gradient(135deg, var(--success), #1f9d56);
    box-shadow: 0 4px 16px rgba(61, 255, 154, 0.4);
}

#btn-word-clear {
    background: transparent;
    border: 2px solid var(--text-dim);
    color: var(--text-dim);
    font-size: 1rem;
}

/* ── Found words ── */
.found-words {
    width: 100%;
    margin-top: 4px;
}

.bonus-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.legend-chip {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    padding: 3px 8px;
    border-radius: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.legend-chip.dl { background: rgba(61, 255, 154, 0.12); border: 1px solid #3dff9a; color: #3dff9a; text-shadow: none; }
.legend-chip.tl { background: rgba(92, 225, 255, 0.12); border: 1px solid #5ce1ff; color: #5ce1ff; text-shadow: none; }
.legend-chip.dw { background: rgba(255, 210, 74, 0.12); border: 1px solid #ffd24a; color: #ffd24a; text-shadow: none; }
.legend-chip.tw { background: rgba(255, 61, 104, 0.12); border: 1px solid #ff3d68; color: #ff3d68; text-shadow: none; }

.found-words h3 {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
}

#found-count {
    color: var(--accent);
}

#found-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#found-list li {
    background: rgba(22, 33, 62, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    animation: popIn 0.28s cubic-bezier(0.2, 0.9, 0.2, 1);
}

#found-list li.invalid {
    background: rgba(255, 92, 92, 0.15);
    border-color: rgba(255, 92, 92, 0.35);
    color: var(--danger);
    text-decoration: line-through;
}

@keyframes popIn {
    0% { transform: scale(0.4); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Results ── */
.final-score {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 8vw, 3.2rem);
    font-weight: 900;
    text-align: center;
    background: linear-gradient(120deg, var(--accent), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 16px 0;
}

#result-details {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 12px;
}

#result-details p { margin-bottom: 6px; }

.level-progress-bar {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.level-progress-fill {
    background: linear-gradient(90deg, var(--accent), var(--gold));
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.5s ease;
    box-shadow: 0 0 14px rgba(255, 61, 104, 0.4);
}

#level-progress-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 8px;
}

/* ── High scores ── */
.hs-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.hs-tab {
    flex: 1;
    background: rgba(15, 40, 80, 0.7);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    transition: background 0.15s ease, color 0.15s ease;
}

.hs-tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border-color: transparent;
}

#highscore-list {
    padding-left: 24px;
    margin-bottom: 12px;
}

#highscore-list li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-dim);
}

#highscore-list li:first-child {
    color: var(--gold);
    font-weight: 800;
}

/* ── Landscape / Tablet ── */
@media (orientation: landscape) and (min-width: 820px) {
    #menu-screen,
    #result-screen,
    #highscore-screen {
        width: 100%;
        max-width: 960px;
    }

    #result-screen,
    #highscore-screen {
        max-width: 720px;
    }

    .mode-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    body.in-game header {
        display: none;
    }

    #game-screen {
        display: grid;
        grid-template-columns: minmax(0, 60vh) minmax(280px, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr);
        column-gap: 22px;
        row-gap: 10px;
        width: 100%;
        max-width: 1200px;
    }

    #game-screen .game-hud { grid-column: 1; grid-row: 1; }
    #game-screen .rush-bar,
    #game-screen .challenge-bar { grid-column: 1; grid-row: 2; margin: 0; }
    #game-screen .challenge-bar { width: 100%; }

    #game-screen #grid-container {
        grid-column: 1;
        grid-row: 3;
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        margin: 0;
        overscroll-behavior: contain;
    }

    #game-screen .word-row {
        grid-column: 2;
        grid-row: 1;
        height: auto;
    }

    #game-screen #zen-end {
        grid-column: 2;
        grid-row: 2;
        width: auto;
        min-width: 200px;
        justify-self: center;
        margin: 0;
    }

    #game-screen #found-words {
        grid-column: 2;
        grid-row: 3;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        overscroll-behavior: contain;
        margin: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22, 33, 62, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text);
    padding: 12px 22px;
    border-radius: 14px;
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: var(--shadow);
    z-index: 100;
    animation: toastIn 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--accent);
}

.toast.error { border-left-color: var(--danger); }

@keyframes toastIn {
    0% { transform: translateX(-50%) translateY(20px); opacity: 0; }
    100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.noscript {
    max-width: 420px;
    margin: 40px auto;
    padding: 24px;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius);
}
