:root {
  color-scheme: light;
  --nus-blue: #003d7c;
  --nus-orange: #ef7c00;
  --ink: #071421;
  --muted: #607085;
  --page: #eef3f8;
  --panel: #ffffff;
  --soft: #f6f9fc;
  --line: #d6e0eb;
  --good: #12805c;
  --good-soft: #e8f8ef;
  --bad: #b42318;
  --bad-soft: #fff1f0;
  --amber: #9a5a00;
  --amber-soft: #fff4e6;
  --violet: #6d46ad;
  --teal: #007c89;
  --shadow: 0 18px 48px rgb(0 30 64 / 0.16);
  --app-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --nus-blue: #8ec5ff;
  --nus-orange: #ffad4d;
  --ink: #eef6ff;
  --muted: #b6c4d8;
  --page: #071421;
  --panel: #101e30;
  --soft: #16283e;
  --line: #2c4360;
  --good: #52d58a;
  --good-soft: #0d2b20;
  --bad: #ff8a9b;
  --bad-soft: #351818;
  --amber: #ffbd59;
  --amber-soft: #33200e;
  --shadow: 0 18px 48px rgb(0 0 0 / 0.46);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 300px;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(239 124 0 / 0.62);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  width: 100%;
  height: var(--app-height);
  min-height: 0;
  overflow: hidden;
  padding: 4px;
  place-items: center;
}

.game-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 440px);
  height: calc(var(--app-height) - 8px);
  min-height: 0;
  overflow: hidden;
  border: 2px solid var(--nus-blue);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar,
.brand,
.status-cluster,
.round-strip,
.actionbar,
.mechanism-head,
.result-row,
.modal-header {
  display: flex;
  align-items: center;
}

.topbar {
  min-height: 56px;
  justify-content: space-between;
  gap: 7px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 8px;
}

.brand {
  min-width: 0;
  flex: 1 1 auto;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--nus-blue);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 7px 18px rgb(0 61 124 / 0.18);
}

.brand-copy {
  display: grid;
  min-width: 0;
  width: 116px;
  line-height: 1.02;
}

.brand-copy strong {
  overflow: hidden;
  color: var(--nus-blue);
  font-size: 1.62rem;
  font-weight: 850;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-byline {
  overflow: hidden;
  color: var(--nus-blue);
  font-size: 0.84rem;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-byline span {
  color: var(--nus-orange);
}

.status-cluster {
  flex: 0 0 auto;
  gap: 4px;
}

.status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--nus-blue);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 7px;
  white-space: nowrap;
}

.status-pill.urgent {
  border-color: rgb(180 35 24 / 0.42);
  background: var(--bad-soft);
  color: var(--bad);
}

.icon-button,
.nav-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--nus-blue);
  cursor: pointer;
}

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
}

.nav-button {
  width: 32px;
  height: 36px;
  border-radius: 8px;
}

.icon-button:hover,
.nav-button:hover {
  border-color: rgb(239 124 0 / 0.55);
  background: var(--amber-soft);
}

.icon-button svg,
.nav-button svg,
.status-pill svg,
.elapsed-strip svg,
.action-button svg,
.modal-link svg,
.support-card svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.play-screen {
  display: grid;
  grid-template-rows: 42px 30px 106px minmax(150px, 1fr) 44px 50px 44px;
  min-height: 0;
  gap: 6px;
  overflow: hidden;
  padding: 7px;
}

.play-screen.has-answer-focus {
  grid-template-rows: 42px 30px 106px minmax(150px, 1fr) 44px 50px 44px;
}

.round-strip {
  min-width: 0;
  justify-content: space-between;
  gap: 7px;
}

.round-meta {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  justify-items: center;
  gap: 2px;
  text-align: center;
}

.round-meta span,
.mechanism-head span,
.feedback-kicker {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
}

.round-meta strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.elapsed-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 0 11px;
}

.elapsed-strip span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.elapsed-strip span:last-child {
  justify-content: flex-end;
}

.elapsed-strip strong {
  color: var(--nus-blue);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: max-content max-content;
  justify-content: space-between;
  min-height: 0;
  column-gap: 52px;
  overflow: hidden;
  border: 1px solid rgb(0 61 124 / 0.2);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.78), rgb(255 244 230 / 0.55) 50%, rgb(255 255 255 / 0.78)),
    var(--soft);
  padding: 7px;
}

