:root {
  --bg: #edf7ff;
  --bg-deep: #d8eeff;
  --surface: #ffffff;
  --surface-soft: #f7fbff;
  --line: #d5e9fb;
  --line-strong: #b9dbf6;
  --text: #13324f;
  --muted: #6b7f95;
  --primary: #1cb0f6;
  --primary-dark: #1593cf;
  --primary-deep: #0f7bb2;
  --primary-soft: #e7f7ff;
  --success: #58cc02;
  --success-dark: #469e02;
  --success-soft: #f2ffe8;
  --warn: #fff1e4;
  --warn-line: #ffd5b2;
  --danger: #d74d4d;
  --shadow: 0 24px 48px rgba(20, 78, 126, 0.14);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  color-scheme: light;
  font-family: "Bahnschrift", "Aptos", "Trebuchet MS", "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(28, 176, 246, 0.25), transparent 34%),
    radial-gradient(circle at top right, rgba(88, 204, 2, 0.08), transparent 26%),
    linear-gradient(180deg, #f7fbff 0%, #eaf6ff 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: none;
  border-color: rgba(28, 176, 246, 0.4);
  box-shadow: 0 0 0 4px rgba(28, 176, 246, 0.12);
}

#app {
  min-height: 100vh;
}

.auth-shell,
.app-shell {
  width: min(100%, 540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px calc(110px + env(safe-area-inset-bottom));
}

.screen,
.stack-sm,
.stack-md,
.stack-lg,
.challenge-stack,
.detail-list,
.history-list,
.voice-pills,
.term-grid,
.overview-grid,
.game-grid,
.course-grid {
  display: grid;
  gap: 12px;
}

.stack-lg,
.screen {
  gap: 18px;
}

.panel,
.hero-card,
.challenge-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.auth-hero {
  overflow: hidden;
  padding: 28px 20px 24px;
  text-align: center;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.9), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #eef8ff 100%);
}

.auth-hero h1,
.hero-card h2,
.challenge-head h2,
.section-head h3 {
  margin: 0;
  line-height: 1.15;
}

.auth-hero p,
.hero-card p,
.section-head p,
.quick-card p,
.game-card p,
.lesson-copy p,
.course-card p,
.phone-access-card p,
.phrase-card p,
.empty-card p {
  margin: 0;
  color: var(--muted);
}

.brand-image {
  width: min(220px, 70%);
  display: block;
  margin: 0 auto 10px;
  object-fit: contain;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  margin-bottom: 18px;
}

.topbar-panel {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.92);
}

.brand-row,
.brand-lockup,
.pill-row,
.hero-inline,
.hero-actions,
.lesson-top,
.inline-actions,
.footer-actions,
.tab-row,
.section-head,
.course-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-row,
.section-head {
  justify-content: space-between;
}

.brand-lockup p {
  margin: 0;
  color: var(--muted);
}

.pill-row,
.hero-inline,
.hero-actions,
.inline-actions,
.tab-row,
.voice-pills {
  flex-wrap: wrap;
}

.brand-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  border: 2px solid #d4eafb;
  background: #fff;
  padding: 5px;
  object-fit: cover;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 24px 20px;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.38), transparent 30%),
    radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.18), transparent 26%),
    linear-gradient(180deg, #1cb0f6 0%, #1599d8 100%);
  color: #fff;
}

.hero-card.compact {
  padding: 22px 20px;
}

.hero-card p,
.hero-card .hero-chip {
  color: rgba(255, 255, 255, 0.95);
}

.hero-topline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.hero-mark,
.course-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.hero-mark {
  width: 52px;
  height: 52px;
  font-size: 1.2rem;
}

.hero-tag,
.hero-chip,
.stat-pill,
.tiny-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 800;
}

.hero-tag,
.hero-chip {
  background: rgba(255, 255, 255, 0.16);
}

.stat-pill,
.tiny-badge {
  border: 2px solid var(--line);
  background: #f7fbff;
}

