/* Thermopylae Front — bronze, dust and deep shade. */

:root {
  --ink: #14110d;
  --ink-2: #1d1913;
  --panel: rgba(30, 25, 19, 0.82);
  --panel-solid: #221d16;
  --line: rgba(200, 161, 90, 0.24);
  --bronze: #c8a15a;
  --bronze-bright: #e6c583;
  --dust: #e8dcc4;
  --dust-dim: #b3a68d;
  --blood: #b8443a;
  --persian: #5a8fc0;
  --ok: #86b06a;
  --radius: 14px;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.5);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --tap: 44px;
}

* { box-sizing: border-box; }

/* A hidden element must not sit on top of the battlefield eating clicks. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--dust);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body::before {
  /* a warm wash so the page and the battlefield feel like one place */
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(90% 60% at 50% -10%, rgba(200, 161, 90, 0.13), transparent 60%),
    radial-gradient(60% 50% at 100% 100%, rgba(90, 143, 192, 0.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: clamp(2rem, 5.4vw, 3.4rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.1rem, 2.4vw, 1.35rem); letter-spacing: .01em; }
h3 { font-size: 1rem; color: var(--bronze-bright); letter-spacing: .04em; text-transform: uppercase; }
p { margin: 0 0 1rem; }
a { color: var(--bronze-bright); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--bronze); color: #1a1409; padding: .7rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--bronze-bright);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  /* the DataPilot report button sits top-right: leave it room */
  padding: .55rem clamp(11rem, 16vw, 13rem) .55rem clamp(.75rem, 3vw, 1.75rem);
  background: linear-gradient(to bottom, rgba(15, 12, 9, .95), rgba(15, 12, 9, .78));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--tap); padding-right: .4rem;
  text-decoration: none; color: var(--dust);
}
.brand-mark {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, var(--bronze-bright), #8a6526 62%, #4b3714);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35), 0 2px 10px rgba(200, 161, 90, .35);
}
.brand-text { font-family: var(--serif); font-size: 1.05rem; letter-spacing: .12em; text-transform: uppercase; }
.brand-text em { font-style: normal; color: var(--bronze); }

.nav { display: flex; gap: .2rem; margin-left: auto; flex-wrap: wrap; }
.nav a {
  display: inline-flex; align-items: center; min-height: var(--tap);
  padding: .35rem .8rem; border-radius: 999px;
  color: var(--dust-dim); text-decoration: none; font-size: .93rem;
  transition: color .18s ease, background .18s ease;
}
.nav a:hover { color: var(--dust); background: rgba(200, 161, 90, .1); }
.nav a[aria-current="page"] { color: #1a1409; background: var(--bronze); font-weight: 600; }

.icon-btn {
  min-height: var(--tap); padding: .35rem .8rem; border-radius: 999px;
  background: transparent; color: var(--dust-dim); border: 1px solid var(--line);
  font: inherit; font-size: .88rem; cursor: pointer;
}
.icon-btn:hover { color: var(--dust); border-color: var(--bronze); }

/* ----------------------------------------------------------- the canvas */
#stage {
  position: absolute; inset: auto; display: block;
  width: 100%; height: 100%; border-radius: inherit;
  touch-action: none;
}
.stage-slot { position: fixed; left: -9999px; top: 0; width: 10px; height: 10px; overflow: hidden; }
.scene-mount { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }

/* -------------------------------------------------------------- screens */
main { position: relative; z-index: 1; }
.screen { padding: clamp(1rem, 3vw, 2rem); max-width: 1180px; margin: 0 auto; }
.screen[hidden] { display: none; }

/* --- home */
.scene-frame {
  position: relative;
  aspect-ratio: 16 / 8.5;
  min-height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #2a2318;
}
.scene-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(1rem, 3.5vw, 2.5rem);
  background: linear-gradient(to top, rgba(12, 10, 7, .93) 12%, rgba(12, 10, 7, .55) 48%, transparent 78%);
  pointer-events: none;
}
.scene-overlay > * { pointer-events: auto; }
.eyebrow {
  font-size: .78rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--bronze); margin: 0 0 .4rem;
}
.lede { max-width: 46ch; color: var(--dust-dim); }
.cta-row { display: flex; flex-wrap: wrap; gap: .7rem; }