html[data-theme="dark"] .board {
  border-color: var(--line);
  background:
    linear-gradient(90deg, rgb(16 30 48 / 0.82), rgb(51 32 14 / 0.58) 50%, rgb(16 30 48 / 0.82)),
    var(--soft);
}

.column {
  display: grid;
  width: var(--column-card-width, max-content);
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  gap: 10px;
  align-content: space-around;
  justify-items: stretch;
}

.column-left {
  justify-self: start;
}

.column-right {
  justify-self: end;
}

.entity-card {
  position: relative;
  display: grid;
  grid-template-columns: 25px minmax(0, max-content);
  align-items: center;
  gap: 6px;
  width: var(--column-card-width, 100%);
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgb(0 61 124 / 0.2);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 5px 11px 5px 8px;
  text-align: left;
  touch-action: manipulation;
  transition:
    border-color 120ms ease,
    opacity 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.entity-card:hover {
  border-color: rgb(239 124 0 / 0.55);
}

.entity-card.kind-drug {
  border-radius: 22px;
}

.entity-card.kind-food {
  border-radius: 19px 10px 21px 12px;
}

.entity-card.kind-supplement {
  border-radius: 8px 18px 8px 18px;
}

.entity-card.kind-herb {
  border-radius: 18px 8px 18px 8px;
}

.entity-card.pending {
  border-color: var(--nus-orange);
  box-shadow: 0 0 0 3px rgb(239 124 0 / 0.18);
  transform: translateY(-1px);
}

.entity-card.review-focused {
  border-color: var(--nus-blue);
  box-shadow:
    0 0 0 3px rgb(0 61 124 / 0.16),
    0 8px 18px rgb(0 61 124 / 0.12);
  transform: translateY(-1px);
}

html[data-theme="dark"] .entity-card {
  border-color: var(--line);
}

html[data-theme="dark"] .entity-card.review-focused {
  border-color: var(--nus-blue);
  box-shadow:
    0 0 0 3px rgb(142 197 255 / 0.22),
    0 8px 18px rgb(0 0 0 / 0.32);
}

.entity-card.dimmed {
  opacity: 0.58;
}

.entity-card.review-dimmed {
  opacity: 0.34;
}

.entity-visual {
  position: relative;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  overflow: hidden;
  color: #fff;
}

.kind-drug .entity-visual {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--nus-blue) 0 50%, var(--nus-orange) 50% 100%);
}

.kind-drug .entity-visual::after {
  content: "";
  position: absolute;
  inset: 3px 12px;
  background: rgb(255 255 255 / 0.74);
  transform: rotate(28deg);
}

.kind-food .entity-visual {
  border-radius: 50% 45% 48% 52%;
  background: var(--good);
}

.kind-food .entity-visual::before {
  content: "";
  position: absolute;
  top: 1px;
  right: 4px;
  width: 10px;
  height: 7px;
  border-radius: 100% 0;
  background: #76c983;
  transform: rotate(-24deg);
}

.kind-food .entity-visual::after {
  content: "";
  position: absolute;
  bottom: 6px;
  left: 7px;
  width: 14px;
  height: 8px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.58);
}

.kind-supplement .entity-visual {
  border-radius: 8px;
  background: var(--teal);
}

.kind-supplement .entity-visual::before {
  content: "";
  position: absolute;
  top: 5px;
  width: 14px;
  height: 4px;
  border-radius: 4px;
  background: rgb(255 255 255 / 0.82);
}

.kind-supplement .entity-visual::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 12px;
  height: 9px;
  border: 2px solid rgb(255 255 255 / 0.78);
  border-top: 0;
}

.kind-herb .entity-visual {
  border-radius: 70% 0 70% 0;
  background: linear-gradient(135deg, #0f7a4f, #55b86f);
  transform: rotate(-12deg);
}

.kind-herb .entity-visual::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 12px;
  width: 2px;
  height: 20px;
  border-radius: 2px;
  background: rgb(255 255 255 / 0.65);
  transform: rotate(32deg);
}

.kind-herb .entity-visual::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 5px;
  width: 9px;
  height: 5px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.42);
}

.entity-copy {
  display: grid;
  min-width: 0;
}

.entity-name {
  display: block;
  min-width: 0;
  max-width: var(--column-name-width, clamp(82px, 27vw, 128px));
  overflow: hidden;
  color: var(--ink);
  font-size: 0.81rem;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.12;
  overflow-wrap: normal;
  text-wrap: balance;
  white-space: normal;
}

