/* XenoTech — chrome around the canvas.
   The canvas itself is drawn by Phaser; everything here is the menu layer that
   sits on top of it, plus the page it all floats in. */

:root {
  --void: #05060f;
  --hull: #0b1026;
  --hull-edge: #1b2450;
  --cyan: #00f0ff;
  --acid: #7cff5a;
  --violet: #7a4dff;
  --bone: #d8e4ff;
  --dim: #7c88b8;
  --danger: #ff3d6e;
  --display: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --arcade: 'Press Start 2P', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--bone);
  font-family: var(--display);
  overflow: hidden;
  overscroll-behavior: none;
  /* A stray swipe on a phone should move the ship, not the page. */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  /* Deep-space wash behind the letterbox bars so they read as part of the game
     rather than as dead browser chrome. */
  background:
    radial-gradient(ellipse at 50% 0%, #17205c 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, #2a1152 0%, transparent 55%),
    var(--void);
}

/* Phaser's FIT mode scales the canvas to its parent, so the parent has to have
   a size of its own. Left to size itself around the canvas, it reports 1280px
   on a 390px phone and the game never scales down at all. */
#game {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  line-height: 0;
}
#game canvas { display: block; touch-action: none; }

/* --- Menu layer ------------------------------------------------------- */

#ui {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  /* Transparent while playing: pointer events belong to the canvas unless a
     screen is actually up. */
  pointer-events: none;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen {
  pointer-events: auto;
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(18px, 4vmin, 34px);
  text-align: center;
  background: linear-gradient(160deg, rgba(11, 16, 38, 0.94), rgba(5, 6, 15, 0.97));
  border: 1px solid var(--hull-edge);
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(0, 240, 255, 0.08), 0 30px 80px rgba(0, 0, 0, 0.7),
              inset 0 1px 0 rgba(124, 255, 90, 0.06);
  animation: screen-in 220ms ease-out;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

.logo {
  font-size: clamp(34px, 9vmin, 64px);
  font-weight: 900;
  letter-spacing: 0.14em;
  margin: 0 0 6px;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.55), 0 0 60px rgba(122, 77, 255, 0.35);
}
.logo span { color: var(--acid); text-shadow: 0 0 18px rgba(124, 255, 90, 0.5); }

.tagline { color: var(--dim); margin: 0 0 22px; font-size: 13px; letter-spacing: 0.06em; }

.screen-title {
  font-family: var(--arcade);
  font-size: clamp(13px, 3.4vmin, 19px);
  letter-spacing: 0.04em;
  color: var(--cyan);
  margin: 0 0 16px;
}

.difficulty { border: 0; margin: 0 0 18px; padding: 0; }
.difficulty legend {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
  padding: 0;
}
.difficulty-note { min-height: 2.4em; margin: 10px 2px 0; font-size: 12px; color: var(--dim); }

.segmented {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.seg, .btn {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--bone);
  background: rgba(27, 36, 80, 0.5);
  border: 1px solid var(--hull-edge);
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms, transform 80ms;
  /* Comfortably tappable on a phone without a stylus. */
  min-height: 44px;
}

.seg { font-size: 12px; padding: 10px 14px; }

.seg:hover, .btn:hover { border-color: var(--cyan); background: rgba(0, 240, 255, 0.1); }
.seg:active, .btn:active { transform: translateY(1px); }

.seg.is-active {
  color: var(--void);
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.4);
}

.btn-primary {
  color: var(--void);
  background: linear-gradient(180deg, var(--acid), #48c62f);
  border-color: var(--acid);
  box-shadow: 0 0 22px rgba(124, 255, 90, 0.3);
}
.btn-primary:hover { background: linear-gradient(180deg, #9dff85, var(--acid)); border-color: #9dff85; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

:where(.seg, .btn, input):focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.byline {
  margin: 18px 0 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.byline a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 240, 255, 0.35);
  padding-bottom: 1px;
  transition: color 120ms, border-color 120ms;
}

.byline a:hover {
  color: var(--acid);
  border-bottom-color: var(--acid);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px 14px;
  margin: 24px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--hull-edge);
  font-size: 11px;
}
.controls div { display: flex; justify-content: space-between; gap: 8px; }
.controls dt { color: var(--dim); letter-spacing: 0.16em; text-transform: uppercase; }
.controls dd { margin: 0; color: var(--bone); }

/* --- Game over -------------------------------------------------------- */

.final-score {
  font-family: var(--arcade);
  font-size: clamp(26px, 8vmin, 46px);
  color: var(--acid);
  text-shadow: 0 0 24px rgba(124, 255, 90, 0.45);
  margin: 6px 0 4px;
}
.final-meta { color: var(--dim); font-size: 12px; letter-spacing: 0.08em; margin: 0 0 20px; }

.submit-form { margin: 0 0 6px; }
.submit-form label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}
.submit-row { display: flex; gap: 8px; justify-content: center; }

input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 260px;
  font-family: var(--arcade);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(5, 6, 15, 0.9);
  border: 1px solid var(--hull-edge);
  border-radius: 8px;
  padding: 12px;
}
input[type="text"]::placeholder { color: #3b466f; }

.form-status { min-height: 1.4em; margin: 10px 0 0; font-size: 12px; letter-spacing: 0.05em; color: var(--dim); }
.form-status.is-error { color: var(--danger); }
.form-status.is-success { color: var(--acid); }

/* --- Leaderboard ------------------------------------------------------ */

.board {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 12px;
  text-align: left;
}
.board li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto 4.6em;
  gap: 10px;
  align-items: baseline;
  padding: 9px 12px;
  background: rgba(27, 36, 80, 0.28);
  border-left: 2px solid var(--hull-edge);
  border-radius: 0 6px 6px 0;
}
.board li.is-you { border-left-color: var(--acid); background: rgba(124, 255, 90, 0.08); }
.board .rank { font-family: var(--arcade); font-size: 10px; color: var(--dim); }
.board li:nth-child(1) .rank { color: #ffd447; }
.board li:nth-child(2) .rank { color: #c8d4ee; }
.board li:nth-child(3) .rank { color: #e08b4a; }
.board .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.06em; }
.board .detail { color: var(--dim); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.board .score { font-family: var(--arcade); font-size: 11px; color: var(--cyan); text-align: right; }
.board .empty, .board .error {
  display: block;
  padding: 22px 10px;
  text-align: center;
  color: var(--dim);
  background: none;
  border: 0;
}
.board .error { color: var(--danger); }

@media (max-width: 420px) {
  .board li { grid-template-columns: 2em 1fr 4.4em; }
  .board .detail { display: none; }
}
