:root {
  --ink: #050505;
  --paper: #ffffff;
  --soft: #f4f1e8;
  --muted: #50545d;
  --blue: #0067b1;
  --red: #e30613;
  --yellow: #f7d84a;
  --green: #118c4f;
  --shadow: 6px 6px 0 #050505;
  --radius: 2px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, transparent 0 78%, var(--yellow) 78% 84%, transparent 84%),
    linear-gradient(180deg, transparent 0 18%, var(--blue) 18% 22%, transparent 22%),
    var(--soft);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font-family: inherit;
}

.app {
  width: min(520px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border-left: 3px solid var(--ink);
  border-right: 3px solid var(--ink);
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 16px 16px 28px;
}

.screen.active {
  display: block;
}

.screen::before {
  content: "";
  display: block;
  width: 100%;
  height: 10px;
  margin-bottom: 14px;
  background: linear-gradient(90deg, var(--ink) 0 34%, var(--red) 34% 50%, var(--yellow) 50% 72%, var(--blue) 72% 100%);
}

.brand-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 18px;
  padding: 8px 0;
}

.brand-strip strong,
.brand-strip small {
  display: block;
}

.brand-strip strong {
  font-size: 22px;
  font-weight: 950;
}

.brand-strip small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  border: 3px solid var(--ink);
  background: var(--paper);
}

.brand-mark span:nth-child(1) {
  background: var(--yellow);
}

.brand-mark span:nth-child(2) {
  background: var(--blue);
}

.brand-mark span:nth-child(3) {
  background: var(--red);
}

.brand-mark span:nth-child(4) {
  background: var(--ink);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 7px 11px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--yellow);
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
}

.muted {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  text-align: right;
}

h1,
h2 {
  max-width: 820px;
  margin: 0 0 14px;
  color: var(--ink);
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(36px, 13vw, 58px);
  font-weight: 950;
}

h2 {
  font-size: clamp(32px, 10vw, 46px);
  font-weight: 950;
}

.lead,
.instruction {
  max-width: 800px;
  margin: 0 0 22px;
  color: #222;
  font-size: clamp(18px, 5vw, 22px);
  line-height: 1.55;
}

.task-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(92px, 1fr);
  gap: 8px;
  margin: 18px -16px 24px;
  padding: 0 16px 9px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  border-bottom: 3px solid var(--ink);
}

.task-tabs.compact {
  margin-top: 0;
  margin-bottom: 22px;
}

.task-tab {
  min-width: 92px;
  min-height: 66px;
  padding: 8px 6px;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 16px;
  font-weight: 950;
  line-height: 1.1;
  scroll-snap-align: start;
}

.task-tab span {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.task-tab.active {
  background: var(--blue);
  color: #fff;
}

.task-tab.done {
  background: var(--yellow);
  color: var(--ink);
}

.task-tab:disabled {
  opacity: 1;
  cursor: default;
}

.task-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 20px 0 28px;
}

.task-item {
  min-height: 0;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 6px 12px;
  padding: 14px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--ink);
}

.task-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
}

.task-item:nth-child(2) .task-icon {
  background: var(--blue);
  color: #fff;
}

.task-item:nth-child(3) .task-icon {
  background: var(--red);
  color: #fff;
}

.task-item:nth-child(4) .task-icon {
  background: var(--ink);
  color: #fff;
}

.task-item:nth-child(5) .task-icon {
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.task-item strong {
  font-size: 21px;
  font-weight: 950;
}

.task-item span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.42;
}

button {
  min-height: 60px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px 18px;
  font: inherit;
  font-size: 22px;
  font-weight: 950;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

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

button:active {
  transform: translateY(0);
}

button:focus-visible {
  outline: 4px solid rgba(0, 103, 177, 0.28);
  outline-offset: 2px;
}

button:disabled {
  cursor: default;
  transform: none;
  filter: grayscale(0.35);
}

.primary {
  min-width: 190px;
  color: #fff;
  background: var(--blue);
  box-shadow: var(--shadow);
}

.secondary {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--ink);
}

.hidden {
  display: none !important;
}

