/* =========================================================
   NOVA: Street Legends — base styles, tokens and screen system
   ========================================================= */

:root {
  --bg-0: #03040a;
  --bg-1: #070a1a;
  --bg-2: #0b1030;
  --panel: rgba(8, 12, 34, 0.78);
  --panel-solid: #0a0f2a;
  --line: rgba(120, 140, 255, 0.18);
  --line-strong: rgba(140, 160, 255, 0.4);

  --blue: #2f7bff;
  --electric: #29d3ff;
  --purple: #9b4dff;
  --magenta: #d24dff;
  --gold: #ffcc4d;
  --silver: #c9d3e6;
  --bronze: #d9894a;
  --danger: #ff4d6d;

  --text: #e8ecff;
  --text-dim: #8a93c2;
  --text-faint: #565f8f;

  --grad-accent: linear-gradient(90deg, var(--blue), var(--purple));
  --glow-blue: 0 0 18px rgba(47, 123, 255, 0.55);
  --glow-purple: 0 0 22px rgba(155, 77, 255, 0.55);

  --font-display: "Orbitron", "Eurostile", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Rajdhani", "Segoe UI", system-ui, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-med: 380ms;
  --t-slow: 700ms;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --gutter: clamp(16px, 3.2vw, 48px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.45em;
  margin: 0 0.1em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 0.85em;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: rgba(20, 28, 70, 0.6);
}

/* ---------- WebGL viewport ---------- */
#viewport {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

/* ---------- Screen system ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), visibility 0s linear var(--t-med);
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--t-med) var(--ease-out), visibility 0s linear 0s;
}

/* ---------- Fade transition ---------- */
.fade {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg-0);
  opacity: 0;
  pointer-events: none;
  transition: opacity 450ms ease;
}

.fade.on {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Shared buttons ---------- */
.primary-btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2em;
  color: #fff;
  background: var(--grad-accent);
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: filter var(--t-fast), transform var(--t-fast);
}

.primary-btn:hover,
.primary-btn:focus-visible {
  filter: brightness(1.2) drop-shadow(0 0 12px rgba(155, 77, 255, 0.7));
  outline: none;
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn[disabled] {
  filter: grayscale(0.9) brightness(0.6);
  cursor: not-allowed;
}

.danger-btn {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--danger);
  border: 1px solid rgba(255, 77, 109, 0.5);
  border-radius: 4px;
  transition: background var(--t-fast);
}

.danger-btn:hover,
.danger-btn:focus-visible {
  background: rgba(255, 77, 109, 0.12);
  outline: none;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 12px 22px;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--purple);
  box-shadow: var(--glow-purple);
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Fatal error ---------- */
.fatal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font-size: 18px;
  line-height: 1.5;
  background: var(--bg-0);
}

.fatal[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.danger-btn.confirming {
  color: #fff;
  background: rgba(255, 77, 109, 0.35);
  border-color: var(--danger);
}

/* The hidden attribute must always win over component display rules */
[hidden] {
  display: none !important;
}
