/* Fragment — base tokens, typography, controls. A naturalist's cabinet:
   walnut board, cream specimen paper, three print inks for the fragments. */
:root {
  --board: #1c1813;
  --board-2: #26211a;
  --board-3: #312a21;
  --rule: #4a3f31;
  --paper: #f3ead8;
  --paper-2: #e9dcc2;
  --paper-edge: #cdbb98;
  --ink: #2a2118;
  --ink-soft: #6b5a45;
  --on-board: #efe4cf;
  --on-board-soft: #b3a38a;

  --trigger: #b7791f;   /* ochre */
  --target: #3f7f74;    /* verdigris */
  --effect: #a3402f;    /* madder */
  --trigger-bg: #f5e3c0;
  --target-bg: #d9ebe5;
  --effect-bg: #f3d6cd;

  --gold: #d9a441;
  --life: #c0533f;
  --win: #7fae6a;
  --loss: #c0533f;
  --focus: #f0c75e;

  --display: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  --serif: 'EB Garamond', Georgia, serif;          /* prose: hints, log, rules */
  --ui: 'IBM Plex Sans Condensed', 'Arial Narrow', system-ui, sans-serif;

  --r: 6px;
  /* faint paper grain for cream surfaces */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .27 0 0 0 0 .17 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* engraving plate-mark: a thin rule inset from the paper edge */
  --plate: inset 0 0 0 4px var(--paper), inset 0 0 0 5px rgba(107, 90, 69, .28);
  --shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 6px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2d261d 0%, transparent 70%),
    var(--board);
  color: var(--on-board);
  font: 15px/1.4 var(--ui);
  overscroll-behavior-y: none;
}
#app { max-width: 1180px; margin: 0 auto; padding: 16px 16px 48px; }

h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: .02em; }
a { color: var(--focus); }

button {
  font: 600 14px/1 var(--ui);
  letter-spacing: .02em;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--paper-edge);
  transition: transform .08s, box-shadow .08s, opacity .15s;
  touch-action: manipulation;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 3px 0 var(--paper-edge); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 var(--paper-edge); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.primary { background: var(--gold); border-color: #a87a25; box-shadow: 0 2px 0 #8a6420; font-size: 16px; padding: 12px 20px; }
button.ghost { background: transparent; color: var(--on-board); border-color: var(--rule); box-shadow: none; }
button.ghost:hover:not(:disabled) { background: var(--board-3); box-shadow: none; }
button.small { padding: 7px 10px; font-size: 13px; }
.cost { font-weight: 700; color: #7a5410; }
button.ghost .cost { color: var(--gold); }

input[type=text] {
  font: 500 16px var(--ui);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}

.muted { color: var(--on-board-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--paper); color: var(--ink); border: 1px solid var(--paper-edge);
  padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow);
  font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 8, 6, .7); z-index: 50;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--grain), var(--paper); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow);
  max-width: 640px; width: 100%; max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px;
}
.modal h2 { font-size: 28px; margin-bottom: 6px; }
.modal h3 { font-size: 18px; margin: 16px 0 4px; }
.modal p, .modal li { font-family: var(--serif); font-size: 16px; line-height: 1.45; }
.modal ul { padding-left: 20px; margin: 6px 0; }
.modal .close { float: right; }
.lanes-diagram { font: 13px/1.5 var(--ui); background: var(--paper-2); border-radius: 8px; padding: 8px 12px; }

.chip-inline {
  display: inline-block; font: 600 12px/1 var(--ui); padding: 4px 7px; border-radius: 5px; vertical-align: 1px;
}
.chip-inline.trigger { background: var(--trigger-bg); color: #6d4610; box-shadow: inset 0 0 0 1px var(--trigger); }
.chip-inline.target { background: var(--target-bg); color: #24534b; box-shadow: inset 0 0 0 1px var(--target); }
.chip-inline.effect { background: var(--effect-bg); color: #6f2619; box-shadow: inset 0 0 0 1px var(--effect); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

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