:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #071019;
  --panel: #101c28;
  --panel-strong: #172536;
  --text: #f4f8fb;
  --muted: #91a8b8;
  --line: #284055;
  --accent: #37c4d8;
  --accent-strong: #14a8be;
  --good: #59c783;
  --warn: #f4b95a;
  --danger: #f07167;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(55, 196, 216, 0.12), transparent 34rem),
    linear-gradient(180deg, #06111b 0%, var(--bg) 100%);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 22px) 16px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 5vw, 2.4rem);
  line-height: 1;
}

.counter {
  min-width: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 28, 40, 0.78);
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.progress-wrap {
  padding: 2px 0;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #132333;
}

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

.card {
  width: 100%;
  border: 0;
  padding: 0;
  display: block;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: initial;
  perspective: 1400px;
  cursor: pointer;
  touch-action: manipulation;
}

.card:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}

.card-inner {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 2 / 3;
  margin: 0 auto;
  border-radius: 10px;
  transform-style: preserve-3d;
  transition: transform 260ms ease;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card:not(.is-flipped) .card-back,
.card.is-flipped .card-front {
  visibility: hidden;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: inherit;
  background: #05090d;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card-front {
  align-items: center;
  justify-content: center;
}

#cardImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #05090d;
}

.card.is-day-card .card-front,
.card.is-day-card #cardImage {
  background: #ffffff;
}

#cardImage[hidden],
.instruction-card[hidden],
.sound-card[hidden] {
  display: none;
}

.sound-card {
  width: 100%;
  height: 100%;
  padding: clamp(30px, 7vw, 48px) clamp(12px, 3.2vw, 24px) 84px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(55, 196, 216, 0.12), transparent 44%),
    #071019;
  color: var(--text);
}

.sound-label {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.sound-front-title {
  color: var(--text);
  font-size: clamp(1.65rem, 6.2vw, 2.45rem);
  font-weight: 850;
  line-height: 1.05;
  text-align: center;
}

.sound-stage {
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-symbols {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 3vw, 20px);
}

.sound-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.26);
}

.sound-symbol-svg {
  width: 90%;
  height: 90%;
  overflow: visible;
}

.sound-symbol-box,
.sound-symbol-cone,
.sound-symbol-arc {
  fill: none;
  stroke: #05090d;
  stroke-width: 7;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sound-symbol-box,
.sound-symbol-cone {
  stroke-width: 8;
}

.sound-symbols--one-short .sound-symbol {
  width: clamp(170px, 50vw, 220px);
  height: clamp(116px, 34vw, 148px);
}

.sound-symbols--two-short .sound-symbol {
  width: clamp(126px, 35vw, 168px);
  height: clamp(92px, 25vw, 120px);
}

.sound-symbols--three-short {
  gap: clamp(9px, 2.2vw, 14px);
}

.sound-symbols--three-short .sound-symbol {
  width: clamp(84px, 24vw, 112px);
  height: clamp(72px, 19vw, 92px);
}

.sound-symbols--five-short {
  gap: clamp(5px, 1.4vw, 8px);
}

.sound-symbols--five-short .sound-symbol {
  width: clamp(56px, 15vw, 66px);
  height: clamp(50px, 13vw, 60px);
  border-radius: 10px;
}

.sound-symbols--one-prolonged .sound-symbol {
  width: clamp(250px, 72vw, 340px);
  height: clamp(116px, 34vw, 148px);
}

.sound-symbols--repeated-prolonged {
  gap: clamp(8px, 2vw, 14px);
}

.sound-symbols--repeated-prolonged .sound-symbol {
  width: clamp(142px, 40vw, 174px);
  height: clamp(92px, 25vw, 120px);
}

.instruction-card {
  width: 100%;
  height: 100%;
  padding: clamp(30px, 7vw, 48px) clamp(24px, 6vw, 42px) 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(55, 196, 216, 0.16), transparent 48%),
    var(--panel);
  color: #d7e4ec;
  text-align: left;
}

.instruction-card h2 {
  max-width: 12ch;
  color: var(--text);
  font-size: clamp(1.8rem, 7vw, 2.7rem);
  line-height: 1.02;
}

.card.is-section .instruction-card {
  justify-content: center;
}

.card.is-menu .instruction-card {
  align-items: stretch;
  justify-content: center;
  gap: 26px;
  text-align: center;
}

.menu-title {
  align-self: center;
}

.menu-end-title {
  align-self: center;
  margin-bottom: 16px;
}

.menu-list {
  width: min(100%, 260px);
  display: grid;
  gap: 12px;
  align-self: center;
}

.menu-option {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: clamp(1rem, 3.4vw, 1.18rem);
  font-weight: 850;
  line-height: 1.1;
  cursor: pointer;
}