.node {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid var(--nus-blue);
  border-radius: 999px;
  background: var(--panel);
  transform: translateY(-50%);
  box-shadow: 0 0 0 2px rgb(255 255 255 / 0.8);
}

.column-left .node {
  right: -7px;
}

.column-right .node {
  left: -7px;
}

.line-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.wire {
  fill: none;
  stroke: var(--mech-color, var(--nus-blue));
  stroke-linecap: round;
  stroke-width: 4;
  opacity: 0.86;
}

.wire.pending {
  stroke: var(--mech-color, var(--violet));
}

.wire.correct {
  stroke: var(--mech-color, var(--good));
  stroke-width: 5;
  filter:
    drop-shadow(0 0 3px var(--mech-glow, rgb(18 128 92 / 0.76)))
    drop-shadow(0 0 10px var(--mech-glow, rgb(18 128 92 / 0.62)));
  opacity: 1;
}

.wire.wrong {
  stroke: var(--mech-color, var(--bad));
  stroke-dasharray: 3 7;
  stroke-width: 5;
  opacity: 0.3;
}

.wire.wrong.same-pair-wrong {
  stroke-width: 12;
  opacity: 0.36;
}

.wire.missed {
  stroke: var(--mech-color, var(--nus-orange));
  stroke-dasharray: 1 8;
  stroke-width: 5;
  filter:
    drop-shadow(0 0 3px var(--mech-glow, rgb(239 124 0 / 0.76)))
    drop-shadow(0 0 10px var(--mech-glow, rgb(239 124 0 / 0.62)));
  opacity: 0.92;
}

.wire-label-chip {
  opacity: 0.98;
}

.wire-label-chip rect {
  fill: var(--panel);
  fill: color-mix(in srgb, var(--panel) 86%, var(--mech-color, var(--nus-blue)) 14%);
  stroke: var(--mech-color, var(--nus-blue));
  stroke-width: 1.2;
}

.wire-label-chip.wrong {
  opacity: 0.78;
}

.wire-label-chip.correct,
.wire-label-chip.missed {
  filter:
    drop-shadow(0 0 3px var(--mech-glow, rgb(18 128 92 / 0.62)))
    drop-shadow(0 0 10px var(--mech-glow, rgb(18 128 92 / 0.5)));
}

.wire-label-chip.wrong rect {
  stroke-width: 1.6;
  stroke-dasharray: 3 2.5;
}

.wire-label-chip.correct rect,
.wire-label-chip.missed rect {
  stroke-dasharray: none;
  stroke-width: 1.7;
}

.wire-label {
  dominant-baseline: middle;
  fill: var(--mech-color, var(--ink));
  paint-order: stroke;
  stroke: var(--panel);
  stroke-linejoin: round;
  stroke-width: 3px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-anchor: middle;
}

.wire-label.correct {
  fill: var(--mech-color, var(--good));
}

.wire-label.wrong {
  fill: var(--mech-color, var(--bad));
  opacity: 0.74;
}

.wire-label.missed {
  fill: var(--mech-color, var(--nus-orange));
}

.mechanism-rack {
  display: grid;
  min-height: 0;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 7px;
}

.mechanism-head {
  justify-content: space-between;
  min-width: 0;
  gap: 8px;
}

.selected-mech {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  color: var(--mech-color, var(--nus-blue)) !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-mech::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--mech-color, var(--nus-blue));
  content: "";
}

.mechanism-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  min-height: 0;
}

.mechanism-chip {
  display: grid;
  min-width: 0;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-color: var(--mech-glow, var(--line));
  border-radius: 8px;
  background: var(--mech-soft, var(--soft));
  background: color-mix(in srgb, var(--soft) 88%, var(--mech-color, var(--nus-blue)) 12%);
  color: var(--mech-color, var(--ink));
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.05;
  padding: 3px;
  text-align: center;
}

.mechanism-chip[aria-pressed="true"] {
  border-color: var(--mech-color, var(--nus-orange));
  background: var(--mech-soft, var(--amber-soft));
  color: var(--mech-color, var(--nus-blue));
  box-shadow:
    inset 0 0 0 1px var(--mech-glow, rgb(239 124 0 / 0.25)),
    0 0 0 2px var(--mech-soft, rgb(239 124 0 / 0.18));
}

.mechanism-chip.good {
  border-color: var(--mech-color, var(--good));
  background: var(--mech-soft, var(--good-soft));
  color: var(--mech-color, var(--good));
}

