/* SciBit G.02 — Crystal Forest */

@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;
  --cyan-dim: rgba(61, 224, 224, 0.25);
  --accent: #ff6b35;
  --gold: #ffd35c;
  --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);
}

.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;
}

.game-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 5px 12px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, 0.55);
  font-family: 'Instrument Sans', monospace, sans-serif;
}

.timer-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.timer-digits {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(61, 224, 224, 0.35);
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

.game-timer.low .timer-digits {
  color: var(--accent);
  text-shadow: 0 0 16px rgba(255, 107, 53, 0.55);
  animation: timerPulse 0.8s ease-in-out infinite;
}

.game-timer.critical .timer-digits {
  color: #ff4d4d;
  text-shadow: 0 0 20px rgba(255, 77, 77, 0.65);
  animation: timerPulse 0.4s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.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: 90px;
}

.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;
}

.progress {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.stat-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.stat-icon.crystal { color: var(--cyan); text-shadow: 0 0 10px rgba(61, 224, 224, 0.5); }
.stat-icon.heart { color: #ff5d7a; text-shadow: 0 0 10px rgba(255, 93, 122, 0.4); letter-spacing: 2px; }

.voucher-teaser {
  max-width: 190px;
  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: 0;
  z-index: 15;
  pointer-events: none;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px calc(96px + env(safe-area-inset-bottom));
}

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

.touch-pad {
  display: flex;
  gap: 14px;
  pointer-events: auto;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(5, 7, 10, 0.55);
  color: var(--cyan);
  font-size: 1.3rem;
  line-height: 1;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto;
  -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);
}

.touch-jump {
  width: 74px;
  height: 74px;
  font-size: 1.5rem;
}

/* Banner */
.banner {
  position: fixed;
  top: 22%;
  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;
}

/* 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; }

/* Overlay / voucher / help */
.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;
}

/* Forms */
.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 / start */
.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); }
.help-card .crystal { color: var(--cyan); }

.progress-note {
  color: var(--cyan);
  font-size: 0.85rem;
  margin: 0 0 18px;
}

/* 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;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .hud-top { padding: 8px 12px; }
  .hud-title { font-size: 0.65rem; }

  .hud-bottom {
    flex-wrap: wrap;
    gap: 10px;
  }

  .progress { order: 3; width: 100%; text-align: left; }
  .voucher-teaser { order: 4; width: 100%; max-width: none; text-align: left; }

  .overlay-card, .voucher-card, .help-card { padding: 22px; }
}
