:root {
    --bg-dark: #07080a;
    --bg-card: rgba(15, 18, 25, 0.75);
    --border-glow: rgba(0, 242, 254, 0.15);
    --neon-cyan: #00f2fe;
    --neon-violet: #8a2be2;
    --neon-green: #39ff14;
    --neon-red: #ff3860;
    --neon-yellow: #ffdf00;
    --text-primary: #f0f2f5;
    --text-muted: rgba(240, 242, 245, 0.5);
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-pixel: 'Pixelify Sans', system-ui, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow-x: hidden;
    overflow-y: hidden;
    height: 100vh;   /* fallback */
    height: 100dvh;  /* shrinks with mobile browser chrome */
    user-select: none;
    -webkit-user-select: none;
}

/* Glowing Neon Text */
.text-neon-cyan {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.6);
}

.text-neon-green {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.6);
}

.text-neon-red {
    color: var(--neon-red);
    text-shadow: 0 0 10px rgba(255, 56, 96, 0.6);
}

/* Glassmorphism Cards */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.glass-panel:hover {
    border-color: rgba(0, 242, 254, 0.25);
    box-shadow: 0 8px 32px 0 rgba(0, 242, 254, 0.05);
}

/* Timeline Cards */
.chrono-card {
    position: relative;
    padding: 8px 12px;
    margin-bottom: 6px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    touch-action: none; /* Crucial for pointer events on mobile */
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.chrono-card:active {
    cursor: grabbing;
}

/* Dragging State styling */
.chrono-card.dragging {
    opacity: 0.92;
    transform: scale(1.03) rotate(0.5deg);
    border-color: var(--neon-cyan);
    box-shadow: 0 15px 30px rgba(0, 242, 254, 0.3), 0 0 15px rgba(0, 242, 254, 0.2);
    z-index: 9999;
}

/* Invisible gap placeholder while a card is being dragged */
.drag-placeholder {
    background: rgba(0, 242, 254, 0.04);
    border: 1px dashed rgba(0, 242, 254, 0.2);
    border-radius: 16px;
    pointer-events: none;
}

/* Card drag handle icon */
.drag-handle {
    color: var(--text-muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chrono-card.dragging .drag-handle {
    color: var(--neon-cyan);
}

.chrono-card-text {
    flex-grow: 1;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.35;
    padding-right: 4px;
}

/* Year indicator inside card - hidden during play, revealed on round clear / game over */
.chrono-card-year {
    position: absolute;
    right: 12px;
    font-family: var(--font-mono);
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
}

.chrono-card.revealed .chrono-card-year {
    opacity: 1;
    transform: translateX(0);
    color: var(--neon-cyan);
    background: #051f24;
    border-color: rgba(0, 242, 254, 0.3);
    text-shadow: 0 0 5px rgba(0, 242, 254, 0.5);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.8);
}

/* Correct Year Reveal (Green Glow) */
.chrono-card.revealed.correct .chrono-card-year {
    color: var(--neon-green);
    background: #0b2408;
    border-color: rgba(57, 255, 20, 0.3);
    text-shadow: 0 0 5px rgba(57, 255, 20, 0.5);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.8);
}

/* HUD Progress Bar */
.chrono-progress {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.chrono-progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--neon-green) 0%, var(--neon-cyan) 100%);
    transition: width 0.1s linear, background-color 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.chrono-progress-bar.warning {
    background: linear-gradient(90deg, var(--neon-yellow) 0%, #ff8c00 100%);
    box-shadow: 0 0 10px rgba(255, 223, 0, 0.3);
}

.chrono-progress-bar.danger {
    background: linear-gradient(90deg, var(--neon-red) 0%, #b22222 100%);
    box-shadow: 0 0 10px rgba(255, 56, 96, 0.5);
}

/* Success flash overlay */
.success-flash {
    animation: flashGreen 0.6s ease-out;
}

@keyframes flashGreen {
    0% { background-color: rgba(57, 255, 20, 0.2); }
    100% { background-color: transparent; }
}

/* Interstitial Overlay styles */
#interstitial-overlay {
    position: absolute;
    inset: 0;
    background: rgba(7, 8, 10, 0.9);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#interstitial-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.countdown-number {
    font-size: 6rem;
    font-weight: 900;
    font-family: var(--font-mono);
    line-height: 1;
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.5);
}

.countdown-number.pulse {
    transform: scale(1.2);
    opacity: 1;
    color: var(--neon-cyan);
    text-shadow: 0 0 30px rgba(0, 242, 254, 0.8);
}

/* Leaderboard custom styles */
.rank-badge {
    font-family: var(--font-mono);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.rank-1 {
    background: rgba(255, 215, 0, 0.2);
    color: var(--neon-yellow);
    border: 1px solid var(--neon-yellow);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.rank-2 {
    background: rgba(192, 192, 192, 0.2);
    color: #e0e0e0;
    border: 1px solid #c0c0c0;
}

.rank-3 {
    background: rgba(205, 127, 50, 0.2);
    color: #cd7f32;
    border: 1px solid #cd7f32;
}

/* Custom scrollbars for glass panels */
.custom-scroll::-webkit-scrollbar {
    width: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 242, 254, 0.3);
}

/* Responsive constraints */
.max-width-mobile {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* Sections fill the main container */
main {
    height: 100%;
}

#onboarding-screen {
    height: 100%;
}

#game-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
}

#game-over-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
}

/* Animations */
.pulse-text {
    animation: textGlowPulse 2s infinite ease-in-out;
}

@keyframes textGlowPulse {
    0%, 100% { text-shadow: 0 0 10px rgba(0, 242, 254, 0.4); }
    50% { text-shadow: 0 0 20px rgba(0, 242, 254, 0.8); }
}

.font-pixel {
    font-family: var(--font-pixel) !important;
    letter-spacing: 0.03em;
}

.btn-arcade {
    background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-violet) 100%);
    border: none;
    color: #000;
    font-family: var(--font-pixel);
    font-weight: 700;
    letter-spacing: 0.05em;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-arcade:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 242, 254, 0.7);
    color: #000;
}

.btn-arcade:active:not(:disabled) {
    transform: translateY(0);
}

.btn-arcade:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Mode Picker Cards */
.mode-card {
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 16px !important;
}

.mode-card:hover {
    color: var(--text-primary);
    border-color: rgba(0, 242, 254, 0.25) !important;
}

.mode-card.active {
    color: var(--neon-cyan);
    border: 1px solid rgba(0, 242, 254, 0.4) !important;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.1), inset 0 0 20px rgba(0, 242, 254, 0.04);
}

.mode-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.mode-label {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}
