:root {
  color-scheme: light;
  --bg: #efe7d5;
  --surface: #faf6ea;
  --surface-2: #e3d5b8;
  --ink: #241305;
  --muted: #6a583d;
  --line: #d0bf9c;
  --accent: #a31f16;
  --accent-ink: #ffffff;
  --focus: #1a4fd6;
  --arena: #201309;
  --arena-2: #2c1c0d;
  --cheese: #f2b632;
  --sauce: #c33d2a;
  --crust: #8a4d12;
  --basil: #1e6b2e;
  --win: #f2b632;
  --chip-bg: #f0e3c8;
  --radius: 12px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", "DejaVu Serif", serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14100a;
  --surface: #201710;
  --surface-2: #2e2114;
  --ink: #f4ebd6;
  --muted: #c2af87;
  --line: #4c3e27;
  --accent: #ff9d7e;
  --accent-ink: #2b0d06;
  --focus: #9db9ff;
  --arena: #0e0a06;
  --arena-2: #1c140b;
  --cheese: #f2b632;
  --sauce: #d65440;
  --crust: #a86a2a;
  --basil: #7ed08a;
  --win: #f2b632;
  --chip-bg: #2a2114;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  font-size: 1.0625rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}

.topbar .home { font-weight: 800; color: var(--ink); text-decoration: none; flex: none; letter-spacing: -0.01em; }
.topnav { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { flex: none; padding: 0.5rem 0.6rem; color: var(--muted); text-decoration: none; border-radius: 6px; }
.topnav a[aria-current="true"] { color: var(--ink); font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .chip { flex: none; color: var(--accent); font-weight: 600; }
.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

section { scroll-margin-top: 3.75rem; }

.hero { padding: 2.75rem 0 0.5rem; max-width: 46rem; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.6vw, 3.5rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
  text-wrap: balance;
}
.deck { font-size: 1.2rem; color: var(--muted); margin: 0 0 1rem; max-width: 40rem; }
.deck strong { color: var(--ink); }
.answer-line {
  font-family: var(--font-mono);
  font-size: 1.02rem;
  background: var(--arena);
  color: var(--cheese);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 1.25rem 0 0;
  max-width: 40rem;
  letter-spacing: 0.01em;
}

/* ---------- duel ---------- */

.duel-section { padding-top: 1.5rem; }
.duel-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 560px) {
  .duel-inputs { grid-template-columns: 1fr; }
}
.side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.1rem;
}
.side h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}
.side h3 .tag {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  padding: 0.1rem 0.55rem;
}
[data-theme="dark"] .side h3 .tag { background: var(--cheese); color: #241a04; }
.side h3 .area-out {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.field { display: grid; gap: 0.25rem; min-width: 0; }
.field label { font-size: 0.9rem; font-weight: 700; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}
.field input:focus { border-color: var(--focus); outline: none; }
.unit-hint { font-size: 0.82rem; color: var(--muted); }

.arena {
  margin-top: 1rem;
  background: var(--arena);
  border-radius: 16px;
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: 0 1.25rem 2.5rem rgba(0, 0, 0, 0.22);
}
[data-theme="dark"] .arena { border: 1px solid var(--line); box-shadow: none; }
#duel { width: 100%; height: auto; display: block; }
.pz-disc { fill: var(--cheese); transition: r 0.35s ease, cx 0.35s ease, cy 0.35s ease; }
.pz-sauce { fill: var(--sauce); opacity: 0.85; transition: r 0.35s ease, cx 0.35s ease, cy 0.35s ease; }
.pz-dot { fill: #7c1f14; opacity: 0.9; }
[data-theme="dark"] .pz-dot { fill: #5e150d; }
.pz-ghost { fill: none; stroke: #5a4a2e; stroke-width: 2; stroke-dasharray: 6 5; }
.pz-name { fill: #f5ead0; font-family: var(--font-mono); font-size: 19px; font-weight: 700; text-anchor: middle; }
.pz-sub { fill: #b7a67c; font-family: var(--font-mono); font-size: 15px; text-anchor: middle; }
.pz-badge {
  fill: #241a04;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--cheese);
  stroke-width: 7px;
  stroke-linejoin: round;
}
.pz.is-winner .pz-disc { stroke: #fff3d6; stroke-width: 5; }
.verdict {
  margin: 0.9rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff6df;
  text-wrap: balance;
}
.verdict[data-state="idle"] { color: #b7a67c; }
.per-line {
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--cheese);
}
.weight-line { margin: 0.3rem 0 0; font-size: 0.95rem; color: #d8cba4; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 1rem; }
.btn {
  font-size: 1rem;
  font-weight: 700;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  border: 1px solid #8a6a2f;
  background: transparent;
  color: var(--cheese);
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--cheese); }
.btn:disabled { opacity: 0.45; cursor: default; }
.copy-status { color: #b7a67c; margin: 0; min-height: 1.5em; }
.error {
  margin: 1rem 0 0;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: #3d1414;
  border: 1px solid #7c2b2b;
  color: #ffd7d7;
  font-weight: 600;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- prose ---------- */

.prose { max-width: 44rem; padding-top: 2.5rem; }
.prose h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.2vw, 1.9rem);
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}
.prose p { margin: 0 0 1rem; }
.prose a { color: var(--accent); }
.prose code, td code, .menu-row code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 5px;
}
.menu-list { list-style: none; margin: 1.25rem 0; padding: 0; display: grid; gap: 0.7rem; }
.menu-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 1rem;
  align-items: center;
}
.menu-row .name { font-weight: 800; font-size: 1.05rem; }
.menu-row .name small { font-weight: 400; color: var(--muted); }
.menu-row .deal { font-family: var(--font-mono); font-size: 0.92rem; color: var(--muted); }
.menu-row .deal strong { color: var(--basil); }
.menu-row button {
  grid-row: span 2;
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.menu-row button:hover { background: var(--accent); color: var(--accent-ink); }
[data-theme="dark"] .menu-row button:hover { color: #2b0d06; }
@media (max-width: 560px) {
  .menu-row { grid-template-columns: 1fr; }
  .menu-row button { grid-row: auto; justify-self: start; }
}
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table.sizes { border-collapse: collapse; width: 100%; font-size: 0.98rem; }
table.sizes caption { text-align: left; color: var(--muted); padding-bottom: 0.5rem; }
table.sizes th, table.sizes td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
table.sizes thead th { background: var(--surface-2); }
table.sizes tbody th { font-family: var(--font-mono); white-space: nowrap; }
table.sizes tr.hl td, table.sizes tr.hl th { background: var(--chip-bg); font-weight: 700; }
.formula {
  font-family: var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--sauce);
  border-radius: 8px;
  padding: 0.8rem 1rem;
}
.faq { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.6rem; background: var(--surface); }
.faq summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.8rem 1rem;
  min-height: 44px;
}
.faq p { padding: 0 1rem 0.9rem; margin: 0; }
.sources ul { padding-left: 1.2rem; }
.sources li { margin-bottom: 0.6rem; }

footer.site {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
footer.site a { color: var(--accent); }
footer.site .spacer { flex: 1; }

@media (max-width: 480px) {
  main { padding: 0 1rem 3rem; }
}
