/* ────────────────────────────────────────────────────────────────────────
   modle — styles
   Aesthetic: "Terminal Oracle"
   - Editorial italic serif (Instrument Serif) for wordmark
   - Industrial monospace (JetBrains Mono) for data + UI
   - Warm near-black palette, lab-green + amber match feedback
   - Atmospheric layers: dot grid, grain, soft glow blobs
   ──────────────────────────────────────────────────────────────────────── */

:root {
  --bg:          #0a0908;
  --bg-warm:     #0d0c0a;
  --surface:     #15130f;
  --surface-2:   #1b1814;
  --surface-3:   #221e18;
  --border:      #2a2620;
  --border-bright:#3a342a;
  --ink:         #f4efe4;
  --ink-dim:     #a8a294;
  --ink-faint:   #6a6358;
  --ink-ghost:   #3f3a32;

  --match:       #9eff5b;
  --match-deep:  #4b8a2c;
  --match-glow:  rgba(158, 255, 91, 0.22);
  --match-ink:   #0a1502;

  --close:       #ffc06b;
  --close-deep:  #8a5818;
  --close-glow:  rgba(255, 192, 107, 0.18);
  --close-ink:   #1f1404;

  /* "Warm" — between close and miss for numeric distance feedback */
  --warm:        #8a6033;
  --warm-deep:   #5a3e22;
  --warm-glow:   rgba(180, 130, 70, 0.14);
  --warm-ink:    #f0d3a4;

  --miss:        #1f1c17;
  --miss-line:   #2c2820;
  --miss-ink:    #6a6358;

  --accent:      #5ce1ff;
  --accent-warm: #ffd28a;

  --r-card:      14px;
  --r-cell:      10px;
  --r-pill:      999px;

  --shadow-soft: 0 1px 0 rgba(255,255,255,0.04) inset, 0 18px 50px -25px rgba(0,0,0,.8);
  --shadow-deep: 0 30px 80px -30px rgba(0,0,0,.85), 0 1px 0 rgba(255,255,255,0.04) inset;

  --col-name: minmax(220px, 2.4fr);
  --col-attr: minmax(68px, 1fr);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, "Menlo", monospace;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(92, 225, 255, 0.04), transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(255, 192, 107, 0.035), transparent 55%),
    var(--bg-warm);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 130px;
  overflow-x: hidden;
  position: relative;
}

/* ── Atmospheric layers ─────────────────────────────────────────────── */

.grain {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.96  0 0 0 0 0.94  0 0 0 0 0.86  0 0 0 0.32 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.dotgrid {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(244, 239, 228, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 0 0;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 30%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 30%, #000 35%, transparent 100%);
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}
.glow-1 {
  width: 520px; height: 520px;
  top: -180px; left: -160px;
  background: radial-gradient(circle, rgba(92, 225, 255, 0.18), transparent 70%);
}
.glow-2 {
  width: 480px; height: 480px;
  bottom: -200px; right: -120px;
  background: radial-gradient(circle, rgba(158, 255, 91, 0.10), transparent 70%);
}

/* ── Header ─────────────────────────────────────────────────────────── */

.header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px clamp(20px, 5vw, 56px) 18px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(to bottom, rgba(13, 12, 10, 0.85), rgba(13, 12, 10, 0.55) 80%, transparent);
  backdrop-filter: blur(6px);
}

.brand { display: flex; flex-direction: column; gap: 6px; }

.wordmark {
  font-family: "Instrument Serif", "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(46px, 8vw, 78px);
  line-height: 0.88;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}
.wordmark-italic {
  font-style: italic;
  color: var(--accent);
  text-shadow: 0 0 38px rgba(92, 225, 255, 0.35);
  margin-right: -0.02em;
}
.wordmark-dot {
  color: var(--accent);
  font-style: italic;
}

.tagline {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--ink-dim);
  margin: 0;
  font-weight: 500;
}
.tagline .five {
  color: var(--accent);
  font-weight: 700;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 18px;
}

.puzzle-no {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
  gap: 4px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(34, 30, 24, 0.4);
}
.puzzle-no-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.puzzle-no-value {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: 28px;
  color: var(--accent-warm);
}

.header-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  background: rgba(34, 30, 24, 0.4);
  color: var(--ink-dim);
  border-radius: 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .15s, background .15s;
}
.icon-btn:hover {
  color: var(--ink);
  border-color: var(--border-bright);
  background: var(--surface-2);
}
.icon-btn:active { transform: scale(0.96); }