.timer {
  display: inline-grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 0 0 20px;
  border: 4px solid var(--ink);
  color: var(--ink);
  background: var(--yellow);
  font-size: 38px;
  font-weight: 950;
  box-shadow: 6px 6px 0 var(--ink);
}

.grid {
  display: grid;
  gap: 14px;
}

.memory-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.tile {
  position: relative;
  min-height: 142px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: 16px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
}

.tile.selectable {
  cursor: pointer;
}

.tile.selectable:hover {
  background: #f7f2d8;
}

.tile.selected {
  background: var(--yellow);
  box-shadow: inset 0 0 0 5px var(--paper);
}

.shape {
  width: 72px;
  height: 72px;
  border: 3px solid rgba(5, 5, 5, 0.84);
  box-shadow: 5px 5px 0 var(--ink);
}

.shape.circle {
  border-radius: 50%;
}

.shape.rounded {
  border-radius: 0;
}

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

.shape.triangle {
  width: 0;
  height: 0;
  border-left: 38px solid transparent;
  border-right: 38px solid transparent;
  border-bottom: 72px solid #111827;
  background: transparent !important;
  box-shadow: none;
}

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

.actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.actions.stacked {
  flex-wrap: wrap;
}

.word-card,
.number-card {
  display: grid;
  place-items: center;
  min-height: 214px;
  margin: 24px 0;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
}

.nback-card {
  min-height: 248px;
  background: var(--yellow);
}

#nback-shape-stage {
  display: grid;
  place-items: center;
}

#nback-shape-stage .tile {
  width: min(250px, 76vw);
  min-height: 184px;
  pointer-events: none;
  background: var(--paper);
}

#nback-shape-stage .shape {
  width: 86px;
  height: 86px;
}

#nback-shape-stage .shape.triangle {
  width: 0;
  height: 0;
  border-left-width: 44px;
  border-right-width: 44px;
  border-bottom-width: 86px;
}

#stroop-word,
#category-word {
  font-size: clamp(52px, 16vw, 78px);
  font-weight: 950;
  line-height: 1.1;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice {
  min-height: 76px;
  color: #fff;
  border-color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
}

.choice.light {
  color: var(--ink);
}

.live-feedback {
  min-height: 58px;
  display: grid;
  align-items: center;
  margin: -8px 0 18px;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  color: var(--ink);
  font-size: 19px;
  font-weight: 950;
  line-height: 1.35;
}

.live-feedback.correct {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.live-feedback.wrong {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

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

.serial7-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.nback-options .choice,
.serial7-options .choice,
.category-options .choice {
  color: var(--ink);
  background: var(--paper);
}

.nback-options .choice:hover,
.serial7-options .choice:hover,
.category-options .choice:hover {
  background: var(--yellow);
}

.serial7-options .choice {
  min-height: 112px;
  font-size: 32px;
}

.number-card {
  gap: 6px;
  background: var(--yellow);
}

.number-card small {
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

#serial7-number {
  color: var(--ink);
  font-size: clamp(64px, 18vw, 96px);
  font-weight: 950;
  line-height: 1;
}

.summary {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.feedback-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 18px;
  margin: 24px 0 28px;
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
}

.feedback-rate {
  min-height: 142px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 3px solid var(--ink);
  background: var(--yellow);
}

.feedback-rate span {
  color: var(--ink);
  font-size: 48px;
  font-weight: 950;
  line-height: 1;
}

.feedback-rate small {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.feedback-panel p {
  margin: 0;
  color: #222;
  font-size: 20px;
  line-height: 1.55;
}

.summary-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 18px;
}

.summary-row strong {
  font-weight: 950;
}

#result-json {
  width: 100%;
  min-height: 132px;
  margin-top: 14px;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.small-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

@media (min-width: 720px) {
  .app {
    margin: 18px auto;
    min-height: calc(100vh - 36px);
    box-shadow: 12px 12px 0 var(--ink);
  }

  .screen {
    min-height: calc(100vh - 36px);
    padding: 26px 28px 36px;
  }

  .task-tabs {
    margin-left: -28px;
    margin-right: -28px;
    padding-left: 28px;
    padding-right: 28px;
  }

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