/* Home and results: a full-screen TUI with two panes.
   One monospace scale for both pages: logo 88 / headline 34 / body 16 / small 13. */

* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --faint: #9b9b9b;
  --line: #d2d2d2;
  --accent: #1f7a45;
  --sunk: #f0f0f0;
  --add: #dcf5e3;
  --del: #fde4e4;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
html[data-theme="dark"] {
  --bg: #101010;
  --fg: #e6e6e6;
  --muted: #9a9a9a;
  --faint: #6a6a6a;
  --line: #363636;
  --accent: #5fd38a;
  --sunk: #1a1a1a;
  --add: rgba(95, 211, 138, 0.14);
  --del: rgba(255, 110, 110, 0.14);
}

body.on-screen { background: var(--bg); color: var(--fg); }
body.in-game { overflow: hidden; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 22px;
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  display: flex;
}
.screen p { margin: 0; }
.screen * { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.screen :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The frame fills the screen. Labels sit in its border. */
.frame {
  position: relative;
  flex: 1;
  display: flex;
  height: calc(100vh - 44px);
  height: calc(100dvh - 44px);
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.edge {
  position: absolute;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}
.edge span { background: var(--bg); padding: 0 8px; color: var(--muted); }
.edge.top { top: -7px; }
.edge.bottom { bottom: -7px; justify-content: flex-start; gap: 6px; }

.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); }
.pane { min-width: 0; min-height: 0; padding: 48px 52px; }
.pane.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 22px; overflow-y: auto; }
.pane.main { display: flex; flex-direction: column; overflow-y: auto; }
.grow { flex: 1; min-height: 32px; }

