:root {
  --sea: #0b2a3d;
  --ink: #f3ead7;
  --muted: #b9ae98;
  --paper: rgba(20, 16, 12, 0.88);
  --edge: #8a6a3f;
  --gold: #f2c14e;
  --good: #7fd67f;
  --warn: #f0a040;
  --bad: #ff5a45;
  --unk: #9aa7ad;
  --whale: #8fc1e3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sea);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

#sea {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* ---- HUD ---- */
#hud {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  right: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 6px 12px;
  background: rgba(8, 20, 30, 0.6);
  border: 1px solid rgba(243, 234, 215, 0.15);
  border-radius: 10px;
  pointer-events: none;
}
#hud[hidden] { display: none; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.value { font-weight: 700; font-variant-numeric: tabular-nums; }
.rep span { margin-right: 8px; white-space: nowrap; }
.rep span::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  background: currentColor;
}
.hunger { flex: 1 1 120px; }
.bar {
  height: 10px;
  margin-top: 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#hHunger { height: 100%; width: 100%; background: var(--good); transition: background 0.2s; }
#hHunger.low { background: var(--warn); }
#hHunger.critical { background: var(--bad); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { opacity: 0.45; } }

.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.unk { color: var(--unk); }

/* ---- Fire button ---- */
#fire {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: rgba(40, 24, 10, 0.75);
  color: var(--gold);
  font: 700 13px/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  touch-action: none;
  cursor: pointer;
}
#fire[hidden] { display: none; }
#fire.cooling { opacity: 0.45; }
#fire:active { transform: scale(0.95); }

/* ---- Overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(4, 12, 20, 0.45);
}
.overlay[hidden] { display: none; }
.card {
  width: 100%;
  max-width: 480px;
  margin: auto;
  padding: 24px 22px;
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 6px;
  box-shadow: 0 0 0 6px rgba(138, 106, 63, 0.25), 0 20px 60px rgba(0, 0, 0, 0.5);
  -webkit-user-select: text;
  user-select: text;
}
h1, h2 {
  font-family: "IM Fell English SC", Georgia, serif;
  font-weight: 400;
  margin: 0 0 8px;
  text-align: center;
  line-height: 1.05;
}
h1 { font-size: clamp(34px, 9vw, 48px); color: var(--gold); }
h2 { font-size: clamp(24px, 6vw, 30px); }
.tag {
  font-family: "IM Fell English", Georgia, serif;
  font-style: italic;
  text-align: center;
  color: var(--muted);
  margin: 0 0 16px;
}
.rules { padding-left: 18px; margin: 0 0 12px; }
.rules li { margin-bottom: 6px; }
kbd {
  font: 12px ui-monospace, monospace;
  padding: 1px 5px;
  border: 1px solid var(--muted);
  border-radius: 3px;
}
.legend { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin: 0 3px 0 6px;
  background: currentColor;
}
.go {
  display: block;
  width: 100%;
  padding: 12px;
  font: 400 22px "IM Fell English SC", Georgia, serif;
  color: #1c1307;
  background: var(--gold);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.go:hover { filter: brightness(1.08); }
.best { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.stats { text-align: center; margin: 0 0 12px; }
#chart { display: block; width: 100%; height: 140px; }
.chart-key { font-size: 12px; color: var(--muted); margin: 6px 0 14px; text-align: center; }
.swatch { display: inline-block; width: 14px; height: 3px; margin: 0 4px 3px 10px; vertical-align: middle; }
.swatch.whale { background: var(--whale); }
.swatch.ship { background: var(--gold); }
.swatch.line { border-top: 2px dashed var(--gold); opacity: 0.6; height: 0; }
.debrief p { margin: 0 0 10px; }
.debrief .ask {
  font-family: "IM Fell English", Georgia, serif;
  font-style: italic;
  font-size: 17px;
  color: var(--gold);
}
