/* ============================================================
   MEOUST — Smoke's Raptor Joust
   Design System & Responsive Layout
   ============================================================ */

:root {
    --bg-dark:       #07080d;
    --card-bg:       rgba(14, 16, 28, 0.88);
    --border-color:  rgba(255, 255, 255, 0.08);
    --neon-purple:   #9d4edd;
    --neon-pink:     #ff007f;
    --lava-orange:   #ff6b00;
    --lava-red:      #e02020;
    --raptor-teal:   #5f8a8b;
    --pink-feather:  #ff69b4;
    --text-color:    #f0f4f8;
    --text-muted:    #828a9b;
    --font-pixel:    'Press Start 2P', monospace;
    --font-sans:     'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-color);
    font-family: var(--font-sans);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 30%, #1a0d2e 0%, #07080d 70%);
    touch-action: none;
}

/* ============================================================
   GAME CONTAINER & CANVAS
   ============================================================ */

#game-container {
    position: relative;
    width: 95vw;
    height: auto;
    max-height: 82vh;
    max-height: 82dvh;
    aspect-ratio: 16 / 9;
    max-width: min(1000px, calc(82vh * 16 / 9));
    max-width: min(1000px, calc(82dvh * 16 / 9));
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
        0 24px 70px rgba(0,0,0,0.85),
        0 0 40px rgba(255, 107, 0, 0.12),
        0 0 15px rgba(157, 78, 221, 0.1);
    border: 1px solid rgba(255, 107, 0, 0.12);
    touch-action: none;
}

#game-container:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    aspect-ratio: unset !important;
}
#game-container:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    aspect-ratio: unset !important;
}

#game-canvas {
    position: absolute;
    top: 0; left: 0;
    display: block;
    width: 100%;
    height: 100%;
    background-color: #060810;
    touch-action: none;
}

/* ============================================================
   HUD
   ============================================================ */

#hud {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    padding: 0 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
    gap: 6px;
}

.hud-item {
    background: rgba(7, 8, 16, 0.65);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
}

.hud-btn {
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    pointer-events: auto;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.hud-btn:hover {
    background: rgba(255, 107, 0, 0.25);
    border-color: var(--lava-orange);
    color: #fff;
}

.hud-btn:active { transform: scale(0.93); }

.hud-label {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--text-muted);
    margin-bottom: 3px;
    letter-spacing: 0.5px;
}

.hud-value {
    font-family: var(--font-pixel);
    font-size: 13px;
    color: #fff;
    text-shadow: 0 0 6px rgba(255,255,255,0.2);
}

#score-val  { color: #ffcc00; text-shadow: 0 0 8px rgba(255,204,0,0.4); }
#wave-val   { color: var(--pink-feather); }
#lives-val  { font-size: 14px; letter-spacing: 2px; }

/* ============================================================
   OVERLAY SYSTEM
   ============================================================ */

.overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(4, 5, 10, 0.82);
    backdrop-filter: blur(7px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ============================================================
   CARD (start / game-over panels)
   ============================================================ */

.card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 107, 0, 0.18);
    border-radius: 16px;
    padding: 28px 36px;
    width: 90%;
    max-width: 460px;
    text-align: center;
    box-shadow:
        0 18px 50px rgba(0,0,0,0.6),
        0 0 20px rgba(255,107,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card.border-red {
    border-color: rgba(224, 32, 32, 0.3);
    box-shadow: 0 18px 50px rgba(0,0,0,0.6), 0 0 18px rgba(224,32,32,0.1);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

.logo {
    font-family: var(--font-pixel);
    font-size: 28px;
    letter-spacing: 2px;
    color: #fff;
    text-shadow:
        0 0 12px var(--lava-orange),
        0 0 30px rgba(255,107,0,0.4);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { text-shadow: 0 0 12px var(--lava-orange), 0 0 30px rgba(255,107,0,0.4); }
    50%       { text-shadow: 0 0 20px var(--pink-feather), 0 0 40px rgba(255,105,180,0.5); }
}

.tagline {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 3px;
}

.story-box {
    background: rgba(255, 107, 0, 0.06);
    border: 1px solid rgba(255, 107, 0, 0.2);
    border-radius: 8px;
    padding: 11px 14px;
    font-size: 13px;
    line-height: 1.55;
    color: #e2e8f0;
    text-align: center;
    box-shadow: inset 0 0 12px rgba(255,107,0,0.04);
}

/* ============================================================
   CONTROLS REFERENCE CARD
   ============================================================ */

.controls-card {
    background: rgba(0,0,0,0.22);
    border-radius: 8px;
    padding: 11px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 13px;
    text-align: left;
}

.controls-card p {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ctrl-section-label {
    font-weight: bold;
    color: var(--lava-orange);
    font-size: 10px;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.key {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-bottom: 2px solid rgba(0,0,0,0.5);
    border-radius: 4px;
    padding: 1px 6px;
    font-weight: bold;
    color: #fff;
    font-size: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    background: linear-gradient(135deg, var(--lava-orange) 0%, var(--lava-red) 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: var(--font-sans);
    font-weight: bold;
    font-size: 15px;
    padding: 12px 24px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.12s;
    box-shadow: 0 0 12px rgba(255, 107, 0, 0.35);
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 22px rgba(255, 107, 0, 0.65);
}

.btn:active { transform: translateY(0); }

.btn-restart {
    background: linear-gradient(135deg, #e63946 0%, #ff007f 100%);
    box-shadow: 0 0 12px rgba(230,57,70,0.35);
}
.btn-restart:hover { box-shadow: 0 0 22px rgba(230,57,70,0.65); }

.btn-share {
    background: linear-gradient(135deg, #ff69b4 0%, #9d4edd 100%);
    box-shadow: 0 0 12px rgba(255,105,180,0.3);
}
.btn-share:hover { box-shadow: 0 0 22px rgba(255,105,180,0.6); }

.btn-back {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-color);
    box-shadow: none;
    text-decoration: none;
    display: inline-block;
}
.btn-back:hover {
    background: rgba(255,255,255,0.11);
    border-color: rgba(255,255,255,0.3);
    color: #fff;
}

/* ============================================================
   GAME OVER PANEL
   ============================================================ */

.gameover-title {
    font-family: var(--font-pixel);
    font-size: 22px;
    color: var(--lava-red);
    text-shadow: 0 0 12px rgba(224,32,32,0.5);
}

.gameover-desc {
    font-size: 14px;
    color: var(--text-muted);
}

.scores-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.score-card {
    background: rgba(0,0,0,0.28);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.score-card span { color: var(--text-muted); }

.score-card strong {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: #fff;
}

.stats-footer {
    font-size: 11px;
    color: var(--text-muted);
}

/* ============================================================
   VIRTUAL GAMEPAD (Mobile)
   ============================================================ */

#virtual-gamepad {
    position: absolute;
    bottom: 22px;
    left: 0;
    width: 100%;
    padding: 0 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 15;
}

#virtual-gamepad.hidden { display: none !important; }

.gamepad-group {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.gamepad-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(7, 8, 16, 0.72);
    border: 2px solid rgba(255,107,0,0.5);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 22px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.55), 0 0 12px rgba(255,107,0,0.15);
    backdrop-filter: blur(5px);
    touch-action: none;
    transition: transform 0.08s, border-color 0.08s, background-color 0.08s, box-shadow 0.08s;
}

.gamepad-btn:active,
.gamepad-btn.pressed {
    transform: scale(0.88);
    background-color: rgba(255,107,0,0.32);
    border-color: var(--lava-orange);
    box-shadow: 0 0 18px rgba(255,107,0,0.55);
}

#btn-flap,
#btn-flap-left {
    background: rgba(255, 105, 180, 0.12);
    border-color: var(--pink-feather);
    box-shadow: 0 4px 12px rgba(0,0,0,0.55), 0 0 14px rgba(255,105,180,0.2);
}

#btn-flap:active,
#btn-flap.pressed,
#btn-flap-left:active,
#btn-flap-left.pressed {
    background: rgba(255, 105, 180, 0.38);
    border-color: var(--pink-feather);
    box-shadow: 0 0 22px rgba(255,105,180,0.65);
}

#btn-flap {
    width: 80px;
    height: 80px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
}

#btn-flap-left {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* ============================================================
   PAUSE BANNER (wave clear, extra life flash)
   ============================================================ */

#wave-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-pixel);
    font-size: 20px;
    color: #ffcc00;
    text-shadow: 0 0 16px rgba(255,204,0,0.6);
    text-align: center;
    pointer-events: none;
    z-index: 18;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

#wave-banner.visible { opacity: 1; }

/* ============================================================
   MOBILE RESPONSIVE BREAKPOINTS
   ============================================================ */

@media (max-width: 600px) {
    .logo      { font-size: 20px; }
    .hud-value { font-size: 10px; }
    .card      { padding: 18px 20px; gap: 10px; }
    .gamepad-btn { width: 55px; height: 55px; font-size: 18px; }
    #btn-flap  { width: 70px; height: 70px; font-size: 10px; }
    #btn-left, #btn-right { font-size: 18px; }
}

/* Portrait layout */
@media (max-aspect-ratio: 1/1) {
    #game-container {
        width: 95vw;
        height: auto;
        aspect-ratio: 16 / 9;
        max-height: 65vh;
        max-height: 65dvh;
        max-width: min(600px, calc(65vh * 16 / 9));
        max-width: min(600px, calc(65dvh * 16 / 9));
    }

    #hud { padding: 0 12px; top: 8px; }

    .hud-item  { padding: 4px 8px; }
    .hud-value { font-size: 10px; }
    .hud-label { font-size: 6px; }

    .card {
        padding: 14px 16px;
        gap: 8px;
        max-height: 95%;
        overflow-y: auto;
    }

    .story-box     { font-size: 11px; padding: 6px 10px; }
    .logo          { font-size: 18px; }
    .tagline       { font-size: 9px; }
    .controls-card { font-size: 11px; padding: 6px 10px; gap: 5px; }

    #virtual-gamepad {
        bottom: 14px;
        padding: 0 16px;
    }

    .gamepad-btn { width: 56px; height: 56px; font-size: 18px; }
    #btn-flap    { width: 68px; height: 68px; }
}

/* Very small screens */
@media (max-height: 500px) and (orientation: landscape) {
    #game-container {
        max-height: 95vh;
        max-height: 95dvh;
    }

    #virtual-gamepad { bottom: 8px; }
    .gamepad-btn { width: 50px; height: 50px; }
    #btn-flap { width: 60px; height: 60px; }
    #hud { top: 5px; }
    .hud-item { padding: 3px 7px; }
    .hud-value { font-size: 9px; }
}
