:root {
  color-scheme: light;
  --ink: #18202b;
  --muted: #617084;
  --paper: #f7f8fb;
  --panel: #ffffff;
  --line: #d9e0e8;
  --teal: #0f766e;
  --teal-dark: #0b5652;
  --coral: #e25d4f;
  --amber: #d8941f;
  --blue: #3d6fd6;
  --violet: #6b5bd6;
  --shadow: 0 18px 45px rgba(24, 32, 43, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(226, 93, 79, 0.14), transparent 34%),
    var(--paper);
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow,
.case-meta,
.panel-title,
.scorebox span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 6px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  max-width: 780px;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.15;
}

.scorebox {
  min-width: 118px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.scorebox strong {
  display: block;
  margin-top: 2px;
  font-size: 2rem;
  line-height: 1;
}

.case-panel,
.log-panel,
.trace-panel,
.graph-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.case-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 20px;
  padding: 18px;
  margin-bottom: 18px;
}

.case-copy {
  display: grid;
  gap: 8px;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.case-copy p {
  color: var(--muted);
  line-height: 1.45;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

#progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber), var(--coral));
  transition: width 180ms ease;
}

.play-grid {
  display: grid;
  grid-template-columns: 270px minmax(430px, 1fr) 290px;
  gap: 18px;
  align-items: stretch;
}

.log-panel,
.trace-panel {
  min-height: 520px;
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 12px;
}

.ghost-button,
.controls button,
.primary-button,
.utility-button,
.next-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 7px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.ghost-button,
.controls button {
  border: 1px solid var(--line);
  background: #f3f6f9;
  color: var(--ink);
}

.primary-button,
.utility-button,
.next-button {
  background: var(--teal);
  color: white;
  font-weight: 800;
}

.utility-button {
  width: 100%;
  margin-top: 10px;
  background: var(--blue);
}

.share-button {
  background: var(--violet);
}

.share-output {
  width: 100%;
  min-height: 132px;
  margin-top: 10px;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcff;
  color: var(--ink);
  font: 0.76rem/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.log-list,
.trace-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-list {
  display: grid;
  gap: 10px;
}

.log-list li {
  padding: 10px 11px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f4f7fb;
  color: #2f3c4c;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.4;
}

.hint-box,
.status-line {
  margin-top: 14px;
  padding: 12px;
  border-radius: 7px;
  background: #fff7e7;
  color: #61420c;
  line-height: 1.45;
}

.graph-card {
  min-height: 520px;
  padding: 14px;
}

.graph {
  position: relative;
  width: 100%;
  min-height: 492px;
  height: 100%;
  overflow: hidden;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background:
    linear-gradient(rgba(24, 32, 43, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 32, 43, 0.045) 1px, transparent 1px),
    linear-gradient(140deg, #fbfcfe, #eef5f5);
  background-size: 34px 34px, 34px 34px, auto;
}

#edge-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.edge-line {
  stroke: rgba(97, 112, 132, 0.42);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.graph-node {
  position: absolute;
  z-index: 1;
  display: grid;
  width: min(180px, 30%);
  min-height: 78px;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: white;
  box-shadow: 0 9px 22px rgba(24, 32, 43, 0.16);
  color: var(--ink);
  text-align: left;
  transform: translate(-50%, -50%);
}

.graph-node strong {
  font-size: 0.9rem;
}

.graph-node span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.node-symptom {
  border-color: var(--coral);
}

.node-logic {
  border-color: var(--blue);
}

.node-store {
  border-color: var(--amber);
}

.node-root {
  border-color: var(--teal);
}

.node-decoy {
  border-color: #a4acb8;
}

.graph-node.selected {
  background: #10212b;
  color: white;
}

.graph-node.selected span {
  color: #cad7df;
}

.graph-node.solved {
  box-shadow:
    0 0 0 3px rgba(15, 118, 110, 0.2),
    0 9px 22px rgba(24, 32, 43, 0.16);
}

.trace-list {
  display: grid;
  gap: 8px;
  min-height: 192px;
}

.trace-list li {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9fc;
}

.trace-list li.trace-step-ok {
  border-color: rgba(15, 118, 110, 0.55);
  background: #effaf7;
}

.trace-list li.trace-step-break {
  border-color: rgba(226, 93, 79, 0.65);
  background: #fff1ef;
}

.trace-list li span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--violet);
  color: white;
  font-size: 0.78rem;
  font-weight: 800;
}

.empty-trace {
  grid-template-columns: 1fr !important;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 8px;
  margin-top: 14px;
}

.next-button {
  width: 100%;
  margin-top: 10px;
  background: var(--coral);
}

@media (max-width: 980px) {
  .play-grid {
    grid-template-columns: 1fr;
  }

  .log-panel,
  .trace-panel,
  .graph-card {
    min-height: auto;
  }

  .graph {
    min-height: 480px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar,
  .case-panel {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .topbar {
    display: grid;
  }

  .scorebox {
    width: 100%;
  }

  .case-panel {
    display: grid;
  }

  .graph-card {
    padding: 10px;
  }

  .graph {
    min-height: 620px;
  }

  .graph-node {
    width: 43%;
    min-height: 86px;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 2.15rem;
  }

  .graph {
    min-height: 690px;
  }

  .graph-node {
    width: 44%;
    padding: 9px;
  }

  .graph-node strong {
    font-size: 0.78rem;
  }

  .graph-node span {
    font-size: 0.66rem;
  }
}
