/* Day is warm and legible; night is deep indigo. The interface may look like a
   game — the scientific content may not. Numbers and formulas always render in
   plain readable type at full contrast. */
:root {
  --bg: #f4ecdd; --panel: #fffaf0; --ink: #241c12; --muted: #6d6152;
  --accent: #b26a00; --line: #d8c8ac; --ok: #1f6b46; --warn: #9a3412;
  --shadow: #cbb894;
}
[data-phase="night"] {
  --bg: #14132b; --panel: #1e1d3d; --ink: #e9e8f7; --muted: #9d9ac4;
  --accent: #8b83ff; --line: #34325e; --ok: #3ecf8e; --warn: #ff8a5c;
  --shadow: #0c0b1c;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif; font-size: 15px; line-height: 1.6;
}
.frame { max-width: 760px; margin: 0 auto; padding: 14px 16px 28px; }

.hud {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-family: "Press Start 2P", monospace; font-size: 9px; letter-spacing: .5px;
  color: var(--muted); border-bottom: 3px solid var(--line);
  padding-bottom: 12px; margin-bottom: 22px;
}
.hud-role { color: var(--accent); }
.foot {
  margin-top: 36px; padding-top: 14px; border-top: 3px solid var(--line);
  font-family: "Press Start 2P", monospace; font-size: 8px; color: var(--muted);
  letter-spacing: .5px; text-align: center; line-height: 2;
}

h1 { font-family: "Press Start 2P", monospace; font-size: 17px; line-height: 1.7;
     margin: 0 0 6px; color: var(--ink); }
h2 { font-family: "Press Start 2P", monospace; font-size: 11px; line-height: 1.9;
     margin: 26px 0 10px; color: var(--accent); letter-spacing: .3px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.panel {
  background: var(--panel); border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow); padding: 16px 18px; margin: 0 0 14px;
}
.panel > p:first-child { margin-top: 0; }
.panel > p:last-child { margin-bottom: 0; }
.brief p + p { margin-top: 10px; }
.brief { border-left: 6px solid var(--accent); }
.brief p:first-child { margin-top: 0; }
.brief p:last-child { margin-bottom: 0; }

.case dt { font-weight: 700; margin-top: 12px; font-size: 13px; }
.case dd { margin: 2px 0 0; color: var(--muted); }
ol.obj { margin: 8px 0 0; padding-left: 20px; }
ol.obj li { margin-bottom: 6px; }

label { display: block; font-weight: 600; margin: 16px 0 5px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=number], input[type=text], textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 0;
}
input:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-weight: 400; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }

button {
  font-family: "Press Start 2P", monospace; font-size: 10px; line-height: 1.8;
  background: var(--accent); color: #fff; border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow); padding: 13px 18px; margin-top: 22px;
  cursor: pointer; letter-spacing: .5px;
}
button:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--shadow); }

.keyrow { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 0; }
.key {
  flex: 1 1 150px; border: 3px solid var(--ink); background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow); padding: 12px 14px;
}
.key.empty { border-style: dashed; box-shadow: none; opacity: .55; }
.key .label { font-family: "Press Start 2P", monospace; font-size: 8px;
              color: var(--muted); letter-spacing: .5px; }
.key .value { font-size: 30px; font-weight: 700; margin-top: 6px; }

.mission { display: flex; justify-content: space-between; align-items: center;
           gap: 14px; padding: 14px 0; border-bottom: 2px solid var(--line); }
.mission:last-child { border-bottom: 0; }
.mission .t { font-weight: 600; }
.mission .l { color: var(--muted); font-size: 13px; }
.pill { font-family: "Press Start 2P", monospace; font-size: 8px; padding: 6px 9px;
        border: 2px solid currentColor; white-space: nowrap; }
.pill.done { color: var(--ok); }
.pill.open { color: var(--accent); }
.pill.locked { color: var(--muted); opacity: .7; }

.verdict { font-family: "Press Start 2P", monospace; font-size: 13px; line-height: 1.8;
           margin: 0 0 12px; }
.verdict.good { color: var(--ok); }
.verdict.bad { color: var(--warn); }
.worked { border-top: 2px dashed var(--line); margin-top: 18px; padding-top: 16px; }
table.key-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
table.key-table th, table.key-table td { text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line); }
table.key-table th { color: var(--muted); font-weight: 600; }
table.key-table td.n { font-weight: 700; font-size: 17px; }
.a { color: var(--accent); text-decoration: none; font-weight: 600; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
           background: var(--bg); border: 2px solid var(--line); padding: 10px 12px;
           display: inline-block; margin-top: 8px; }

select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 0;
}
select:focus { outline: 3px solid var(--accent); outline-offset: 1px; }

/* Escape hatch. Inside an iframe on another domain the browser may refuse the
   game's cookies outright; opening in its own tab makes them first-party and
   everything works. The token in the link carries the learner across. */
.foot .pop { color: var(--accent); text-decoration: none; letter-spacing: .5px; }
.foot .pop:hover { text-decoration: underline; }

/* --- how this works ----------------------------------------------------- */
.rules {
  background: var(--panel); border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--shadow); margin: 0 0 20px; padding: 0;
}
.rules > summary {
  font-family: "Press Start 2P", monospace; font-size: 10px; letter-spacing: .5px;
  color: var(--accent); padding: 15px 18px; cursor: pointer; list-style: none;
}
.rules > summary::-webkit-details-marker { display: none; }
.rules > summary::after { content: " ▾"; }
.rules[open] > summary::after { content: " ▴"; }
.rules > summary:hover { text-decoration: underline; }
.rules-body { padding: 0 18px 18px; }
.rules-body .lead { margin-top: 0; }

.roles { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0 6px; }
.role {
  flex: 1 1 240px; border: 2px solid var(--line); padding: 12px 14px;
  background: var(--bg);
}
.role-t { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.role .glyph { color: var(--accent); }
.role p { margin: 0; font-size: 14px; color: var(--muted); }

ol.rulelist { margin: 18px 0 0; padding-left: 22px; }
ol.rulelist li { margin-bottom: 12px; }
ol.rulelist strong { display: block; }
ol.rulelist span { color: var(--muted); font-size: 14px; }
.rules-body .close {
  margin: 18px 0 0; padding-top: 14px; border-top: 2px solid var(--line);
  font-weight: 600;
}

/* --- an open mission is clickable across its whole row ------------------- */
a.mission {
  display: flex; text-decoration: none; color: inherit;
  margin: 0 -8px; padding: 14px 8px; border-radius: 2px;
}
a.mission:hover { background: var(--bg); }
a.mission:hover .t { text-decoration: underline; }
a.mission:hover .pill.open { background: var(--accent); color: #fff; }
a.mission .pill.open { transition: background .12s, color .12s; }