.icon-btn-infinity {
  position: relative;
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(92, 225, 255, 0.18), rgba(255, 92, 200, 0.14)) padding-box,
              linear-gradient(135deg, #5ce1ff 0%, #b97cff 50%, #ff5ca8 100%) border-box;
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(92, 225, 255, 0.12), 0 8px 22px -10px rgba(185, 124, 255, 0.45);
  overflow: hidden;
  animation: infinity-pulse 3.5s ease-in-out infinite;
}
.icon-btn-infinity::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 100%, rgba(255, 92, 200, 0.35), transparent 70%);
  opacity: 0.7;
  pointer-events: none;
}
.icon-btn-infinity:hover {
  color: var(--ink);
  filter: brightness(1.08) saturate(1.1);
  box-shadow: 0 0 0 1px rgba(92, 225, 255, 0.22), 0 12px 28px -10px rgba(185, 124, 255, 0.6);
}
.icon-btn-infinity .infinity-glyph {
  position: relative;
  z-index: 1;
  font-family: "Instrument Serif", serif;
  font-size: 28px;
  line-height: 1;
  display: inline-block;
  transform: translateY(-1px);
  background: linear-gradient(135deg, #ffffff 0%, #d0f6ff 40%, #ffd6f3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(92, 225, 255, 0.5));
}
@keyframes infinity-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(92, 225, 255, 0.12), 0 8px 22px -10px rgba(185, 124, 255, 0.45); }
  50%      { box-shadow: 0 0 0 1px rgba(92, 225, 255, 0.32), 0 14px 30px -10px rgba(255, 92, 200, 0.55); }
}
/* Stop the pulse once active so the green active state doesn't fight it */
.icon-btn-infinity.active {
  animation: none;
  background: linear-gradient(180deg, var(--match), #6dcf3f);
  border-color: var(--match);
}
.icon-btn-infinity.active::before { display: none; }
.icon-btn-infinity.active .infinity-glyph {
  background: none;
  -webkit-text-fill-color: var(--match-ink);
  filter: none;
}
.icon-btn.active {
  color: var(--match-ink);
  background: linear-gradient(180deg, var(--match), #6dcf3f);
  border-color: var(--match);
  box-shadow: 0 0 0 1px rgba(158, 255, 91, 0.12), 0 6px 20px -10px var(--match-glow);
}
.icon-btn.active:hover {
  color: var(--match-ink);
  background: linear-gradient(180deg, var(--match), #6dcf3f);
  filter: brightness(1.04);
}

body.infinite .puzzle-no {
  border-color: var(--match);
  background: linear-gradient(180deg, rgba(158, 255, 91, 0.10), rgba(158, 255, 91, 0.02));
}
body.infinite .share-wrap { display: none; }
body.infinite .puzzle-no-value {
  color: var(--match);
  font-style: italic;
}
body.infinite .puzzle-no-label {
  color: var(--match);
  opacity: 0.9;
}

/* ── Board ──────────────────────────────────────────────────────────── */

.board-wrap {
  position: relative;
  z-index: 4;
  width: 100%;
  max-width: 1140px;
  margin: 32px auto 0;
  padding: 0 clamp(16px, 4vw, 40px);
}

.board-headings,
.row {
  display: grid;
  grid-template-columns: var(--col-name) repeat(9, var(--col-attr));
  gap: 8px;
  align-items: stretch;
}

.board-headings {
  margin-bottom: 10px;
  padding: 0 4px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.board-headings > div {
  padding: 0 4px;
}
.board-headings .head-name { padding-left: 12px; }
.board-headings .head-attr { text-align: center; }

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

.row {
  min-height: 64px;
}

/* Name cell — wider, italic serif accent */
.cell-name {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--r-cell);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row.empty .cell-name {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--ink-ghost);
}

.cell-name .row-no {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  color: var(--ink-faint);
  margin-right: 12px;
  font-size: 18px;
  line-height: 1;
}

/* Attribute cells */
.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-cell);
  text-align: center;
  font-size: 12px;
  line-height: 1.15;
  color: var(--ink-dim);
  transition: background .25s, border-color .25s, color .25s;
  transform-style: preserve-3d;
  perspective: 600px;
  min-height: 64px;
}

.row.empty .cell {
  background: transparent;
  border: 1px dashed var(--border);
}

.cell-value {
  font-weight: 500;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-sub {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.arrow {
  font-size: 10px;
  line-height: 1;
  opacity: 0.85;
  display: inline-block;
  transform: translateY(-1px);
}

/* Cell verdict states ─ apply after flip */
.cell.match {
  background: linear-gradient(180deg, var(--match) 0%, #6dcf3f 100%);
  border-color: var(--match);
  color: var(--match-ink);
  box-shadow: 0 0 0 1px rgba(158, 255, 91, 0.1), 0 6px 24px -8px var(--match-glow);
}
.cell.match .cell-value,
.cell.match .cell-sub { color: var(--match-ink); }
.cell.match .cell-sub { opacity: 0.65; }

.cell.close {
  background: linear-gradient(180deg, var(--close) 0%, #d9893d 100%);
  border-color: var(--close);
  color: var(--close-ink);
  box-shadow: 0 0 0 1px rgba(255, 192, 107, 0.12), 0 6px 24px -8px var(--close-glow);
}
.cell.close .cell-value,
.cell.close .cell-sub { color: var(--close-ink); }
.cell.close .cell-sub { opacity: 0.65; }

.cell.warm {
  background: linear-gradient(180deg, var(--warm) 0%, var(--warm-deep) 100%);
  border-color: #7a5028;
  color: var(--warm-ink);
  box-shadow: 0 0 0 1px rgba(180, 130, 70, 0.08), 0 4px 16px -10px var(--warm-glow);
}
.cell.warm .cell-value { color: var(--warm-ink); }
.cell.warm .cell-sub { color: #c8a672; opacity: 0.75; }

.cell.miss {
  background: var(--miss);
  border-color: var(--miss-line);
  color: var(--miss-ink);
}
.cell.miss .cell-value { color: var(--ink-dim); }

/* Flip animation */
@keyframes flip-in {
  0%   { transform: rotateX(0deg);   background: var(--surface); border-color: var(--border); }
  49%  { transform: rotateX(-90deg); background: var(--surface); border-color: var(--border); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(0deg); }
}
.cell.flipping {
  animation: flip-in 0.55s cubic-bezier(0.4, 0.05, 0.2, 1) forwards;
}

/* Win celebration */
@keyframes win-pulse {
  0%   { transform: translateY(0); box-shadow: 0 0 0 1px rgba(158, 255, 91, 0.1), 0 6px 24px -8px var(--match-glow); }
  50%  { transform: translateY(-4px); box-shadow: 0 0 0 1px rgba(158, 255, 91, 0.4), 0 18px 36px -8px var(--match-glow); }
  100% { transform: translateY(0); box-shadow: 0 0 0 1px rgba(158, 255, 91, 0.1), 0 6px 24px -8px var(--match-glow); }
}
.row.winning .cell.match {
  animation: win-pulse 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Row entrance */
@keyframes row-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.row.live { animation: row-pop 0.25s ease both; }

/* ── Input dock ─────────────────────────────────────────────────────── */

.input-dock {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  z-index: 10;
}

.autocomplete {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0; right: 0;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: var(--shadow-deep);
  max-height: 280px;
  overflow-y: auto;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
}
.autocomplete.open { display: block; }
.autocomplete::-webkit-scrollbar { width: 8px; }
.autocomplete::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }

.ac-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid rgba(42, 38, 32, 0.5);
  transition: background .12s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover,
.ac-item.active {
  background: var(--surface-3);
}
.ac-item-lab {
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.ac-item mark {
  background: transparent;
  color: var(--accent);
  font-weight: 500;
}
.ac-item.used {
  color: var(--ink-ghost);
  text-decoration: line-through;
  cursor: not-allowed;
}
.ac-item.used .ac-item-lab { color: var(--ink-ghost); }

.input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow-deep);
  transition: border-color .15s;
}
.input-form:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-deep), 0 0 0 3px rgba(92, 225, 255, 0.08);
}
.input-prompt {
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  user-select: none;
}
.input-field {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  padding: 12px 0;
  letter-spacing: -0.01em;
}
.input-field::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}
.input-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .12s, background .15s;
}
.input-submit:hover { background: var(--match); }
.input-submit:active { transform: scale(0.97); }
.input-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-submit-next {
  background: linear-gradient(180deg, var(--match), #6dcf3f);
  color: var(--match-ink);
  box-shadow: 0 6px 18px -8px var(--match-glow);
}
.input-submit-next:hover {
  background: linear-gradient(180deg, var(--match), #7be145);
  filter: brightness(1.05);
}

/* ── Type filter ────────────────────────────────────────────────────── */

.type-filter {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(to bottom, rgba(34, 30, 24, 0.5), rgba(34, 30, 24, 0.2));
  flex-wrap: wrap;
}

.type-filter-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: 4px;
}

.chip {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: rgba(8, 7, 6, 0.4);
  color: var(--ink-dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .12s;
}
.chip:hover {
  color: var(--ink);
  border-color: var(--border-bright);
  background: var(--surface-2);
}
.chip:active { transform: scale(0.96); }
.chip.active {
  color: var(--match-ink);
  background: linear-gradient(180deg, var(--match), #6dcf3f);
  border-color: var(--match);
  box-shadow: 0 0 0 1px rgba(158, 255, 91, 0.12), 0 6px 18px -8px var(--match-glow);
}
.chip.active:hover {
  color: var(--match-ink);
  filter: brightness(1.05);
}

/* ── Modal ──────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 7, 6, 0.7);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  max-width: 520px;
  width: 100%;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 32px 30px 28px;
  box-shadow: var(--shadow-deep);
  animation: modal-pop .25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(34, 30, 24, 0.5);
  color: var(--ink-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  transition: color .12s, border-color .12s;
}
.modal-close:hover { color: var(--ink); border-color: var(--border-bright); }

.modal-title {
  font-family: "Instrument Serif", serif;
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  margin: 0 0 12px;
}
.serif-italic {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  color: var(--accent);
}

.modal-lede {
  color: var(--ink-dim);
  font-size: 13px;
  margin: 0 0 22px;
  line-height: 1.55;
}

.legend {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.legend li { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); }
.legend b { color: var(--ink); margin-right: 4px; font-weight: 500; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.swatch-match { background: var(--match); border-color: var(--match); }
.swatch-close { background: var(--close); border-color: var(--close); }
.swatch-warm  { background: var(--warm);  border-color: #7a5028; }
.swatch-miss  { background: var(--miss);  border-color: var(--miss-line); }

.rule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin: 0 0 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(8, 7, 6, 0.4);
  font-size: 12px;
}
.rule-grid > div { display: flex; flex-direction: column; gap: 2px; }
.rule-grid b { color: var(--ink); font-weight: 500; font-size: 13px; }
.rule-grid span { color: var(--ink-faint); }

.modal-foot {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 0;
  line-height: 1.55;
}
.arrow-demo {
  color: var(--accent-warm);
  font-weight: 700;
  font-size: 13px;
  display: inline-block;
  padding: 0 2px;
}

/* Stats card */
.result-banner {
  background: linear-gradient(180deg, rgba(158, 255, 91, 0.08), transparent 80%);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 22px;
  text-align: left;
}
.result-banner.lost {
  background: linear-gradient(180deg, rgba(255, 192, 107, 0.06), transparent 80%);
}
.result-eyebrow {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--match);
  font-weight: 700;
  margin-bottom: 6px;
}
.result-banner.lost .result-eyebrow { color: var(--close); }
.result-name {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: 38px;
  line-height: 1;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.result-description {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 400;
  border-left: 2px solid var(--accent);
  padding-left: 12px;
  font-style: italic;
}
body.infinite .result-description {
  border-left-color: var(--match);
}
.result-banner.lost .result-description {
  border-left-color: var(--close);
}
.result-sub {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.55;
}
.result-sub b { color: var(--ink); font-weight: 500; }

.stats-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 12px;
  font-weight: 500;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}
.stat {
  text-align: center;
  padding: 12px 6px;
  background: rgba(8, 7, 6, 0.4);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat b {
  display: block;
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
}
.stat span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.dist-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 10px;
  font-weight: 500;
}

.dist { display: flex; flex-direction: column; gap: 5px; margin-bottom: 22px; }
.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.dist-row .dist-label {
  width: 18px;
  color: var(--ink-faint);
  text-align: center;
}
.dist-row .dist-bar {
  flex: 1;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-3);
  position: relative;
  overflow: hidden;
}
.dist-row .dist-fill {
  height: 100%;
  background: linear-gradient(90deg, #2a2620, var(--border-bright));
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 500;
  min-width: 22px;
  transition: width .5s cubic-bezier(0.4, 0.05, 0.2, 1);
}
.dist-row.hit .dist-fill {
  background: linear-gradient(90deg, var(--match-deep), var(--match));
  color: var(--match-ink);
}

.end-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.countdown-wrap { display: flex; flex-direction: column; }
.countdown-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.countdown {
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.share-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.share-hint {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--match);
  color: var(--match-ink);
  border: 0;
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .12s, filter .15s;
  box-shadow: 0 8px 28px -10px var(--match-glow);
}
.btn-share:hover { filter: brightness(1.07); }
.btn-share:active { transform: scale(0.97); }

/* ── Toast ──────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  box-shadow: var(--shadow-deep);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  :root {
    --col-name: minmax(170px, 1.8fr);
    --col-attr: minmax(58px, 1fr);
  }
  .board-headings { font-size: 9px; }
  .cell { font-size: 11px; padding: 6px 4px; min-height: 58px; }
  .cell-value { font-size: 12px; }
  .cell-sub { font-size: 8px; }
  .cell-name { font-size: 13px; padding: 8px 12px; }
  .cell-name .row-no { font-size: 16px; margin-right: 8px; }
}

@media (max-width: 620px) {
  .header { padding: 22px 18px 14px; flex-wrap: wrap; gap: 14px; }
  .header-meta { width: 100%; justify-content: space-between; }
  .board-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 14px 4px;
    scrollbar-width: thin;
  }
  .board-headings,
  .row {
    min-width: 880px;
  }
  .rule-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .end-actions { flex-direction: column; align-items: stretch; gap: 12px; }
  .btn-share { justify-content: center; }
}

@media (max-width: 380px) {
  .modal-card { padding: 24px 20px 22px; }
  .result-name { font-size: 30px; }
}

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