.answer-focus-panel {
  display: grid;
  min-height: 0;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 5px 8px 6px;
}

.answer-focus-labels {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.answer-focus-labels strong {
  color: var(--nus-blue);
  font-size: 0.62rem;
}

.answer-focus-labels span:last-child {
  text-align: right;
}

.answer-focus-slider {
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  accent-color: var(--nus-orange);
  cursor: pointer;
}

.answer-focus-slider::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--nus-orange), var(--good));
}

.answer-focus-slider::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border: 2px solid var(--nus-blue);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 0 0 3px rgb(239 124 0 / 0.18);
  appearance: none;
}

.answer-focus-slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--nus-orange), var(--good));
}

.answer-focus-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--nus-blue);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 0 0 3px rgb(239 124 0 / 0.18);
}

.mechanism-detail-panel {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border-color: var(--mech-glow, var(--line));
  background: color-mix(in srgb, var(--panel) 84%, var(--mech-color, var(--nus-blue)) 16%);
}

.mechanism-detail-kicker {
  display: inline-flex;
  min-width: 54px;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--mech-glow, var(--line));
  border-radius: 8px;
  background: var(--panel);
  color: var(--mech-color, var(--nus-blue));
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
}

.mechanism-detail-panel p {
  display: grid;
  min-width: 0;
  gap: 2px;
  margin: 0;
}

.mechanism-detail-panel strong,
.mechanism-detail-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.mechanism-detail-panel strong {
  text-overflow: ellipsis;
}

.mechanism-detail-panel strong {
  color: var(--mech-color, var(--nus-blue));
  font-size: 0.68rem;
  line-height: 1;
}

.mechanism-detail-text {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
  line-height: 1.1;
  text-overflow: clip;
}

.feedback-panel {
  display: grid;
  min-height: 0;
  align-content: center;
  gap: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 7px 9px;
}

.feedback-kicker {
  color: var(--mech-color, var(--nus-orange));
}

.feedback-panel p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feedback-panel strong {
  color: var(--nus-blue);
}

.actionbar {
  min-width: 0;
  gap: 6px;
}

.action-button {
  display: inline-flex;
  min-width: 0;
  min-height: 40px;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--nus-blue);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
  padding: 0 8px;
}

.action-button.primary {
  border-color: var(--nus-blue);
  background: var(--nus-blue);
  color: #fff;
}

html[data-theme="dark"] .action-button.primary {
  border-color: var(--nus-blue);
  background: #0b4f8a;
  color: #ffffff;
}

.action-button.accent {
  border-color: rgb(239 124 0 / 0.44);
  background: var(--amber-soft);
  color: var(--nus-blue);
}

.action-button:disabled,
.nav-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: center;
  justify-items: center;
  background: rgb(7 20 33 / 0.52);
  padding: 10px;
  backdrop-filter: blur(2px);
}

.modal-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(calc(100vw - 20px), 430px);
  max-height: calc(var(--app-height) - 20px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-header {
  position: relative;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
  padding: 11px 48px 11px 12px;
}

.modal-header h2,
.modal-header p,
.modal-body p,
.modal-body h3,
.result-row p {
  margin: 0;
}

.modal-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--nus-orange);
}

.modal-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.modal-header h2 {
  color: var(--nus-blue);
  font-size: 1rem;
  line-height: 1.15;
}

.modal-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
}

.modal-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.modal-body a {
  color: var(--nus-blue);
  font-weight: 850;
  text-decoration-color: var(--nus-orange);
  text-decoration-line: underline;
  text-underline-offset: 3px;
}

.modal-card,
.modal-note,
.support-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}

.modal-card h3,
.support-card h3 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal-note {
  border-color: rgb(239 124 0 / 0.34);
  background: var(--amber-soft);
  color: var(--amber) !important;
  font-size: 0.74rem !important;
  font-weight: 750 !important;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.result-tile {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 8px;
  text-align: center;
}

.result-tile strong {
  color: var(--nus-blue);
  font-size: 1.15rem;
  line-height: 1;
}

.result-tile span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 850;
  text-transform: uppercase;
}

.result-row {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
}

.result-row p {
  flex: 1 1 150px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.25;
}

.result-row strong {
  color: var(--nus-blue);
}

.result-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.result-actions .action-button {
  min-height: 34px;
  flex: 0 0 auto;
  padding-inline: 10px;
}

