:root {
    --description: "A fast-paced neon air hockey game built with Canvas 2D, featuring responsive mouse, touch and keyboard controls, dynamic physics, CPU opponent AI with 3 difficulty levels, local 2-player mode, particle effects, sound design, and arcade-style UI. Track stats like streaks, top speed, and power hits while racing to 7 in a glowing, high-energy arena. Includes slo-mo game point moments, screen shake, and confetti victory effects for a polished arcade experience. Fully responsive across desktop, tablet and mobile.";
    --keywords: "air hockey, arcade game, canvas game, javascript game, neon, sports game, physics, puck, mallet, cpu ai, 2 player, local multiplayer, particle effects, confetti, sound effects, touch controls, mouse controls, keyboard controls, responsive, html5 canvas, game ui, codepen, codepen challenge";
    --content-language: "en";
    --generator: "HTML5, CSS3 (Grid, Flexbox, Animations, Keyframes), JavaScript, Canvas 2D API";

    --blue: #00d4ff;
    --red: #ff2d55;
    --gold: #ffc940;
    --bg: #04060a;
    --panel: #080d14;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: system-ui, "Segoe UI", sans-serif;
    overflow: hidden;
    cursor: none;
    user-select: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#arena {
    position: relative;
    width: 100%;
    max-width: 760px;
    aspect-ratio: 760 / 520;
    margin: 0 auto;
    touch-action: none;
}

.screen {
    cursor: default;
}

button {
    cursor: pointer;
}

/* ── Layout ── */
#outer {
    display: grid;
    grid-template-columns: 130px minmax(0, 760px) 130px;
    grid-template-areas: "left arena right";
    align-items: stretch;
    justify-content: center;
    gap: 0;
    width: 1020px;
    transform-origin: center center;
    will-change: transform;
}

#stat-left { grid-area: left; }
#arena { grid-area: arena; }
#stat-right { grid-area: right; }

canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2), 0 0 50px rgba(0, 212, 255, 0.1),
        0 20px 70px rgba(0, 0, 0, 0.8);
}

/* ── Stat Panels ── */
.stat-panel {
    width: 130px;
    flex-shrink: 0;
    padding: 16px 10px 12px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

#stat-left {
    border-radius: 16px 0 0 16px;
    border-right: none;
}

#stat-right {
    border-radius: 0 16px 16px 0;
    border-left: none;
}

.stat-name {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 4px;
    margin-bottom: 6px;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-score {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 900;
    font-size: 52px;
    line-height: 1;
    margin-bottom: 6px;
    text-align: center;
    width: 100%;
    letter-spacing: -2px;
}

.stat-divider {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.07);
    margin: 6px 0 8px;
}

.stat-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 9px;
}

.stat-label {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 500;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
}

.stat-val {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.stat-footer {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 500;
    font-size: 9px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.2);
    text-align: center;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── HUD buttons (mute / pause) ── */
#hud-buttons {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 5;
}

.hud-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(4, 6, 10, 0.55);
    border: 1px solid rgba(0, 212, 255, 0.35);
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
}

.hud-btn:hover {
    color: var(--blue);
    border-color: var(--blue);
}

.hud-btn:active {
    transform: scale(0.9);
}

.hud-btn.is-muted {
    color: rgba(255, 45, 85, 0.85);
    border-color: rgba(255, 45, 85, 0.4);
}

/* ── Screens ── */
#ui {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 18px;
    overflow: hidden;
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    background: rgba(4, 6, 10, 0.55);
    backdrop-filter: blur(8px);
    border-radius: 18px;
    padding: 16px;
    overflow-y: auto;
}

.screen.on {
    opacity: 1;
    pointer-events: all;
}

/* ── Start screen ── */
.start-inner {
    text-align: center;
    max-width: 480px;
    width: 100%;
}

.ready-logo {
    font-weight: 900;
    font-size: clamp(30px, 6.5vw, 52px);
    line-height: 0.95;
    color: #fff;
}

.ready-logo span {
    display: block;
    color: var(--blue);
    text-shadow: 0 0 30px var(--blue), 0 0 70px rgba(0, 212, 255, 0.35);
    font-size: 0.42em;
    letter-spacing: 4px;
    margin-top: 4px;
}

.ready-sub {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 8px;
    color: var(--gold);
    margin-top: 10px;
    margin-bottom: 22px;
}

.menu-step {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeUp 0.35s ease both;
}

