/* ============================================================
   PATH HEROES 3D — Styles
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Haptic hidden switch */
#__hapticSwitch {
    position: fixed; top: 0; left: 0; width: 54px; height: 32px;
    opacity: 0.01; z-index: 0; -webkit-appearance: switch; appearance: auto;
    background: transparent; border: none; pointer-events: none;
}

body {
    font-family: -apple-system, 'SF Pro Display', 'Segoe UI', Tahoma, sans-serif;
    background: #0a1628;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* ============ THREE.JS CANVAS ============ */
#world3d {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 0;
    display: block;
}

/* ============ SCREENS ============ */
.screen {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    animation: fadeIn 0.5s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 3D: gameScreen is a dummy compat container — let events pass through to HUD */
#gameScreen.active {
    pointer-events: none;
}

.hidden { display: none !important; }

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

/* ============ MAIN MENU ============ */
.menu-bg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    width: 100%;
    max-width: 420px;
    gap: 18px;
}

#mainMenu {
    background: radial-gradient(ellipse at 50% 30%, rgba(30,60,114,0.92) 0%, rgba(10,22,40,0.97) 100%);
    backdrop-filter: blur(8px);
}

.title-container { text-align: center; }

.game-title {
    font-size: 2em;
    text-shadow: 0 0 30px rgba(255,215,0,0.6), 0 2px 8px rgba(0,0,0,0.8);
    background: linear-gradient(135deg, #ffd700, #ffaa00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.95em;
    opacity: 0.75;
    margin-top: 6px;
}

.player-name-container {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 300px;
    position: relative;
}

.player-name-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 12px;
    border: 2px solid rgba(255,215,0,0.3);
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s;
}
.player-name-input:focus {
    border-color: rgba(255,215,0,0.7);
}
.player-name-input::placeholder { color: rgba(255,255,255,0.35); }

.confirm-name-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    border: 2px solid rgba(255,215,0,0.4);
    background: rgba(255,215,0,0.15);
    color: #ffd700;
    font-size: 1.3em;
    cursor: pointer;
}

.login-progress-bar {
    position: absolute;
    bottom: -8px; left: 0;
    width: 100%; height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}
.login-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ff8c00);
    width: 0;
    transition: width 0.3s;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.menu-btn {
    padding: 14px 20px;
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
}
.menu-btn:active {
    transform: scale(0.97);
    background: rgba(255,255,255,0.15);
}
.menu-btn.play-btn {
    background: linear-gradient(135deg, rgba(255,215,0,0.25), rgba(255,140,0,0.2));
    border-color: rgba(255,215,0,0.4);
    font-size: 1.15em;
}
.menu-btn.danger-btn {
    border-color: rgba(255,80,80,0.4);
    color: #ff8888;
}

.credits { opacity: 0.4; font-size: 0.7em; text-align: center; }

/* ============ HUD (In-Game Overlay) ============ */
.hud {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 5;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}
.hud > * { pointer-events: auto; }

.hud-top {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 12px;
    padding-top: max(env(safe-area-inset-top), 12px);
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 1em;
}
.hud-icon { font-size: 1.1em; }
.hud-val {
    font-weight: 700;
    font-size: 1.1em;
    min-width: 20px;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* Weather banners */
.weather-banner {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 1.1em;
    font-weight: 700;
    animation: bannerPulse 1s ease infinite;
    z-index: 6;
    pointer-events: none;
}
.storm-banner {
    background: linear-gradient(135deg, rgba(255,80,0,0.85), rgba(180,0,0,0.85));
    box-shadow: 0 0 30px rgba(255,80,0,0.5);
}
.fog-banner {
    background: linear-gradient(135deg, rgba(150,150,180,0.8), rgba(100,100,130,0.8));
    box-shadow: 0 0 20px rgba(200,200,220,0.4);
}

@keyframes bannerPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
}

