/* SciBit G.04 — Coin Rush */

@font-face {
  font-family: 'Instrument Sans';
  src: url('../../Res/Fonts/instrument-sans-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Instrument Serif';
  src: url('../../Res/Fonts/instrument-serif.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #05070a;
  --panel: rgba(8, 12, 18, 0.96);
  --ink: #e8eef5;
  --muted: #93a2b3;
  --cyan: #3de0e0;
  --accent: #ff6b35;
  --gold: #ffd35c;
  --bad: #ff5d7a;
  --line: rgba(147, 162, 179, 0.18);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Instrument Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

/* Loader */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: radial-gradient(circle at 50% 50%, #0b1118 0%, #05070a 70%);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--cyan);
  animation: spin 1s linear infinite;
}

.loader-text { margin: 0; color: var(--muted); font-size: 0.875rem; letter-spacing: 0.12em; text-transform: uppercase; }
@keyframes spin { to { transform: rotate(360deg); } }

/* HUD */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

.hud-top {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(5, 7, 10, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1rem; }
.hud-brand img { display: block; filter: brightness(1.2); }
.hud-title { flex: 1; text-align: center; font-size: 0.75rem; letter-spacing: 0.18em; color: var(--muted); text-transform: uppercase; }
.hud-fig { color: var(--cyan); }

.speedo {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, 0.55);
  font-family: 'Instrument Sans', monospace, sans-serif;
}

.speedo-value { font-size: 1.15rem; font-weight: 700; color: var(--cyan); text-shadow: 0 0 12px rgba(61, 224, 224, 0.35); }
.speedo-unit { font-size: 0.6rem; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }

.hud-help {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(61, 224, 224, 0.08);
  color: var(--cyan); font-weight: 700; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.hud-help:hover, .hud-help:focus-visible { background: rgba(61, 224, 224, 0.18); border-color: var(--cyan); outline: none; }

.hud-bottom {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(5, 7, 10, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.score-board { display: flex; flex-direction: column; min-width: 84px; }
.score-label { font-size: 0.65rem; letter-spacing: 0.15em; color: var(--muted); }
.score-count { font-size: 1.5rem; font-weight: 700; color: var(--cyan); line-height: 1.1; }

.race-progress {
  position: relative;
  flex: 1;
  height: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  overflow: hidden;
}

.race-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #2fa88f, #3de0e0);
  box-shadow: 0 0 14px rgba(61, 224, 224, 0.5);
  transition: width 0.12s linear;
}

.race-progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--ink);
  font-weight: 700;
}

.lives { font-size: 1.15rem; color: var(--bad); letter-spacing: 3px; text-shadow: 0 0 10px rgba(255, 93, 122, 0.4); }

.voucher-teaser { max-width: 200px; text-align: right; font-size: 0.8rem; color: var(--muted); }
.voucher-teaser.unlocked { color: var(--accent); font-weight: 600; }

/* Touch controls */
.touch-controls {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 16;
  pointer-events: none;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 22px calc(96px + env(safe-area-inset-bottom));
}

body.touch .touch-controls { display: flex; }

.touch-btn {
  pointer-events: auto;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, 0.55);
  color: var(--cyan);
  font-size: 1.6rem;
  line-height: 1;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.touch-btn:active, .touch-btn.active { background: rgba(61, 224, 224, 0.25); border-color: var(--cyan); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
  border: 1px solid transparent;
}

.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--cyan); color: #021417; box-shadow: 0 0 20px rgba(61, 224, 224, 0.25); }
.btn-primary:hover, .btn-primary:focus-visible { background: #5fffff; box-shadow: 0 0 28px rgba(61, 224, 224, 0.4); outline: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover, .btn-ghost:focus-visible { border-color: var(--cyan); color: var(--cyan); outline: none; }
.hidden { display: none !important; }

/* Modals */
.overlay, .voucher, .help {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 7, 10, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  overflow: hidden;
}

.overlay.open, .voucher.open, .help.open { opacity: 1; visibility: visible; }

.overlay-card, .voucher-card, .help-card {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  position: relative;
}

.overlay-close {
  position: absolute; top: 16px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, 0.7);
  color: var(--ink); font-size: 1.5rem; line-height: 1; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.overlay-close:hover:not(:disabled), .overlay-close:focus-visible:not(:disabled) { background: rgba(61, 224, 224, 0.12); border-color: var(--cyan); outline: none; }
.overlay-close:disabled { opacity: 0.35; cursor: not-allowed; }

.overlay-countdown { position: absolute; top: 24px; right: 66px; font-size: 0.8rem; letter-spacing: 0.08em; color: var(--accent); text-transform: uppercase; }

.overlay-fig, .voucher-badge, .help-fig {
  display: block; margin-bottom: 8px; font-size: 0.72rem; letter-spacing: 0.2em; color: var(--cyan); text-transform: uppercase;
}

.voucher-badge { color: var(--accent); }

.overlay-title, .voucher-title, .help-card h2 {
  margin: 0 0 16px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 400;
  line-height: 1.1;
}

.overlay-body { color: var(--muted); font-size: 1rem; line-height: 1.7; }
.overlay-body h3 { margin: 24px 0 10px; color: var(--ink); font-size: 1.1rem; font-weight: 600; }
.overlay-body p { margin: 0 0 14px; }
.overlay-body ul, .overlay-body ol { margin: 0 0 16px; padding-left: 22px; }
.overlay-body li { margin-bottom: 8px; }
.overlay-body strong { color: var(--ink); font-weight: 600; }
.overlay-more { margin-top: 20px; }

.overlay-more a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border: 1px solid var(--cyan); border-radius: 8px;
  background: rgba(61, 224, 224, 0.1); color: var(--cyan); font-weight: 600; text-decoration: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.overlay-more a:hover, .overlay-more a:focus-visible { background: rgba(61, 224, 224, 0.2); box-shadow: 0 0 20px rgba(61, 224, 224, 0.25); }

.voucher-code {
  display: inline-block; padding: 14px 28px; margin: 10px 0 20px;
  background: rgba(61, 224, 224, 0.1);
  border: 2px dashed var(--cyan);
  border-radius: 10px; color: var(--cyan);
  font-family: 'Instrument Sans', monospace, sans-serif;
  font-size: 1.8rem; font-weight: 700; letter-spacing: 0.08em;
}

.voucher-note { color: var(--muted); margin-bottom: 8px; }
.voucher-terms { grid-column: 1 / -1; color: var(--accent); font-size: 0.9rem; font-weight: 600; margin: 0 0 18px; }

.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 540px) { .form-grid.two { grid-template-columns: 1fr; } }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.form-field input, .form-field textarea, .form-field select {
  padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03); color: var(--ink); font: inherit; font-size: 1rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-field input:focus, .form-field textarea:focus, .form-field select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(61, 224, 224, 0.1); }
.form-field textarea { min-height: 100px; resize: vertical; }
.form-field select option { background: #0b1118; color: var(--ink); }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.help-intro { color: var(--muted); line-height: 1.6; margin: 0 0 18px; }
.help-card ul { margin: 0 0 20px; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.help-card li { margin-bottom: 10px; }
.help-card strong { color: var(--ink); }
.progress-note { color: var(--cyan); font-size: 0.85rem; margin: 0 0 18px; }

/* Banner */
.banner {
  position: fixed; top: 12%; left: 50%; z-index: 18;
  transform: translate(-50%, -12px);
  text-align: center; padding: 14px 30px; border-radius: 14px;
  background: rgba(5, 7, 10, 0.62); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
  pointer-events: none;
}

.banner.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.banner span { display: block; font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--cyan); margin-bottom: 4px; }
.banner strong { font-family: 'Instrument Serif', Georgia, serif; font-size: 1.8rem; font-weight: 400; }

/* Toast */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 45;
  padding: 12px 24px; background: var(--panel); border: 1px solid var(--cyan); border-radius: 10px;
  color: var(--ink); font-size: 0.95rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(61, 224, 224, 0.1);
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  pointer-events: none; max-width: min(90vw, 420px); text-align: center;
}

.toast.show { opacity: 1; visibility: visible; }

@media (max-width: 640px) {
  .hud-top { padding: 8px 10px; gap: 8px; }
  .hud-title { font-size: 0.62rem; letter-spacing: 0.12em; }
  .speedo { padding: 3px 8px; }
  .hud-bottom { flex-wrap: wrap; gap: 8px; }
  .race-progress { order: 3; width: 100%; flex: none; }
  .voucher-teaser { order: 4; width: 100%; max-width: none; text-align: left; }
  .overlay-card, .voucher-card, .help-card { padding: 22px; }
}