.review-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-list li {
  display: grid;
  gap: 3px;
  border-left: 4px solid var(--line);
  background: var(--soft);
  padding: 7px;
}

.review-list li.good {
  border-color: var(--good);
  background: var(--good-soft);
}

.review-list li.bad {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.review-list li.missed {
  border-color: var(--nus-orange);
  background: var(--amber-soft);
}

.review-list strong {
  color: var(--nus-blue);
  font-size: 0.76rem;
}

.review-list span,
.modal-body p {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

.modal-note .disclaimer-label,
.modal-note .disclaimer-label em {
  color: var(--amber) !important;
  display: inline-block;
  font-family: inherit !important;
  font-style: italic !important;
  font-synthesis: style weight;
  font-weight: 900 !important;
}

.report-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgb(180 35 24 / 0.2);
  border-radius: 8px;
  background: var(--bad-soft);
  padding: 8px;
}

.report-strip div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.report-strip strong {
  color: var(--bad);
  font-size: 0.76rem;
}

.report-strip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.report-link {
  border-color: rgb(180 35 24 / 0.26);
  background: var(--panel);
  color: var(--bad);
  padding-inline: 10px;
}

.modal-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--nus-blue);
  font-size: 0.74rem;
  font-weight: 850;
  text-decoration: none;
}

.report-details {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font: 700 0.72rem/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  padding: 9px;
}

.report-modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.report-action-button,
.report-submit-link {
  background: var(--panel);
}

.report-submit-link {
  border-color: rgb(239 124 0 / 0.45);
  background: var(--amber-soft);
}

.source-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-list li {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 7px;
}

.source-list a,
.source-label {
  color: var(--nus-blue);
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1.15;
}

.source-list a {
  text-decoration-color: var(--nus-orange);
  text-decoration-line: underline;
  text-underline-offset: 3px;
}

.modal-panel-about .modal-body {
  gap: 8px;
}

.modal-panel-about .modal-note {
  font-weight: 650 !important;
}

.modal-panel-about .modal-note .disclaimer-label,
.modal-panel-about .modal-note .disclaimer-label em {
  font-weight: 900 !important;
}

.about-created-card,
.source-card {
  padding: 8px;
}

.source-card {
  display: grid;
  gap: 5px;
}

.source-card h3 {
  margin-bottom: 0;
}

.source-card .source-list {
  gap: 6px;
}

.source-card .source-list li {
  background: var(--panel);
  padding: 6px 7px;
}

.howto-list,
.support-card ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.howto-list li {
  display: grid;
  gap: 3px;
  border-left: 4px solid var(--nus-orange);
  background: var(--soft);
  padding: 8px;
}

.howto-list strong {
  color: var(--nus-blue);
  font-size: 0.8rem;
}

.howto-list span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

.support-card li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
}

.support-card li svg {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--good);
}

.support-link {
  display: block;
  width: min(100%, 380px);
  margin: 0 auto;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.support-link:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.support-link img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.12);
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  max-width: min(340px, calc(100vw - 24px));
  border: 1px solid rgb(0 61 124 / 0.22);
  border-radius: 8px;
  background: var(--panel);
  color: var(--nus-blue);
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  font-weight: 850;
  padding: 10px 12px;
}

html[data-theme="dark"] .toast {
  border-color: var(--line);
}

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

