:root {
  --font-primary: 'RocknRoll One', system-ui, sans-serif;
  --font-mark: 'Source Sans 3', system-ui, sans-serif;
  /* Arena SVG labels only — leave diagram typography unchanged. */
  --font: system-ui, -apple-system, sans-serif;

  --bg-card: #12161c;
  --bg-panel: #161920;
  --bg-sunken: #0e1014;
  --border: #1e242d;
  --line-soft: #161b22;
  --gold: #0fb0a2;
  --gold-light: #5ecfc4;
  --text-primary: #e8e6e0;
  --text-secondary: #9a9890;
  --accent: var(--gold);
  --radius: 6px;
  --page-pad-x: clamp(16px, 4vw, 44px);
  --page-max-width: 1400px;

  /* Mechanic colours (arena + UI) */
  --fire: #ff6b35;
  --ice: #38bdf8;
  --lightning: #facc15;

  --footer-bg: #0a0e14;
  --footer-text: #6b7280;
  --footer-text-secondary: #b4bcc8;
  --footer-border: rgba(55, 65, 81, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(15, 176, 162, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(29, 155, 240, 0.04), transparent),
    linear-gradient(180deg, #0a0e14 0%, #080b0f 100%);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Shared width constraint for header, main, and footer innards. */
.page-container {
  width: 100%;
  max-width: var(--page-max-width);
  margin-inline: auto;
  padding-inline: var(--page-pad-x);
}

/* ── Header (Kaia Tools chrome) ─────────────────────────────────────── */

.header-bar {
  --header-by: #5c5a55;

  background: linear-gradient(#14171ef2, #0d0f13e6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid #0fb0a233;
  padding: 0.65rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  min-height: 4.25rem;
}

.header-brand {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.85rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.site-logo-title {
  margin: 0;
  font-family: var(--font-primary);
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  line-height: 1.4;
  padding-bottom: 0.12em;
  overflow: visible;
  color: var(--text-primary);
  -webkit-text-fill-color: var(--text-primary);
  opacity: 0.92;
}

.site-home-link {
  color: inherit;
  text-decoration: none;
}

.site-home-link:hover {
  color: var(--gold-light);
  -webkit-text-fill-color: var(--gold-light);
}

.header-by {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  color: var(--header-by);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.kaia-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.kaia-mark:hover .kaia-mark-kaia {
  color: #12c9b8;
  -webkit-text-fill-color: #12c9b8;
}

.kaia-mark-kaia {
  font-family: var(--font-primary);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: #0fb0a2;
  -webkit-text-fill-color: #0fb0a2;
}

.kaia-mark-tools {
  font-family: var(--font-mark);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
  -webkit-text-fill-color: var(--text-primary);
}

.header-encounter {
  margin: 0;
  font-family: var(--font-mark);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

/* ── Layout ───────────────────────────────────────────────────────────── */

main {
  flex: 1 0 auto;
  padding-block: 1.25rem 2rem;
}

.page-intro {
  margin: 0 0 1.25rem;
  max-width: 52ch;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
}

.view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.view[hidden] { display: none; }

.stage {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.setup-hint {
  margin: 14px 0 0;
  padding: 0 8px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.setup-hint[hidden] { display: none; }

.results-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.full-view-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.full-view-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.full-view-label {
  margin: 0;
  text-align: center;
  font-family: var(--font-primary);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  line-height: 1.35;
}

.full-view-arena {
  max-width: none;
}

/* Full view: let diagrams use the full viewport width (page-container keeps side padding). */
body:has(#resultsView.is-full-view) .page-container {
  max-width: none;
}

/* Full view: diagrams span the page; controls sit in a bar below. */
#resultsView.is-full-view {
  grid-template-columns: 1fr;
}

#resultsView.is-full-view .results-main {
  width: 100%;
}

#resultsView.is-full-view .full-view {
  padding: 16px;
}

#resultsView.is-full-view .panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.8fr) auto;
  gap: 16px;
  align-items: start;
  width: 100%;
}

#resultsView.is-full-view .panel .card:last-child .button-row {
  margin-top: 0;
}

#resultsView.is-full-view .panel .card:last-child {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 220px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.card h2 {
  margin: 0 0 8px;
  font-family: var(--font-primary);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.muted {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.hint {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ── Counters ─────────────────────────────────────────────────────────── */

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

.count-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-sunken);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.count-chip b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.count-chip .count-dot { width: 8px; height: 8px; border-radius: 50%; }
.count-fire .count-dot { background: var(--fire); }
.count-ice .count-dot { background: var(--ice); }
.count-lightning .count-dot { background: var(--lightning); }
.count-chip.is-full { opacity: 0.5; }

/* ── Order list ───────────────────────────────────────────────────────── */

.order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.order-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  font-size: 0.8125rem;
}

.order-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #1a1f28;
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.order-empty { color: #6b7280; font-style: italic; }
.order-element { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.order-fire .order-element { color: var(--fire); }
.order-ice .order-element { color: var(--ice); }
.order-lightning .order-element { color: var(--lightning); }
.order-item.is-set { border-color: var(--border); }

.order-item-btn {
  width: 100%;
  margin: 0;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  border: 1px solid var(--line-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.order-item-btn:hover {
  border-color: var(--border);
  background: var(--bg-panel);
}

.order-item-btn.is-current {
  background: #1a1f28;
}

.order-fire.is-current { border-color: var(--fire); }
.order-ice.is-current { border-color: var(--ice); }
.order-lightning.is-current { border-color: var(--lightning); }

.order-fire.is-current .order-head { color: var(--fire); }
.order-ice.is-current .order-head { color: var(--ice); }
.order-lightning.is-current .order-head { color: var(--lightning); }
.order-fire .order-num { background: rgba(255, 107, 53, 0.18); color: var(--fire); }
.order-ice .order-num { background: rgba(56, 189, 248, 0.18); color: var(--ice); }
.order-lightning .order-num { background: rgba(250, 204, 21, 0.18); color: var(--lightning); }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.button-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.btn {
  flex: 1;
  min-width: 90px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: #1a1f28;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-block { width: 100%; margin-top: 10px; }
.btn-block:first-child { margin-top: 0; margin-bottom: 12px; }
.btn-small { flex: none; padding: 6px 12px; font-size: 0.68rem; margin-top: 4px; }

.btn-primary.is-ready {
  background: var(--gold);
  border-color: var(--gold);
  color: #06231f;
}

.btn-nav { flex: none; width: 44px; font-size: 15px; text-transform: none; }

/* ── Settings ─────────────────────────────────────────────────────────── */

.card-settings summary {
  cursor: pointer;
  font-family: var(--font-primary);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  list-style: none;
}

.card-settings summary::before { content: "▸ "; color: var(--text-secondary); }
.card-settings[open] summary::before { content: "▾ "; }

.hint-top { margin-top: 10px; }
.hint-top b { color: var(--text-primary); }

.field-group {
  margin: 20px 0 -2px;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.field { display: block; margin-top: 14px; font-size: 0.78rem; color: var(--text-secondary); }
.field span { display: flex; justify-content: space-between; margin-bottom: 6px; }
.field b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; accent-color: var(--gold); }

/* ── Slideshow chrome ─────────────────────────────────────────────────── */

.stage-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.stage-nav-hint {
  margin: 10px 0 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.5;
}

.stage-nav-hint kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.68rem;
  line-height: 1.4;
}

.dots { display: flex; gap: 8px; flex: 1; }

.dot {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.dot:hover { color: var(--text-primary); }
.dot-fire.is-current { border-color: var(--fire); color: var(--fire); }
.dot-ice.is-current { border-color: var(--ice); color: var(--ice); }
.dot-lightning.is-current { border-color: var(--lightning); color: var(--lightning); }
.dot-overview.is-current { border-color: var(--accent); color: var(--accent); }
.dot.is-current { background: #1a1f28; }

.slide-spell {
  font-family: var(--font-primary);
  font-size: 1.25rem;
  font-weight: 400;
  margin: 0 0 6px;
}

.text-fire { color: var(--fire); }
.text-ice { color: var(--ice); }
.text-lightning { color: var(--lightning); }

.safe-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }

.safe-list li {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid rgba(88, 250, 170, 0.55);
  background: rgba(88, 250, 170, 0.12);
}

.safe-list-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

/* ── Arena SVG ────────────────────────────────────────────────────────── */

/* Scale up to the stage column, but cap so the block doesn't dominate the page. */
.arena {
  display: block;
  width: 100%;
  max-width: min(100%, 78vh, 820px);
  aspect-ratio: 1;
  height: auto;
  margin: 0 auto;
}

.arena-floor { fill: #0d2038; }
.arena-border { fill: none; stroke: #3c4c60; stroke-width: 0.012; }
.arena-grid line { stroke: rgba(255, 255, 255, 0.05); stroke-width: 0.006; }
.arena-grid line.axis { stroke: rgba(255, 255, 255, 0.09); stroke-dasharray: 0.04 0.03; }

.compass text { fill: #5f7188; font-size: 0.075px; font-family: var(--font); letter-spacing: 0.02em; }

.boss-marker { pointer-events: none; }
.boss-icon { pointer-events: none; }
.boss-marker.is-casting .boss-icon { filter: drop-shadow(0 0 0.03px rgba(255, 255, 255, 0.6)); }

/* Deliberately strong. The safe floor is the one thing a player needs to find at
   a glance, so it reads as a solid colour rather than a tint over the floor. */
.safe-fill { fill: rgba(88, 250, 170, 0.72); }

.aoe { pointer-events: none; }
.aoe-preview { stroke-dasharray: 0.08 0.06; }
.aoe-preview-head { opacity: 0.75; }
.aoe-preview-boss { opacity: 0.28; }

/* Wave-slide hover: brightest copy on the focus layer, stacked above all base AOEs. */
.layer-aoe-focus .aoe-focus-highlight {
  opacity: 1;
  filter: brightness(1.2);
}

/* Drop the solid base stroke so only the focus-layer dashes show on hover. */
.aoe-emitter.is-focused .aoe { stroke: none; }

.aoe-emitter.is-focused { opacity: 1; }

.layer-safe, .layer-aoe, .layer-aoe-focus { pointer-events: none; }

.boss-hit {
  cursor: pointer;
  pointer-events: all;
}

.head-hit-static {
  cursor: pointer;
  pointer-events: all;
}

.head-static.is-active { cursor: pointer; }

/* Landmarks — in-game FFXIV waymark icons */
.landmark-icon { pointer-events: none; }
.landmark.is-safe .landmark-icon {
  filter: drop-shadow(0 0 0.04px #ffffff) brightness(1.15);
}
.landmark.is-hit { opacity: 0.22; }

/* Heads */
.head-plate { fill: #10161e; stroke: rgba(255, 255, 255, 0.12); stroke-width: 0.006; }
.head-ring { fill: none; stroke: rgba(255, 255, 255, 0.30); stroke-width: 0.017; opacity: 0.85; }
.head-ring.is-assigned { opacity: 1; }
.head-static.is-emitter-hover .head-ring,
.boss-marker.is-emitter-hover .boss-icon {
  filter: drop-shadow(0 0 0.04px #ffffff) brightness(1.2);
}
.head-static.is-emitter-hover .head-ring {
  stroke: #fff;
  stroke-width: 0.022;
  opacity: 1;
}
.head-hit { fill: transparent; cursor: pointer; }

.slice {
  opacity: 0.82;
  stroke: #10161e;
  stroke-width: 0.008;
  cursor: pointer;
  transition: opacity 0.12s;
}

.slice:hover, .slice:focus { opacity: 1; outline: none; }
.slice:focus { stroke: #fff; stroke-width: 0.012; }
.slice.is-blocked { opacity: 0.14; cursor: not-allowed; }
.slice.is-blocked:hover { opacity: 0.14; }

.glyph { pointer-events: none; }

.order-badge circle { fill: #0b0e13; stroke: rgba(255, 255, 255, 0.55); stroke-width: 0.008; }
.order-badge text { fill: #fff; font-size: 0.075px; font-family: var(--font); font-weight: 700; }

.head-static.is-idle { opacity: 0.4; }

/* ── Footer (Kaia Tools) ──────────────────────────────────────────────── */

footer {
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--footer-border);
  background: var(--footer-bg);
}

.footer-inner {
  padding-block: 1rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--footer-text);
}

.footer-inner:has(.footer-calibration-btn) {
  position: relative;
  padding-inline: 2.5rem;
}

footer p { margin: 0; }

.footer-credit {
  margin: 0.35rem 0 0;
  color: var(--footer-text-secondary);
}

.footer-calibration-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--footer-text);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.footer-calibration-btn:hover {
  color: var(--footer-text-secondary);
  border-color: var(--footer-border);
  background: rgba(255, 255, 255, 0.04);
}

.footer-calibration-btn.is-active {
  color: var(--gold-light);
  border-color: rgba(15, 176, 162, 0.35);
  background: rgba(15, 176, 162, 0.1);
}

.footer-calibration-icon {
  display: block;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1040px) {
  .view { grid-template-columns: minmax(0, 1fr); }

  .full-view-grid { grid-template-columns: 1fr; }

  #resultsView.is-full-view .panel {
    grid-template-columns: 1fr;
  }

  .header-encounter {
    width: 100%;
    order: 3;
  }
}

@media (max-width: 640px) {
  .header-brand { flex-wrap: wrap; gap: 0.35rem 0.85rem; }
}
