:root {
    --bg-color: #000000;
    --primary-green: #4caf50;
    --dark-green: #2e7d32;
    --box-bg: #1a1a1a;
    --play-size: min(82vw, 320px);
    --ink: #f2fff3;
    --muted: #91a493;
    --warning: #ffeb3b;
    --danger: #ff6259;
    --cyan: #80cbc4;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 18px;
    --space-5: 26px;
    --terminal-border: 1px solid rgba(93, 255, 112, 0.48);
    --terminal-shadow: 0 0 0 1px rgba(0, 0, 0, 0.8), 0 12px 34px rgba(0, 0, 0, 0.55);
    --soft-glow: 0 0 14px rgba(76, 175, 80, 0.32);
    --fast: 120ms;
    --normal: 220ms;
    --layer-bg: 1;
    --layer-stage: 20;
    --layer-hud: 80;
    --layer-overlay: 1000;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg-color);
}

body {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    color: white;
    font-family: "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid #ffeb3b;
    outline-offset: 4px;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#bg-overlay {
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: url("bg.png") no-repeat right center;
    background-size: contain;
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.8s ease;
    mask-image: linear-gradient(to right, transparent 0%, black 35%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 35%);
}

#stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mode-selection {
    position: absolute;
    z-index: 10;
    top: 50%;
    left: 8%;
    max-height: calc(100% - 24px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow-y: auto;
    padding: 8px;
    transform: translateY(-50%);
    transition: transform 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.7s ease;
}

#stage.is-playing #mode-selection {
    opacity: 0;
    pointer-events: none;
    transform: translate(-150%, -50%);
}

.logo {
    margin: 0;
    color: var(--primary-green);
    font-size: 3.5rem;
    text-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
}

#selection-content {
    width: 260px;
}

.language-selector {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 4px 0 14px;
    color: #777;
    font-family: "VT323", monospace;
    font-size: 1.3rem;
}

.language-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 4px 9px;
    background: transparent;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.language-btn:hover,
.language-btn.active {
    border-color: var(--primary-green);
    background: rgba(76, 175, 80, 0.14);
    color: white;
}

#high-score-display {
    margin-bottom: 20px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 0 0 10px var(--primary-green), 0 0 20px var(--primary-green);
    animation: pulse-glow 2s infinite;
}

.nickname-prompt {
    margin: 0 0 20px;
    font-family: "VT323", monospace;
    font-size: 1.5rem;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: bold;
}

#nickname-input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--primary-green);
    border-radius: 12px;
    outline: none;
    background: #000;
    color: var(--primary-green);
    font-weight: bold;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#nickname-input:hover {
    border-color: #81c784;
}

.mode-btn {
    width: 100%;
    margin: 10px 0;
    padding: 18px;
    border: none;
    border-radius: 15px;
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.mode-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
}

.mode-btn:disabled {
    cursor: wait;
    filter: saturate(0.6);
    opacity: 0.68;
}

.yavas {
    background: var(--primary-green);
    box-shadow: 0 6px 0 var(--dark-green);
}

.hizli {
    background: #ff9800;
    box-shadow: 0 6px 0 #e68a00;
}

#play-area {
    position: absolute;
    z-index: 5;
    top: 50%;
    left: 150%;
    width: var(--play-size);
    opacity: 0;
    text-align: center;
    transform: translate(-50%, -50%);
    transition: left 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.7s ease;
}

#stage.is-playing #play-area {
    z-index: 20;
    left: 50%;
    opacity: 1;
}

#level-display {
    min-height: 1.5em;
    margin-bottom: 12px;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.7);
}

#announcement {
    position: absolute;
    z-index: 80;
    top: -62px;
    left: 50%;
    width: min(92vw, 420px);
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 9px;
    opacity: 0;
    background: rgba(0, 0, 0, 0.88);
    color: #ffeb3b;
    font-family: "VT323", monospace;
    font-size: 1.25rem;
    pointer-events: none;
    transform: translate(-50%, -6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

#announcement.visible {
    border-color: var(--primary-green);
    opacity: 1;
    transform: translate(-50%, 0);
}

#gameplay-indicators {
    min-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 5px;
    font-family: "VT323", monospace;
    font-size: 0.95rem;
}

#global-rule-badge,
#modifier-indicator {
    max-width: 100%;
    color: #ffeb3b;
    white-space: normal;
}