/* --- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: var(--tap);
  padding: .6rem 1.2rem; border-radius: 999px;
  font: inherit; font-size: .95rem; font-weight: 600;
  border: 1px solid var(--line); background: rgba(40, 33, 24, .85); color: var(--dust);
  cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:hover { background: rgba(58, 48, 34, .95); border-color: var(--bronze); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, var(--bronze-bright), #b0873f);
  color: #1a1409; border-color: #d8b46e;
  box-shadow: 0 8px 22px rgba(200, 161, 90, .26);
}
.btn-primary:hover { background: linear-gradient(180deg, #f0d296, #bd9247); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 36px; padding: .3rem .8rem; font-size: .85rem; }

/* --- panels */
.panel-grid {
  display: grid; gap: 1rem; margin-top: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(1rem, 2.4vw, 1.4rem);
  backdrop-filter: blur(6px);
}
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-sub { color: var(--dust-dim); font-size: .93rem; }

.stat-list { display: grid; gap: .1rem; margin: 0 0 1rem; }
.stat-list > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .5rem 0; border-bottom: 1px solid rgba(200, 161, 90, .12);
}
.stat-list dt { color: var(--dust-dim); font-size: .9rem; margin: 0; }
.stat-list dd {
  margin: 0; font-family: var(--serif); font-size: 1.35rem; color: var(--bronze-bright);
  font-variant-numeric: tabular-nums;
}

.field { margin-top: 1rem; }
.field label { display: block; font-size: .85rem; color: var(--dust-dim); margin-bottom: .35rem; }
.hint { font-size: .82rem; color: var(--dust-dim); margin: .35rem 0 0; }

input[type="range"] {
  width: 100%; height: var(--tap); accent-color: var(--bronze); background: transparent;
}
select {
  width: 100%; min-height: var(--tap); padding: .5rem .7rem;
  background: var(--ink-2); color: var(--dust);
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
}

.how { margin: 0; padding-left: 1.1rem; color: var(--dust-dim); }
.how li { margin-bottom: .5rem; }
.how b { color: var(--dust); }
.note { font-size: .85rem; color: var(--dust-dim); margin: 1rem 0 0; }

/* --- battle field screen */
.screen-field { max-width: none; padding: clamp(.5rem, 1.6vw, 1rem); }
.field-stage {
  position: relative;
  height: calc(100dvh - 76px);
  min-height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #2a2318;
  box-shadow: var(--shadow);
  touch-action: none;
}

.hud {
  position: absolute;
  background: rgba(18, 15, 11, .8);
  backdrop-filter: blur(9px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem .9rem;
  font-size: .88rem;
  max-width: 260px;
}
.hud-title {
  font-size: .72rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--bronze); margin: 0 0 .5rem;
}
/* Read-only panels never take a click: the battlefield is underneath them. */
.hud-status, .hud-log, .tip { pointer-events: none; }
.hud-log .log { pointer-events: auto; }
.hud-status { top: .8rem; left: .8rem; width: 230px; }
.hud-row { display: flex; justify-content: space-between; gap: .8rem; padding: .18rem 0; }
.hud-row span { color: var(--dust-dim); }
.hud-row b { font-variant-numeric: tabular-nums; }

