/* ===================================================
   Coin Rush - Modern 2D Arcade Style System
   =================================================== */

:root {
    --bg-dark: #0d111e;
    --bg-gradient: radial-gradient(circle at 50% 20%, #1a2238 0%, #0c101c 100%);
    --gold-primary: #ffc400;
    --gold-glow: #ffe066;
    --gold-dark: #ff9100;
    --cyan-accent: #00e5ff;
    --pink-accent: #ff2a7a;
    --emerald-accent: #00e676;
    --purple-accent: #9d4edd;
    
    --card-bg: rgba(18, 25, 45, 0.85);
    --card-border: rgba(255, 255, 255, 0.12);
    --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 196, 0, 0.15);
    
    --font-heading: 'Fredoka', 'Luckiest Guy', cursive, sans-serif;
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    background-image: var(--bg-gradient);
    font-family: var(--font-ui);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background animated glow orbs */
.bg-ambient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    animation: floatOrb 12s ease-in-out infinite alternate;
}

.orb-1 {
    top: -10%;
    left: 15%;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, #ff9100, #ff007f);
}

.orb-2 {
    bottom: -10%;
    right: 15%;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, #00e5ff, #8a2be2);
    animation-delay: -6s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 40px) scale(1.15); }
}

/* Master Game Container */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    max-height: 860px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--card-shadow);
    border-radius: 24px;
    overflow: hidden;
    background: #080c14;
    border: 2px solid var(--card-border);
    z-index: 1;
}

@media (max-width: 520px), (max-height: 880px) {
    #game-wrapper {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
}

/* Top HUD Header */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    pointer-events: auto;
    background: linear-gradient(180deg, rgba(8, 12, 20, 0.9) 0%, rgba(8, 12, 20, 0.4) 75%, transparent 100%);
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-display-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 12px rgba(255, 196, 0, 0.2);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.score-display-box.score-bump {
    transform: scale(1.18);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    border-color: #ffd700;
}

.coin-icon-hud {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 0 6px var(--gold-primary));
    animation: coinPulse 2s ease-in-out infinite;
}

@keyframes coinPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.score-number {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.streak-pill {
    font-size: 11px;
    font-weight: 800;
    color: var(--cyan-accent);
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.streak-pill.active {
    opacity: 1;
    transform: translateY(0);
}

/* Center HUD - Countdown Timer & Combo Multiplier */
.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 229, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(0, 229, 255, 0.35);
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.2);
    transition: all 0.3s ease;
}

.timer-icon {
    font-size: 15px;
}

.timer-text {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.timer-text span {
    color: var(--cyan-accent);
    font-size: 17px;
}

.timer-box.warning {
    background: rgba(255, 23, 68, 0.25);
    border-color: #ff1744;
    box-shadow: 0 0 16px rgba(255, 23, 68, 0.6);
    animation: timerPulse 0.6s ease-in-out infinite alternate;
}

.timer-box.warning .timer-text span {
    color: #ff5252;
}

@keyframes timerPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

.combo-badge {
    background: linear-gradient(135deg, #ff007f, #9d4edd);
    padding: 3px 10px;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.6);
    transform: scale(0);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-badge.active {
    transform: scale(1);
    animation: comboWobble 0.6s ease-in-out infinite alternate;
}

@keyframes comboWobble {
    0% { transform: scale(1) rotate(-3deg); }
    100% { transform: scale(1.08) rotate(3deg); }
}

/* Right HUD - Hearts & Action buttons */
.hud-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hearts-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 51, 102, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 51, 102, 0.35);
    box-shadow: 0 4px 12px rgba(255, 51, 102, 0.2);
}

.heart-icon {
    font-size: 20px;
    line-height: 1;
    display: inline-block;
    filter: drop-shadow(0 0 6px rgba(255, 51, 102, 0.9));
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease, filter 0.35s ease;
    animation: heartPulse 2.4s ease-in-out infinite;
}

@keyframes heartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.heart-icon.lost {
    opacity: 0.18;
    transform: scale(0.65);
    filter: grayscale(100%) blur(0.5px);
    animation: none;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    font-size: 16px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
}

