:root {
  color-scheme: light;
  font-family: "Zen Maru Gothic", "BIZ UDPGothic", "Segoe UI", sans-serif;
  --ink: #273248;
  --muted: #6d7184;
  --cream: #fff8e7;
  --sun: #ffcf56;
  --pink: #ff7aa8;
  --mint: #6de3b3;
  --sky: #72c9ff;
  --line: rgba(39, 50, 72, 0.14);
  --shadow: 0 18px 40px rgba(39, 50, 72, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 122, 168, 0.28), transparent 24rem),
    radial-gradient(circle at 90% 18%, rgba(109, 227, 179, 0.32), transparent 24rem),
    linear-gradient(145deg, #fff8e7 0%, #f0fbff 54%, #fff1f6 100%);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

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

.hero,
.controls,
.stage,
.status-row,
.toolbar,
.advanced {
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 132px;
  padding: 22px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.icon-button {
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), #ff9b63);
  box-shadow: 0 12px 26px rgba(255, 122, 168, 0.36);
  cursor: pointer;
}

.icon-button span {
  display: inline-block;
  margin-left: 5px;
  font-size: 2.2rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
}

.controls label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.controls .check-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-control input {
  width: 24px;
  height: 24px;
  accent-color: var(--pink);
}

.controls span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--pink);
}

#choiceCountLabel {
  justify-self: end;
  min-width: 2.5rem;
  padding: 4px 10px;
  border-radius: 999px;
  text-align: center;
  background: #fff3bd;
}

.stage {
  margin-top: 14px;
  padding: 18px;
  border-radius: 8px;
}

.prompt-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 14px;
  border: 2px dashed rgba(39, 50, 72, 0.2);
  border-radius: 8px;
  background: rgba(255, 248, 231, 0.82);
}

.prompt-icon {
  display: grid;
  place-items: center;
  flex: 0 0 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background: var(--sky);
  font-size: 1.5rem;
  font-weight: 900;
}

#promptLabel {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.choice {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 130px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 10px 22px rgba(39, 50, 72, 0.11);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.choice:hover,
.choice:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 16px 28px rgba(39, 50, 72, 0.16);
  outline: none;
  box-shadow:
    0 16px 28px rgba(39, 50, 72, 0.16),
    0 0 0 4px rgba(114, 201, 255, 0.16);
}

.choice strong {
  font-size: clamp(2.7rem, 11vw, 5rem);
  line-height: 1;
}

.choice.correct {
  background: #dcfff1;
  outline: 4px solid var(--mint);
}

.choice.wrong {
  background: #ffe4ee;
  outline: 4px solid var(--pink);
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
}

.status-row div {
  display: grid;
  place-items: center;
  min-height: 66px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.status-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-row strong {
  font-size: 1.65rem;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
}

.toolbar button {
  flex: 1;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--sun);
  font-weight: 900;
  cursor: pointer;
}

.toolbar button:nth-child(2) {
  background: var(--mint);
}

.toolbar button:nth-child(3) {
  background: #e7e9f4;
}

.advanced {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 16px;
  border-radius: 8px;
}

.advanced p:last-child {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 16px);
  min-width: min(420px, calc(100% - 32px));
  padding: 14px 18px;
  border-radius: 8px;
  color: #fff;
  background: rgba(39, 50, 72, 0.92);
  text-align: center;
  font-size: 1.2rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 760px) {
  .controls,
  .status-row {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 116px;
  }

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

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

  .choice {
    min-height: 104px;
  }

.advanced,
.toolbar {
    flex-direction: column;
  }
}

.setup-screen,
.practice-screen {
  display: none;
}

body.setup-mode .setup-screen,
body.practice-mode .practice-screen {
  display: block;
}

body.practice-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
}

body.practice-mode .app-shell {
  width: 100%;
  height: 100svh;
  padding: 0;
}

body.practice-mode .practice-screen {
  display: flex;
  flex-direction: column;
  height: 100svh;
  overflow: hidden;
}

.setup-actions {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.setup-actions button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--sun);
  font-weight: 900;
  cursor: pointer;
}

.setup-actions button:first-child {
  min-height: 76px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), #ff9b63);
  font-size: 1.35rem;
}

.setup-actions button:nth-child(2) {
  background: var(--mint);
}

.setup-actions button:nth-child(3) {
  background: #e7e9f4;
}

.practice-screen {
  min-height: 0;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  gap: 14px;
}

.practice-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  flex: 0 0 auto;
}

.listen-button {
  justify-self: start;
  width: min(22vw, 88px);
  height: min(22vw, 88px);
  min-width: 64px;
  min-height: 64px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), #ff9b63);
  box-shadow: 0 12px 24px rgba(255, 122, 168, 0.34);
  cursor: pointer;
}

