/* ============================================
   Chemistry Element Blaster - Main Stylesheet
   Lab / Chemistry Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;500;700&display=swap');

:root {
    /* Lab palette */
    --lab-green:   #00e676;
    --lab-cyan:    #4fc3f7;
    --lab-amber:   #ffa726;
    --lab-red:     #ef5350;
    --lab-purple:  #ab47bc;
    --lab-teal:    #26a69a;
    --lab-yellow:  #ffd54f;
    --lab-pink:    #f06292;

    /* Legacy neon aliases — keep ui-components working */
    --neon-blue:   #00d4ff;
    --neon-pink:   #ff006e;
    --neon-green:  #00ff87;
    --neon-orange: #ff8c00;
    --neon-yellow: #ffd600;
    --neon-purple: #b200ff;

    /* Backgrounds */
    --bg-dark:    #050d10;
    --bg-medium:  #0a1a1f;
    --bg-light:   #102a30;
    --bg-panel:   rgba(10, 26, 31, 0.92);

    /* Text */
    --text-primary:   #e8f5e9;
    --text-secondary: rgba(232, 245, 233, 0.7);
    --text-muted:     rgba(232, 245, 233, 0.4);

    /* Borders */
    --border-subtle: rgba(0, 230, 118, 0.1);
    --border-light:  rgba(0, 230, 118, 0.25);
    --border-glow:   rgba(0, 230, 118, 0.5);

    /* Spacing */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  12px;
    --space-lg:  16px;
    --space-xl:  24px;
    --space-2xl: 32px;

    /* Radii */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-full: 50%;

    /* Fonts */
    --font-display: 'Orbitron', monospace;
    --font-body:    'Rajdhani', sans-serif;

    /* Transitions */
    --transition-fast:   0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow:   0.5s ease;

    /* Z-layers */
    --z-canvas:   1;
    --z-effects:  5;
    --z-hud:     10;
    --z-buttons: 15;
    --z-floating:50;
    --z-popups:  60;
    --z-screens:100;
    --z-ads:     200;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    position: relative;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

/* ---- Lab background bubbles ---- */
.stars-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Reuse star divs as floating element symbols */
.star {
    position: absolute;
    background: var(--text-primary);
    border-radius: var(--radius-full);
    animation: bubble var(--duration, 6s) ease-in-out infinite;
    opacity: 0.15;
}

@keyframes bubble {
    0%, 100% { transform: translateY(0) scale(1);   opacity: 0.08; }
    50%       { transform: translateY(-20px) scale(1.2); opacity: 0.2; }
}

/* Periodic table grid lines (subtle) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,230,118,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,230,118,0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: 0;
    pointer-events: none;
}

#gameContainer {
    position: relative;
    width: 100%; height: 100%;
    z-index: 1;
}

#gameCanvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: var(--z-canvas);
    display: block;
}

#hiddenInput {
    position: absolute;
    left: -9999px; top: -9999px;
    opacity: 0; width: 0; height: 0;
    border: none; outline: none;
}

/* ---------- Icon Sizes ---------- */
.btn-icon       { width: 18px; height: 18px; display: block; }
.btn-icon-inline{ width: 16px; height: 16px; display: inline-block; vertical-align: middle; margin-right: 6px; }
.title-icon     { width: 28px; height: 28px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.setting-icon   { width: 16px; height: 16px; display: inline-block; }

/* ============================================
   Loading Screen
   ============================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

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

.loading-content {
    text-align: center;
    padding: var(--space-xl);
    max-width: 400px;
    width: 90%;
}

.loading-title {
    font-family: var(--font-display);
    font-size: clamp(28px, 7vw, 48px);
    font-weight: 900;
    background: linear-gradient(135deg, var(--lab-green), var(--lab-cyan), var(--lab-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
    animation: loadingTitleGlow 3s ease infinite;
    line-height: 1.1;
}

@keyframes loadingTitleGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(0, 230, 118, 0.5)); }
    50%       { filter: drop-shadow(0 0 25px rgba(79, 195, 247, 0.6)); }
}

.loading-subtitle {
    font-family: var(--font-display);
    font-size: clamp(9px, 2.5vw, 12px);
    color: var(--text-muted);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: var(--space-2xl);
}

.loading-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: var(--space-lg);
    position: relative;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--lab-green), var(--lab-cyan), var(--lab-amber));
    border-radius: 2px;
    transition: width 0.3s ease;
    position: relative;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
    border-radius: 2px;
    animation: loadingShine 1.5s ease infinite;
}

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

.loading-status {
    font-family: var(--font-display);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: var(--space-xl);
}

.loading-tip {
    font-family: var(--font-body);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
    line-height: 1.5;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--lab-green);
    border-radius: 50%;
    animation: loadingSpin 0.8s linear infinite;
    margin: 0 auto var(--space-lg);
}

@keyframes loadingSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   NEW FEATURES — Hint, MiniMap, Badge, Revive, Score Card
   ============================================================ */

/* ---------- Hint Button ---------- */
.hint-btn {
    position: absolute;
    bottom: 100px;
    right: 12px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(79, 195, 247, 0.12);
    border: 2px solid rgba(79, 195, 247, 0.5);
    color: #4fc3f7;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 12px rgba(79, 195, 247, 0.2);
    padding: 0;
}

.hint-btn:hover { background: rgba(79, 195, 247, 0.25); box-shadow: 0 0 20px rgba(79, 195, 247, 0.5); }
.hint-btn.hint-btn-empty { opacity: 0.35; cursor: not-allowed; border-color: rgba(255,255,255,0.15); color: rgba(255,255,255,0.3); }

.hint-count {
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    font-weight: 700;
    color: #4fc3f7;
    line-height: 1;
}

/* ---------- Hint Bubble ---------- */
.hint-bubble {
    position: fixed;
    z-index: 800;
    max-width: 220px;
    background: rgba(10, 25, 50, 0.97);
    border: 1.5px solid rgba(79, 195, 247, 0.5);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 12px;
    color: rgba(200, 230, 255, 0.9);
    line-height: 1.6;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(79, 195, 247, 0.25);
    backdrop-filter: blur(6px);
}

.hint-bubble strong { color: #4fc3f7; }
.hint-bubble.hidden { display: none; }
.hint-bubble-visible { animation: hintFadeIn 0.25s ease; }

@keyframes hintFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- MiniMap Overlay ---------- */
.minimap-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 900;
    background: rgba(10, 20, 40, 0.98);
    border: 1.5px solid rgba(0, 212, 255, 0.3);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.2);
    backdrop-filter: blur(10px);
}

