/* SciBit G.05 — Pinball */

@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); }

.balls { display: flex; gap: 6px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(5, 7, 10, 0.55); }
.balls i {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #8ea3b8 55%, #3a4a5c);
  box-shadow: 0 0 8px rgba(180, 220, 255, 0.35);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.balls i.spent { opacity: 0.18; transform: scale(0.8); box-shadow: none; }

.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; }
.status { flex: 1; text-align: center; font-size: 0.85rem; color: var(--muted); }
.status.hot { color: var(--gold); font-weight: 600; }
.voucher-teaser { max-width: 220px; text-align: right; font-size: 0.8rem; color: var(--muted); }
.voucher-teaser.unlocked { color: var(--accent); font-weight: 600; }

/* Pinball controls */
.pb-controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 16;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 14px calc(92px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.pb-btn {
  pointer-events: auto;
  border: 1px solid var(--line);
  background: rgba(8, 12, 18, 0.8);
  color: var(--ink);
  font: inherit; cursor: pointer;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pb-btn.flip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 118px; height: 66px; border-radius: 14px;
}

.pb-btn .pb-name { font-weight: 700; letter-spacing: 0.08em; font-size: 0.9rem; }
.pb-btn .pb-key { font-size: 0.62rem; letter-spacing: 0.16em; color: var(--muted); }

.pb-btn.flip:hover, .pb-btn.flip:focus-visible,
.pb-btn.flip.active { border-color: var(--cyan); box-shadow: 0 0 22px rgba(61, 224, 224, 0.3); outline: none; }
.pb-btn.flip.active { transform: translateY(2px); }

.pb-btn.launch {
  display: none; /* shown only while a ball is waiting to launch */
  flex-direction: column; align-items: center; gap: 6px;
  width: 168px; padding: 10px 14px; border-radius: 14px;
}
body.launching .pb-btn.launch { display: flex; }
.pb-btn.launch .pb-name { font-size: 0.78rem; letter-spacing: 0.18em; }
.pb-btn.launch:hover, .pb-btn.launch:focus-visible { border-color: var(--gold); box-shadow: 0 0 22px rgba(255, 211, 92, 0.3); outline: none; }
.pb-btn.launch.active { border-color: var(--gold); }

.charge-track { width: 100%; height: 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.charge-fill { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #3de0e0, #ffd35c); box-shadow: 0 0 10px rgba(255, 211, 92, 0.6); transition: width 0.05s linear; }

/* 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; }
  .hud-bottom { flex-wrap: wrap; gap: 8px; }
  .status { order: 3; width: 100%; text-align: left; }
  .voucher-teaser { order: 4; width: 100%; max-width: none; text-align: left; }
  .pb-btn.flip { width: 96px; height: 60px; }
  .pb-btn.launch { width: 140px; }
  .overlay-card, .voucher-card, .help-card { padding: 22px; }
}
