/* 
 * CATCH THE COIN 🪙 - Stylesheet
 * Vibrant, modern arcade aesthetic with responsive glassmorphism.
 */

:root {
    --primary-sky: #38bdf8;
    --sky-gradient: linear-gradient(180deg, #38bdf8 0%, #7dd3fc 60%, #bae6fd 100%);
    --gold-primary: #f59e0b;
    --gold-light: #fef08a;
    --gold-dark: #b45309;
    --btn-play: linear-gradient(180deg, #10b981 0%, #059669 100%);
    --btn-play-shadow: #047857;
    --btn-restart: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    --btn-restart-shadow: #b45309;
    --text-dark: #1e293b;
    --font-arcade: 'Fredoka', 'Quicksand', 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    font-family: var(--font-arcade);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Background ambient glow outside container */
body::before {
    content: '';
    position: absolute;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 40%, rgba(56, 189, 248, 0.25) 0%, rgba(15, 23, 42, 0.95) 75%);
    pointer-events: none;
    z-index: 0;
}

/* Main Game Wrapper Container */
#gameContainer {
    position: relative;
    width: 100%;
    max-width: 580px;
    height: 100%;
    max-height: 880px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    overflow: hidden;
    background: #38bdf8;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

@media (max-width: 600px) or (max-height: 800px) {
    #gameContainer {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }
}

/* 2D Canvas */
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* ========================================================
   HUD (Heads-Up Display)
   ======================================================== */
#gameHud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.hud-pill {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.95);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-dark);
}

.hud-pill .icon {
    font-size: 1.35rem;
    line-height: 1;
}

.hud-pill .value {
    color: #b45309;
    font-size: 1.3rem;
}

/* Timer Pill with Urgency Animation */
#hudTimerPill {
    font-variant-numeric: tabular-nums;
}

#hudTimer.urgent {
    color: #e11d48;
    animation: pulseTimer 0.6s infinite alternate;
}

@keyframes pulseTimer {
    0% { transform: scale(1); }
    100% { transform: scale(1.18); text-shadow: 0 0 10px rgba(225, 29, 72, 0.5); }
}

/* Combo Badge */
#hudComboBadge {
    position: absolute;
    top: 68px;
    left: 50%;
    transform: translateX(-50%) scale(0.7);
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 900;
    padding: 4px 14px;
    border-radius: 20px;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    pointer-events: none;
}

#hudComboBadge.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1.05);
}

/* Audio Mute Toggle Button */
#muteToggleBtn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 999px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text-dark);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 25;
    pointer-events: auto;
    transition: transform 0.15s ease, background 0.2s ease;
}

#muteToggleBtn:hover {
    transform: scale(1.05);
    background: #ffffff;
}

#muteToggleBtn:active {
    transform: scale(0.95);
}

/* ========================================================
   MODAL SCREENS (Start, Game Over, Pause)
   ======================================================== */
.game-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    z-index: 20;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#gameHud.hidden,
.new-high-badge.hidden {
    display: none;
}

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

.modal-card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 32px;
    padding: 32px 28px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25), 0 0 0 6px rgba(255, 255, 255, 0.8);
    animation: popModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes popModal {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Title & Branding */
.game-title-wrap {
    margin-bottom: 20px;
}

.game-title {
    font-size: 2.35rem;
    font-weight: 900;
    color: #b45309;
    text-shadow: 0 3px 0 #fde68a, 0 6px 12px rgba(180, 83, 9, 0.3);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.title-subtext {
    font-size: 0.95rem;
    font-weight: 700;
    color: #64748b;
    margin-top: 4px;
}

/* Character Showcase Graphic */
.character-preview {
    font-size: 4rem;
    margin: 12px 0 16px;
    animation: gentleBounce 2s ease-in-out infinite;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.15));
}

@keyframes gentleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* Instructions card */
.instructions-box {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 600;
    line-height: 1.5;
}

.instructions-box p {
    margin-bottom: 6px;
}

.instructions-box .keys-badge {
    display: inline-block;
    background: #e2e8f0;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    padding: 2px 7px;
    font-weight: 800;
    color: #1e293b;
    font-size: 0.85rem;
}

/* Arcade Buttons */
.btn-arcade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    border-radius: 999px;
    border: none;
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 900;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 0 var(--btn-play-shadow), 0 12px 24px rgba(0, 0, 0, 0.2);
    transition: all 0.1s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--btn-play);
    box-shadow: 0 8px 0 var(--btn-play-shadow), 0 12px 24px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
    box-shadow: 0 10px 0 var(--btn-play-shadow), 0 16px 28px rgba(16, 185, 129, 0.4);
}

.btn-primary:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0 var(--btn-play-shadow), 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-restart {
    background: var(--btn-restart);
    box-shadow: 0 8px 0 var(--btn-restart-shadow), 0 12px 24px rgba(245, 158, 11, 0.35);
}

.btn-restart:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
    box-shadow: 0 10px 0 var(--btn-restart-shadow), 0 16px 28px rgba(245, 158, 11, 0.4);
}

.btn-restart:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0 var(--btn-restart-shadow), 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
    background: #64748b;
    box-shadow: 0 6px 0 #334155;
    margin-top: 12px;
    font-size: 1rem;
    padding: 12px;
}

/* ========================================================
   GAME OVER SCREEN DETAILS
   ======================================================== */
.game-over-title {
    font-size: 2.2rem;
    color: #e11d48;
    font-weight: 900;
    margin-bottom: 4px;
}

.new-high-badge {
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    color: white;
    font-size: 0.9rem;
    font-weight: 900;
    padding: 5px 16px;
    border-radius: 999px;
    display: inline-block;
    margin-bottom: 16px;
    animation: pulseBadge 1s infinite alternate;
}

@keyframes pulseBadge {
    0% { transform: scale(0.96); }
    100% { transform: scale(1.05); }
}

.score-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 18px 0 24px;
}

.stat-card {
    background: #f1f5f9;
    border-radius: 16px;
    padding: 12px 10px;
    border: 2px solid #e2e8f0;
}

.stat-card.highlight {
    background: #fef3c7;
    border-color: #fde68a;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 900;
    color: #1e293b;
    margin-top: 2px;
}

.stat-card.highlight .stat-value {
    color: #b45309;
}

/* ========================================================
   MOBILE ON-SCREEN TOUCH BUTTONS
   ======================================================== */
#mobileControls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 24px;
    pointer-events: none;
    z-index: 12;
}

.touch-btn {
    pointer-events: auto;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border: 3px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15), 0 4px 0 #cbd5e1;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    cursor: pointer;
    touch-action: none;
    transition: transform 0.1s ease;
}

.touch-btn:active {
    transform: translateY(4px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 1px 0 #cbd5e1;
    background: #f8fafc;
}

/* Hide touch buttons on wide desktop screens by default */
@media (min-width: 900px) and (hover: hover) {
    #mobileControls {
        display: none;
    }
}