/* Feedback message */
.feedback-message {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.3em;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    padding: 12px 28px;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
    pointer-events: none;
    max-width: 90%;
}
.feedback-message.show {
    opacity: 1;
}
.feedback-message.correct {
    background: rgba(0,180,80,0.85);
    box-shadow: 0 0 40px rgba(0,255,100,0.3);
}
.feedback-message.wrong {
    background: rgba(200,30,30,0.85);
    box-shadow: 0 0 40px rgba(255,50,50,0.3);
}

/* ============ STEERING WHEEL ============ */
.wheel-area {
    position: absolute;
    bottom: 18%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    height: 220px;
    z-index: 6;
    padding-bottom: env(safe-area-inset-bottom);
}

.steering-wheel {
    position: relative;
    width: 220px;
    height: 220px;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.wheel-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.6));
    pointer-events: none; /* ensure SVG doesn't intercept button taps */
}

/* Invisible direction hit areas */
.wheel-btn {
    position: absolute;
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    z-index: 2;
}
.wheel-btn:active {
    background: rgba(255,215,0,0.15);
}

.wheel-north {
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 70px; height: 70px;
    border-radius: 50%;
}
.wheel-south {
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 70px; height: 70px;
    border-radius: 50%;
}
.wheel-east {
    right: 0; top: 50%;
    transform: translateY(-50%);
    width: 70px; height: 70px;
    border-radius: 50%;
}
.wheel-west {
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 70px; height: 70px;
    border-radius: 50%;
}

/* Ghost diagonal buttons (fog mode) — positioned in .wheel-area, outside #steeringWheel */
.wheel-ghost {
    width: 54px; height: 54px;
    border-radius: 50%;
    display: none;
    -webkit-tap-highlight-color: rgba(255,255,255,0.15);
    touch-action: manipulation;
    z-index: 10;
}
.wheel-ne { top: 10px; right: 10px; }
.wheel-se { bottom: 10px; right: 10px; }
.wheel-sw { bottom: 10px; left: 10px; }
.wheel-nw { top: 10px; left: 10px; }

.fog-active .wheel-ghost {
    display: block;
    background: rgba(180,200,255,0.15);
    border: 2px solid rgba(200,200,255,0.35);
    box-shadow: 0 0 12px rgba(150,180,255,0.25), inset 0 0 8px rgba(200,220,255,0.15);
    pointer-events: auto !important;
    z-index: 12;
    animation: ghostPulse 2s ease infinite;
}
.fog-active .wheel-ghost:active {
    background: rgba(200,220,255,0.35);
    transform: scale(0.92);
}

@keyframes ghostPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Center compass button */
.wheel-center-btn {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 50px; height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, #5C3A1E, #3A2210);
    border: 2px solid #D4AF37;
    color: #F5D76E;
    font-size: 1.3em;
    cursor: pointer;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
}

/* Wheel disabled state (between rounds) — keep transform transition intact */
.steering-wheel.wheel-disabled {
    opacity: 0.65;
    filter: saturate(0.4) brightness(0.8);
}
.steering-wheel.wheel-disabled .wheel-svg {
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.6)) saturate(0.4) brightness(0.8);
}

/* Play button loading overlay */
#playBtn {
    position: relative;
}
.play-loading-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(200,200,200,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.play-loading-overlay .dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: rgba(120,130,140,0.9);
    box-shadow: -12px 0 0 rgba(150,160,170,0.7), 12px 0 0 rgba(150,160,170,0.7);
    animation: playSpinner 0.9s linear infinite;
}
@keyframes playSpinner {
    0%   { transform: scale(1);   opacity: 1; }
    50%  { transform: scale(0.7); opacity: 0.6; }
    100% { transform: scale(1);   opacity: 1; }
}
.menu-btn.loading {
    color: transparent !important;
    text-shadow: none !important;
    pointer-events: none;
}

/* Storm effect on wheel */
.storm-active .steering-wheel {
    animation: wheelShake 0.3s ease infinite;
}