.icon-btn:active {
    transform: scale(0.92);
}

/* Game Canvas */
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
    cursor: grab;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* Mobile Virtual Controls Area */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 15;
}

.control-btn {
    pointer-events: auto;
    min-width: 96px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(30, 42, 74, 0.85) 0%, rgba(16, 24, 46, 0.95) 100%);
    border: 2px solid rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.35);
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.control-btn .btn-label {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #ffffff;
}

.control-btn-left {
    border-left: 4px solid var(--cyan-accent);
}

.control-btn-right {
    border-right: 4px solid var(--gold-primary);
}

.control-btn:active, .control-btn.active {
    background: linear-gradient(180deg, rgba(255, 196, 0, 0.4) 0%, rgba(255, 145, 0, 0.5) 100%);
    border-color: #ffffff;
    transform: scale(0.92);
    box-shadow: 0 0 25px rgba(255, 196, 0, 0.7), inset 0 0 10px rgba(255, 255, 255, 0.4);
}

.control-btn-left:active, .control-btn-left.active {
    border-left-color: var(--cyan-accent);
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.7), inset 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Fullscreen Overlays / Modals */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 12, 22, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 30px 24px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
    transform: scale(0.95);
}

.overlay-screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* Game Title & Branding */
.game-title {
    font-family: var(--font-heading);
    font-size: 46px;
    line-height: 1.1;
    margin-bottom: 8px;
    background: linear-gradient(180deg, #fff275 0%, #ffc400 45%, #ff8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 15px rgba(255, 140, 0, 0.6));
    animation: titleFloat 3s ease-in-out infinite alternate;
}

@keyframes titleFloat {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-6px) scale(1.02); }
}

.game-subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 24px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Big Hero Play Card */
.menu-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

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

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-item.highlight-score {
    background: linear-gradient(135deg, rgba(255, 196, 0, 0.18) 0%, rgba(255, 145, 0, 0.08) 100%);
    border: 1.5px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 4px 20px rgba(255, 196, 0, 0.25);
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 28px;
    color: #fff;
}

.stat-val.gold {
    color: var(--gold-primary);
    text-shadow: 0 0 14px rgba(255, 196, 0, 0.5);
}

.stat-val.cyan {
    color: var(--cyan-accent);
    text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}

/* Powerup instructions mini badges */
.instructions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.instruction-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
}

.instruction-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Primary Arcade Play / Restart Button */
.btn-primary {
    width: 100%;
    padding: 16px 28px;
    border-radius: 20px;
    border: none;
    font-family: var(--font-heading);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #121624;
    background: linear-gradient(180deg, #fff37a 0%, #ffc400 45%, #ff8c00 100%);
    box-shadow: 0 6px 0 #cc6d00, 0 12px 26px rgba(255, 145, 0, 0.45), inset 0 2px 2px rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #cc6d00, 0 16px 32px rgba(255, 145, 0, 0.6), inset 0 2px 2px rgba(255, 255, 255, 0.9);
}

.btn-primary:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #cc6d00, 0 4px 12px rgba(255, 145, 0, 0.35);
}

/* Secondary Button */
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 12px 24px;
    border-radius: 16px;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

/* High Score Badge */
.highscore-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
}

.highscore-banner span {
    color: var(--gold-primary);
    font-weight: 800;
}

/* New High Score Alert tag */
.new-record-tag {
    background: linear-gradient(90deg, #ff007f, #ff8c00);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    margin-bottom: 8px;
    display: inline-block;
    animation: flashRecord 0.8s ease-in-out infinite alternate;
}

@keyframes flashRecord {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.08); filter: brightness(1.3); }
}

/* Responsive tweaks */
@media (max-height: 650px) {
    .game-title { font-size: 34px; margin-bottom: 4px; }
    .game-subtitle { font-size: 13px; margin-bottom: 12px; }
    .menu-card { padding: 16px; gap: 10px; }
    .stat-val { font-size: 20px; }
    .control-btn { width: 58px; height: 58px; font-size: 22px; }
}