.integrity { margin-top: .6rem; }
.integrity-label { display: flex; justify-content: space-between; font-size: .82rem; color: var(--dust-dim); }
.meter { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-top: .3rem; }
.meter i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--ok), var(--bronze));
  transition: width .3s ease, background .3s ease;
}
.meter.broken i { background: linear-gradient(90deg, var(--blood), #e07a4a); }
.flank-warn {
  margin: .5rem 0 0; font-size: .8rem; color: #ffb3a6;
  background: rgba(184, 68, 58, .18); border: 1px solid rgba(184, 68, 58, .5);
  border-radius: 8px; padding: .35rem .5rem;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

.hud-log { top: .8rem; right: .8rem; width: 270px; max-width: 42vw; }
.log { list-style: none; margin: 0; padding: 0; max-height: 30vh; overflow-y: auto; }
.log li {
  padding: .28rem 0; border-bottom: 1px solid rgba(200, 161, 90, .1);
  font-size: .82rem; color: var(--dust-dim);
  animation: slidein .35s ease;
}
.log li b { color: var(--dust); font-weight: 600; }
.log li[data-sev="high"] { color: #ffc2b6; }
@keyframes slidein { from { opacity: 0; transform: translateX(8px); } }

.hud-controls {
  bottom: .8rem; left: .8rem; right: .8rem;
  max-width: none; display: flex; gap: .5rem; flex-wrap: wrap;
  justify-content: center;
}

.select-box {
  position: absolute; z-index: 5; pointer-events: none;
  border: 1.5px solid var(--bronze-bright);
  background: rgba(230, 197, 131, .14);
  border-radius: 3px;
}

.tip {
  position: absolute; bottom: 4.6rem; left: 50%; transform: translateX(-50%);
  margin: 0; font-size: .78rem; color: var(--dust-dim);
  background: rgba(18, 15, 11, .7); padding: .3rem .8rem; border-radius: 999px;
  border: 1px solid var(--line); white-space: nowrap;
  transition: opacity .4s ease;
}

.banner {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  background: rgba(10, 8, 6, .72); backdrop-filter: blur(4px); z-index: 8;
  padding: 2rem; gap: .6rem;
  animation: fadein .5s ease;
}
@keyframes fadein { from { opacity: 0; } }
.banner h2 { font-size: clamp(1.8rem, 6vw, 3rem); color: var(--bronze-bright); }
.banner p { color: var(--dust-dim); max-width: 40ch; margin-inline: auto; }
.banner .btn { margin-top: .6rem; }

/* --- history */
.history-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem;
}
.battle-list { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .6rem; }
.battle-card {
  display: grid; gap: .5rem;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: .85rem 1rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(20, 17, 12, .6);
  transition: border-color .2s ease, transform .2s ease;
}
.battle-card:hover { border-color: var(--bronze); transform: translateY(-1px); }
.verdict {
  font-family: var(--serif); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase;
  padding: .3rem .6rem; border-radius: 999px; white-space: nowrap;
}
.verdict.won { background: rgba(134, 176, 106, .18); color: #b7d89e; border: 1px solid rgba(134, 176, 106, .45); }
.verdict.lost { background: rgba(184, 68, 58, .16); color: #f0a99e; border: 1px solid rgba(184, 68, 58, .45); }
.verdict.fighting { background: rgba(200, 161, 90, .14); color: var(--bronze-bright); border: 1px solid var(--line); }
.battle-main b { font-family: var(--serif); font-size: 1.05rem; }
.battle-meta { color: var(--dust-dim); font-size: .84rem; }
.battle-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

.state {
  padding: 1.4rem; text-align: center; color: var(--dust-dim);
  border: 1px dashed var(--line); border-radius: 12px; margin-top: .8rem;
}
.state.error { border-color: rgba(184, 68, 58, .5); color: #f0a99e; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; display: inline-block; vertical-align: -3px;
  border: 2px solid rgba(200, 161, 90, .3); border-top-color: var(--bronze);
  animation: spin .8s linear infinite; margin-right: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.two-col { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kit, .waves { margin: .6rem 0 0; padding-left: 1.1rem; color: var(--dust-dim); font-size: .9rem; }
.kit { list-style: none; padding-left: 0; }
.kit li { padding: .4rem 0; border-bottom: 1px solid rgba(200, 161, 90, .1); }
.kit b { color: var(--dust); }
.kit .faction { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; }
.kit .faction.spartan { color: var(--blood); }
.kit .faction.persian { color: var(--persian); }
.waves li { margin-bottom: .55rem; }
.waves b { color: var(--dust); display: block; }
.source-note { margin: 1.2rem 0 0; font-size: .8rem; color: var(--dust-dim); }

/* --------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(10px);
  z-index: 60; padding: .7rem 1.1rem; border-radius: 999px;
  background: rgba(24, 20, 14, .96); border: 1px solid var(--line);
  color: var(--dust); font-size: .9rem; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
  max-width: min(92vw, 520px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(184, 68, 58, .6); color: #f6bdb3; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 760px) {
  .topbar { padding-right: .5rem; flex-wrap: wrap; }
  .nav { margin-left: 0; width: 100%; justify-content: center; }
  .nav a { padding: .35rem .6rem; font-size: .86rem; }
  .brand-text { font-size: .9rem; letter-spacing: .08em; }
  .icon-btn { display: none; }
  .scene-frame { aspect-ratio: 4 / 5; min-height: 380px; }
  .field-stage { height: calc(100dvh - 130px); }
  /* On a phone the status becomes one compact strip, so the pass stays visible. */
  .hud-status {
    width: auto; left: .5rem; right: .5rem; top: .5rem; max-width: none;
    display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .9rem;
    padding: .5rem .7rem;
  }
  .hud-status .hud-title { display: none; }
  .hud-status .hud-row { padding: 0; gap: .35rem; font-size: .8rem; }
  .hud-status .integrity { margin-top: 0; flex: 1 1 100%; }
  .hud-status .integrity-label { font-size: .75rem; }
  .hud-log { display: none; }
  .hud-controls { bottom: .5rem; left: .5rem; right: .5rem; gap: .4rem; }
  .hud-controls .btn { flex: 1 1 44%; padding: .6rem .5rem; font-size: .88rem; }
  .tip { bottom: 7.2rem; font-size: .72rem; white-space: normal; text-align: center; max-width: 90%; }
  .battle-card { grid-template-columns: 1fr; }
  .battle-actions { justify-content: flex-start; }
}

@media (max-width: 380px) {
  .nav a { padding: .3rem .45rem; font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
