/* VERDICT — base style: tokens, type, layout primitives, controls ("Ember Fresco").
 * Owned by the shell lane. Other lanes reuse these tokens and classes; see design/UI_CONTRACT.md. */

:root {
  /* palette (CHARTER) */
  --night: #14162b;
  --indigo: #23264a;
  --indigo-2: #2e3260;
  --ember: #f08a3c;
  --ember-hot: #ffb15e;
  --coal: #b23a2a;
  --gold: #e2b65a;
  --gold-deep: #a9802f;
  --bone: #efe6d3;
  --ochre: #c58b3f;
  --iron: #8f3b2b;
  --ash: #cfc8ba;
  --ash-dim: #8f8a99;
  --soot: #0b0c18;

  /* roles */
  --bg: var(--night);
  --text: var(--ash);
  --text-strong: var(--bone);
  --accent: var(--ember);
  --god: var(--gold);
  --human: var(--ochre);
  --panel: rgba(20, 22, 43, 0.82);
  --panel-solid: #1a1c36;
  --line: rgba(239, 230, 211, 0.14);
  --line-warm: rgba(240, 138, 60, 0.45);

  /* type */
  --font-display: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", "Leelawadee UI", "Noto Serif Thai", Thonburi, serif;
  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Leelawadee UI", "Noto Sans Thai", Thonburi, Tahoma, sans-serif;
  --lh: 1.5;

  /* space and shape */
  --gap: 12px;
  --gap-l: 20px;
  --radius: 6px;
  --touch: 44px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  /* motion */
  --t-fast: 160ms;
  --t-mid: 320ms;
  --t-slow: 700ms;
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: dark;
}

/* Thai needs room for upper and lower marks */
:lang(th) { --lh: 1.75; }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  /* the mural: cold light from above, warm from below */
  background:
    radial-gradient(120% 60% at 50% 115%, rgba(240, 138, 60, 0.30), rgba(178, 58, 42, 0.10) 45%, transparent 70%),
    radial-gradient(140% 70% at 50% -20%, rgba(70, 86, 170, 0.30), transparent 60%),
    var(--night);
}

button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--ember-hot); outline-offset: 2px; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--text-strong);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  margin: 0;
}
:lang(th) h1, :lang(th) h2, :lang(th) h3, :lang(th) .display { line-height: 1.45; letter-spacing: 0; }

p { margin: 0 0 0.8em; }
.muted { color: var(--ash-dim); }
.small { font-size: 0.85rem; }
.caps { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; }
:lang(th) .caps { text-transform: none; letter-spacing: 0.02em; font-size: 0.85rem; }
.gold { color: var(--gold); }
.ochre { color: var(--ochre); }
.ember { color: var(--ember); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* plaster grain laid over panels (pure CSS, no file) */
.grain { position: relative; }
.grain::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background-image:
    repeating-radial-gradient(circle at 17% 32%, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 71% 64%, rgba(0,0,0,0.05) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}

/* ---------------------------------------------------------------- app frame */

#embers { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

#app {
  position: fixed; inset: 0; z-index: 1;
  overflow: hidden;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 16px);
  overflow: hidden;
}
.screen.is-entering { animation: screen-in var(--t-mid) var(--ease) both; }
.screen.is-leaving { animation: screen-out var(--t-fast) ease-in both; pointer-events: none; }
.screen.is-back.is-entering { animation-name: screen-in-back; }
@keyframes screen-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes screen-in-back { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes screen-out { from { opacity: 1; } to { opacity: 0; } }

/* reduced motion: fades only */
[data-motion="reduce"] .screen.is-entering,
[data-motion="reduce"] .screen.is-back.is-entering { animation-name: fade-in; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

/* top bar of a screen */
.bar {
  display: flex; align-items: center; gap: 8px;
  min-height: var(--touch);
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.bar h1, .bar h2 { flex: 1 1 auto; font-size: 1.25rem; min-width: 0; }
.bar .spacer { flex: 1 1 auto; }

.scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--indigo-2) transparent;
  margin: 0 -4px; padding: 0 4px 12px;
}

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: var(--gap); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: flex; align-items: center; justify-content: center; }
.wide { max-width: 1100px; width: 100%; margin: 0 auto; }
.narrow { max-width: 640px; width: 100%; margin: 0 auto; }

/* ---------------------------------------------------------------- controls */

.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: var(--touch); min-width: var(--touch);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.03em;
  color: var(--text-strong);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(0,0,0,0.18)),
    var(--indigo-2);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 8px rgba(0,0,0,0.3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast);
  user-select: none; -webkit-user-select: none;
  text-align: center;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: default; filter: none; transform: none; }
