/* The launcher page (index.html): the colours of the game's menus, the
   fonts the port draws them with (Overpass, and OpenCE for the title). */

@font-face {
  font-family: "OpenCE";
  src: url("fonts/OpenCE-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Overpass";
  font-weight: 750;
  src: url("fonts/Overpass-750.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #0a0e14;
  --panel: #111925;
  --panel-edge: #23324a;
  --text: #dbe4f0;
  --muted: #8ea0b8;
  --accent: #4fb3ff;
  --accent-text: #04121f;
  --good: #5ed39a;
  --bad: #ff6b6b;
  --warn: #f2c14e;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a { color: var(--accent); }
code { font-size: 0.9em; }

#launcher {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.masthead {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.masthead img { border-radius: 16px; flex: none; }
.masthead h1 {
  margin: 0;
  font: 400 44px/1 "OpenCE", "Overpass", system-ui, sans-serif;
  letter-spacing: 0.04em;
}
.tagline { margin: 6px 0 0; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}
.panel h2, .panel summary, .sheet h2 {
  margin: 0 0 8px;
  font: 750 15px/1.3 "Overpass", system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
details.panel summary { cursor: pointer; margin: 0; }
details.panel[open] summary { margin-bottom: 12px; }

.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 10px; align-items: baseline; padding: 2px 0; }
.checks li::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-1px);
}
.checks li.good::before { background: var(--good); }
.checks li.bad::before { background: var(--bad); }
.checks li.warn::before { background: var(--warn); }
.checks .detail { color: var(--muted); font-size: 14px; }

.status { margin: 0 0 12px; }
.note { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  background: #182436;
  color: var(--text);
  font: 750 14px/1 "Overpass", system-ui, sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:focus-visible, .button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled, .button.disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
button.danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); }

.mods { list-style: none; margin: 0 0 12px; padding: 0; }
.mods li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 4px 0; }
.mods .detail { color: var(--muted); font-size: 14px; }
.mods .actions { display: flex; gap: 8px; flex-shrink: 0; }

.play-row { margin: 24px 0; }
.play-row .primary { min-width: 200px; min-height: 52px; font-size: 18px; }

.progress { margin-top: 12px; }
.progress-bar { height: 8px; border-radius: 4px; background: #1d2a3e; overflow: hidden; }
.progress-bar > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 14px; }

.site-footer { margin: 32px 0 8px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.site-footer p { margin: 0; }

/* the game: the canvas fills the window */
#game { position: fixed; inset: 0; background: #000; }
#canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}
.starting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  pointer-events: none;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #1d2a3e;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toolbar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  gap: 6px;
  opacity: 0.25;
  transition: opacity 0.2s;
}
.toolbar:hover, .toolbar:focus-within { opacity: 1; }
.toolbar button { min-height: 32px; padding: 6px 10px; font-size: 12px; background: rgba(10, 14, 20, 0.8); }
/* a game hosted for the internet: its invite link (app.js) */
.invite {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  max-width: calc(100% - 200px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(10, 14, 20, 0.85);
  color: var(--text);
  font-size: 12px;
}
.invite input {
  flex: 1 1 260px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  background: #0a0e14;
  color: var(--text);
  font: 12px ui-monospace, monospace;
}
.invite button { min-height: 30px; padding: 6px 10px; font-size: 12px; }

.sheet {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10;
}
#ask-text { white-space: pre-line; }

.sheet-body {
  width: min(760px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 20px;
}
.sheet pre {
  max-height: 40vh;
  overflow: auto;
  padding: 12px;
  background: #070a0f;
  border-radius: 6px;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.banner {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  z-index: 5;
}

/* the on-screen touch controls (touch.js): circles over the game */
.touch { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-control {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(219, 228, 240, 0.45);
  background: rgba(10, 14, 20, 0.28);
  color: rgba(219, 228, 240, 0.85);
  font-family: "Overpass", system-ui, sans-serif;
  font-weight: 750;
  text-align: center;
  line-height: 1;
  pointer-events: none;
}
.touch-control.held { background: rgba(79, 179, 255, 0.45); border-color: var(--accent); }
.touch-stick-zone { background: rgba(10, 14, 20, 0.12); border-style: dashed; }
.touch-stick-ring, .touch-stick-knob { position: absolute; display: none; border-radius: 50%; pointer-events: none; }
.touch-stick-ring { border: 2px solid rgba(219, 228, 240, 0.4); }
.touch-stick-knob { background: rgba(219, 228, 240, 0.55); }

/* the orders to the Marines (orders.js): a button, a wheel, a line */
.orders-button {
  position: absolute;
  /* (below the game's ammunition and grenades at the top left) */
  top: calc(env(safe-area-inset-top, 0px) + 19%);
  left: max(10px, env(safe-area-inset-left));
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 750;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.6);
  border: 2px solid rgba(79, 179, 255, 0.7);
  color: #dbe4f0;
  z-index: 6;
  touch-action: manipulation;
}
.orders-wheel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 14, 0.35);
  z-index: 7;
  touch-action: manipulation;
}
.orders-ring {
  --radius: min(40vmin, 180px);
  position: relative;
  width: calc(var(--radius) * 2 + 96px);
  height: calc(var(--radius) * 2 + 96px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(10, 14, 20, 0.75) 0 58%, rgba(10, 14, 20, 0.35) 60%);
}
.orders-item {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 80px;
  height: 64px;
  margin: -32px 0 0 -40px;
  transform: translate(calc(var(--x) * var(--radius)), calc(var(--y) * var(--radius)));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 3px;
  border-radius: 14px;
  background: rgba(16, 24, 36, 0.92);
  border: 2px solid rgba(219, 228, 240, 0.35);
  color: #dbe4f0;
  font-size: 11px;
  line-height: 1.1;
}
.orders-item.current { border-color: var(--accent); background: rgba(79, 179, 255, 0.28); }
.orders-icon { font-size: 19px; }
.orders-key { font-size: 10px; opacity: 0.6; }
.orders-close {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.85);
}
@media (pointer: coarse) { .orders-key { display: none; } }
.orders-toast {
  position: absolute;
  top: max(60px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.8);
  border: 1px solid var(--accent);
  color: #dbe4f0;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
  z-index: 6;
}

