/* ============================================================
   ASTEROID ESCAPE — cosmic arcade terminal
   ============================================================ */

:root {
  --bg:        #060709;
  --bg-panel:  #0b0d14;
  --ink:       #f3f1e7;
  --ink-dim:   #8b909d;
  --lime:      #c8ff2b;
  --cyan:      #37e6ff;
  --coral:     #ff5436;
  --line:      rgba(243, 241, 231, 0.14);
  --font-display: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "Space Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(ellipse 80% 55% at 50% -12%, rgba(55, 230, 255, 0.12), transparent 70%),
    radial-gradient(ellipse 70% 50% at 92% 112%, rgba(200, 255, 43, 0.08), transparent 70%),
    radial-gradient(ellipse 65% 50% at 4% 105%, rgba(255, 84, 54, 0.07), transparent 70%),
    var(--bg);
}

/* ===== Full-screen decorative overlays ===== */
.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.fx-grain {
  z-index: 41;
  opacity: 0.4;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.fx-scan {
  z-index: 42;
  opacity: 0.55;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0)    0px,
    rgba(0, 0, 0, 0)    2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0.16) 4px
  );
}

.fx-vignette {
  z-index: 43;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.62) 100%);
}

/* ===== Anaubi back link ===== */
#anaubi-back {
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 9999;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

#anaubi-back a {
  color: var(--bg);
  text-decoration: none;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--lime);
  padding: 5px 10px;
  border-radius: 0;
  transition: transform 0.15s ease, background 0.15s ease;
  display: inline-block;
}

#anaubi-back a:hover {
  transform: translateX(-2px);
  background: var(--cyan);
}

/* ===== Top UI region ===== */
#ui {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: 16px clamp(14px, 4vw, 48px) 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

/* --- Brand / title --- */
.brand {
  text-align: left;
  flex: 0 1 auto;
}

h1 {
  margin: 0;
  font-weight: 700;
  font-size: clamp(26px, 5vw, 58px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.brand-accent {
  color: var(--lime);
  -webkit-text-stroke: 0;
}

.brand-sub {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* --- HUD stat blocks --- */
#hud {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.stat {
  min-width: 78px;
  padding: 7px 12px 8px;
  background: rgba(11, 13, 20, 0.72);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat:nth-child(1) .stat-value { color: var(--lime); }
.stat:nth-child(2) .stat-value { color: var(--coral); }
.stat:nth-child(3) .stat-value { color: var(--cyan); }

.stat-unit {
  font-size: 0.8rem;
  color: var(--ink-dim);
  margin-left: 1px;
}

/* --- Message line --- */
#message {
  margin: 12px 0 0;
  min-height: 18px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(55, 230, 255, 0.4);
}

/* --- Start button --- */
#startButton {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px auto 0;
  padding: 13px 22px;
  background: var(--lime);
  border: none;
  border-radius: 0;
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: color 0.2s ease, transform 0.12s ease;
}

#startButton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cyan);
  transform: translateX(-101%);
  transition: transform 0.28s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: 0;
}

#startButton:hover::before { transform: translateX(0); }
#startButton:active { transform: translateY(1px); }

.btn-label,
.btn-arrow {
  position: relative;
  z-index: 1;
}

.btn-arrow {
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

#startButton:hover .btn-arrow { transform: translateX(4px); }

/* ===== Game canvas ===== */
#gameCanvas {
  display: block;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  background: radial-gradient(circle at center, #090c1a, #030308 80%);
  border: 1px solid rgba(55, 230, 255, 0.18);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(55, 230, 255, 0.1),
    0 24px 80px rgba(0, 0, 0, 0.8);
}

/* ===== Mobile controls ===== */
#mobile-controls {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  left: max(14px, env(safe-area-inset-left, 14px));
  right: max(14px, env(safe-area-inset-right, 14px));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 5;
}

#mobile-controls * { pointer-events: auto; }

#joystick {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(55, 230, 255, 0.08), rgba(3, 4, 8, 0.85));
  border: 2px solid rgba(55, 230, 255, 0.45);
  box-shadow: 0 0 22px rgba(55, 230, 255, 0.18), inset 0 0 24px rgba(0, 0, 0, 0.6);
}

#joystick-handle {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(55, 230, 255, 0.7);
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
}