/* Left pane: the game */
.logo { margin: 0 0 10px; font-size: 88px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.sub { color: var(--muted); font-size: 18px; margin-bottom: 28px !important; }
.intro { max-width: 34em; font-size: 17px; line-height: 1.7; }

.gate {
  margin: 0 0 24px;
  padding: 16px 18px;
  font: inherit;
  font-size: 15px;
  line-height: 1.8;
  background: var(--sunk);
  border-radius: 3px;
  overflow-x: auto;
  tab-size: 4;
}
.gate .file { display: block; color: var(--faint); margin-bottom: 4px; }
.gate .del { display: block; background: var(--del); margin: 0 -18px; padding: 0 18px; }
.gate .add { display: block; background: var(--add); margin: 0 -18px; padding: 0 18px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.fine { margin-top: 28px !important; font-size: 12px; line-height: 1.6; color: var(--faint); max-width: 40em; }

/* Right pane: one titled box per setting */
.box {
  margin: 0;
  padding: 14px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
  min-width: 0;
}
.box legend, .box-title {
  padding: 0 8px;
  margin: 0 0 0 -8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.box.on { border-color: var(--fg); }
.box.on legend { color: var(--fg); }
.box.on legend::before { content: "❯ "; color: var(--accent); }
.opts { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.opts label { position: relative; cursor: pointer; display: block; }
.opts input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.opts span { display: inline-block; padding: 2px 8px; margin-left: -8px; color: var(--muted); border-radius: 2px; }
.opts span::before { content: "  "; white-space: pre; }
.opts label:hover span { color: var(--fg); }
.opts input:checked + span { background: var(--fg); color: var(--bg); }
.opts input:checked + span::before { content: "› "; }
.opts input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.box-note { margin-top: 10px !important; font-size: 13px; color: var(--faint); }

/* Buttons */
.screen button {
  font: inherit;
  font-size: 15px;
  padding: 9px 18px;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg);
  border-radius: 3px;
  cursor: pointer;
  touch-action: manipulation;
}
.screen button:hover { background: var(--sunk); }
.screen button.primary { background: var(--fg); color: var(--bg); }
.screen button.primary:hover { opacity: 0.88; }
.screen button.link { padding: 0; border: 0; background: none; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.screen button.link:hover { color: var(--fg); background: none; }
.links { display: flex; flex-wrap: wrap; gap: 6px 22px; }

/* Results: report card in the left pane */
.rc { margin: auto 0; }
.rc-status { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); margin-bottom: 14px !important; }
.rc-status i { width: 9px; height: 9px; border-radius: 50%; }
.rc-verdict { font-size: 34px; line-height: 1.25; font-weight: 700; max-width: 22em; margin-bottom: 30px !important; }
.rc-rank { margin: 8px 0 28px !important; font-size: 15px; color: var(--muted); }
.rc-exhibit { margin: 0 0 30px; padding: 16px 18px; background: var(--sunk); border-radius: 3px; }
.rc-exhibit code { display: block; font: inherit; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.rc-exhibit span { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.rc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 22px; padding-top: 22px; border-top: 1px dashed var(--line); }
.rc-stats dt { font-size: 13px; color: var(--muted); }
.rc-stats dd { margin: 0; font-size: 30px; font-weight: 700; }
.rc-trail { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 22px; }
.rc-trail i { width: 12px; height: 12px; border-radius: 1px; }
.rc-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--faint); }

/* Results: incident report in the right pane */
.report-box { flex: 1; min-height: 0; overflow-y: auto; }
.box-title { display: inline-block; margin-top: -24px !important; background: var(--bg); position: relative; top: -2px; }
#report-body { font-size: 14px; line-height: 1.65; }
#report-body h1 { font-size: 20px; line-height: 1.3; margin: 6px 0 2px; }
#report-body h2 { font-size: 14px; margin: 20px 0 6px; color: var(--muted); font-weight: 400; }
#report-body p { margin: 0 0 10px; }
#report-body .meta { color: var(--muted); }
#report-body code { font: inherit; font-size: 13px; }
#report-body ul { margin: 0; padding-left: 1.4em; }
#report-body li { margin-bottom: 4px; }
#report-body ul.todo { list-style: none; padding: 0; }
#report-body ul.todo li::before { content: "[ ] "; color: var(--faint); }
.exhibit {
  margin: 10px 0 14px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  background: var(--sunk);
  border-radius: 3px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.exhibit .file, .exhibit .ctx { display: block; }
.exhibit .file { color: var(--faint); }
.exhibit .del { display: block; background: var(--del); margin: 0 -12px; padding: 0 12px; }
.exhibit .add { display: block; background: var(--add); margin: 0 -12px; padding: 0 12px; }
.timeline { border-collapse: collapse; font-size: 13px; }
.timeline td { padding: 2px 14px 2px 0; vertical-align: top; }
.timeline td:first-child { color: var(--muted); white-space: nowrap; }
.timeline code { word-break: break-all; }

@media (pointer: coarse) {
  .help { display: none; }
  .box.on { border-color: var(--line); }
  .box.on legend { color: var(--muted); }
  .box.on legend::before { content: none; }
}

@media (max-width: 960px) {
  .pane { padding: 36px 32px; }
  .logo { font-size: 64px; }
}

@media (max-width: 820px) {
  .screen { padding: 14px; font-size: 15px; }
  .frame { height: auto; min-height: calc(100dvh - 28px); }
  .pane.main { overflow: visible; }
  .panes { grid-template-columns: 1fr; }
  .pane { padding: 30px 20px; }
  .pane.side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .pane.main .grow { min-height: 24px; flex: none; }
  .logo { font-size: 52px; }
  .sub { font-size: 16px; margin-bottom: 18px !important; }
  .intro { font-size: 15px; }
  .rc-verdict { font-size: 26px; }
  .rc-stats { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .rc-stats dd { font-size: 26px; }
  .report-box { overflow: visible; }
  .actions button:not(.link) { flex: 1 1 calc(50% - 18px); }

  /* Home on a phone: settings come before the diff and the start button. */
  #landing .panes { display: flex; flex-direction: column; padding: 30px 20px 34px; }
  #landing .pane.main { display: contents; }
  #landing .pane.side { order: 4; padding: 0; border: 0; margin: 26px 0 28px; gap: 18px; }
  #landing .logo { order: 1; }
  #landing .sub { order: 2; }
  #landing .intro { order: 3; }
  #landing .grow { display: none; }
  #landing .gate { order: 5; }
  #landing .actions { order: 6; }
  #landing .actions .primary { flex-basis: 100%; }
  #landing .fine { order: 7; }
}