.minimap-overlay.hidden { display: none; }

.minimap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.15);
}

.minimap-title {
    font-family: 'Orbitron', monospace;
    font-size: 12px;
    color: rgba(0, 212, 255, 0.8);
    letter-spacing: 1px;
}

.minimap-close-btn {
    width: 26px; height: 26px;
    background: rgba(239,83,80,0.1);
    border: 1px solid rgba(239,83,80,0.3);
    border-radius: 5px;
    color: #ef5350;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.minimap-close-btn:hover { background: rgba(239,83,80,0.25); }

.minimap-canvas { display: block; }

.minimap-legend {
    display: flex;
    gap: 12px;
    padding: 6px 14px;
    border-top: 1px solid rgba(0, 212, 255, 0.1);
    flex-wrap: wrap;
}

.legend-item {
    font-size: 10px;
    font-family: 'Orbitron', monospace;
    padding: 2px 8px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.legend-correct { background: rgba(50, 200, 100, 0.2); color: #32c864; border: 1px solid rgba(50,200,100,0.4); }
.legend-wrong   { background: rgba(220, 60, 60, 0.2);  color: #dc3c3c; border: 1px solid rgba(220,60,60,0.4); }
.legend-current { background: rgba(255,220,50,0.2);    color: #ffdc32; border: 1px solid rgba(255,220,50,0.4); }
.legend-unseen  { background: rgba(30,50,80,0.5);      color: rgba(150,180,220,0.5); border: 1px solid rgba(150,180,220,0.2); }

/* MiniMap toggle button in HUD */
.minimap-btn {
    position: absolute;
    bottom: 155px;
    right: 12px;
    z-index: 500;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.1);
    border: 2px solid rgba(0, 212, 255, 0.4);
    color: #00d4ff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    padding: 0;
    box-shadow: 0 0 10px rgba(0,212,255,0.15);
}

.minimap-btn:hover { background: rgba(0, 212, 255, 0.22); box-shadow: 0 0 20px rgba(0,212,255,0.4); }

/* ---------- Badge Popup ---------- */
.badge-popup {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 1000;
    min-width: 260px;
    max-width: 300px;
    pointer-events: none;
}

.badge-popup.hidden { display: none; }

.badge-popup-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(10, 20, 40, 0.97);
    border: 1.5px solid rgba(255, 200, 50, 0.5);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 0 30px rgba(255, 200, 50, 0.2);
    backdrop-filter: blur(10px);
}

.badge-popup-anim { animation: badgeSlideIn 0.4s ease; }

@keyframes badgeSlideIn {
    from { opacity: 0; transform: translateX(60px); }
    to   { opacity: 1; transform: translateX(0); }
}

.badge-popup-icon { flex-shrink: 0; }
.badge-popup-text { display: flex; flex-direction: column; gap: 2px; }
.badge-popup-title { font-family: 'Orbitron', monospace; font-size: 10px; color: rgba(255,200,50,0.7); letter-spacing: 1px; text-transform: uppercase; }
.badge-popup-label { font-family: 'Orbitron', monospace; font-size: 13px; color: #fff; font-weight: 700; }
.badge-popup-desc  { font-size: 11px; color: rgba(200,220,255,0.6); }

/* ---------- Revive Container ---------- */
.revive-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
}

.revive-container.hidden { display: none; }

.revive-card {
    background: rgba(10, 25, 45, 0.98);
    border: 2px solid rgba(46, 204, 113, 0.4);
    border-radius: 16px;
    padding: 32px 28px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    box-shadow: 0 0 50px rgba(46, 204, 113, 0.2);
    animation: revivePopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes revivePopIn {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

.revive-icon { margin-bottom: 12px; }

.revive-title {
    font-family: 'Orbitron', monospace;
    font-size: 22px;
    font-weight: 700;
    color: #2ecc71;
    margin-bottom: 8px;
}

.revive-desc {
    font-size: 13px;
    color: rgba(200, 230, 200, 0.7);
    line-height: 1.6;
    margin-bottom: 24px;
}

.revive-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.revive-watch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(46,204,113,0.25), rgba(39,174,96,0.2));
    border: 2px solid #2ecc71;
    color: #2ecc71;
    font-family: 'Orbitron', monospace;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.revive-watch-btn:hover {
    background: linear-gradient(135deg, rgba(46,204,113,0.4), rgba(39,174,96,0.35));
    box-shadow: 0 0 20px rgba(46,204,113,0.4);
}

.revive-skip-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.35);
    font-size: 12px;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Orbitron', monospace;
}

.revive-skip-btn:hover { color: rgba(255,255,255,0.55); border-color: rgba(255,255,255,0.3); }