@media (max-width: 400px), (max-height: 690px) {
  .topbar {
    min-height: 50px;
    padding: 6px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy {
    width: 100px;
  }

  .brand-copy strong {
    font-size: 1.32rem;
  }

  .brand-byline {
    font-size: 0.67rem;
  }

  .status-pill {
    min-height: 27px;
    padding-inline: 5px;
    font-size: 0.62rem;
  }

  .icon-button {
    width: 27px;
    height: 27px;
  }

  .play-screen {
    grid-template-rows: 38px 28px 96px minmax(132px, 1fr) 40px 44px 40px;
    gap: 5px;
    padding: 6px;
  }

  .play-screen.has-answer-focus {
    grid-template-rows: 38px 28px 96px minmax(132px, 1fr) 40px 44px 40px;
  }

  .board {
    gap: 42px;
    padding: 6px;
  }

  .entity-card {
    grid-template-columns: 22px minmax(0, max-content);
    min-height: 36px;
    gap: 5px;
    padding: 4px 7px;
  }

  .entity-visual {
    width: 22px;
    height: 22px;
  }

  .entity-name {
    font-size: 0.72rem;
    max-width: clamp(76px, 27vw, 112px);
  }

  .mechanism-rack {
    padding: 6px;
  }

  .mechanism-grid {
    gap: 4px;
  }

  .mechanism-chip {
    min-height: 30px;
    font-size: 0.6rem;
  }

  .feedback-panel {
    padding: 6px 8px;
  }

  .answer-focus-panel {
    padding: 4px 7px 5px;
  }

  .answer-focus-labels {
    font-size: 0.55rem;
  }

  .mechanism-detail-kicker {
    min-width: 48px;
    min-height: 25px;
    font-size: 0.56rem;
  }

  .mechanism-detail-panel strong {
    font-size: 0.62rem;
  }

  .mechanism-detail-text {
    font-size: 0.58rem;
  }

  .feedback-panel p {
    font-size: 0.68rem;
  }

  .action-button {
    min-height: 36px;
    gap: 4px;
    font-size: 0.7rem;
    padding-inline: 6px;
  }
}

@media (max-width: 340px), (max-height: 570px) {
  .app-shell {
    padding: 2px;
  }

  .game-card {
    height: calc(var(--app-height) - 4px);
    border-width: 1px;
  }

  .topbar {
    min-height: 42px;
    gap: 4px;
    padding: 4px;
  }

  .brand {
    gap: 5px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
  }

  .brand-copy {
    width: 86px;
  }

  .brand-copy strong {
    font-size: 1.15rem;
  }

  .brand-byline {
    font-size: 0.6rem;
  }

  .status-cluster .status-pill:nth-child(2) {
    display: none;
  }

  .play-screen {
    grid-template-rows: 34px 26px 84px minmax(104px, 1fr) 36px 40px 34px;
    gap: 4px;
    padding: 4px;
  }

  .play-screen.has-answer-focus {
    grid-template-rows: 34px 26px 84px minmax(104px, 1fr) 36px 40px 34px;
  }

  .nav-button {
    width: 27px;
    height: 31px;
  }

  .round-meta strong {
    font-size: 0.8rem;
  }

  .board {
    gap: 32px;
    padding: 4px;
  }

  .column {
    gap: 4px;
  }

  .entity-card {
    grid-template-columns: 19px minmax(0, max-content);
    min-height: 32px;
    padding: 3px 6px;
  }

  .entity-visual {
    width: 19px;
    height: 19px;
  }

  .entity-name {
    font-size: 0.63rem;
    max-width: clamp(62px, 25vw, 96px);
  }

  .node {
    width: 10px;
    height: 10px;
  }

  .column-left .node {
    right: -6px;
  }

  .column-right .node {
    left: -6px;
  }

  .mechanism-head {
    display: none;
  }

  .mechanism-grid {
    height: 100%;
  }

  .mechanism-chip {
    min-height: 26px;
    border-radius: 7px;
    font-size: 0.53rem;
  }

  .feedback-panel p {
    font-size: 0.6rem;
  }

  .answer-focus-labels {
    gap: 5px;
    font-size: 0.5rem;
  }

  .answer-focus-labels strong {
    font-size: 0.54rem;
  }

  .answer-focus-slider {
    height: 15px;
  }

  .mechanism-detail-panel {
    gap: 5px;
    padding: 4px 6px;
  }

  .mechanism-detail-kicker {
    min-width: 41px;
    min-height: 22px;
    border-radius: 7px;
    font-size: 0.48rem;
  }

  .mechanism-detail-panel strong {
    font-size: 0.56rem;
  }

  .mechanism-detail-text {
    font-size: 0.52rem;
  }

  .action-button span {
    display: none;
  }
}

@media (max-height: 460px) and (orientation: landscape) {
  .game-card {
    width: min(100%, 760px);
  }

  .play-screen {
    grid-template-rows: 34px 28px minmax(92px, 1fr) 38px 62px 36px;
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 4px;
  }

  .play-screen.has-answer-focus {
    grid-template-rows: 34px 28px minmax(92px, 1fr) 38px 62px 36px;
  }

  .round-strip,
  .elapsed-strip,
  .board,
  .answer-focus-panel,
  .feedback-panel {
    grid-column: 1;
  }

  .mechanism-rack {
    grid-row: 1 / 6;
    grid-column: 2;
  }

  .play-screen.has-answer-focus .mechanism-rack {
    grid-row: 1 / 6;
  }

  .mechanism-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actionbar {
    grid-column: 1 / 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