#modifier-indicator {
    color: #80cbc4;
}

.button-wrapper {
    position: relative;
    width: var(--play-size);
    height: var(--play-size);
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-background {
    fill: none;
    stroke: #222;
    stroke-width: 3;
}

#timer-bar {
    fill: none;
    stroke: var(--primary-green);
    stroke-width: 3;
    stroke-dasharray: 301.6;
    stroke-linecap: round;
}

#main-button {
    position: relative;
    z-index: 25;
    width: 75%;
    height: 75%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    border: none;
    border-radius: 50%;
    background: var(--primary-green);
    box-shadow: 0 10px 0 var(--dark-green), 0 20px 30px rgba(0, 0, 0, 0.5);
    color: white;
    font-size: clamp(0.9rem, 4vw, 1.2rem);
    font-weight: bold;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.1s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

#main-button:active {
    transform: translateY(6px);
    box-shadow: 0 4px 0 var(--dark-green), 0 10px 15px rgba(0, 0, 0, 0.5);
}

#instruction {
    line-height: 1.35;
    white-space: pre-line;
    pointer-events: none;
    transition: color 0.3s ease;
}

#arena-instruction {
    position: absolute;
    z-index: 45;
    top: 8px;
    left: 7%;
    width: 86%;
    display: none;
    padding: 7px 9px;
    border: 1px solid rgba(76, 175, 80, 0.55);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.86);
    color: white;
    font-weight: bold;
    line-height: 1.25;
    white-space: pre-line;
    pointer-events: none;
}

#arena-instruction[data-authority]::before {
    content: attr(data-authority) " · ";
    color: #80cbc4;
    font-family: "VT323", monospace;
}

#arena-instruction.final-authority {
    border-bottom: 3px solid #ffeb3b;
}

#decoy-instruction {
    position: absolute;
    z-index: 44;
    right: 7%;
    bottom: 5px;
    max-width: 86%;
    display: none;
    padding: 4px 7px;
    color: #777;
    font-size: 0.74rem;
    text-decoration: line-through;
    pointer-events: none;
}

.mirrored-instruction {
    direction: rtl;
    transform: rotateY(14deg);
}

body.success-flash #game-container {
    filter: brightness(1.22) drop-shadow(0 0 10px rgba(76, 175, 80, 0.65));
}

#fail-message {
    color: #ff8a80;
    font-weight: bold;
    text-shadow: 0 0 9px rgba(255, 82, 82, 0.35);
}

#fail-message {
    white-space: pre-line;
    color: #ff8a80;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

body.shake {
    animation: shake 0.4s;
}

@keyframes pulse-glow {
    0%, 100% {
        color: white;
        text-shadow: 0 0 10px var(--primary-green);
    }
    50% {
        color: #e8f5e9;
        text-shadow: 0 0 25px var(--primary-green), 0 0 35px white;
    }
}

#main-button.waiting-signal {
    border: 3px dashed rgba(255, 255, 255, 0.62);
    cursor: wait;
}

#main-button.go-signal {
    border: 6px double white;
    outline: 4px solid rgba(255, 235, 59, 0.78);
    outline-offset: 5px;
    background: var(--primary-green) !important;
    box-shadow: 0 8px 0 var(--dark-green), 0 0 30px rgba(255, 235, 59, 0.75);
    animation: go-signal-flash 220ms ease-out 1;
}

.patience-countdown {
    position: absolute;
    z-index: 40;
    top: 4%;
    left: 50%;
    min-width: 2.2em;
    padding: 2px 9px;
    border: 2px solid white;
    background: #050805;
    color: var(--warning);
    font-family: "VT323", monospace;
    font-size: clamp(2rem, 9vw, 3.4rem);
    line-height: 1;
    pointer-events: none;
    transform: translateX(-50%);
}

.color-choice {
    border-style: double;
    border-width: 4px;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.9);
}

.choice-grid.final-instruction-active {
    outline: 3px solid rgba(255, 255, 255, 0.85);
    outline-offset: -4px;
}

#arena-instruction.instruction-change {
    border-style: double;
    border-width: 4px;
    animation: instruction-change-flash 240ms ease-out 1;
}

@keyframes go-signal-flash {
    50% { filter: brightness(1.55); transform: scale(1.035); }
}