/* the deliveries by Pelican (deliveries.js): a button under the orders', a
wheel with its tabs, a line under the orders' */
.delivery-button { top: calc(env(safe-area-inset-top, 0px) + 19% + 50px); }
.delivery-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.delivery-tabs { display: flex; gap: 6px; }
.delivery-tab {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.85);
  border: 2px solid rgba(219, 228, 240, 0.35);
  color: #dbe4f0;
}
.delivery-tab.current { border-color: var(--accent); background: rgba(79, 179, 255, 0.28); }
.delivery-wheel .orders-item:disabled { opacity: 0.35; }
.delivery-hint {
  max-width: calc(100vw - 32px);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.8);
  color: #dbe4f0;
  font-size: 12px;
  text-align: center;
}
/* the wheel of what to say to a Marine (chat.js): the orders' wheel, its
choices wider for their sentences */
.chat-wheel .orders-item { width: 112px; height: 72px; margin: -36px 0 0 -56px; font-size: 11px; }
.delivery-toast { top: max(104px, calc(env(safe-area-inset-top) + 100px)); }

/* the Warthog race (race.js): a button under the deliveries', its line under
theirs, and the race at the top: the countdown, then the lap, the place and
the time */
.race-button { top: calc(env(safe-area-inset-top, 0px) + 19% + 100px); }
.race-button.race-button-up { top: calc(env(safe-area-inset-top, 0px) + 19% + 50px); }
.race-toast { top: max(148px, calc(env(safe-area-inset-top) + 144px)); }
.race-panel {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 32px);
  pointer-events: none;
  z-index: 6;
  --hud: #74d2ff;
  --hud-bright: #c9f0ff;
}
.race-line {
  padding: 6px 14px;
  background: rgba(8, 30, 50, 0.72);
  border-top: 1px solid rgba(116, 210, 255, 0.42);
  border-bottom: 1px solid rgba(116, 210, 255, 0.42);
  color: var(--hud);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 0 6px rgba(116, 210, 255, 0.65);
  font-variant-numeric: tabular-nums;
}
.race-big {
  color: var(--hud-bright);
  font-size: clamp(44px, 14vmin, 96px);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(116, 210, 255, 0.9);
}