@keyframes wheelShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-3deg); }
    75% { transform: rotate(3deg); }
}

/* ============ LAND MODE: SEPARATE SECTORS ============ */
.wheel-area.land-mode .wheel-svg {
    display: none;
}
.wheel-area.land-mode .wheel-center-btn {
    display: none;
}

/* In land mode, direction buttons become visible independent sectors */
.wheel-area.land-mode .wheel-btn:not(.wheel-ghost) {
    background: radial-gradient(ellipse at center, rgba(60,40,20,0.55) 0%, rgba(35,22,10,0.65) 100%);
    border: 2px solid rgba(180,140,80,0.5);
    border-radius: 14px;
    box-shadow:
        0 0 10px rgba(0,0,0,0.4),
        inset 0 1px 2px rgba(255,220,150,0.1);
    width: 62px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s, opacity 0.3s;
}
.wheel-area.land-mode .wheel-btn:not(.wheel-ghost)::after {
    font-size: 22px;
    font-weight: bold;
    color: rgba(245,215,110,0.9);
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.wheel-area.land-mode .wheel-north::after { content: '▲'; }
.wheel-area.land-mode .wheel-south::after { content: '▼'; }
.wheel-area.land-mode .wheel-east::after  { content: '▶'; }
.wheel-area.land-mode .wheel-west::after  { content: '◀'; }

.wheel-area.land-mode .wheel-btn:not(.wheel-ghost):active {
    background: radial-gradient(ellipse at center, rgba(100,80,30,0.7) 0%, rgba(60,40,15,0.75) 100%);
    border-color: rgba(245,215,110,0.9);
}

/* Position sectors with gaps (centered via translate) */
.wheel-area.land-mode .wheel-north {
    top: 8px; left: 50%;
    transform: translateX(-50%);
}
.wheel-area.land-mode .wheel-south {
    bottom: 8px; left: 50%;
    transform: translateX(-50%);
}
.wheel-area.land-mode .wheel-east {
    right: 8px; top: 50%;
    transform: translateY(-50%);
}
.wheel-area.land-mode .wheel-west {
    left: 8px; top: 50%;
    transform: translateY(-50%);
}

/* Hidden buttons in land-mode stay hidden but gracefully */
.wheel-area.land-mode .wheel-btn:not(.wheel-ghost)[style*="display: none"] {
    opacity: 0;
    pointer-events: none;
}

/* Land-mode disabled state */
.wheel-area.land-mode .steering-wheel.wheel-disabled .wheel-btn:not(.wheel-ghost) {
    opacity: 0.4;
    filter: saturate(0.3) brightness(0.7);
}

/* Storm shake still works in land mode */
.storm-active .wheel-area.land-mode .wheel-btn:not(.wheel-ghost) {
    animation: sectorShake 0.4s ease infinite;
}
@keyframes sectorShake {
    0%, 100% { margin: 0; }
    25% { margin-top: -1px; margin-left: 1px; }
    50% { margin-top: 1px; margin-left: -1px; }
    75% { margin-top: -1px; margin-left: -1px; }
}

/* Wrong-shake override in land mode (no rotation, just shake) */
.wheel-area.land-mode .wheel-wrong-shake {
    animation: none !important;
}
.wheel-area.land-mode .wheel-wrong-shake .wheel-btn:not(.wheel-ghost) {
    animation: sectorWrongBounce 0.4s ease-out !important;
}
@keyframes sectorWrongBounce {
    0%, 100% { border-color: rgba(180,140,80,0.5); box-shadow: 0 0 10px rgba(0,0,0,0.4); }
    20% { border-color: rgba(255,50,50,0.95); box-shadow: 0 0 18px rgba(255,0,0,0.5); }
    50% { border-color: rgba(255,60,60,0.7); box-shadow: 0 0 12px rgba(255,0,0,0.3); }
    80% { border-color: rgba(255,50,50,0.5); box-shadow: 0 0 6px rgba(255,0,0,0.15); }
}

/* Wrong answer wheel shake (short jolt) */
.wheel-wrong-shake {
    animation: wheelWrongJolt 0.45s ease-out !important;
}
@keyframes wheelWrongJolt {
    0%   { transform: rotate(0deg); }
    12%  { transform: rotate(-11deg); }
    28%  { transform: rotate(9deg); }
    42%  { transform: rotate(-7deg); }
    58%  { transform: rotate(5deg); }
    72%  { transform: rotate(-3deg); }
    100% { transform: rotate(0deg); }
}

/* Correct sector green arc highlight (blinking, for correct answers) */
.wheel-correct-arc {
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(68, 255, 136, 0.9));
    animation: correctArcPulse 0.35s ease-out forwards;
}
@keyframes correctArcPulse {
    0%   { stroke-opacity: 0; }
    12%  { stroke-opacity: 1; }
    30%  { stroke-opacity: 0.5; }
    50%  { stroke-opacity: 1; }
    70%  { stroke-opacity: 0.6; }
    85%  { stroke-opacity: 0.9; }
    100% { stroke-opacity: 0; }
}