.btn.primary {
  color: #2a1406;
  background:
    linear-gradient(180deg, rgba(255,240,210,0.35), rgba(120,40,10,0.25)),
    linear-gradient(90deg, var(--ember), var(--ember-hot));
  box-shadow: inset 0 -3px 0 rgba(110,36,10,0.55), 0 0 22px rgba(240,138,60,0.35), 0 3px 10px rgba(0,0,0,0.4);
}
.btn.gold {
  color: #2b1d05;
  background: linear-gradient(180deg, #f4d68f, var(--gold) 45%, var(--gold-deep));
  box-shadow: inset 0 -3px 0 rgba(90,60,10,0.5), 0 0 18px rgba(226,182,90,0.3);
}
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn.icon { padding: 0; width: var(--touch); background: transparent; box-shadow: none; }
.btn.icon:hover { background: rgba(255,255,255,0.06); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn svg { width: 22px; height: 22px; flex: 0 0 auto; }

/* segmented choice */
.seg { display: inline-flex; border-radius: var(--radius); background: rgba(0,0,0,0.3); padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button {
  appearance: none; border: 0; cursor: pointer; background: transparent;
  min-height: 38px; padding: 6px 14px; border-radius: 4px; color: var(--ash);
  font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--indigo-2); color: var(--bone); box-shadow: inset 0 -2px 0 var(--ember); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.tabs button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  min-height: var(--touch); padding: 8px 14px; color: var(--ash-dim);
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--bone); border-bottom-color: var(--ember); }

/* text inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.9rem; color: var(--ash-dim); }
.input {
  min-height: var(--touch); padding: 8px 12px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: rgba(0,0,0,0.35); color: var(--bone);
}
.input:focus { border-color: var(--ember); outline: none; box-shadow: 0 0 0 3px rgba(240,138,60,0.2); }
textarea.input { min-height: 120px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; }

/* range slider */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: var(--touch); background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--coal), var(--ember)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--coal), var(--ember)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--bone); box-shadow: 0 0 0 3px var(--ember), 0 2px 6px rgba(0,0,0,0.5); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--bone); box-shadow: 0 0 0 3px var(--ember); }

/* panels */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line), 0 6px 24px rgba(0,0,0,0.35);
  padding: 14px 16px;
}
.panel.warm { box-shadow: inset 0 0 0 1px var(--line-warm), 0 0 30px rgba(240,138,60,0.12), 0 6px 24px rgba(0,0,0,0.35); }
.rule { height: 1px; border: 0; margin: 10px 0; background: linear-gradient(90deg, transparent, var(--line-warm), transparent); }

/* side colours */
.side-gods { --side: var(--god); }
.side-humans { --side: var(--human); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0;
  max-width: min(92vw, 520px);
  padding: 10px 16px; border-radius: var(--radius);
  background: var(--panel-solid); color: var(--bone);
  box-shadow: inset 0 0 0 1px var(--line-warm), 0 8px 30px rgba(0,0,0,0.5);
  transition: opacity var(--t-mid), transform var(--t-mid) var(--ease);
  pointer-events: none; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* modal / bottom sheet */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(8, 9, 20, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in var(--t-fast) both;
}
.sheet {
  position: relative;
  width: 100%; max-width: 560px; max-height: 92%;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #232650, #171933 40%);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -1px 0 var(--line-warm), 0 -20px 60px rgba(0,0,0,0.5);
  padding: 8px 16px calc(var(--safe-b) + 14px);
  animation: sheet-up var(--t-mid) var(--ease) both;
}
.sheet .grip { width: 44px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; flex: 0 0 auto; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
[data-motion="reduce"] .sheet { animation-name: fade-in; }
@media (min-width: 900px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 14px; max-height: 86%; }
}

/* notice banner */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius);
  background: rgba(178, 58, 42, 0.18); box-shadow: inset 0 0 0 1px rgba(178,58,42,0.5);
  color: var(--bone); font-size: 0.92rem;
}
.notice.info { background: rgba(70, 86, 170, 0.18); box-shadow: inset 0 0 0 1px rgba(110,126,210,0.4); }
.notice svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; }

/* ---------------------------------------------------------------- fighter pieces */

.portrait { position: relative; overflow: hidden; background: transparent; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }

.namebar .name { font-family: var(--font-display); color: var(--bone); font-size: 1.1rem; font-weight: 600; }
.namebar .epithet { color: var(--side, var(--ash-dim)); font-style: italic; font-size: 0.9rem; }
:lang(th) .namebar .epithet { font-style: normal; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: #1c1205; background: var(--side, var(--ash));
}
:lang(th) .badge { text-transform: none; letter-spacing: 0; }

/* ?still=1 (testing and screenshots only): every animation and transition jumps to its end */
[data-still] *, [data-still] *::before, [data-still] *::after {
  animation-duration: 0s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
  transition-duration: 0s !important; transition-delay: 0s !important;
}