.stat-pill.active {
  border-color: rgba(28, 176, 246, 0.35);
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.quick-card,
.game-card,
.empty-card,
.phrase-card,
.review-card,
.phone-access-card,
.server-banner,
.result-banner {
  padding: 16px;
  border-radius: 20px;
}

.quick-card,
.game-card,
.empty-card,
.phrase-card,
.review-card,
.phone-access-card,
.server-banner {
  border: 2px solid var(--line);
  background: #fbfeff;
}

.quick-card strong,
.game-card strong,
.phrase-card strong,
.review-face strong,
.empty-card strong {
  font-size: 1.06rem;
}

.quick-card small,
.phrase-card small,
.tiny-text {
  color: var(--muted);
}

.quick-card {
  min-height: 112px;
}

.game-card.accent {
  background: linear-gradient(180deg, #f4fbff 0%, #edf8ff 100%);
}

.course-card,
.choice-btn,
.primary-btn,
.ghost-btn,
.install-chip,
.tab-btn,
.lesson-node,
.memory-card,
.chess-square {
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.primary-btn,
.ghost-btn,
.install-chip {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 900;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 5px 0 var(--primary-dark);
}

.primary-btn.secondary {
  background: var(--success);
  box-shadow: 0 5px 0 var(--success-dark);
}

.ghost-btn,
.install-chip,
.tab-btn,
.choice-btn,
.course-card,
.memory-card {
  border: 2px solid var(--line);
  background: #fff;
}

.ghost-btn.danger {
  color: var(--danger);
}

.ghost-btn.small {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.ghost-btn.selected {
  border-color: rgba(28, 176, 246, 0.36);
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.install-chip {
  border-color: rgba(28, 176, 246, 0.2);
  background: linear-gradient(180deg, #ffffff 0%, #f1fbff 100%);
  color: var(--primary-deep);
}

.tab-row {
  justify-content: center;
}

.tab-btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 900;
}

.tab-btn.is-active {
  border-color: rgba(28, 176, 246, 0.32);
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.server-banner.ok,
.result-banner.ok {
  border-color: #d3f0ba;
  background: var(--success-soft);
  color: #2f8500;
}

.server-banner.warn,
.result-banner,
.result-banner.warn {
  border-color: var(--warn-line);
  background: var(--warn);
  color: #9a5720;
}

.phone-access-card {
  display: grid;
  gap: 10px;
}

.phone-access-card small {
  color: var(--muted);
}

.phone-url-list {
  display: grid;
  gap: 10px;
}

.phone-url-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
}

.lesson-top {
  gap: 12px;
}

.lesson-progress {
  flex: 1;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #e8f4fd;
}

.lesson-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1cb0f6 0%, #58ccff 100%);
}

.challenge-card {
  padding: 20px;
}

.challenge-head {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.choice-grid,
.memory-grid {
  display: grid;
  gap: 12px;
}

.choice-btn {
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border-radius: 18px;
  text-align: left;
  font-weight: 800;
  color: var(--text);
}

.choice-btn.correct {
  border-color: rgba(28, 176, 246, 0.35);
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.choice-btn.wrong {
  border-color: #ffb6b6;
  background: #fff0f0;
  color: #b03d3d;
}

.reading-billboard {
  padding: 18px;
  border-radius: 20px;
  border: 2px dashed var(--line-strong);
  background: #f4fbff;
  font-size: 1.32rem;
  font-weight: 900;
  text-align: center;
}

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

.phrase-card {
  display: grid;
  gap: 6px;
}

.phrase-card span {
  color: var(--muted);
  font-size: 0.93rem;
}

.path-panel {
  overflow: hidden;
}

.path-list {
  display: grid;
  gap: 18px;
}

.path-item {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
}

.path-item.right {
  grid-template-columns: 1fr 88px;
}

.path-item.right .lesson-node {
  order: 2;
}

.path-item.right .lesson-copy {
  order: 1;
}

.lesson-node {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 900;
}

.lesson-node.current {
  background: linear-gradient(180deg, #1cb0f6 0%, #169ad9 100%);
  color: #fff;
  box-shadow: 0 6px 0 var(--primary-dark);
}

.lesson-node.done {
  background: linear-gradient(180deg, #58cc02 0%, #49b302 100%);
  color: #fff;
  box-shadow: 0 6px 0 #429a02;
}

.lesson-node.locked {
  background: #ecf3f9;
  color: #a0b1c0;
  box-shadow: 0 6px 0 #d8e3ed;
}

.lesson-copy {
  position: relative;
  min-height: 104px;
  padding: 14px 14px 14px 104px;
  border-radius: 22px;
  border: 2px solid var(--line);
  background: #fbfeff;
  display: grid;
  gap: 6px;
}

.lesson-copy.done {
  border-color: #d8efc4;
  background: #fbfff7;
}

.lesson-copy.current {
  border-color: rgba(28, 176, 246, 0.24);
}

.lesson-thumb {
  position: absolute;
  inset: 10px auto 10px 10px;
  width: 82px;
  height: 82px;
  object-fit: contain;
  border-radius: 18px;
  border: 2px solid #d7ebfa;
  background: #eef8ff;
  padding: 6px;
}

.lesson-copy small {
  color: var(--muted);
}

.course-grid,
.overview-grid,
.game-grid {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.course-card {
  width: 100%;
  padding: 16px;
  border-radius: 22px;
  text-align: left;
  display: grid;
  gap: 10px;
}

.course-card.active {
  border-color: rgba(28, 176, 246, 0.34);
  background: linear-gradient(180deg, #f1fbff 0%, #e6f7ff 100%);
  box-shadow: 0 14px 26px rgba(28, 176, 246, 0.12);
}

.course-card small {
  color: var(--muted);
}

.course-icon,
.course-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  border: 2px solid #d9ebf9;
  background: #f8fcff;
}

.course-icon {
  padding: 8px;
  object-fit: contain;
}

.course-mark {
  background: linear-gradient(180deg, #1cb0f6 0%, #1599d8 100%);
}

.course-icon.small,
.course-mark.small {
  width: 46px;
  height: 46px;
  border-radius: 15px;
}

.review-card {
  display: grid;
  gap: 12px;
}

.review-face {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: #fff;
  border: 2px solid var(--line);
}

.review-face.back {
  background: var(--primary-soft);
}

.review-actions {
  margin-top: 2px;
}

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

.memory-card {
  min-height: 90px;
  padding: 10px;
  border-radius: 18px;
  font-weight: 900;
}

.memory-card.open {
  background: #fbfeff;
}

.memory-card.matched {
  background: var(--primary-soft);
  border-color: rgba(28, 176, 246, 0.3);
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.chess-wrap {
  display: grid;
  gap: 10px;
}

.board-label {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  padding: 0 4px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  padding: 6px;
  border-radius: 24px;
  background: #dff1ff;
  border: 2px solid var(--line);
}

.chess-square {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
}

.chess-square.light {
  background: #f5fbff;
}

.chess-square.dark {
  background: #b4def5;
}

.chess-square.selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 3px rgba(28, 176, 246, 0.18);
}

.chess-square.legal {
  border-color: rgba(88, 204, 2, 0.55);
}

.chess-square.last-move {
  background: #fff6d9;
}

.chess-piece {
  font-size: clamp(1.35rem, 4.8vw, 2rem);
  line-height: 1;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fbfeff;
}

.history-row span {
  color: var(--muted);
  text-align: right;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 540px);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 18px 34px rgba(20, 78, 126, 0.12);
}

.nav-btn {
  min-height: 50px;
  border-radius: 15px;
  font-weight: 900;
  color: var(--muted);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary-deep);
}

.flash {
  position: fixed;
  left: 50%;
  bottom: 94px;
  transform: translateX(-50%);
  width: min(88vw, 440px);
  padding: 14px 16px;
  border-radius: 18px;
  color: #fff;
  box-shadow: 0 18px 28px rgba(17, 55, 89, 0.22);
  animation: riseIn 0.18s ease;
}

.flash.is-default {
  background: #173557;
}

.flash.is-success {
  background: #2d8b02;
}

.flash.is-warn {
  background: #b36d16;
}

.flash.is-error {
  background: #b34040;
}

.mono {
  font-family: "Consolas", "Courier New", monospace;
}

.primary-btn:hover,
.ghost-btn:hover,
.install-chip:hover,
.choice-btn:hover,
.course-card:hover,
.lesson-node:hover,
.memory-card:hover,
.chess-square:hover,
.nav-btn:hover,
.tab-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.ghost-btn:disabled,
.install-chip:disabled,
.choice-btn:disabled,
.lesson-node:disabled {
  opacity: 0.52;
  transform: none;
  cursor: not-allowed;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.chess-wrap {
  display: grid;
  gap: 14px;
}

.chess-frame {
  position: relative;
  --coord-size: 30px;
  --square-size: calc((100% - (var(--coord-size) * 2)) / 8);
  width: min(100%, 560px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--coord-size) repeat(8, minmax(0, 1fr)) var(--coord-size);
  grid-template-rows: var(--coord-size) repeat(8, minmax(0, 1fr)) var(--coord-size);
  aspect-ratio: 1 / 1;
  padding: 10px;
  border: 4px solid #24170a;
  border-radius: 24px;
  background: linear-gradient(180deg, #ecd36c 0%, #d0ac45 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.26),
    0 20px 30px rgba(39, 23, 6, 0.18);
}

.coord-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  font-size: clamp(1rem, 3vw, 1.55rem);
  font-weight: 900;
  color: #1f150b;
}

.coord-cell.corner {
  font-size: 0;
}

.chess-square {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chess-square.light {
  background: #f3eee7;
}

.chess-square.dark {
  background: #c18b43;
}

.chess-square.selected {
  box-shadow: inset 0 0 0 4px #1cb0f6;
  z-index: 2;
}

.chess-square.legal {
  z-index: 1;
}

.chess-square.capture {
  z-index: 1;
}

.chess-square.last-move {
  box-shadow: inset 0 0 0 4px rgba(255, 217, 80, 0.9);
}

.chess-square.in-check {
  box-shadow: inset 0 0 0 4px rgba(215, 77, 77, 0.92);
}

.legal-dot,
.legal-ring {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.legal-dot {
  width: 18%;
  height: 18%;
  min-width: 10px;
  min-height: 10px;
  border-radius: 999px;
  background: rgba(27, 93, 27, 0.56);
}

.legal-ring {
  inset: 12%;
  border-radius: 999px;
  border: 4px solid rgba(181, 39, 39, 0.62);
}

.chess-piece {
  position: relative;
  z-index: 2;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Arial Unicode MS", serif;
  font-size: clamp(2.05rem, 7.4vw, 4rem);
  line-height: 0.86;
  transform: translateY(2%);
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.14));
}

.chess-piece.white {
  color: #fffdfa;
  -webkit-text-stroke: 1.8px #111111;
  paint-order: stroke fill;
}

.chess-piece.black {
  color: #101010;
  -webkit-text-stroke: 0.8px #151515;
  paint-order: stroke fill;
}

.chess-anim-piece {
  position: absolute;
  left: calc(var(--coord-size) + (var(--square-size) * var(--from-col)) + (var(--square-size) / 2));
  top: calc(var(--coord-size) + (var(--square-size) * var(--from-row)) + (var(--square-size) / 2));
  width: var(--square-size);
  height: var(--square-size);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
  transform: translate(-50%, -50%);
}

.chess-anim-piece.moving {
  animation: chessGlideAbs 280ms cubic-bezier(0.22, 0.84, 0.32, 1) forwards;
}

.chess-square:hover {
  transform: none;
}

.chess-meta {
  gap: 0;
}

@keyframes chessGlideAbs {
  from {
    transform: translate(-50%, -50%) scale(1);
  }
  70% {
    transform: translate(
        calc(-50% + (var(--dx) * var(--square-size))),
        calc(-50% + (var(--dy) * var(--square-size)))
      )
      scale(1.04);
  }
  to {
    transform: translate(
        calc(-50% + (var(--dx) * var(--square-size))),
        calc(-50% + (var(--dy) * var(--square-size)))
      )
      scale(1);
  }
}

@media (min-width: 640px) {
  .overview-grid,
  .game-grid,
  .course-grid,
  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .chess-frame {
    --coord-size: 36px;
  }
}

@media (max-width: 430px) {
  .auth-shell,
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  .path-item,
  .path-item.right {
    grid-template-columns: 74px 1fr;
  }

  .path-item.right .lesson-node {
    order: 1;
  }

  .path-item.right .lesson-copy {
    order: 2;
  }

  .lesson-node {
    width: 68px;
    height: 68px;
  }

  .lesson-copy {
    padding-left: 90px;
    min-height: 96px;
  }

  .lesson-thumb {
    width: 70px;
    height: 70px;
  }

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

  .chess-frame {
    --coord-size: 24px;
    padding: 8px;
    border-radius: 20px;
  }

  .coord-cell {
    font-size: 0.95rem;
  }
}

.auth-consent-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
}

.auth-consent-card strong {
  font-size: 1rem;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.consent-row input {
  width: 20px;
  min-height: 20px;
  margin: 2px 0 0;
  padding: 0;
  flex: 0 0 auto;
}

.consent-row a,
.legal-doc-link {
  color: var(--primary-deep);
  font-weight: 800;
  text-decoration: none;
}

.consent-row a:hover,
.legal-doc-link:hover {
  text-decoration: underline;
}

.leaderboard-card {
  gap: 14px;
}

.notification-list,
.rank-section {
  display: grid;
  gap: 10px;
}

.notification-row,
.notification-empty,
.rank-row {
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fbfeff;
}

.notification-row {
  display: grid;
  gap: 4px;
}

.notification-row span,
.notification-empty,
.rank-row small {
  color: var(--muted);
}

.rank-title {
  font-size: 0.95rem;
}

.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rank-row.is-me {
  border-color: rgba(28, 176, 246, 0.34);
  background: var(--primary-soft);
}

.rank-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-main strong {
  display: block;
}

.rank-main small {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rank-no {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8f5ff;
  color: var(--primary-deep);
  font-weight: 900;
}

.chapter-list {
  display: grid;
  gap: 18px;
}

.chapter-card {
  display: grid;
  gap: 16px;
}

.chapter-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.chapter-copy {
  display: grid;
  gap: 8px;
}

.chapter-copy h3,
.chapter-copy p {
  margin: 0;
}

.chapter-meter {
  min-width: 92px;
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: #f8fcff;
  text-align: center;
}

.chapter-meter strong {
  font-size: 1.1rem;
}

.chapter-meter span {
  color: var(--muted);
  font-size: 0.9rem;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.lesson-pill {
  min-height: 88px;
  padding: 14px;
  border-radius: 22px;
  border: 2px solid var(--line);
  background: #fff;
  text-align: left;
  display: grid;
  gap: 6px;
}

.lesson-pill.current {
  background: linear-gradient(180deg, #eef9ff 0%, #e5f5ff 100%);
  border-color: rgba(28, 176, 246, 0.36);
  box-shadow: 0 12px 24px rgba(28, 176, 246, 0.12);
}

.lesson-pill.done {
  background: linear-gradient(180deg, #f7fff0 0%, #f2ffea 100%);
  border-color: rgba(88, 204, 2, 0.3);
}

.lesson-pill.locked {
  background: #f5f8fb;
  color: #91a4b5;
}

.lesson-pill-no {
  color: var(--primary-deep);
  font-weight: 900;
}

.lesson-pill strong {
  font-size: 1rem;
}

.lesson-pill small {
  color: inherit;
  opacity: 0.8;
}

.legal-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.legal-doc-link {
  min-height: 56px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.legal-doc-link.wide {
  grid-column: 1 / -1;
}

@media (max-width: 430px) {
  .chapter-head {
    display: grid;
  }

  .lesson-grid,
  .legal-doc-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

.quest-panel,
.potion-panel {
  gap: 14px;
}

.quest-list,
.potion-grid {
  display: grid;
  gap: 12px;
}

.quest-row,
.potion-card,
.speech-status,
.speech-transcript,
.leaderboard-foot {
  padding: 14px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: #fbfeff;
}

.quest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quest-row.complete {
  border-color: rgba(88, 204, 2, 0.28);
  background: #f6fff0;
}

.quest-row strong,
.potion-card strong {
  display: block;
}

.quest-row small,
.potion-status,
.leaderboard-foot,
.speech-status {
  color: var(--muted);
}

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

.potion-card {
  display: grid;
  gap: 10px;
  text-align: center;
}

.potion-card span {
  font-size: 1.1rem;
  font-weight: 900;
}

.potion-status {
  padding: 0 4px;
  font-size: 0.95rem;
}

.speech-transcript {
  color: var(--primary-deep);
  font-weight: 700;
}

.choice-label {
  display: block;
}

.choice-hint,
.phrase-romanization,
.reading-romanization,
.review-romanization {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.reading-billboard strong {
  display: block;
}

.review-romanization {
  margin-bottom: 10px;
}

@media (max-width: 430px) {
  .quest-row {
    display: grid;
  }

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

body.stategame-theme {
  background:
    radial-gradient(circle at top, rgba(81, 141, 255, 0.24), transparent 34%),
    linear-gradient(180deg, #071120 0%, #040913 100%);
  color: #e7efff;
}

body.stategame-theme .app-shell {
  background: transparent;
}

body.stategame-theme .screen,
body.stategame-theme .panel,
body.stategame-theme .hero-card,
body.stategame-theme .quick-card,
body.stategame-theme .game-card,
body.stategame-theme .leaderboard-card,
body.stategame-theme .quest-panel,
body.stategame-theme .potion-panel {
  background: rgba(7, 17, 32, 0.82);
  border-color: rgba(96, 148, 255, 0.22);
  box-shadow: 0 20px 42px rgba(0, 6, 17, 0.34);
  color: #edf3ff;
}

body.stategame-theme .topbar-panel,
body.stategame-theme .state-topbar-panel {
  background:
    radial-gradient(circle at top left, rgba(88, 150, 255, 0.24), transparent 40%),
    rgba(7, 17, 32, 0.88);
}

body.stategame-theme .stat-pill,
body.stategame-theme .tiny-badge,
body.stategame-theme .install-chip {
  background: rgba(74, 122, 240, 0.16);
  border-color: rgba(114, 164, 255, 0.26);
  color: #dce9ff;
}

body.stategame-theme .stat-pill.active,
body.stategame-theme .state-chip {
  background: linear-gradient(135deg, #3d7cff 0%, #63c3ff 100%);
  color: #03111f;
}

.state-screen {
  gap: 1rem;
}

.state-hero-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(89, 148, 255, 0.26), transparent 38%),
    linear-gradient(180deg, rgba(12, 24, 43, 0.98) 0%, rgba(5, 12, 24, 0.98) 100%);
  border: 1px solid rgba(104, 156, 255, 0.22);
}

.state-hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(120, 179, 255, 0.08), transparent);
  transform: translateX(-100%);
  animation: state-scan 8s linear infinite;
  pointer-events: none;
}

.state-hero-card h2,
.state-panel h3,
.state-promo-shell h3 {
  color: #f4f8ff;
}

.state-score-grid,
.state-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.state-score-card,
.state-action-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(99, 145, 237, 0.2);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.state-action-card {
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.state-action-card:hover,
.state-action-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(117, 171, 255, 0.42);
  background: rgba(88, 144, 255, 0.1);
}

.state-score-card small,
.state-action-card small {
  color: rgba(214, 228, 255, 0.78);
}

.state-score-card strong,
.state-action-card strong {
  font-size: 1.05rem;
  color: #ffffff;
}

.state-panel {
  border-radius: 28px;
}

.state-map {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(97, 150, 255, 0.2), transparent 24%),
    radial-gradient(circle at 78% 72%, rgba(37, 86, 180, 0.22), transparent 28%),
    linear-gradient(180deg, #081325 0%, #050b15 100%);
  border: 1px solid rgba(100, 154, 255, 0.18);
}

.state-map-noise {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 12% 12%;
  opacity: 0.28;
  pointer-events: none;
}

.state-link-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.state-link {
  stroke: rgba(125, 163, 230, 0.3);
  stroke-width: 1.5;
}

.state-link.hot {
  stroke: rgba(122, 191, 255, 0.8);
  stroke-width: 2;
}

.state-sector {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 6.3rem;
  min-height: 6.3rem;
  padding: 0.65rem 0.5rem 0.7rem;
  border: 1px solid rgba(135, 174, 255, 0.22);
  border-radius: 50%;
  display: grid;
  place-items: center;
  gap: 0.18rem;
  background: rgba(17, 30, 54, 0.96);
  color: #eef5ff;
  z-index: 2;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.state-sector small {
  max-width: 4.8rem;
  font-size: 0.64rem;
  line-height: 1.2;
  text-align: center;
  color: rgba(228, 238, 255, 0.86);
}

.state-sector-count {
  font-size: 1.15rem;
  font-weight: 800;
}

.state-sector-ring {
  position: absolute;
  inset: 0.4rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.state-sector.player {
  background: radial-gradient(circle at top, rgba(104, 176, 255, 0.28), rgba(14, 38, 78, 0.98));
  border-color: rgba(99, 181, 255, 0.62);
  box-shadow: 0 0 0 1px rgba(76, 157, 255, 0.18), 0 0 32px rgba(54, 118, 255, 0.2);
}

.state-sector.enemy {
  background: radial-gradient(circle at top, rgba(255, 124, 109, 0.3), rgba(72, 14, 18, 0.96));
  border-color: rgba(255, 128, 103, 0.52);
}

.state-sector.neutral {
  background: radial-gradient(circle at top, rgba(175, 193, 224, 0.18), rgba(28, 38, 58, 0.94));
  border-color: rgba(181, 197, 226, 0.3);
}

.state-sector.selected,
.state-sector.targetable:hover,
.state-sector.targetable:focus-visible {
  transform: translate(-50%, -50%) scale(1.03);
  border-color: rgba(129, 199, 255, 0.96);
  box-shadow: 0 0 0 2px rgba(89, 156, 255, 0.24), 0 0 26px rgba(91, 155, 255, 0.28);
}

.state-squad {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  z-index: 3;
  box-shadow: 0 0 14px currentColor;
}

.state-squad.player {
  background: #82d0ff;
  color: #82d0ff;
}

.state-squad.enemy {
  background: #ff8b72;
  color: #ff8b72;
}

.state-sector-list,
.state-log-list {
  display: grid;
  gap: 0.7rem;
}

.state-sector-row,
.state-log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(115, 153, 225, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.state-sector-row.player {
  border-color: rgba(91, 179, 255, 0.28);
}

.state-sector-row.enemy {
  border-color: rgba(255, 128, 111, 0.24);
}

.state-sector-row small,
.state-log-row p,
.state-promo-foot {
  color: rgba(221, 232, 255, 0.78);
}

.state-sector-meta {
  display: grid;
  gap: 0.22rem;
  justify-items: end;
  color: rgba(239, 244, 255, 0.92);
  font-size: 0.88rem;
}

.state-log-row {
  justify-content: flex-start;
}

.state-log-row span {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #70b0ff;
}

.state-log-row.success span {
  background: #7de0b1;
}

.state-log-row.warn span {
  background: #ffb068;
}

.state-log-row p {
  margin: 0;
  line-height: 1.45;
}

.state-lockup {
  gap: 0.9rem;
}

.state-orb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #e8f3ff 0%, #79c4ff 22%, #376eff 54%, #0a1531 100%);
  box-shadow:
    0 0 0 1px rgba(121, 182, 255, 0.2),
    0 0 26px rgba(78, 136, 255, 0.36);
  animation: state-pulse 3.2s ease-in-out infinite;
}

.state-bottom-nav {
  background: rgba(4, 10, 20, 0.82);
  border-top-color: rgba(83, 132, 240, 0.24);
}

.state-promo-shell {
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(90, 147, 255, 0.14), transparent 40%),
    rgba(15, 23, 36, 0.98);
}

.state-promo-form {
  display: grid;
  gap: 0.8rem;
}

.state-promo-form input {
  background: rgba(255, 255, 255, 0.04);
  color: #eff6ff;
  border-color: rgba(110, 157, 255, 0.26);
}

[data-action="prime-state-promo"] {
  cursor: pointer;
}

@keyframes state-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 1px rgba(121, 182, 255, 0.2),
      0 0 26px rgba(78, 136, 255, 0.36);
  }
  50% {
    transform: scale(1.05);
    box-shadow:
      0 0 0 1px rgba(121, 182, 255, 0.28),
      0 0 34px rgba(101, 167, 255, 0.44);
  }
}

@keyframes state-scan {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(120%);
  }
}

@media (max-width: 560px) {
  .state-sector {
    width: 5.5rem;
    min-height: 5.5rem;
  }

  .state-sector small {
    max-width: 4.1rem;
    font-size: 0.58rem;
  }
}

.quick-switch-panel {
  overflow: hidden;
}

.quick-switch-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(176px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}

.switch-chip,
.fastlane-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.switch-chip {
  min-height: 84px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: #fff;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  text-align: left;
  scroll-snap-align: start;
}

.switch-chip.active {
  border-color: rgba(28, 176, 246, 0.36);
  background: linear-gradient(180deg, #f5fbff 0%, #eaf7ff 100%);
  box-shadow: 0 10px 18px rgba(28, 176, 246, 0.12);
}

.switch-chip-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
}

.switch-chip-copy {
  display: grid;
  gap: 4px;
}

.switch-chip small,
.fastlane-card p,
.fastlane-card span {
  color: var(--muted);
}

.fastlane-panel {
  background:
    radial-gradient(circle at top right, rgba(28, 176, 246, 0.08), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
}

.fastlane-meta,
.account-actions,
.lesson-helper-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fastlane-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fastlane-card {
  min-height: 132px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: #fff;
  display: grid;
  gap: 10px;
  align-content: space-between;
  text-align: left;
}

.fastlane-card strong {
  font-size: 1.06rem;
}

.fastlane-card p,
.fastlane-card span {
  margin: 0;
}

.fastlane-card.primary {
  border-color: transparent;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.2), transparent 32%),
    linear-gradient(180deg, #1cb0f6 0%, #1599d8 100%);
  box-shadow: 0 16px 26px rgba(21, 153, 216, 0.2);
}

.fastlane-card.primary,
.fastlane-card.primary p,
.fastlane-card.primary span {
  color: #fff;
}

.secret-trigger {
  min-width: 70px;
  letter-spacing: 0.18em;
  opacity: 0.76;
}

.lesson-helper-row {
  justify-content: space-between;
}

.lesson-reward-chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 2px solid #cfe9fb;
  background: #eaf7ff;
  color: var(--primary-deep);
  display: inline-flex;
  align-items: center;
  font-weight: 800;
}

.switch-chip:hover,
.fastlane-card:hover {
  transform: translateY(-1px);
}

@media (max-width: 560px) {
  .fastlane-grid {
    grid-template-columns: 1fr;
  }
}

.trace-copy-card {
  text-align: center;
}

.trace-copy-card strong {
  font-size: clamp(1.8rem, 8vw, 3rem);
  line-height: 1.05;
}

.trace-shell {
  display: grid;
  gap: 14px;
}

.trace-board {
  position: relative;
  min-height: 320px;
  border-radius: 24px;
  border: 2px solid #cfe9fb;
  background:
    linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
  overflow: hidden;
}

.trace-board::before,
.trace-board::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 0;
  width: 100%;
  border-top: 1px dashed rgba(29, 94, 146, 0.12);
  pointer-events: none;
}

.trace-board::after {
  inset: 0 auto auto 50%;
  width: 0;
  height: 100%;
  border-top: 0;
  border-left: 1px dashed rgba(29, 94, 146, 0.12);
}

.trace-guide,
.trace-canvas {
  position: absolute;
  inset: 0;
}

.trace-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(5rem, 26vw, 8rem);
  font-weight: 900;
  color: rgba(28, 176, 246, 0.22);
  user-select: none;
  pointer-events: none;
}

.trace-board.light .trace-guide {
  color: rgba(28, 176, 246, 0.15);
}

.trace-board.free .trace-guide {
  color: rgba(28, 176, 246, 0.08);
}

.trace-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.trace-metrics {
  gap: 8px;
}

.chess-placement-shell {
  background:
    radial-gradient(circle at top right, rgba(28, 176, 246, 0.08), transparent 36%),
    linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.save-state-card.saved,
.save-inline-panel.saved {
  border-color: #d9efc3;
  background: linear-gradient(180deg, #ffffff 0%, #f6ffef 100%);
}

.save-state-card.saving,
.save-inline-panel.saving {
  border-color: rgba(28, 176, 246, 0.3);
  background: linear-gradient(180deg, #ffffff 0%, #eef9ff 100%);
}

.save-state-card.queued,
.save-inline-panel.queued,
.save-state-card.retry,
.save-inline-panel.retry,
.save-state-card.offline,
.save-inline-panel.offline {
  border-color: var(--warn-line);
  background: linear-gradient(180deg, #ffffff 0%, #fff8ef 100%);
}

.manage-hero-card {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.26), transparent 36%),
    linear-gradient(180deg, #178ad0 0%, #0f73b8 100%);
}

.device-list {
  display: grid;
  gap: 10px;
}

.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: #fbfeff;
}

.device-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.save-inline-panel .section-head {
  align-items: flex-start;
}
