:root {
  --bg-a: #2c1a0a;
  --bg-b: #ffae00;
  --text-a: #ffae00;
  --text-b: #2c1a0a;
  --line: rgba(44, 26, 10, 0.16);
  --panel-stripe: rgba(44, 26, 10, 0.05);
  --result-ok: #2d6a4f;
  --result-ng: #a61e16;
  --result-cream: #f9f2d8;
  --shadow: 0 34px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-family: "Plus Jakarta Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", "Malgun Gothic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(180deg, #050505 0%, #141414 100%);
  color: #fff;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#app {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.boot-card,
.error-card {
  width: min(92vw, 420px);
  border-radius: 28px;
  padding: 28px 24px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.boot-title,
.error-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.boot-subtitle,
.error-copy {
  margin-top: 8px;
  font-size: 14px;
  opacity: 0.72;
}

.gg-content-disclosure {
  width: min(420px, calc(100% - 24px));
  margin: 0 auto 24px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  line-height: 1.55;
  box-shadow: var(--shadow);
}

.gg-content-disclosure summary {
  cursor: pointer;
  padding: 9px 11px;
  color: #fff;
  font-weight: 850;
}

.gg-content-disclosure__body {
  display: grid;
  gap: 7px;
  padding: 0 11px 11px;
}

.gg-content-disclosure__body p {
  margin: 0;
}

.gg-content-disclosure__links a {
  color: var(--bg-b);
  font-weight: 850;
}

.gg-content-disclosure--game {
  width: min(380px, calc(100% - 32px));
  margin: 0 auto 14px;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  font-size: 0.72rem;
  opacity: 0.72;
}

.gg-content-disclosure--game[open] {
  opacity: 0.92;
}

.gg-content-disclosure--game summary {
  padding: 6px 8px;
}

.gg-content-disclosure--game .gg-content-disclosure__body {
  gap: 5px;
  padding: 0 8px 8px;
}

.tones-shell {
  width: 100%;
  display: grid;
  place-items: center;
}

.device {
  width: min(92vw, calc(96dvh * 390 / 844), 420px);
  height: min(96dvh, 860px);
  position: relative;
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 38px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.debug-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  min-width: 44px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.debug-toggle.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.device[data-debug="off"] .debug-only {
  display: none;
}

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition:
    opacity 0.38s ease,
    transform 0.72s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

.scene-menu {
  background: linear-gradient(180deg, var(--bg-b) 0%, var(--bg-b) 50%, var(--bg-a) 50%, var(--bg-a) 100%);
  color: var(--text-b);
  opacity: 1;
  transform: rotateX(0deg) scale(1);
  transform-origin: center center;
  z-index: 2;
}

.scene-game {
  background: var(--bg-a);
  color: var(--text-a);
  pointer-events: none;
  opacity: 0;
  transform: rotateX(88deg) scale(0.96);
  transform-origin: center top;
  z-index: 1;
}

.device[data-scene="game"] .scene-menu {
  pointer-events: none;
  opacity: 0;
  transform: rotateX(-88deg) scale(0.96);
}

.device[data-scene="game"] .scene-game {
  pointer-events: auto;
  opacity: 1;
  transform: rotateX(0deg) scale(1);
  z-index: 3;
}

.menu-top,
.menu-bottom {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
}

.menu-top {
  color: var(--text-b);
  position: relative;
}

.home-link {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: inherit;
  opacity: 0.6;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.home-link:active {
  opacity: 1;
}

.home-link svg {
  width: 24px;
  height: 24px;
}

.menu-bottom {
  color: var(--text-a);
  border-top: 2px solid rgba(255, 255, 255, 0.08);
}

.brand-lockup {
  width: 100%;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.brand-title {
  font-size: clamp(54px, 14vw, 72px);
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  font-size: 13px;
  opacity: 0.62;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.menu-box {
  width: min(100%, 286px);
  display: grid;
  gap: 20px;
  margin-top: 12px;
}

.menu-row {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.row-prefix {
  display: grid;
  place-items: center;
  opacity: 0.6;
}

.row-prefix svg {
  width: 22px;
  height: 22px;
}

.option-group {
  width: 100%;
}

.option-btn,
.lang-btn,
.theme-btn,
.action-btn,
.power-btn {
  background: transparent;
  color: inherit;
}

.lang-btn {
  padding: 6px 0;
  display: grid;
  place-items: center;
  opacity: 0.44;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.lang-btn.is-active {
  opacity: 1;
}

.flag-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  filter: grayscale(1);
  transition: filter 0.2s ease;
}

.lang-btn.is-active .flag-icon {
  filter: grayscale(0);
}

#levelOptions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
}

#languageOptions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
}

/* Time modes share the row rhythm: 5 evenly distributed cells (45/60/120/240/∞). */
#timeOptions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
}
#timeOptions .option-btn { font-size: 14px; padding-left: 0; padding-right: 0; }

/* Consistent vertical rhythm so the rows do not look jagged. */
.menu-row { min-height: 30px; }
.option-btn, .lang-btn { justify-self: stretch; text-align: center; }

.theme-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
}

.theme-btn {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1.4px solid rgba(24, 24, 24, 0.72);
  padding: 0;
  cursor: pointer;
  position: relative;
}


.power-btn {
  width: 148px;
  height: 148px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.power-btn:active {
  transform: scale(0.94);
}

.power-btn svg {
  width: 94px;
  height: 94px;
}

.stage {
  flex: 1;
  position: relative;
  transition: background 0.45s ease, color 0.45s ease;
}

.top-stage,
.bottom-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.top-stage {
  background: var(--state-top-idle-bg, var(--bg-a));
  color: var(--state-top-idle-text, var(--text-a));
  padding: 28px 20px 20px;
}

.top-stage[data-result="resolved"] {
  background: var(--state-top-resolved-bg, var(--result-cream));
  color: var(--state-top-resolved-text, var(--bg-a));
}

.bottom-stage {
  background: var(--state-bottom-idle-bg, var(--bg-b));
  color: var(--state-bottom-idle-text, var(--text-b));
  padding: 18px 18px 28px;
}

.bottom-stage[data-result="ok"] {
  background: var(--state-bottom-ok-bg, var(--result-ok));
  color: var(--state-bottom-ok-text, var(--result-cream));
}

.bottom-stage[data-result="ng"] {
  background: var(--state-bottom-ng-bg, var(--result-ng));
  color: var(--state-bottom-ng-text, var(--result-cream));
}

.bottom-stage[data-result="ng-resolved"] {
  background: var(--state-bottom-ng-resolved-bg, var(--result-ok));
  color: var(--state-bottom-ng-resolved-text, var(--result-cream));
}

.bottom-stage[data-result="ok"] .submit-area,
.bottom-stage[data-result="ng"] .submit-area,
.bottom-stage[data-result="ng-resolved"] .submit-area {
  height: 0;
  margin-top: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.bottom-stage[data-result="ok"] .bottom-word,
.bottom-stage[data-result="ng"] .bottom-word,
.bottom-stage[data-result="ng-resolved"] .bottom-word {
  flex: 0 0 auto;
}

.top-toolbar,
.bottom-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-toolbar {
  position: absolute;
  top: 16px;
  left: 0;
  padding: 0 16px;
}

.bottom-toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  justify-content: flex-end;
  min-height: 0;
  margin-bottom: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100% - 54px);
}

.badge {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.58;
  text-transform: uppercase;
}

.action-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: inherit;
  cursor: pointer;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
}

.action-btn svg {
  width: 24px;
  height: 24px;
}

.silhouette {
  width: 124px;
  height: 124px;
  margin-bottom: 18px;
}

.silhouette svg {
  width: 100%;
  height: 100%;
}



.lemma-box {
  width: 100%;
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.lemma-main {
  font-size: clamp(40px, 9.8vw, 52px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding-left: 0.06em;
}

/* LV + band chip (dual difficulty notation) */
.lemma-meta {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* progressive hint reveal (definition / example as extra surfaces) */
.lemma-hint-btn {
  font-size: 12px;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 12px;
  opacity: 0.75;
  cursor: pointer;
}
.lemma-hint-btn[disabled] { opacity: 0.35; cursor: default; }
.lemma-hint {
  width: min(100%, 292px);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.9;
}
.lemma-hint-line { margin-top: 2px; }

.lemma-kicker,
.lemma-translation {
  width: min(100%, 292px);
  min-height: 0;
}

.lemma-kicker[data-hint-type="base"],
.lemma-translation[data-hint-type="base"] {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2em;
  opacity: 0.66;
}

.lemma-kicker[data-hint-type="translation"],
.lemma-translation[data-hint-type="translation"] {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.74;
}

.lemma-kicker:empty,
.lemma-translation:empty {
  display: none;
}

.word-surface {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0.04em;
}

.word-token {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.01em;
}

.word-gap {
  display: inline-flex;
  width: 0.18em;
  justify-content: center;
}

.word-static,
.word-group {
  font: inherit;
  line-height: inherit;
  color: inherit;
}

.word-group {
  appearance: none;
  padding: 0;
  margin: 0;
  border: 0;
  border-bottom: 0.08em solid transparent;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}

.word-group:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 0.08em;
}

.word-group--pending {
  opacity: 0.48;
  border-bottom-color: currentColor;
}

.word-group--active {
  opacity: 1;
  border-bottom-color: currentColor;
  border-bottom-width: 0.12em;
}

.word-group--confirmed,
.word-group--resolved,
.word-static {
  opacity: 1;
}

.result-mark {
  width: 124px;
  height: 124px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  font-family: "Arial Black", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 108px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.06em;
  text-align: center;
  opacity: 0.98;
  pointer-events: none;
  -webkit-text-stroke: 1.6px currentColor;
}

.result-mark[hidden] {
  display: none;
}

.result-mark[data-result-mark-mode="ok"],
.result-mark[data-result-mark-mode="ng"] {
  color: currentColor;
}

.bottom-word {
  flex: 1;
  display: grid;
  place-items: center;
  width: 100%;
  position: relative;
  font-size: clamp(44px, 12vw, 62px);
  line-height: 1;
  font-weight: 700;
  text-align: center;
  transition: transform 0.32s ease, opacity 0.24s ease;
}

.bottom-word.is-zoomed {
  transform: scale(0.72);
  opacity: 0.08;
}

.result-support {
  width: min(100%, 304px);
  display: grid;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 14px;
  text-align: center;
}

.result-support[hidden] {
  display: none;
}

.result-support-vi {
  font-size: 15px;
  line-height: 1.45;
  font-weight: 650;
  opacity: 0.96;
}

.result-support-gloss {
  font-size: 13px;
  line-height: 1.38;
  font-weight: 600;
  opacity: 0.82;
}

.session-progress {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.54;
}

.submit-area {
  width: 100%;
  margin-top: 20px;
  height: 48px;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.submit-line {
  position: absolute;
  inset: 50% 0 auto;
  height: 2px;
  background: currentColor;
  opacity: 0.28;
  transform: translateY(-50%);
}

.submit-marker {
  position: absolute;
  left: 8px;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-top: -28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: inherit;
  cursor: grab;
}

.submit-marker svg {
  width: 36px;
  height: 36px;
}

.submit-area.is-disabled {
  opacity: 0.36;
  pointer-events: none;
}

.handwriting-pad {
  position: absolute;
  inset: auto 0 0;
  height: 50%;
  background: var(--bg-b);
  color: var(--text-b);
  border-top: 2px solid var(--line);
  box-shadow: none;
  display: none;
  flex-direction: column;
  z-index: 20;
}

.scene-game.is-pad-open .handwriting-pad {
  display: flex;
  animation: slide-up 0.34s cubic-bezier(0.2, 1, 0.3, 1);
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.pad-head {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 10px 0;
}

.pad-body {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.pad-tiers,
.pad-columns,
.guide-layer {
  position: absolute;
  inset: 0;
}

.pad-tiers {
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.pad-tier {
  position: relative;
  border-bottom: 1.5px dashed var(--line);
}

.pad-tier:nth-child(1),
.pad-tier:nth-child(3) {
  flex: 3;
}

.pad-tier:nth-child(2) {
  flex: 4;
}

.pad-tier:nth-child(even) {
  background: var(--panel-stripe);
}

.pad-tier:last-child {
  border-bottom: 0;
}

.pad-columns {
  display: flex;
}

.pad-column {
  flex: 1;
  position: relative;
  border-right: 1px solid var(--line);
}

.pad-column:last-child {
  border-right: 0;
}

.pad-vowel-bg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(72px, 20vw, 140px);
  font-weight: 600;
  pointer-events: none;
}

.tone-choice-panel {
  width: min(92%, 330px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 8px;
}

.tone-choice-panel button {
  min-height: 48px;
  border-radius: 8px;
  border: 2px solid currentColor;
  background: color-mix(in srgb, var(--bg-b) 12%, transparent);
  color: inherit;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.tone-choice-panel button:active {
  transform: translateY(1px);
}

.session-progress {
  min-height: 22px;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.78;
}

.vowel-group {
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.v-base,
.v-mod {
  grid-area: 1 / 1;
}

.v-base {
  opacity: 0.56;
}

.v-mod {
  opacity: 0.18;
}

.vowel-group--consonant .v-base {
  position: relative;
  z-index: 1;
}

.vowel-group--consonant .c-mark {
  grid-area: 1 / 1;
  opacity: 0.22;
}

.guide-layer {
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.guide-sub {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-sub:nth-child(1),
.guide-sub:nth-child(3) {
  flex: 3;
}

.guide-sub:nth-child(2) {
  flex: 4;
}

.g-tone-container {
  position: absolute;
  bottom: 2px;
  left: -2px;
  right: -2px;
  display: flex;
  justify-content: space-between;
  height: 72px;
  overflow: hidden;
  opacity: 0.18;
}

.guide-layer[data-tone-guides="full"] .g-tone-container {
  opacity: 0.26;
}

.native-tone {
  flex: 1;
  font-size: 204px;
  line-height: 0.96;
  text-align: center;
  transform: scaleX(0.64);
  transform-origin: top center;
}

.flip-tone {
  transform: scaleX(-0.64);
}

.g-nang-glyph {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.22;
  margin-top: -36px;
}

.guide-layer[data-tone-guides="light"] .g-nang-glyph {
  opacity: 0.14;
}

.pad-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.handwriting-pad.is-flashing {
  animation: pad-flash 0.28s ease-out;
}

@keyframes pad-flash {
  0% {
    background: var(--bg-b);
  }

  35% {
    background: rgba(255, 255, 255, 0.42);
  }

  100% {
    background: var(--bg-b);
  }
}

@media (max-width: 420px) {
  .badge {
    font-size: 10px;
  }

  .menu-box {
    width: 100%;
  }

  .menu-top {
    align-items: flex-end;
    padding: 20px 14px 10px;
  }

  .home-link {
    top: 10px;
    left: 10px;
    width: 36px;
    height: 36px;
  }

  .home-link svg {
    width: 20px;
    height: 20px;
  }

  .brand-title {
    font-size: 42px;
    line-height: 1;
  }

}

@media (max-height: 720px) {
  .menu-top,
  .menu-bottom {
    flex: 0 0 auto;
    min-height: 112px;
  }

  .brand-title {
    font-size: 42px;
    line-height: 1;
  }
}










/* ============================================================
   V4 - non-verbal progress dots + quiet run summary
   ============================================================ */

.session-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 14px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.18;
}

.progress-dot--ok {
  opacity: 0.9;
}

.progress-dot--ng {
  opacity: 0.9;
  border-radius: 2px;
  transform: rotate(45deg);
}

.progress-dot--current {
  opacity: 0.7;
  background: transparent;
  border: 1.5px solid currentColor;
}

.run-summary {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-a, rgba(0, 0, 0, 0.65));
  opacity: 1;
  transition: opacity 0.6s ease;
}

.run-summary.is-leaving {
  opacity: 0;
}

.run-summary-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  max-width: 70%;
}

.run-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.run-dot--ok {
  border: 3px solid var(--text-a, #fff);
  background: transparent;
}

.run-dot--ng {
  background: var(--text-a, #fff);
  border-radius: 3px;
  transform: rotate(45deg);
  opacity: 0.75;
}

.run-summary[hidden] { display: none; }

/* ============================================================
   V5 - STAGE + time-attack: tone preview/send, timer HUD,
   stage dropdown, score summary
   ============================================================ */

/* Tone choice active (preview selected, before send) */
.tone-choice-panel .tone-choice.is-active {
  background: var(--text-b, currentColor);
  color: var(--bg-b, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 35%, transparent);
}
.tone-choice-panel .tone-choice:disabled { opacity: 0.5; cursor: default; }

/* Send button */
.send-btn {
  margin-top: 14px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid currentColor;
  background: var(--bg-b, transparent);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.send-btn svg { width: 30px; height: 30px; }
.send-btn:not(:disabled) {
  background: var(--text-b, currentColor);
  color: var(--bg-b, #fff);
}
.send-btn:disabled { opacity: 0.35; cursor: default; }
.send-btn:not(:disabled):active { transform: scale(0.94); }

/* Time HUD (remaining + score) */
.time-hud {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 18px;
  margin: 2px 0 6px;
  font-variant-numeric: tabular-nums;
}
.time-remaining { font-size: 30px; font-weight: 800; line-height: 1; }
.time-score { font-size: 18px; font-weight: 700; opacity: 0.75; }
.time-score::before { content: "○ "; opacity: 0.7; }

/* Stage = cumulative segmented bar (one segment per pack in the LV) */
.stage-bar {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  align-items: center;
}
.stage-seg {
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background: transparent;
  opacity: 0.4;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.stage-seg.is-filled {
  opacity: 1;
  background: currentColor;
}

/* Run summary: correct count + best + dots */
.run-summary { flex-direction: column; gap: 20px; cursor: pointer; }

/* Simple tally: ○ N  × N */
.run-summary-counts {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 32px;
}
.rs-count { display: inline-flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.rs-sym { font-size: 34px; font-weight: 700; opacity: 0.8; }
.rs-num { font-size: 54px; font-weight: 900; line-height: 1; }
.rs-ng { opacity: 0.7; }

.run-summary-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
}
.run-summary-best .hud-icon { width: 22px; height: 22px; }
.run-summary-best .hud-val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
#runSummaryBestRow.is-new { opacity: 1; color: var(--accent, #ffcf33); animation: toneBestPulse 0.8s ease-in-out infinite; }
@keyframes toneBestPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

.run-summary-hint { opacity: 0.5; animation: toneHintPulse 1.4s ease-in-out infinite; }
.run-summary-hint .hud-icon { width: 24px; height: 24px; }
@keyframes toneHintPulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.7; } }

/* ============================================================
   V5 fix - visible active state for LV / time option buttons
   (previously LV1-5 and time modes were indistinguishable)
   ============================================================ */
.option-btn {
  cursor: pointer;
  opacity: 0.4;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 4px;
  border: none;
  border-bottom: 3px solid transparent;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.option-btn.is-active {
  opacity: 1;
  border-bottom-color: currentColor;
}
.option-btn:active {
  transform: translateY(1px);
}

/* ============================================================
   V5.1 - game top bar (TIME + correct count), tone button
   redesign (underline default / inverted active), send spacing,
   narrower stage bar, larger setting labels with thin underline
   ============================================================ */

/* --- Game top bar: exit + hourglass/time + check/count --- */
.game-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 14px 4px;
  box-sizing: border-box;
}
.game-topbar .action-btn { margin-right: auto; }
.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hud-icon { width: 20px; height: 20px; opacity: 0.7; }
.hud-val {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* --- Tone choices: plain straight underline by default, inverted when active.
   No border-radius — a radius + border-bottom renders curled 【】-like ends. --- */
.tone-choice-panel { width: min(94%, 320px); gap: 10px 12px; margin: 14px 0 4px; }
.tone-choice-panel .tone-choice {
  min-height: 50px;
  border: none;
  border-bottom: 2px solid color-mix(in srgb, currentColor 32%, transparent);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.tone-choice-panel .tone-choice.is-active {
  background: var(--text-b, currentColor);
  color: var(--bg-b, #fff);
  border-bottom-color: transparent;
}
.tone-choice-panel .tone-choice:disabled { opacity: 0.5; cursor: default; }

/* --- Send button: lower, with breathing room --- */
.send-btn { margin-top: 26px; }

/* --- Stage bar: full-width even row (matches LV/time rows) --- */
.stage-bar { width: 100%; gap: 5px; }
.stage-seg { height: 10px; }

/* --- Setting labels: harmonized size with the time numbers, thin underline --- */
.option-btn {
  font-size: 15px;
  padding: 5px 2px;
  border-bottom-width: 2px;
  line-height: 1.1;
}

/* ============================================================
   V5.2 - judge jitter fix, menu vertical rhythm, balanced LV/time
   labels, tone selector pill redesign
   ============================================================ */

/* Result mark: overlay (no layout shift) instead of a 124px in-flow block.
   The bottom-stage already flashes ok/ng background, so this is just a small
   centered confirm glyph. */
.bottom-stage { position: relative; }
.result-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  margin: 0;
  font-size: 84px;
  -webkit-text-stroke: 0;
  opacity: 0.92;
  z-index: 5;
}

/* Menu: uniform row height so the left icons and right controls line up. */
.menu-row { min-height: 34px; }
.lang-btn { padding: 2px 0; }
.flag-icon { width: 26px; height: 26px; }

/* LV + time labels: same size; underline only as wide as the text (centered),
   thinner so it isn't overbearing. */
.option-btn {
  font-size: 14px;
  justify-self: center;
  padding: 4px 6px 5px;
  border-bottom-width: 1.5px;
}
#timeOptions .option-btn { font-size: 14px; }
.time-inf { font-size: 20px; line-height: 0.7; display: inline-block; vertical-align: middle; }

/* Tone selector: consistent shape in both states — a plain dimmed glyph that
   becomes a filled rounded pill when selected (no underline, no bracket ends). */
.tone-choice-panel { width: min(92%, 300px); gap: 12px 14px; margin: 18px 0 6px; }
.tone-choice-panel .tone-choice {
  min-height: 54px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  opacity: 0.5;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.tone-choice-panel .tone-choice.is-active {
  opacity: 1;
  background: var(--text-b, currentColor);
  color: var(--bg-b, #fff);
}
.tone-choice-panel .tone-choice:disabled { opacity: 0.35; cursor: default; }

/* Hide the send button once a result is showing (was lingering in the green/red
   flash as a stray icon). */
.bottom-stage[data-result="ok"] .send-btn,
.bottom-stage[data-result="ng"] .send-btn,
.bottom-stage[data-result="ng-resolved"] .send-btn {
  opacity: 0;
  pointer-events: none;
}