/* Green arc during wrong answer — solid, semi-transparent, fade in/out */
.wheel-wrong-correct-arc {
    pointer-events: none;
    filter: drop-shadow(0 0 6px rgba(68, 255, 136, 0.7));
    animation: wrongSolidArc 0.5s ease-out forwards;
}

/* Red arc during wrong answer — solid, semi-transparent, fade in/out */
.wheel-wrong-arc {
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(255, 68, 68, 0.7));
    animation: wrongSolidArc 0.5s ease-out forwards;
}

@keyframes wrongSolidArc {
    0%   { stroke-opacity: 0; }
    10%  { stroke-opacity: 0.7; }
    80%  { stroke-opacity: 0.7; }
    100% { stroke-opacity: 0; }
}

/* Exit button */
.hud-exit-btn {
    position: absolute;
    top: max(env(safe-area-inset-top), 12px);
    left: 12px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.2em;
    cursor: pointer;
    z-index: 7;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
}

/* Test mode */
.test-mode-controls {
    position: fixed;
    bottom: 260px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 16px;
    z-index: 10000;
    pointer-events: none;
}
.test-mode-controls.active {
    display: flex;
    pointer-events: auto;
}
.test-nav-btn {
    padding: 12px 24px;
    background: rgba(255, 215, 0, 0.25);
    border: 2px solid rgba(255, 215, 0, 0.6);
    border-radius: 12px;
    color: #FFD700;
    font-size: 1.5em;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: background 0.2s, transform 0.1s;
}
.test-nav-btn:active {
    transform: scale(0.92);
    background: rgba(255, 215, 0, 0.45);
}
.test-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ============ PANEL (for info/achievements/gameover) ============ */
.panel {
    background: rgba(15,25,50,0.95);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 24px 20px;
    max-width: 420px;
    width: calc(100% - 40px);
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.panel h2 {
    text-align: center;
    margin-bottom: 16px;
    font-size: 1.3em;
}
.panel h3 { margin: 16px 0 8px; }
.panel ul { padding-left: 20px; }
.panel li { margin-bottom: 6px; font-size: 0.9em; line-height: 1.4; }
.panel p { margin-bottom: 8px; font-size: 0.92em; line-height: 1.5; }

.highlight {
    color: #ffd700;
    font-weight: 700;
}

.victory-badge {
    display: none;
    text-align: center;
    font-size: 3em;
    margin: 10px 0;
}
.victory-badge.show {
    display: block;
}

.game-over-stats {
    text-align: center;
    margin-bottom: 16px;
}

.info-content { font-size: 0.9em; }
.license { opacity: 0.5; font-size: 0.8em; margin-top: 12px; }

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.stats-container { margin-top: 16px; }

/* ============ BONUS MODAL ============ */
.bonus-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 50;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}
.bonus-modal.show { display: flex; }