@keyframes instruction-change-flash {
    50% { background: white; color: #050805; transform: scale(1.025); }
}

#sequence-container {
    position: absolute;
    z-index: 30;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    pointer-events: none;
}

.choice-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns, 3), minmax(0, 1fr));
    align-content: center;
    gap: clamp(7px, 2.5vw, 12px);
    padding: 62px 10px 34px;
    pointer-events: auto;
}

.task-choice {
    position: relative;
    min-width: 44px;
    min-height: 44px;
    overflow: hidden;
    padding: clamp(7px, 2.5vw, 12px) 5px;
    border: 2px solid #8bc34a;
    border-radius: 11px;
    background: #102313;
    box-shadow: 0 4px 0 #1b5e20;
    color: white;
    font-size: clamp(1rem, 5vw, 1.6rem);
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.task-choice:hover,
.task-choice:focus-visible {
    border-color: #ffeb3b;
}

.task-choice[aria-disabled="true"] {
    cursor: wait;
    opacity: 0.62;
}

.task-choice.selected-choice {
    opacity: 0.35;
}

.task-choice.red-decoy {
    border: 3px dashed #ff5252;
    background: repeating-linear-gradient(135deg, #401010 0 7px, #201010 7px 14px);
}

.task-choice.red-decoy::after {
    content: "×";
    position: absolute;
    top: 1px;
    right: 5px;
    color: white;
    font-size: 0.75rem;
}

.stroop-choice {
    background: #151515;
    text-shadow: 0 1px 2px black;
}

.real-target {
    border-style: solid;
    border-width: 3px;
}

.fake-target {
    border-color: #777;
    border-style: dashed;
    background: #181818;
}

.memory-highlight {
    border-color: #ffeb3b;
    background: #4caf50;
    box-shadow: 0 0 22px #ffeb3b;
}

.moving-control-0 {
    animation: drift-a 1.1s ease-in-out infinite alternate;
}

.moving-control-1 {
    animation: drift-b 1.25s ease-in-out infinite alternate;
}

.shrinking-control {
    animation: safe-shrink 1.2s ease-in-out infinite alternate;
}

.position-swapped {
    animation: swap-feedback 0.22s ease;
}

@keyframes drift-a { to { transform: translate(5px, -4px); } }
@keyframes drift-b { to { transform: translate(-5px, 4px); } }
@keyframes safe-shrink { to { transform: scale(0.82); } }
@keyframes swap-feedback { 50% { opacity: 0.55; } }

.mini-btn {
    position: absolute;
    width: clamp(48px, 18%, 60px);
    height: clamp(48px, 18%, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    border-radius: 50%;
    background: var(--primary-green);
    box-shadow: 0 5px 0 var(--dark-green), 0 10px 15px rgba(0, 0, 0, 0.5);
    color: white;
    font-size: clamp(1.1rem, 5vw, 1.5rem);
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    transform: translate(-50%, -50%);
    transition: top 0.12s ease, left 0.12s ease, transform 0.1s ease;
}

.mini-btn[hidden] {
    display: none;
}

.mini-btn:active {
    box-shadow: 0 2px 0 var(--dark-green), 0 5px 10px rgba(0, 0, 0, 0.5);
}

.mini-btn.evading {
    width: clamp(64px, 24%, 80px);
    height: clamp(64px, 24%, 80px);
    border-color: #ffeb3b;
    background: #ff5722;
    box-shadow: 0 0 15px #ff5722, 0 6px 0 #d84315;
    font-size: clamp(0.8rem, 3.5vw, 1rem);
}

.mini-btn.evading:active {
    box-shadow: 0 0 25px #ff5722, 0 2px 0 #d84315;
}

/* ---------- v1.1.0 IDENTITY, SESSION HUD, AND OVERLAYS ---------- */

#crt-overlay {
    position: fixed;
    z-index: 2000;
    inset: 0;
    pointer-events: none;
    opacity: 0.14;
    background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(0, 0, 0, 0.34) 3px 4px);
    mix-blend-mode: multiply;
}

body::after {
    content: "";
    position: fixed;
    z-index: 1900;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.72);
}

.brand-lockup {
    margin-bottom: var(--space-3);
}

.wordmark {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    margin: 0;
    color: var(--ink);
    font-family: "VT323", "Courier New", monospace;
    font-size: clamp(3.7rem, 8vw, 5.8rem);
    font-weight: normal;
    letter-spacing: 0.06em;
    line-height: 0.78;
    text-shadow: 2px 0 rgba(76, 175, 80, 0.5);
}