.listen-button span {
  display: inline-block;
  margin-left: 4px;
  font-size: clamp(1.8rem, 8vw, 3rem);
}

.progress-panel {
  display: grid;
  gap: 6px;
  align-content: center;
  min-width: 0;
  pointer-events: none;
}

.mini-stats {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-width: 0;
}

.mini-stats span,
.progress-text {
  color: rgba(39, 50, 72, 0.62);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.mini-stats b,
.progress-text b {
  color: var(--ink);
  font-size: 1.05rem;
}

.progress-track {
  width: min(240px, 100%);
  height: 9px;
  justify-self: center;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--sky));
  transition: width 220ms ease;
}

.hold-button {
  justify-self: end;
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  color: rgba(39, 50, 72, 0.42);
  font-size: 1.85rem;
  font-weight: 900;
  cursor: pointer;
}

.hold-button.holding {
  background: rgba(255, 207, 86, 0.86);
  color: var(--ink);
  transform: scale(0.94);
}

body.practice-mode .choices {
  height: auto;
  min-height: 0;
  margin: 0;
  display: grid;
  gap: 14px;
  flex: 1 1 auto;
}

body.practice-mode.has-target .choices {
  height: auto;
  min-height: 0;
}

.target-card {
  display: grid;
  place-items: center;
  width: min(46vw, 210px);
  height: min(30vw, 150px);
  min-width: 150px;
  min-height: 104px;
  margin: 0 auto 14px;
  border: 5px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffcf56, #ff9b63);
  color: #fff;
  box-shadow: 0 12px 28px rgba(39, 50, 72, 0.16);
  font-size: clamp(5rem, 22vw, 9rem);
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.target-card[hidden] {
  display: none;
}

body.practice-mode .choice {
  min-height: 0;
  border: 5px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.78)),
    var(--sun);
  box-shadow: 0 12px 28px rgba(39, 50, 72, 0.12);
}

body.practice-mode .choice strong {
  font-size: clamp(4.8rem, 24vw, 10rem);
}

body.practice-mode .choice-count-2 {
  grid-template-columns: 1fr;
}

body.practice-mode .choice-count-3,
body.practice-mode .choice-count-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.practice-mode .choice-count-5,
body.practice-mode .choice-count-6,
body.practice-mode .choice-count-7,
body.practice-mode .choice-count-8 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.practice-mode .choice.correct {
  background: #dfffee;
  outline: 6px solid var(--mint);
  transform: scale(0.98);
}

body.practice-mode .choice.soft-wrong {
  background: #fff2f7;
  animation: softShake 280ms ease;
}

.practice-bottom {
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
  padding-top: 10px;
}

.practice-bottom button {
  min-width: 148px;
  min-height: 56px;
  border: 0;
  border-radius: 999px;
  color: rgba(39, 50, 72, 0.76);
  background: rgba(255, 255, 255, 0.64);
  font-weight: 900;
  cursor: pointer;
}

.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;
}

@keyframes softShake {
  0%,
  100% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(-6px);
  }

  70% {
    transform: translateX(6px);
  }
}

@media (max-width: 760px) {
  .setup-actions {
    grid-template-columns: 1fr;
  }

  .practice-screen {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .practice-top {
    min-height: 68px;
    gap: 8px;
  }

  .hold-button {
    width: 56px;
    height: 56px;
  }

  .listen-button {
    width: 64px;
    height: 64px;
    min-width: 60px;
    min-height: 60px;
  }

  .mini-stats {
    gap: 5px;
  }

  .mini-stats span,
  .progress-text {
    font-size: 0.68rem;
  }

  .mini-stats b,
  .progress-text b {
    font-size: 0.95rem;
  }

  body.practice-mode .choices {
    height: auto;
    min-height: 0;
    gap: 10px;
  }

  body.practice-mode.has-target .choices {
    height: auto;
    min-height: 0;
  }

  .target-card {
    width: min(52vw, 190px);
    height: 112px;
    min-height: 98px;
    margin-bottom: 10px;
  }

  body.practice-mode .choice-count-2 {
    grid-template-columns: 1fr;
  }

  body.practice-mode .choice strong {
    font-size: clamp(4.1rem, 26vw, 8rem);
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .practice-top {
    min-height: 68px;
  }

  .listen-button {
    min-width: 62px;
    min-height: 62px;
    width: 62px;
    height: 62px;
  }

  .hold-button {
    width: 48px;
    height: 48px;
  }

  body.practice-mode .choices {
    height: auto;
    min-height: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