.bonus-modal-content {
    background: rgba(20,30,60,0.95);
    border: 2px solid rgba(255,215,0,0.4);
    border-radius: 20px;
    padding: 24px;
    max-width: 360px;
    width: calc(100% - 40px);
    text-align: center;
}
.bonus-modal-content h2 { font-size: 1.2em; margin-bottom: 8px; }
.bonus-description { opacity: 0.7; margin-bottom: 16px; }

.bonus-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.bonus-btn {
    flex: 1;
    padding: 16px 8px;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,215,0,0.25);
    border-radius: 14px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.bonus-btn:active {
    transform: scale(0.95);
    background: rgba(255,215,0,0.15);
}
.bonus-icon { font-size: 2em; }
.bonus-text { font-size: 0.8em; opacity: 0.8; }

/* ============ BIRD DELIVERY ANIMATION ============ */
.bird-delivery {
    position: fixed;
    z-index: 60;
    pointer-events: none;
    font-size: 3.5em;
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.6));
    opacity: 0;
    /* Start off-screen: top-right corner */
    top: -80px;
    right: -80px;
    transition: none;
}

/* Bird flying in from top-right to center */
.bird-delivery.fly-in {
    animation: birdFlyIn 1.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* Bird hovering in place while modal is open */
.bird-delivery.hovering {
    opacity: 1;
    top: 12vh;
    right: calc(50% - 40px);
    animation: birdHover 2.5s ease-in-out infinite;
}

/* Bird flying out to the left */
.bird-delivery.fly-out {
    animation: birdFlyOut 1.2s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes birdFlyIn {
    0% {
        opacity: 0;
        top: -80px;
        right: -60px;
        transform: rotate(-25deg) scale(0.5);
    }
    15% {
        opacity: 1;
        transform: rotate(-15deg) scale(0.8);
    }
    40% {
        top: 8vh;
        right: 20%;
        transform: rotate(5deg) scale(1.1);
    }
    60% {
        top: 14vh;
        right: 40%;
        transform: rotate(-8deg) scale(1.05);
    }
    80% {
        top: 11vh;
        right: calc(50% - 30px);
        transform: rotate(3deg) scale(1);
    }
    100% {
        opacity: 1;
        top: 12vh;
        right: calc(50% - 40px);
        transform: rotate(0deg) scale(1);
    }
}

@keyframes birdHover {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(2deg); }
    50% { transform: translateY(4px) rotate(-1deg); }
    75% { transform: translateY(-5px) rotate(1deg); }
}

@keyframes birdFlyOut {
    0% {
        opacity: 1;
        top: 12vh;
        right: calc(50% - 40px);
        transform: rotate(0deg) scale(1);
    }
    20% {
        top: 10vh;
        right: calc(50% - 20px);
        transform: rotate(10deg) scale(1.05);
    }
    50% {
        top: 5vh;
        right: calc(50% + 80px);
        transform: rotate(-15deg) scale(0.9);
    }
    100% {
        opacity: 0;
        top: -100px;
        right: 110%;
        transform: rotate(-30deg) scale(0.4);
    }
}

/* Scroll carried by the bird */
.bird-scroll {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55em;
    animation: scrollSwing 1.5s ease-in-out infinite;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

@keyframes scrollSwing {
    0%, 100% { transform: translateX(-50%) rotate(-5deg); }
    50% { transform: translateX(-50%) rotate(5deg); }
}

/* Feather trail particles */
.bird-feather {
    position: fixed;
    pointer-events: none;
    z-index: 59;
    font-size: 1.2em;
    opacity: 0.8;
    animation: featherFall 2s ease-out forwards;
}

@keyframes featherFall {
    0% { opacity: 0.9; transform: rotate(0deg) translateY(0); }
    50% { opacity: 0.6; transform: rotate(180deg) translateX(30px) translateY(60px); }
    100% { opacity: 0; transform: rotate(360deg) translateX(-20px) translateY(150px); }
}

/* Wind gust effect on bird arrival */
.bird-wind-gust {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 58;
    background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.05) 50%, transparent 60%);
    animation: windGust 0.8s ease-out forwards;
}