.menu-option:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.menu-option:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.section-message {
  max-width: 12.5em;
  color: var(--text);
  font-size: clamp(1.45rem, 6vw, 2.25rem);
  line-height: 1.12;
}

.section-message-answer {
  margin-top: 22px;
  color: var(--text);
  font-size: clamp(1.25rem, 4.6vw, 1.8rem);
  font-weight: 850;
  line-height: 1.14;
}

.instruction-card p {
  font-size: clamp(0.98rem, 3.3vw, 1.18rem);
  font-weight: 650;
  line-height: 1.35;
}

.button-sample {
  width: max-content;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: -4px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--accent-strong);
  color: #031014;
  font-size: clamp(0.82rem, 2.8vw, 0.98rem);
  font-weight: 850;
  line-height: 1;
  text-transform: none;
  pointer-events: none;
}

.button-sample--practice {
  border-color: var(--warn);
  background: var(--panel);
  color: var(--warn);
}

.button-sample--pile {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

#answerText .button-sample {
  margin-top: 14px;
  margin-bottom: 18px;
}

.instruction-answer-line {
  margin-top: 18px;
}

.card-logo {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 4;
  width: clamp(66px, 19vw, 96px);
  height: auto;
  border-radius: 0;
  opacity: 0.96;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  pointer-events: none;
}

.card.is-flipped .card-front .card-logo {
  opacity: 0;
}

@keyframes horn-vibrate {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  25% {
    transform: translateX(-1px) rotate(-0.6deg);
  }

  50% {
    transform: translateX(1px) rotate(0.6deg);
  }

  75% {
    transform: translateX(-1px) rotate(0.3deg);
  }
}

@keyframes sound-wave-pulse {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  22% {
    opacity: 1;
  }

  72% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }
}

@keyframes sound-wave-two-short {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  8% {
    opacity: 1;
  }

  24% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }

  36% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  46% {
    opacity: 1;
  }

  62% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }
}

@keyframes sound-wave-three-short {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  7% {
    opacity: 1;
  }

  19% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }

  29% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  37% {
    opacity: 1;
  }

  49% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }

  59% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  67% {
    opacity: 1;
  }

  79% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.12);
  }
}

@keyframes sound-wave-five-short {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  5% {
    opacity: 1;
  }

  13% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.04);
  }

  21% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  26% {
    opacity: 1;
  }

  34% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.04);
  }

  42% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  47% {
    opacity: 1;
  }

  55% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.04);
  }

  63% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  68% {
    opacity: 1;
  }

  76% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.04);
  }

  84% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.35);
  }

  89% {
    opacity: 1;
  }

  97%,
  100% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.04);
  }
}

@keyframes sound-wave-one-prolonged {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.4);
  }

  10%,
  50% {
    opacity: 1;
  }

  62% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.16);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.16);
  }
}

@keyframes sound-wave-repeated-prolonged {
  0% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.4);
  }

  8%,
  30% {
    opacity: 1;
  }

  40% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.16);
  }

  52% {
    opacity: 0;
    transform: translateY(-50%) scaleX(0.4);
  }

  60%,
  82% {
    opacity: 1;
  }

  92%,
  100% {
    opacity: 0;
    transform: translateY(-50%) scaleX(1.16);
  }
}

@keyframes horn-arc-pulse {
  0%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  12%,
  34% {
    opacity: 1;
    transform: translateX(2px);
  }

  52% {
    opacity: 0;
    transform: translateX(0);
  }
}

@keyframes horn-arc-two-short {
  0%,
  28%,
  70%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  9%,
  47% {
    opacity: 1;
    transform: translateX(2px);
  }
}

@keyframes horn-arc-three-short {
  0%,
  22%,
  52%,
  82%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  8%,
  38%,
  68% {
    opacity: 1;
    transform: translateX(2px);
  }
}

@keyframes horn-arc-five-short {
  0%,
  16%,
  37%,
  58%,
  79%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  5%,
  26%,
  47%,
  68%,
  89% {
    opacity: 1;
    transform: translateX(2px);
  }
}

@keyframes horn-arc-one-prolonged {
  0%,
  72%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  12%,
  52% {
    opacity: 1;
    transform: translateX(2px);
  }
}

@keyframes horn-arc-repeated-prolonged {
  0%,
  44%,
  100% {
    opacity: 0;
    transform: translateX(0);
  }

  10%,
  30%,
  62%,
  82% {
    opacity: 1;
    transform: translateX(2px);
  }
}

@keyframes sound-beat-glow {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.92);
  }

  18%,
  44% {
    opacity: 1;
    transform: scale(1.12);
  }

  66% {
    opacity: 0.45;
    transform: scale(0.96);
  }
}

@keyframes sound-beat-one-short {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }

  18%,
  44% {
    opacity: 1;
    transform: scale(1.12);
  }

  66%,
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes sound-beat-two-short {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }

  10%,
  24% {
    opacity: 1;
    transform: scale(1.16);
  }

  42%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }
}