/* the orders' and the deliveries' look over the game: the HUD's own (thin
cyan lines, cut corners, capitals that glow), after its motion tracker and
its shield bar */
.orders-button, .orders-wheel, .orders-toast, .delivery-hint {
  --hud: #74d2ff;
  --hud-bright: #c9f0ff;
  --hud-dim: rgba(116, 210, 255, 0.42);
  --hud-fill: rgba(8, 30, 50, 0.72);
  --hud-cut: 9px;
}
.orders-button, .delivery-tab, .orders-toast, .delivery-hint, .orders-close {
  border: 0;
  border-radius: 0;
  clip-path: polygon(var(--hud-cut) 0, 100% 0, 100% calc(100% - var(--hud-cut)), calc(100% - var(--hud-cut)) 100%,
    0 100%, 0 var(--hud-cut));
  background:
    linear-gradient(135deg, var(--hud) 0 calc(var(--hud-cut) * 0.7), transparent calc(var(--hud-cut) * 0.7 + 1px)),
    linear-gradient(-45deg, var(--hud) 0 calc(var(--hud-cut) * 0.7), transparent calc(var(--hud-cut) * 0.7 + 1px)),
    linear-gradient(var(--hud-dim), var(--hud-dim)) top / 100% 1px no-repeat,
    linear-gradient(var(--hud-dim), var(--hud-dim)) bottom / 100% 1px no-repeat,
    linear-gradient(var(--hud-dim), var(--hud-dim)) left / 1px 100% no-repeat,
    linear-gradient(var(--hud-dim), var(--hud-dim)) right / 1px 100% no-repeat,
    var(--hud-fill);
  color: var(--hud);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-shadow: 0 0 6px rgba(116, 210, 255, 0.65);
}
.orders-button { font-size: 13px; font-weight: 700; }
/* the keys beside the buttons (keys.js): the keyboard's on a computer, the
gamepad's while one is connected, none on a touch screen alone */
.key-hint {
  display: none;
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid var(--hud-dim);
  border-radius: 3px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--hud-bright);
  background: rgba(116, 210, 255, 0.12);
}
html[data-keys="key"] .key-hint-key, html[data-keys="pad"] .key-hint-pad { display: inline-block; }
.orders-wheel { background: radial-gradient(circle, rgba(4, 16, 28, 0.25), rgba(2, 8, 14, 0.55)); }
.orders-ring {
  background:
    radial-gradient(circle, rgba(6, 22, 38, 0.6) 0 22%, transparent 22.3%),
    radial-gradient(circle, transparent 0 21.6%, var(--hud-dim) 21.8% 22.2%, transparent 22.5% 96%,
      var(--hud) 96.3% 96.9%, transparent 97.3%),
    radial-gradient(circle, rgba(6, 22, 38, 0.55) 0 70%, rgba(6, 22, 38, 0.2) 71%);
}
/* (the tracker's ticks around it) */
.orders-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--hud-dim) 0 0.7deg, transparent 0.7deg 7.5deg);
  -webkit-mask: radial-gradient(circle, transparent 0 91%, #000 91.5% 95%, transparent 95.5%);
  mask: radial-gradient(circle, transparent 0 91%, #000 91.5% 95%, transparent 95.5%);
  pointer-events: none;
}
.orders-item {
  border: 0;
  border-radius: 0;
  clip-path: polygon(14% 0, 86% 0, 100% 50%, 86% 100%, 14% 100%, 0 50%);
  background:
    linear-gradient(var(--hud-dim), var(--hud-dim)) top / 72% 1px no-repeat,
    linear-gradient(var(--hud-dim), var(--hud-dim)) bottom / 72% 1px no-repeat,
    var(--hud-fill);
  color: var(--hud);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-shadow: 0 0 5px rgba(116, 210, 255, 0.6);
}
.orders-item.current, .orders-item:hover:not(:disabled) {
  background:
    linear-gradient(var(--hud-bright), var(--hud-bright)) top / 72% 2px no-repeat,
    linear-gradient(var(--hud-bright), var(--hud-bright)) bottom / 72% 2px no-repeat,
    rgba(116, 210, 255, 0.32);
  color: var(--hud-bright);
  text-shadow: 0 0 8px rgba(201, 240, 255, 0.9);
}
.delivery-wheel .orders-item:disabled { opacity: 0.3; text-shadow: none; }
/* (the icons in the HUD's colour, the emoji too) */
.orders-icon { color: var(--hud); filter: grayscale(1) sepia(1) saturate(4) hue-rotate(160deg) brightness(1.15); }
.orders-close { --hud-cut: 6px; color: var(--hud); }
.delivery-tab { --hud-cut: 7px; }
.delivery-tab.current {
  background:
    linear-gradient(135deg, var(--hud-bright) 0 5px, transparent 6px),
    linear-gradient(-45deg, var(--hud-bright) 0 5px, transparent 6px),
    rgba(116, 210, 255, 0.32);
  color: var(--hud-bright);
}
.orders-toast, .delivery-hint { font-size: 12px; font-weight: 700; }

/* (a short screen, a phone held sideways: the deliveries' tabs beside the
wheel, which keeps to the screen's height) */
.delivery-wheel .orders-ring { --radius: min(34vmin, 180px); }
@media (max-height: 520px) {
  .delivery-panel { flex-direction: row; }
  .delivery-tabs { flex-direction: column; }
  .delivery-hint { position: absolute; bottom: max(4px, env(safe-area-inset-bottom)); }
}

[hidden] { display: none !important; }

/* The dialogue choice fills only while its stick direction is held. */
.chat-hold-progress {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 5px;
  height: 4px;
  background: rgba(116, 210, 255, 0.18);
  pointer-events: none;
}
.chat-hold-progress::after {
  content: "";
  display: block;
  width: var(--hold-progress, 0%);
  height: 100%;
  background: var(--hud-bright);
  box-shadow: 0 0 6px var(--hud);
}
