:root {
  color-scheme: light;
  --paper: #f6f1e7;
  --ink: #17202a;
  --muted: #60707d;
  --line: #222f3e;
  --surface: #fffaf0;
  --surface-strong: #fff3d0;
  --blue: #1479ff;
  --green: #0f9d78;
  --red: #ef476f;
  --yellow: #ffd166;
  --shadow: 0 18px 40px rgb(23 32 42 / 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 24px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: stretch;
}

.play-surface,
.run-panel {
  border: 2px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.play-surface {
  min-height: calc(100svh - 48px);
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  gap: 14px;
}

.run-panel {
  min-height: calc(100svh - 48px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow,
.prompt-kicker,
.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.25rem;
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.25rem;
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    color 140ms ease;
}

.icon-button,
.primary-button {
  background: var(--yellow);
}

.secondary-button {
  background: #ffffff;
}

.icon-button {
  min-width: 84px;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.scorebar,
.result-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.scorebar > div,
.result-list > div {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.scorebar strong,
.result-list strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
  line-height: 1;
}

.challenge-lane {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
  display: grid;
  gap: 14px;
  align-content: center;
}

.timer-track {
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.timer-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--green);
  transform-origin: left center;
  transform: scaleX(0);
}

.incoming {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.incoming-glyph {
  height: 120px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.prompt {
  margin: 4px 0 0;
  font-size: 1.5rem;
  line-height: 1.15;
  font-weight: 900;
}

.feedback {
  min-height: 28px;
  margin: 0;
  color: #303c47;
  font-weight: 800;
}

.feedback.good {
  color: #06785c;
}

.feedback.bad {
  color: #c42d51;
}

.gate-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 10px;
}

.gate {
  min-height: 112px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 10px 8px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.gate::before {
  content: attr(data-key);
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 900;
  background: var(--paper);
}

.gate:hover,
.gate:focus-visible {
  background: #f3fbff;
  outline: none;
}

.gate.is-correct {
  background: #dcfff1;
}

.gate.is-wrong {
  background: #ffe3ea;
}

.gate-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.shape {
  --shape-size: 46px;
  --shape-color: var(--blue);
  display: block;
  width: var(--shape-size);
  height: var(--shape-size);
  background: var(--shape-color);
  border: 2px solid var(--line);
}

.shape.circle {
  border-radius: 999px;
}

.shape.diamond {
  transform: rotate(45deg);
}

.shape.triangle {
  width: 0;
  height: 0;
  background: transparent;
  border-left: calc(var(--shape-size) * 0.5) solid transparent;
  border-right: calc(var(--shape-size) * 0.5) solid transparent;
  border-bottom: calc(var(--shape-size) * 0.92) solid var(--shape-color);
  border-top: 0;
}

.shape.triangle::after {
  content: "";
}

.run-panel p {
  color: #303c47;
  line-height: 1.45;
}

.result-list {
  grid-template-columns: 1fr;
}

.result-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.result-list span {
  color: var(--muted);
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    min-height: auto;
    padding: 10px 0 18px;
    grid-template-columns: 1fr;
  }

  .play-surface,
  .run-panel {
    min-height: auto;
  }

  .play-surface {
    padding: 12px;
    grid-template-rows: auto auto auto auto;
  }

  .run-panel {
    padding: 12px;
  }

  h1 {
    font-size: 1.75rem;
  }

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

  .incoming {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
  }

  .incoming-glyph {
    height: 86px;
  }

  .prompt {
    font-size: 1.15rem;
  }

  .gate-grid {
    grid-template-columns: repeat(3, minmax(76px, 1fr));
    gap: 8px;
  }

  .gate {
    min-height: 88px;
  }

  .shape {
    --shape-size: 36px;
  }
}

@media (max-width: 420px) {
  .title-row {
    align-items: flex-start;
  }

  .icon-button {
    min-width: 74px;
  }

  .scorebar strong,
  .result-list strong {
    font-size: 1.1rem;
  }

  .gate {
    min-height: 80px;
    padding-top: 24px;
  }

  .gate-label {
    font-size: 0.76rem;
  }
}