.wordmark::before {
    content: "R7";
    position: absolute;
    top: -0.28em;
    left: 0.1em;
    color: var(--primary-green);
    font-size: 0.16em;
    letter-spacing: 0.2em;
}

.wordmark b {
    margin-left: 0.04em;
    color: var(--primary-green);
    font-size: 1.22em;
    font-weight: normal;
    text-shadow: var(--soft-glow);
    transform: skewX(-7deg);
}

.brand-tagline {
    margin: var(--space-2) 0 0;
    color: var(--muted);
    font-family: "VT323", monospace;
    font-size: 1.08rem;
    letter-spacing: 0.2em;
}

.terminal-panel,
.terminal-dialog,
.result-panel {
    border: var(--terminal-border);
    border-radius: 6px;
    background: linear-gradient(160deg, rgba(18, 26, 19, 0.96), rgba(4, 8, 5, 0.97));
    box-shadow: var(--terminal-shadow);
}

#selection-content {
    width: min(86vw, 330px);
    padding: var(--space-4);
}

.menu-toolbar,
.result-preferences {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.icon-control,
.text-control {
    min-height: 40px;
    border: 1px solid rgba(76, 175, 80, 0.5);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.55);
    color: var(--cyan);
    font-family: "VT323", monospace;
    cursor: pointer;
}

.sound-toggle {
    padding: 6px 9px;
    font-size: 0.95rem;
    white-space: nowrap;
}

#how-to-button {
    width: 100%;
    margin-top: var(--space-3);
}

#how-to-panel {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px dashed rgba(76, 175, 80, 0.45);
    color: #ced8cf;
    line-height: 1.45;
}

#how-to-panel h2 {
    margin: 0 0 var(--space-2);
    color: var(--primary-green);
    font-family: "VT323", monospace;
    letter-spacing: 0.08em;
}

#how-to-panel ul {
    padding-left: 1.2rem;
}

#session-hud {
    min-height: 38px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 2px var(--space-2);
    margin-bottom: var(--space-2);
    color: var(--ink);
    font-family: "VT323", monospace;
    font-size: 1.08rem;
    letter-spacing: 0.05em;
}

#level-display,
#score-display {
    margin: 0;
    text-align: left;
}

#score-display {
    text-align: right;
}

#combo-display {
    min-height: 1.15em;
    color: var(--warning);
    opacity: 0;
    text-align: left;
    transition: opacity var(--fast) ease;
}

#combo-display.visible {
    opacity: 1;
}

#pause-button {
    justify-self: end;
    min-width: 42px;
    min-height: 36px;
}

#pause-button::before {
    content: "Ⅱ";
    font-size: 1.1rem;
}

.screen-overlay {
    position: fixed;
    z-index: var(--layer-overlay);
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    visibility: hidden;
    overflow-y: auto;
    opacity: 0;
    background: rgba(0, 4, 1, 0.94);
    transition: opacity var(--normal) ease, visibility var(--normal) ease;
}

.screen-overlay.active {
    visibility: visible;
    opacity: 1;
}

.terminal-dialog,
.result-panel {
    width: min(94vw, 560px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: clamp(22px, 6vw, 42px);
    outline: none;
    text-align: center;
}

.terminal-dialog h2,
.result-panel h1 {
    margin-top: 0;
    color: var(--primary-green);
    font-family: "VT323", monospace;
    font-size: clamp(2rem, 8vw, 3.2rem);
    font-weight: normal;
    letter-spacing: 0.08em;
}

.primary-action,
.secondary-action {
    min-height: 44px;
    padding: 10px 22px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
}

.primary-action {
    border: 1px solid #8cff91;
    background: var(--primary-green);
    color: white;
}

.secondary-action {
    border: var(--terminal-border);
    background: #111;
    color: var(--ink);
}

.result-kicker {
    margin: 0;
    color: var(--muted);
    font-family: "VT323", monospace;
    letter-spacing: 0.2em;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: var(--space-4) 0;
}

.result-grid p,
.failure-context {
    margin: 0;
    padding: var(--space-3);
    border: 1px solid rgba(76, 175, 80, 0.25);
    background: rgba(0, 0, 0, 0.28);
}

#result-player-stat {
    grid-column: 1 / -1;
}

.failure-context p {
    margin: 4px 0;
}

