:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #141414;
  --muted: #77736c;
  --soft: #ece8df;
  --line: #ded9cf;
  --accent: #a42424;
  --pale: #f4f1eb;
  --shadow: 0 24px 70px rgba(20, 20, 20, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  text-rendering: geometricPrecision;
}

body.training {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.screen {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 44px);
  min-height: calc(100dvh - 44px);
  animation: settle 360ms ease both;
}

.center {
  width: min(100%, 620px);
  text-align: center;
}

.task-screen {
  align-content: center;
  justify-items: center;
  gap: 22px;
}

.top-count {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  z-index: 5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.title {
  margin: 0;
  font-size: clamp(40px, 8vw, 82px);
  line-height: 0.96;
  font-weight: 720;
  letter-spacing: 0;
}

.intro-title,
.result-value,
.summary-title {
  margin: 0;
  font-size: clamp(42px, 9vw, 86px);
  line-height: 0.96;
  font-weight: 720;
  letter-spacing: 0;
}

.subtitle,
.instruction,
.result-label,
.tiny,
.history-link,
.setting {
  color: var(--muted);
}

.subtitle {
  margin: 22px 0 44px;
  font-size: clamp(18px, 3.6vw, 28px);
  line-height: 1.35;
}

.instruction {
  display: grid;
  gap: 8px;
  margin: 26px auto 42px;
  font-size: clamp(18px, 3.6vw, 28px);
  line-height: 1.28;
}

.primary,
.secondary,
.answer,
.zone {
  min-height: 56px;
  padding: 0 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 680;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.secondary,
.answer,
.zone {
  background: var(--surface);
  color: var(--ink);
}

.primary:active,
.secondary:active,
.answer:active,
.zone:active {
  transform: scale(0.985);
}

.tiny {
  margin-top: 18px;
  font-size: 12px;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 38px;
}

.result-label {
  margin-top: 18px;
  font-size: clamp(18px, 3.3vw, 26px);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 40px 0 36px;
}

.summary-item {
  padding: 22px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-item strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(24px, 5vw, 38px);
  font-weight: 700;
}

.history-link,
.setting {
  display: inline-flex;
  margin-top: 18px;
  padding: 8px 10px;
  font-size: 13px;
  text-decoration: none;
}

.settings {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 8;
  display: flex;
  gap: 8px;
}

.setting {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.skip-exercise {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 9;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.circle {
  width: min(42vw, 210px);
  height: min(42vw, 210px);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: var(--shadow);
  animation: pop 180ms ease both;
  touch-action: none;
}

.circle.pale {
  background: #d9d6ce;
}

.circle.white {
  border: 1px solid var(--line);
  background: #fff;
}

.arrow-symbol {
  display: grid;
  place-items: center;
  width: min(48vw, 240px);
  height: min(48vw, 240px);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: min(24vw, 118px);
  line-height: 1;
}

.fixation {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
}

.peripheral-target {
  position: fixed;
  width: min(14vw, 58px);
  height: min(14vw, 58px);
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: targetFlash var(--target-duration, 520ms) ease both;
}

.peripheral-target.left {
  left: max(18px, env(safe-area-inset-left));
  top: 50%;
}

.peripheral-target.right {
  right: max(18px, env(safe-area-inset-right));
  top: 50%;
}

.peripheral-target.up {
  left: 50%;
  top: max(18px, env(safe-area-inset-top));
}

.peripheral-target.down {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
}

.zones {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
  pointer-events: none;
}

.zone {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  opacity: 0;
  pointer-events: auto;
}

.zone.up {
  grid-column: 2;
}

.zone.left {
  grid-row: 2;
}

.zone.right {
  grid-column: 3;
  grid-row: 2;
}

.zone.down {
  grid-column: 2;
  grid-row: 3;
}

.shape {
  display: grid;
  place-items: center;
  width: min(40vw, 190px);
  height: min(40vw, 190px);
  color: var(--ink);
}

.shape svg {
  width: 100%;
  height: 100%;
}

.answers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: min(100%, 720px);
}

.answer {
  min-width: 112px;
}

.answer.shape-choice {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  padding: 22px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size, 3), minmax(54px, 88px));
  gap: 12px;
  justify-content: center;
}

.cell {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  transition: background 120ms ease, transform 120ms ease;
}

.cell.on,
.cell.selected {
  background: var(--ink);
}

.cell:active {
  transform: scale(0.97);
}

.word {
  font-size: clamp(64px, 18vw, 156px);
  line-height: 0.92;
  font-weight: 730;
}

.rule {
  display: grid;
  gap: 14px;
  font-size: clamp(30px, 8vw, 78px);
  line-height: 1;
  font-weight: 700;
}

.track-area {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.track-dot {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  transform: translate(-50%, -50%);
}

.track-cursor {
  position: absolute;
  width: 74px;
  height: 74px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.signal {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
}

.history {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 38px 0;
}

.history h1 {
  margin: 0 0 22px;
  font-size: clamp(36px, 7vw, 70px);
}

.history-row {
  display: grid;
  grid-template-columns: 1.1fr repeat(5, 1fr);
  gap: 10px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.history-row strong {
  color: var(--ink);
}

.line-chart {
  display: flex;
  align-items: end;
  gap: 6px;
  height: 110px;
  margin: 28px 0;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
}

.line-chart i {
  display: block;
  flex: 1;
  min-width: 8px;
  background: var(--ink);
  border-radius: 999px 999px 0 0;
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes targetFlash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
  12%,
  74% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96);
  }
}

.reduced-motion * {
  animation-duration: 1ms !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}

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

@media (max-width: 720px) {
  .actions {
    display: grid;
  }

  .primary,
  .secondary {
    width: min(100%, 340px);
    margin: 0 auto;
  }

  .summary-grid,
  .history-row {
    grid-template-columns: 1fr;
  }

  .summary-item {
    padding: 18px 14px;
  }
}
