:root {
  --cream: #f7f3e8;
  --navy: #10243f;
  --gold: #e0a106;
  --red: #c62828;
  --white: #fff;
  --radius: 1.25rem;
  --shadow: 0 4px 14px rgba(16, 36, 63, 0.12);
  font-size: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--navy);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  max-width: 430px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--navy);
  color: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.main {
  padding: 1rem;
  padding-bottom: 2.5rem;
}

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

.sub {
  margin: 0 0 1rem;
  opacity: 0.85;
  font-size: 0.95rem;
}

.ko-gloss {
  display: block;
  font-size: 0.85rem;
  opacity: 0.75;
  margin-top: 0.15rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid rgba(16, 36, 63, 0.15);
  border-radius: var(--radius);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--gold);
  color: var(--navy);
  width: 100%;
  margin-top: 0.5rem;
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--navy);
  color: var(--cream);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--gold);
  font-weight: 600;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  width: auto;
  min-height: auto;
  margin: 0;
}

.btn:disabled,
.station-locked {
  opacity: 0.45;
  pointer-events: none;
}

.unit-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.unit-btn {
  text-align: left;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  border: 2px solid rgba(16, 36, 63, 0.12);
  background: var(--white);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.unit-btn strong {
  display: block;
  font-size: 1.1rem;
}

.path-list,
.path-wind {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.path-wind {
  counter-reset: pathstep;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.path-wind .path-node {
  counter-increment: pathstep;
  position: relative;
  border-left: 4px solid var(--gold);
}

.path-wind .path-node:nth-child(odd) {
  margin-right: 1.75rem;
}

.path-wind .path-node:nth-child(even) {
  margin-left: 1.75rem;
}

.path-wind .path-node.later-door {
  border-left-color: rgba(16, 36, 63, 0.25);
}

.path-chevron {
  font-size: 1.35rem;
  opacity: 0.45;
  font-weight: 700;
}

.link-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.later-card {
  text-align: center;
}

.later-big {
  font-size: 2rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0.5rem 0;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.pass-hint {
  font-size: 0.85rem;
}

.btn-back {
  margin-bottom: 0.75rem;
}

.path-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  cursor: pointer;
}

.path-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.path-meta {
  font-size: 0.8rem;
  opacity: 0.8;
}

.game-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.progress-dots {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(16, 36, 63, 0.2);
}

.dot.done {
  background: var(--gold);
}

.dot.now {
  background: var(--navy);
}

.audio-fallback {
  text-align: center;
  padding: 1rem;
}

.audio-fallback .big-word {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0.5rem 0;
}

.scene-wrap {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #dff3e8;
  margin-bottom: 0.75rem;
}

.scene-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.hotspot {
  cursor: pointer;
  transition: fill 0.2s;
}

.hotspot:hover {
  opacity: 0.9;
}

.pulse-gold {
  animation: pulseGold 0.6s ease;
}

@keyframes pulseGold {
  0% {
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    filter: drop-shadow(0 0 12px var(--gold));
  }
  100% {
    filter: drop-shadow(0 0 0 transparent);
  }
}

.shake-red {
  animation: shakeRed 0.45s ease;
}

@keyframes shakeRed {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.highlight-correct {
  stroke: var(--gold) !important;
  stroke-width: 4 !important;
}

.skin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin: 1rem 0;
}

.skin-card {
  padding: 1rem;
  border-radius: var(--radius);
  border: 2px solid rgba(16, 36, 63, 0.15);
  background: var(--white);
  cursor: pointer;
  text-align: center;
  font-weight: 700;
}

.skin-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224, 161, 6, 0.35);
}

.choice-stage {
  min-height: 12rem;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.choice-option {
  position: absolute;
  min-width: 5.5rem;
  min-height: 3.5rem;
  border-radius: 999px;
  border: 2px solid var(--navy);
  background: var(--white);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.choice-option .ko-gloss {
  font-size: 0.7rem;
}

.frog-scene {
  background: linear-gradient(#87ceeb 55%, #3d8b40 55%);
}

.snow-scene {
  background: linear-gradient(#b8d4f0 40%, #eef5ff 40%);
}

.space-scene {
  background: radial-gradient(circle at 30% 20%, #2a2a5a, #0a0a18);
  color: var(--cream);
}

.space-scene .choice-option {
  background: rgba(255, 255, 255, 0.12);
  color: var(--cream);
  border-color: var(--gold);
}

.spell-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 1rem 0;
}

.tile {
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 0.5rem;
  border: 2px solid var(--navy);
  background: var(--white);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
}

.tile.used {
  opacity: 0.3;
  pointer-events: none;
}

.spell-answer {
  min-height: 2.5rem;
  letter-spacing: 0.2em;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  margin: 0.5rem 0;
}

.timer-bar {
  height: 0.5rem;
  background: rgba(16, 36, 63, 0.15);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.timer-fill {
  height: 100%;
  background: var(--gold);
  width: 100%;
  transition: width 0.1s linear;
}

.hangman-drawing {
  text-align: center;
  font-family: monospace;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: pre;
  margin: 0.5rem 0;
}

.keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.key {
  min-width: 2rem;
  min-height: 2.2rem;
  border-radius: 0.35rem;
  border: 1px solid var(--navy);
  background: var(--white);
  font-weight: 700;
  cursor: pointer;
}

.key.guessed {
  opacity: 0.35;
}

.wordsearch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-width: 100%;
  margin: 0 auto 0.75rem;
}

.ws-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--white);
  border: 1px solid rgba(16, 36, 63, 0.12);
  user-select: none;
}

.ws-cell.sel {
  background: rgba(224, 161, 6, 0.45);
}

.ws-cell.found {
  background: rgba(224, 161, 6, 0.75);
}

.crossword-list {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0 0 0.75rem;
}

.crossword-list li {
  margin-bottom: 0.5rem;
}

.crossword-list input {
  width: 100%;
  margin-top: 0.25rem;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}

.mem-card {
  aspect-ratio: 3/4;
  border-radius: 0.65rem;
  border: 2px solid var(--navy);
  background: var(--navy);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem;
  cursor: pointer;
}

.mem-card.flipped,
.mem-card.matched {
  background: var(--white);
  color: var(--navy);
}

.mem-card.matched {
  border-color: var(--gold);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.chip {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 2px solid var(--navy);
  background: var(--white);
  font-weight: 700;
  cursor: pointer;
}

.chip.used {
  opacity: 0.35;
  pointer-events: none;
}

.answer-line {
  min-height: 3rem;
  padding: 0.65rem;
  border: 2px dashed rgba(16, 36, 63, 0.25);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.order-actions {
  display: flex;
  gap: 0.5rem;
}

.order-actions .btn {
  flex: 1;
}

.bell-stage {
  background: linear-gradient(#1a1030, #0d0818);
  color: var(--cream);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  min-height: 14rem;
}

.bell-icon {
  font-size: 4rem;
  display: block;
  margin: 0.5rem auto;
  transition: transform 0.2s;
}

.bell-ring {
  animation: bellRing 0.8s ease;
}

@keyframes bellRing {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(-18deg);
  }
  40% {
    transform: rotate(18deg);
  }
  60% {
    transform: rotate(-12deg);
  }
  80% {
    transform: rotate(12deg);
  }
}

.bell-pad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.bell-pad button {
  min-height: 2.2rem;
  border-radius: 0.35rem;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: var(--cream);
  font-weight: 700;
  cursor: pointer;
}

.result-banner {
  text-align: center;
  padding: 1.5rem;
}

.result-banner .score-big {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--gold);
}

.pass-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.pass-tag.pass {
  background: rgba(224, 161, 6, 0.25);
}

.pass-tag.fail {
  background: rgba(198, 40, 40, 0.15);
  color: var(--red);
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.records-table th,
.records-table td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid rgba(16, 36, 63, 0.1);
}

.err-msg {
  color: var(--red);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