.menu-step.on {
    display: flex;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-title {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.menu-btn-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.menu-btn {
    padding: 16px 22px;
    background: rgba(0, 212, 255, 0.06);
    border: 2px solid rgba(0, 212, 255, 0.4);
    color: #fff;
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    border-radius: 12px;
    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}

.menu-btn i {
    font-size: 20px;
    color: var(--blue);
}

.menu-btn:hover {
    background: rgba(0, 212, 255, 0.16);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.25);
    border-color: var(--blue);
}

.menu-btn:active {
    transform: scale(0.96);
}

.menu-btn-wide {
    min-width: 220px;
    margin-top: 4px;
}

.diff-btn[data-difficulty="easy"] { border-color: rgba(34, 197, 94, 0.5); }
.diff-btn[data-difficulty="easy"] i, .diff-btn[data-difficulty="easy"] span { color: #22c55e; }
.diff-btn[data-difficulty="hard"] { border-color: rgba(255, 45, 85, 0.5); }
.diff-btn[data-difficulty="hard"] i, .diff-btn[data-difficulty="hard"] span { color: var(--red); }

.menu-hint {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 16px;
}

.menu-back {
    margin-top: 18px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.menu-back:hover {
    color: #fff;
}

.pvp-controls {
    display: flex;
    gap: 22px;
    margin-bottom: 22px;
    flex-wrap: wrap;
    justify-content: center;
}

.pvp-side {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid currentColor;
    border-radius: 10px;
    padding: 12px 18px;
}

.pvp-side-name {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.pvp-side-keys {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.55);
}

/* ── Pause ── */
.pause-icon {
    font-size: 40px;
    color: var(--gold);
    text-shadow: 0 0 24px var(--gold);
    margin-bottom: 10px;
}

/* ── Game Over ── */
.go-face {
    font-size: 60px;
    line-height: 1;
    margin-bottom: 8px;
    display: block;
    animation: facePop 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes facePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    65% {
        transform: scale(1.25);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.go-inner {
    text-align: center;
}

.go-who {
    font-size: clamp(32px, 6.5vw, 64px);
    font-weight: 900;
    line-height: 1;
}

.go-wins {
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 300;
    font-size: 16px;
    letter-spacing: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 3px;
}

.go-final {
    font-size: 26px;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold);
    margin: 12px 0 22px;
}

button#btn-again,
button#btn-resume {
    padding: 13px 44px;
    background: transparent;
    border: 2px solid var(--blue);
    color: var(--blue);
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 4px;
    clip-path: polygon(10px 0%, 100% 0%, calc(100% - 10px) 100%, 0% 100%);
    transition: background 0.2s, box-shadow 0.2s, color 0.2s;
    display: block;
    margin: 0 auto;
}

button#btn-again:hover,
button#btn-resume:hover {
    background: var(--blue);
    color: #000;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
}

#gameover-screen.lose-state button#btn-again {
    border-color: var(--red);
    color: var(--red);
}

#gameover-screen.lose-state button#btn-again:hover {
    background: var(--red);
    color: #000;
    box-shadow: 0 0 30px rgba(255, 45, 85, 0.5);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

@keyframes emoji-bounce {
    0% {
        transform: scale(0) rotate(-20deg);
        opacity: 0;
    }

    60% {
        transform: scale(1.3) rotate(8deg);
        opacity: 1;
    }

    80% {
        transform: scale(0.9) rotate(-4deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

#gameover-screen.lose-state {
    background: rgba(20, 4, 8, 0.75);
}

/* ── Rotate device hint (portrait phones only) ── */
#rotate-hint {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 50;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-family: system-ui, "Segoe UI", sans-serif;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 1px;
    text-align: center;
    padding: 0 30px;
}

#rotate-hint i {
    font-size: 44px;
    color: var(--blue);
    animation: rotateHintSpin 1.8s ease-in-out infinite;
}

@keyframes rotateHintSpin {

    0%,
    100% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(90deg);
    }
}

@media (max-width: 560px) and (orientation: portrait) {
    #rotate-hint {
        display: flex;
    }
}

/* ── Responsive: tablets / phones — stack stat panels above the arena ── */
@media (max-width: 860px) {
    #outer {
        width: min(94vw, 620px);
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "left right"
            "arena arena";
        gap: 8px;
    }

    .stat-panel {
        flex-direction: row;
        justify-content: space-between;
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.06) !important;
        padding: 8px 14px;
        gap: 10px;
    }

    .stat-name {
        writing-mode: horizontal-tb;
        margin-bottom: 0;
        width: auto;
        font-size: 11px;
    }

    .stat-score {
        font-size: 30px;
        margin-bottom: 0;
        width: auto;
    }

    .stat-divider {
        display: none;
    }

    .stat-row {
        display: none;
    }

    .stat-footer {
        display: none;
    }
}

@media (max-width: 420px) {
    #outer {
        width: 96vw;
    }

    .stat-score {
        font-size: 26px;
    }
}
