/* ============================================
   FLAPPY WOJAK - STYLE SYSTEM
   ============================================ */

:root {
    --bg-dark: #04080f;
    --bg-card: rgba(12, 26, 46, 0.85);
    --ton-blue: #0098EA;
    --ton-light: #2AABEE;
    --ton-glow: rgba(0, 152, 234, 0.4);
    --ton-dim: rgba(0, 152, 234, 0.15);
    --neon-pink: #ff2d78;
    --neon-purple: #0098EA;
    --neon-cyan: #2AABEE;
    --neon-yellow: #ffd600;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --glass: rgba(0, 152, 234, 0.05);
    --glass-border: rgba(0, 152, 234, 0.12);
    --red-candle: #ff3b3b;
    --green-candle: #00c853;
    --font-pixel: 'Press Start 2P', monospace;
    --font-ui: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: var(--font-ui);
    color: var(--text-primary);
    touch-action: manipulation;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.loader-wojak {
    animation: wobble 1s ease-in-out infinite;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px var(--ton-glow));
}

.loader-wojak-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.loader-text {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--ton-blue);
    margin-bottom: 20px;
    letter-spacing: 1px;
}

.loader-bar-container {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--ton-blue), var(--neon-cyan));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ============================================
   GAME CONTAINER
   ============================================ */

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

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

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
    pointer-events: none;
}

.back-btn {
    pointer-events: all;
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 10px;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.back-btn:active {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

#score-display, #best-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.score-label {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.score-value {
    font-family: var(--font-pixel);
    font-size: 24px;
    color: var(--text-primary);
    text-shadow: 0 0 10px var(--ton-blue), 0 2px 4px rgba(0,0,0,0.5);
}

#best-display .score-value {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow), 0 2px 4px rgba(0,0,0,0.5);
}

/* ============================================
   OVERLAYS
   ============================================ */

.overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 15, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 30px 25px;
    max-width: 340px;
    width: 90%;
}

/* ============================================
   START SCREEN
   ============================================ */

.game-title {
    font-family: var(--font-pixel);
    font-size: 28px;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--ton-glow);
    letter-spacing: 2px;
}

.title-highlight {
    color: var(--ton-blue);
    text-shadow: 0 0 30px var(--ton-blue), 0 0 60px var(--ton-glow);
}

.wojak-preview {
    margin: 15px 0;
    animation: float 2s ease-in-out infinite;
    filter: drop-shadow(0 0 25px var(--ton-glow));
}

.wojak-preview-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.gameover-wojak {
    margin-bottom: 10px;
    animation: shake 0.5s ease;
}

.gameover-wojak-img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 0 15px rgba(255, 45, 120, 0.5));
}

.instruction {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.instruction.sub {
    font-size: 12px;
    color: var(--neon-purple);
    margin-bottom: 25px;
}

.welcome-user {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--ton-blue);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.start-back-btn {
    display: inline-flex;
    margin-top: 8px;
    text-decoration: none;
}

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

.game-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 36px;
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--bg-dark);
    background: linear-gradient(135deg, var(--ton-blue), var(--neon-cyan));
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px var(--ton-glow), inset 0 1px 0 rgba(255,255,255,0.2);
    margin: 6px;
    letter-spacing: 1px;
}

.game-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 152, 234, 0.2);
}

.game-btn.secondary {
    background: var(--glass);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.game-btn.secondary:active {
    background: rgba(255,255,255,0.1);
}

.game-btn.pulse {
    animation: btnPulse 2s ease-in-out infinite;
}

/* ============================================
   GAME OVER SCREEN
   ============================================ */

.gameover-title {
    font-family: var(--font-pixel);
    font-size: 28px;
    color: var(--neon-pink);
    margin-bottom: 25px;
    text-shadow: 0 0 20px rgba(255, 45, 120, 0.5);
    animation: shake 0.5s ease;
}

.gameover-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    min-width: 80px;
}

.stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.stat-value {
    font-family: var(--font-pixel);
    font-size: 18px;
    color: var(--ton-blue);
    white-space: nowrap;
}

.stat-value.coins-value {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 214, 0, 0.4);
}

.total-coins-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 214, 0, 0.08);
    border: 1px solid rgba(255, 214, 0, 0.2);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-top: 10px;
}

.total-coins-value {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--neon-yellow);
    text-shadow: 0 0 8px rgba(255, 214, 0, 0.3);
}

.achievement-banner {
    background: linear-gradient(135deg, rgba(255, 214, 0, 0.15), rgba(255, 214, 0, 0.05));
    border: 1px solid rgba(255, 214, 0, 0.3);
    padding: 10px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--neon-yellow);
    animation: achievementPop 0.5s ease;
}

.achievement-banner.hidden {
    display: none;
}



/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes wobble {
    0%, 100% { transform: rotate(-3deg) scale(1); }
    50% { transform: rotate(3deg) scale(1.05); }
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 4px 20px var(--ton-glow); }
    50% { box-shadow: 0 4px 30px rgba(0, 152, 234, 0.6), 0 0 40px rgba(0, 152, 234, 0.2); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

@keyframes achievementPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes coinSpin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-height: 600px) {
    .game-title { font-size: 22px; }
    .wojak-preview { font-size: 56px; margin: 10px 0; }
    .instruction { font-size: 12px; }
    .game-btn { padding: 12px 28px; font-size: 12px; }
    .gameover-title { font-size: 22px; }
}

@media (max-height: 500px) {
    .wojak-preview { display: none; }
    .instruction.sub { margin-bottom: 15px; }
}

/* How to Play */
.how-to-play {
    display: flex;
    gap: 8px;
    margin: 12px 0 16px;
    justify-content: center;
}

.htp-tip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(0, 152, 234, 0.08);
    border: 1px solid rgba(0, 152, 234, 0.15);
    border-radius: 10px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    animation: fadeInUp 0.4s ease backwards;
}
.htp-tip:nth-child(1) { animation-delay: 0.1s; }
.htp-tip:nth-child(2) { animation-delay: 0.2s; }
.htp-tip:nth-child(3) { animation-delay: 0.3s; }

.htp-icon {
    font-size: 20px;
}
