/* ==========================================================================
   Breakout Arcade
   ========================================================================== */

:root {
    color-scheme: dark;
    --bg: #030817;
    --panel: rgba(8, 18, 38, 0.92);
    --panel-2: rgba(13, 27, 53, 0.92);
    --line: rgba(129, 159, 255, 0.18);
    --text: #f7f9ff;
    --muted: #8fa2c7;
    --cyan: #4ff7ff;
    --blue: #608cff;
    --violet: #a76bff;
    --pink: #ff5fcf;
    --shadow: 0 26px 80px rgba(0, 0, 0, 0.52);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 10%, rgba(79, 247, 255, 0.12), transparent 26rem),
        radial-gradient(circle at 85% 90%, rgba(167, 107, 255, 0.14), transparent 30rem),
        linear-gradient(145deg, #020612 0%, #071025 52%, #030817 100%);
}

button,
kbd {
    font: inherit;
}

.arcade-shell {
    width: 100vw;
    height: 100vh;
    min-height: 520px;
    display: grid;
    place-items: center;
    padding: clamp(10px, 2vw, 28px);
}

.game-card {
    width: min(1180px, 100%);
    max-height: 100%;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid rgba(120, 158, 255, 0.22);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.035), transparent 18%),
        rgba(4, 11, 25, 0.86);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0));
}

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--cyan);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.22em;
}

h1 {
    margin: 0;
    font-size: clamp(1.2rem, 2vw, 1.65rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

.hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(82px, 1fr));
    gap: 10px;
    min-width: min(610px, 62vw);
}

.hud-item {
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
}

.hud-label {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hud-item strong {
    display: block;
    overflow: hidden;
    color: #fff;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.game-stage {
    position: relative;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        linear-gradient(rgba(80, 128, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(80, 128, 255, 0.045) 1px, transparent 1px),
        radial-gradient(circle at center, rgba(43, 78, 149, 0.14), transparent 60%),
        #020713;
    background-size: 34px 34px, 34px 34px, auto, auto;
}

canvas {
    display: block;
    width: min(100%, calc((100vh - 158px) * 16 / 9));
    height: auto;
    max-height: calc(100vh - 158px);
    aspect-ratio: 16 / 9;
    background: transparent;
    outline: none;
}

.scanlines {
    pointer-events: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0.18;
    background: repeating-linear-gradient(
        180deg,
        rgba(255,255,255,0.025) 0,
        rgba(255,255,255,0.025) 1px,
        transparent 1px,
        transparent 4px
    );
    mix-blend-mode: screen;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms ease, visibility 180ms ease;
    background: rgba(2, 7, 19, 0.66);
    backdrop-filter: blur(5px);
}

.overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.overlay-card {
    width: min(540px, 92%);
    max-height: min(100%, 478px);
    overflow: auto;
    padding: clamp(20px, 3vw, 30px);
    text-align: center;
    border: 1px solid rgba(122, 167, 255, 0.24);
    border-radius: 24px;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.045), transparent 35%),
        rgba(7, 16, 35, 0.94);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
}

.overlay-kicker {
    display: inline-flex;
    margin-bottom: 8px;
    color: var(--cyan);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.22em;
}

.overlay h2 {
    margin: 0;
    font-size: clamp(2.3rem, 7vw, 4.2rem);
    line-height: 0.95;
    letter-spacing: -0.07em;
    background: linear-gradient(90deg, #ffffff, #95faff 45%, #c59dff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.overlay p {
    max-width: 440px;
    margin: 14px auto 0;
    color: #a9b9d8;
    line-height: 1.55;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0 16px;
}

.control-grid > div {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    background: rgba(255,255,255,0.035);
}

.control-grid span {
    margin-left: 4px;
    color: #a6b6d4;
    font-size: 0.74rem;
}

kbd {
    min-width: 28px;
    padding: 4px 7px;
    border: 1px solid rgba(255,255,255,0.18);
    border-bottom-width: 2px;
    border-radius: 7px;
    color: #f7fbff;
    background: rgba(255,255,255,0.07);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.3);
    font-size: 0.72rem;
    font-weight: 800;
}

.action-hint {
    margin-top: 0 !important;
    font-size: 0.83rem;
    color: #d7e5ff !important;
}

.action-hint strong {
    color: var(--cyan);
}

.start-button {
    width: 100%;
    min-height: 50px;
    margin-top: 14px;
    border: 0;
    border-radius: 14px;
    color: #041018;
    background: linear-gradient(90deg, var(--cyan), #93a9ff);
    box-shadow: 0 14px 34px rgba(79, 247, 255, 0.18);
    font-weight: 900;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: transform 150ms ease, filter 150ms ease;
}

.start-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.start-button:active {
    transform: translateY(1px);
}

.audio-note {
    margin-top: 10px !important;
    font-size: 0.72rem;
    opacity: 0.72;
}

.game-footer {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: rgba(255,255,255,0.018);
    font-size: 0.72rem;
}

.game-footer a {
    color: #c6d2eb;
    text-decoration: none;
    white-space: nowrap;
}

.game-footer a:hover {
    color: var(--cyan);
}

.game-footer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.music-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 32px;
    padding: 6px 11px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 10px;
    color: #dce7fb;
    background: rgba(255, 255, 255, 0.045);
    font-size: 0.72rem;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease, transform 150ms ease;
}

.music-toggle:hover {
    color: #ffffff;
    border-color: rgba(79, 247, 255, 0.34);
    background: rgba(79, 247, 255, 0.08);
}

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

.music-toggle.is-muted {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
}

.music-toggle-icon {
    display: inline-grid;
    place-items: center;
    width: 18px;
    font-size: 0.9rem;
    line-height: 1;
}

@media (max-width: 840px) {
    .arcade-shell {
        padding: 0;
        min-height: 100vh;
    }

    .game-card {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
    }

    .game-topbar {
        align-items: flex-start;
        padding: 12px;
    }

    .game-topbar > div:first-child {
        display: none;
    }

    .hud {
        width: 100%;
        min-width: 0;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .hud-item {
        padding: 7px 8px;
        border-radius: 10px;
    }

    .hud-label {
        font-size: 0.54rem;
    }

    .hud-item strong {
        font-size: 0.78rem;
    }

    canvas {
        width: 100%;
        max-height: none;
    }

    .game-footer {
        font-size: 0.66rem;
        padding: 8px 12px;
    }
}

@media (max-width: 640px) {
    .game-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .game-footer-actions {
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .control-grid {
        grid-template-columns: 1fr;
    }

    .overlay-card {
        padding: 18px 16px;
    }

    .overlay p {
        font-size: 0.88rem;
    }
}