#btnShoot {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(255, 84, 54, 0.9);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: rgba(255, 84, 54, 0.22);
  color: var(--ink);
  box-shadow: 0 0 22px rgba(255, 84, 54, 0.35), inset 0 0 20px rgba(255, 84, 54, 0.25);
  margin-right: 8px;
  touch-action: none;
}

#btnShoot:active {
  background: rgba(255, 84, 54, 0.5);
}

@media (max-width: 900px) {
  #joystick { width: 140px; height: 140px; }
  #joystick-handle { width: 64px; height: 64px; }
  #btnShoot { width: 104px; height: 104px; }
}

/* ===== Shared modal shell (high scores + name entry) ===== */
#high-scores,
#name-entry {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(8, 10, 18, 0.96);
  z-index: 60;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: center;
}

#high-scores {
  display: none;
  border: 1px solid var(--line);
  border-top: 3px solid var(--lime);
  padding: 20px 26px 22px;
  min-width: 268px;
  max-width: 360px;
  pointer-events: none;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

#high-scores h3 {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  color: var(--lime);
  text-transform: uppercase;
}

.hs-table {
  margin: 0 auto;
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-mono);
}

.hs-table th,
.hs-table td {
  padding: 5px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(243, 241, 231, 0.08);
  font-size: 12px;
}

.hs-table th {
  color: var(--ink-dim);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hs-table td {
  font-variant-numeric: tabular-nums;
}

.hs-current td {
  color: var(--lime);
  font-weight: 700;
  text-shadow: 0 0 10px rgba(200, 255, 43, 0.45);
}

.hs-date {
  color: var(--ink-dim);
  font-size: 11px;
}

@media (max-width: 360px) {
  .hs-col-date { display: none; }
}

/* ===== Name entry modal ===== */
#name-entry {
  border: 1px solid var(--line);
  border-top: 3px solid var(--coral);
  padding: 26px 30px 26px;
  z-index: 70;
  min-width: 256px;
  max-width: 320px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

.ne-title {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--coral);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.ne-score {
  margin: 0 0 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-dim);
  letter-spacing: 0.05em;
}

.ne-hint {
  margin: 8px 0 14px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

#ne-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: rgba(243, 241, 231, 0.05);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  padding: 11px 12px;
  text-align: center;
  letter-spacing: 0.22em;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#ne-input::placeholder {
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  font-weight: 400;
}

#ne-input:focus {
  border-color: var(--coral);
  background: rgba(255, 84, 54, 0.08);
}

#ne-submit {
  padding: 11px 30px;
  background: var(--coral);
  border: none;
  border-radius: 0;
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}

#ne-submit:hover { background: var(--lime); }
#ne-submit:active { transform: translateY(1px); }

/* ===== Orientation banner (portrait phones) ===== */
#orientation-prompt {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--lime);
  color: var(--bg);
  padding: 9px 16px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#orientation-prompt p { margin: 0; }

.rotate-icon {
  font-size: 18px;
  display: inline-block;
  animation: spin 3s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Portrait phones: show rotation banner and push UI below it */
@media (orientation: portrait) and (max-width: 600px) {
  #orientation-prompt { display: flex; }
  #ui { top: 38px; }
}

/* Touch devices: drop the wordy subtitle */
@media (pointer: coarse) {
  .brand-sub { display: none; }
}

/* Compact landscape (phones held sideways) */
@media (max-height: 450px) {
  #ui { padding-top: 8px; }
  h1 { display: none; }
  .brand-sub { display: none; }
  .topbar { justify-content: center; padding-bottom: 8px; }
  .stat { min-width: 64px; padding: 5px 9px 6px; }
  .stat-value { font-size: 1.15rem; }
  #joystick { width: 92px; height: 92px; }
  #joystick-handle { width: 44px; height: 44px; }
  #btnShoot { width: 74px; height: 74px; font-size: 12px; }
}

/* Tablets (touch + wide) */
@media (min-width: 768px) and (pointer: coarse) {
  #joystick { width: 150px; height: 150px; }
  #joystick-handle { width: 68px; height: 68px; }
  #btnShoot { width: 112px; height: 112px; }
}

/* Narrow screens: stack brand above HUD */
@media (max-width: 620px) {
  .topbar {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  .brand { text-align: center; }
  #hud { width: 100%; justify-content: center; }
}