@keyframes windGust {
    0% { opacity: 0; transform: translateX(100%); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-100%); }
}

/* Bonus modal entrance delay (for bird to arrive first) */
.bonus-modal.show .bonus-modal-content {
    animation: modalSlideUp 0.5s ease-out;
}

@keyframes modalSlideUp {
    0% { opacity: 0; transform: translateY(40px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ GAME LIMIT MODAL ============ */
.game-limit-modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 55;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}
.game-limit-modal.show { display: flex; }

.game-limit-modal-content {
    background: rgba(20,40,30,0.95);
    border: 2px solid rgba(100,200,120,0.4);
    border-radius: 20px;
    padding: 30px 24px;
    max-width: 360px;
    width: calc(100% - 40px);
    text-align: center;
    position: relative;
}
.game-limit-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none; border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1.3em;
    cursor: pointer;
}
.game-limit-icon { font-size: 3em; margin-bottom: 10px; }

/* ============ CAMERA EFFECTS ============ */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-8px, 4px); }
    20% { transform: translate(6px, -6px); }
    30% { transform: translate(-4px, 8px); }
    40% { transform: translate(8px, -2px); }
    50% { transform: translate(-6px, 6px); }
    60% { transform: translate(4px, -8px); }
    70% { transform: translate(-8px, 2px); }
    80% { transform: translate(6px, 6px); }
    90% { transform: translate(-2px, -4px); }
}

.screen-shake #world3d {
    animation: screenShake 0.5s ease;
}

/* Speed lines for forward rush */
@keyframes speedLine {
    from { transform: translateY(-100vh); opacity: 1; }
    to { transform: translateY(100vh); opacity: 0; }
}

.speed-lines {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}
.speed-line {
    position: absolute;
    width: 2px;
    height: 80px;
    background: linear-gradient(transparent, rgba(255,255,255,0.6), transparent);
    animation: speedLine 0.4s linear;
}

/* ============ RESPONSIVE ============ */
@media (max-height: 700px) {
    .wheel-area { width: 180px; height: 180px; bottom: 14%; }
    .steering-wheel { width: 180px; height: 180px; }
    .wheel-north, .wheel-south, .wheel-east, .wheel-west { width: 55px; height: 55px; }
    .wheel-ghost { width: 40px; height: 40px; }
    .wheel-center-btn { width: 40px; height: 40px; font-size: 1.1em; }
    .wheel-area.land-mode .wheel-btn:not(.wheel-ghost) { width: 50px; height: 50px; }
    .wheel-area.land-mode .wheel-btn:not(.wheel-ghost)::after { font-size: 18px; }
}

@media (min-height: 800px) {
    .wheel-area { width: 250px; height: 250px; bottom: 20%; }
    .steering-wheel { width: 250px; height: 250px; }
    .wheel-north, .wheel-south, .wheel-east, .wheel-west { width: 80px; height: 80px; }
    .wheel-center-btn { width: 56px; height: 56px; }
}

/* ============ TAVERN (inherits from tavern.css mostly) ============ */
#tavernScreen {
    background: rgba(10,20,40,0.97);
    z-index: 20;
    justify-content: flex-start;
    padding: 20px;
}
.tavern-container {
    max-width: 420px;
    width: 100%;
}
.tavern-header { text-align: center; margin-bottom: 16px; }
.tavern-subtitle { opacity: 0.6; font-size: 0.9em; }

#achievementsScreen, #infoScreen, #gameOverScreen {
    background: rgba(10,20,40,0.97);
    z-index: 20;
}