#sarcasm-message {
    color: var(--muted);
    font-family: "VT323", monospace;
    font-size: 1.25rem;
}

#new-best-result {
    min-height: 1.5em;
    margin: var(--space-3) 0;
    color: var(--warning);
    font-family: "VT323", monospace;
    font-size: 1.5rem;
    text-shadow: 0 0 12px rgba(255, 235, 59, 0.28);
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin: var(--space-4) 0;
}

.result-language {
    margin: 0;
}

body.game-paused #game-container {
    filter: brightness(0.48) saturate(0.7);
}

body.game-paused .moving-control-0,
body.game-paused .moving-control-1,
body.game-paused .shrinking-control,
body.game-paused .pulse-glow {
    animation-play-state: paused !important;
}

body.task-transition .button-wrapper {
    filter: contrast(0.82) brightness(0.72);
}

body.task-transition #level-display {
    animation: level-flicker 120ms steps(2) 2;
}

body.timer-urgent .button-wrapper::after {
    content: "!";
    position: absolute;
    z-index: 60;
    top: 8%;
    right: 8%;
    color: var(--warning);
    font-family: "VT323", monospace;
    font-size: 1.5rem;
}

body.timer-urgent #timer-bar {
    stroke-width: 5;
    stroke-dasharray: 18 4;
}

body.timer-critical .button-wrapper::after {
    content: "!!";
}

body.timer-critical #timer-bar {
    animation: urgency-pulse 320ms steps(2) infinite;
}

body.new-best-flash #session-hud,
body.new-best-flash #new-best-result {
    filter: brightness(1.35);
}

body.cursor-decoy #play-area::after {
    content: "↖";
    position: absolute;
    z-index: 3;
    right: 8%;
    bottom: 12%;
    color: rgba(255, 255, 255, 0.2);
    font-size: 1.4rem;
    pointer-events: none;
    transform: rotate(-18deg);
}

@keyframes level-flicker { 50% { opacity: 0.38; transform: translateX(1px); } }
@keyframes urgency-pulse { 50% { opacity: 0.42; } }

@supports (height: 100dvh) {
    body {
        height: 100dvh;
    }

    :root {
        --play-size: min(82vw, 62dvh, 320px);
    }
}

@media (max-width: 700px) {
    #bg-overlay {
        background-image: url("bg.png");
        background-position: 65% center;
        background-size: cover;
        opacity: 0.26;
        mask-image: linear-gradient(to bottom, transparent 0%, black 30%);
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 30%);
    }

    #mode-selection {
        left: 50%;
        width: min(92vw, 360px);
        align-items: stretch;
        transform: translate(-50%, -50%);
    }

    #stage.is-playing #mode-selection {
        transform: translate(-200%, -50%);
    }

    #selection-content {
        width: 100%;
    }

    .logo {
        align-self: center;
        font-size: clamp(2.7rem, 14vw, 3.5rem);
    }

    .language-selector {
        justify-content: center;
    }

    #play-area {
        max-width: 92vw;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .result-actions {
        flex-direction: column;
    }
}

@media (max-width: 380px) {
    #bg-overlay {
        background-image: none;
        background: radial-gradient(circle at 75% 30%, rgba(32, 120, 53, 0.2), transparent 55%);
    }

    #selection-content {
        padding: 14px;
    }

    .terminal-dialog,
    .result-panel {
        padding: 18px 14px;
    }
}

@media (max-height: 620px) {
    #mode-selection {
        max-height: calc(100dvh - 12px);
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .logo {
        font-size: 2.6rem;
    }

    .language-selector {
        margin-bottom: 7px;
    }

    #high-score-display {
        margin-bottom: 10px;
    }

    .nickname-prompt {
        margin-bottom: 10px;
        font-size: 1.25rem;
    }

    #nickname-input,
    .mode-btn {
        padding: 11px;
    }

    .mode-btn {
        margin: 7px 0;
    }
}

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

    body.shake {
        animation: none;
    }

    #high-score-display {
        animation: none;
    }

    body.timer-critical #timer-bar {
        animation: none;
        opacity: 0.65;
    }

    #main-button.go-signal,
    #arena-instruction.instruction-change {
        animation: none;
    }

    body.task-transition #level-display,
    .moving-control-0,
    .moving-control-1,
    .shrinking-control {
        animation: none;
    }
}