@keyframes sound-beat-three-short {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }

  8%,
  20% {
    opacity: 1;
    transform: scale(1.16);
  }

  36%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }
}

@keyframes sound-beat-five-short {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }

  6%,
  15% {
    opacity: 1;
    transform: scale(1.14);
  }

  30%,
  100% {
    opacity: 0.25;
    transform: scale(0.9);
  }
}

@keyframes sound-beat-one-prolonged {
  0%,
  100% {
    opacity: 0.25;
    transform: scaleX(0.92);
  }

  10%,
  56% {
    opacity: 1;
    transform: scaleX(1.08);
  }

  72% {
    opacity: 0.25;
    transform: scaleX(0.92);
  }
}

@keyframes sound-beat-repeated-prolonged {
  0%,
  100% {
    opacity: 0.25;
    transform: scaleX(0.92);
  }

  8%,
  34% {
    opacity: 1;
    transform: scaleX(1.08);
  }

  48%,
  100% {
    opacity: 0.25;
    transform: scaleX(0.92);
  }
}

.card-back {
  justify-content: flex-start;
  gap: 10px;
  overflow-y: auto;
  padding: clamp(18px, 5vw, 30px);
  background:
    linear-gradient(180deg, rgba(55, 196, 216, 0.14), transparent 46%),
    var(--panel);
  transform: rotateY(180deg);
  text-align: left;
}

.back-label {
  width: max-content;
  padding: 6px 9px;
  border: 1px solid rgba(55, 196, 216, 0.4);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.35rem, 5vw, 2rem);
  line-height: 1.05;
}

#answerText {
  margin-top: 22px;
  color: #d7e4ec;
  font-size: clamp(0.9rem, 3.2vw, 1.08rem);
  line-height: 1.28;
  white-space: pre-wrap;
}

#answerText p,
#answerText h3 {
  margin: 0;
}

.answer-line {
  margin-top: 10px;
}

.answer-or {
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
}

.answer-subtitle {
  margin-top: 14px;
  color: var(--text);
  font-size: clamp(1.25rem, 4.6vw, 1.8rem);
  font-weight: 850;
  line-height: 1.05;
  white-space: normal;
}

#answerText.is-three-option {
  margin-top: 14px;
}

#answerText.is-three-option .answer-line {
  margin-top: 6px;
}

#answerText.is-three-option .answer-or {
  margin-top: 18px;
  margin-bottom: 16px;
}

#answerText.is-three-option .answer-subtitle {
  margin-top: 0;
  margin-bottom: 6px;
}

#answerText.is-three-option .answer-subtitle:first-child {
  margin-top: 12px;
}

#answerText.is-instruction-answer {
  flex: 1;
  display: flex;
  flex-direction: column;
  white-space: normal;
}

#answerText.is-instruction-answer .instruction-answer-line {
  margin-top: 18px;
}

#answerText.is-instruction-answer .instruction-start-line {
  margin-top: auto;
  padding-top: 70px;
  color: var(--text);
  font-size: clamp(1.25rem, 4.6vw, 1.8rem);
  font-weight: 850;
  line-height: 1.12;
  text-align: right;
}

.card.is-instruction .lights-description[hidden] {
  display: none;
}

.lights-description {
  margin-top: auto;
  padding-top: 14px;
  color: #d7e4ec;
  font-size: clamp(0.9rem, 3.2vw, 1.08rem);
  line-height: 1.28;
  white-space: pre-wrap;
}

.lights-description[hidden] {
  display: block;
  visibility: hidden;
}

.filename {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.controls button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 6px;
  background: var(--panel);
  color: var(--text);
  font-size: clamp(0.7rem, 2.5vw, 0.92rem);
  font-weight: 800;
  line-height: 1.1;
  cursor: pointer;
}

.controls button.primary {
  background: var(--accent-strong);
  border-color: var(--accent);
  color: #031014;
}

.controls button.is-known {
  border-color: var(--good);
  color: var(--good);
}

.controls button.is-practice {
  border-color: var(--warn);
  color: var(--warn);
}

.controls button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.session-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.session-controls button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: clamp(0.78rem, 2.7vw, 0.95rem);
  font-weight: 800;
  cursor: pointer;
}

.session-controls button.is-active {
  border-color: var(--warn);
  color: var(--warn);
}

.session-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

@media (max-width: 430px) {
  .app-shell {
    gap: 10px;
    padding-inline: 10px;
  }

  .controls {
    gap: 6px;
  }

  .controls button {
    min-height: 44px;
    padding-inline: 3px;
  }

  .session-controls {
    gap: 6px;
  }
}

@media (max-height: 760px) {
  .card-inner {
    width: min(100%, 340px);
  }

  .app-shell {
    gap: 8px;
  }
}
