:root {
    --bg: #050814;
    --panel: rgba(8, 13, 30, 0.78);
    --line: rgba(163, 193, 255, 0.22);
    --text: #f5f8ff;
    --muted: #9eabc7;
    --glow: #8ad8ff;
    --accent: #a6ffcb;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    display: grid;
    place-items: center;
}

button,
a {
    font: inherit;
}

.game-shell {
    width: min(100vw, 1100px);
    height: 100vh;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
}

.game-frame {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
        radial-gradient(circle at 50% 15%, rgba(71, 108, 181, 0.18), transparent 38%),
        #030610;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.34),
        inset 0 0 35px rgba(84, 134, 255, 0.05);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    outline: none;
    touch-action: none;
}

.hud {
    position: absolute;
    inset: 16px 18px auto;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    pointer-events: none;
    text-shadow: 0 0 16px rgba(138, 216, 255, 0.3);
}

.hud-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.hud-group--center {
    align-items: center;
}

.hud-group--right {
    align-items: flex-end;
}

.hud-label {
    color: var(--muted);
    font-size: clamp(9px, 1.1vw, 12px);
    font-weight: 800;
    letter-spacing: 0.16em;
}

.hud strong {
    font-size: clamp(18px, 2.4vw, 30px);
    line-height: 1;
    letter-spacing: 0.04em;
}

.sound-toggle {
    position: absolute;
    right: 18px;
    bottom: 16px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid rgba(166, 255, 203, 0.28);
    border-radius: 999px;
    background: rgba(5, 10, 24, 0.84);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
    border-color: rgba(166, 255, 203, 0.65);
    background: rgba(14, 24, 48, 0.96);
}

.sound-toggle:active {
    transform: translateY(1px);
}

.sound-toggle__icon {
    color: var(--accent);
    font-weight: 900;
}

.sound-toggle[aria-pressed="true"] .sound-toggle__icon {
    color: #ff9b9b;
}

.message-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    width: min(78%, 560px);
    padding: clamp(18px, 3vw, 30px);
    border: 1px solid rgba(138, 216, 255, 0.26);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(8, 14, 31, 0.91), rgba(4, 8, 20, 0.83));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    text-align: center;
    transform: translate(-50%, -50%) scale(0.97);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
    backdrop-filter: blur(9px);
}

.message-panel.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.message-panel__eyebrow {
    display: block;
    margin-bottom: 7px;
    color: var(--glow);
    font-size: clamp(10px, 1.2vw, 12px);
    font-weight: 900;
    letter-spacing: 0.22em;
}

.message-panel strong {
    display: block;
    font-size: clamp(28px, 6vw, 58px);
    line-height: 1;
    letter-spacing: 0.05em;
    text-shadow: 0 0 24px rgba(138, 216, 255, 0.24);
}

.message-panel p {
    margin: 13px 0 0;
    color: #c1cae0;
    font-size: clamp(12px, 1.5vw, 16px);
    line-height: 1.5;
}

.game-footer {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 0 5px;
    color: #7f8ba7;
    font-size: clamp(9px, 1vw, 11px);
    line-height: 1.3;
}

.game-footer span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-footer a {
    flex: 0 0 auto;
    color: #9fb4dd;
    text-decoration: none;
}

.game-footer a:hover,
.game-footer a:focus-visible {
    color: var(--text);
    text-decoration: underline;
}

@media (max-width: 620px), (max-height: 450px) {
    .game-shell {
        gap: 4px;
        padding: 4px;
    }

    .game-frame {
        border-radius: 10px;
    }

    .hud {
        inset: 9px 10px auto;
    }

    .sound-toggle {
        right: 10px;
        bottom: 9px;
        min-height: 30px;
        padding: 5px 8px;
        font-size: 11px;
    }

    .game-footer {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sound-toggle,
    .message-panel {
        transition: none;
    }
}