/* Floating artifacts display */
.hud-artifacts {
    position: absolute;
    top: 50px;
    right: 12px;
    display: flex;
    gap: 6px;
    font-size: 1.5em;
}

/* ============ PARTICLES ============ */
.particle {
    position: fixed;
    font-size: 1.5em;
    pointer-events: none;
    z-index: 100;
    animation: particleBurst 0.8s ease-out forwards;
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx, 50px), var(--ty, -50px)) scale(0.3);
        opacity: 0;
    }
}

/* Victory hero appear */
@keyframes wolfAppear {
    from { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes wolfDisappear {
    from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    to { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

/* ============ PROGRESS PATH IN HUD ============ */
.hud-progress-area {
    position: absolute;
    top: calc(max(env(safe-area-inset-top), 12px) + 34px);
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    pointer-events: none;
    z-index: 3;
}
.hud-progress-area .progress-path-container {
    position: relative;
    height: 50px;
    overflow: visible;
}
.hud-progress-area .progress-path {
    width: 100%;
    height: 50px;
}
.hud-progress-area #pathBg {
    fill: none;
    stroke: rgba(255,255,255,0.15);
    stroke-width: 4;
    stroke-linecap: round;
}
.hud-progress-area #pathProgress {
    fill: none;
    stroke: #ffd700;
    stroke-width: 4;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(255,215,0,0.5));
    transition: stroke-dashoffset 0.6s ease;
}
.hud-progress-area #pathCharacter {
    position: absolute;
    font-size: 1.3em;
    transition: left 0.6s ease, top 0.6s ease;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.8));
    pointer-events: none;
}

/* Last winner info bar (under top HUD stats) */
.hud-last-winner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 90%;
    text-align: center;
    font-size: 0.7em;
    color: rgba(255,255,255,0.65);
    padding: 3px 14px;
    background: rgba(0,0,0,0.3);
    border-radius: 0 0 12px 12px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
    z-index: 4;
    /* offset below hud-top + progress area */
    top: calc(max(env(safe-area-inset-top), 12px) + 130px);
}
.hud-last-winner:empty { display: none; }

/* ============ SWIPE AREA ============ */
.swipe-area {
    position: absolute;
    top: 100px;
    left: 0;
    right: 0;
    bottom: calc(18% + 230px);
    z-index: 1;
    touch-action: none; /* critical for Safari swipe capture */
    -webkit-user-select: none;
    user-select: none;
}

/* ============ RED X HINT MARKS ON WHEEL ============ */
.wheel-x-mark {
    position: absolute;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    transform: translate(-50%, -50%);
    animation: xMarkAppear 0.4s ease-out;
}
.wheel-x-mark::before {
    content: '✕';
    font-size: 26px;
    font-weight: 900;
    color: #e22;
    text-shadow:
        0 0 6px rgba(255,30,30,0.9),
        0 0 14px rgba(255,0,0,0.5),
        1px 1px 0 #900;
    line-height: 1;
}
.wheel-x-mark::after {
    content: '';
    position: absolute;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255,50,50,0.6);
    background: rgba(255,0,0,0.08);
}
/* Position X marks matching button positions */
.wheel-x-north { top: 16%; left: 50%; }
.wheel-x-south { top: 84%; left: 50%; }
.wheel-x-east  { top: 50%; left: 84%; }
.wheel-x-west  { top: 50%; left: 16%; }
.wheel-x-northeast { top: 20%; left: 80%; }
.wheel-x-southeast { top: 80%; left: 80%; }
.wheel-x-southwest { top: 80%; left: 20%; }
.wheel-x-northwest { top: 20%; left: 20%; }

@keyframes xMarkAppear {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(2.5); }
    60% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* Responsive: smaller screens */
@media (max-height: 700px) {
    .hud-progress-area { top: calc(max(env(safe-area-inset-top), 12px) + 34px); }
    .swipe-area { bottom: 200px; }
}
