:root {
  --ink: #182234;
  --muted: #5f6b7d;
  --paper: #fff8ea;
  --panel: rgba(255, 251, 239, 0.96);
  --line: rgba(24, 34, 52, 0.16);
  --teal: #2d9b88;
  --coral: #df5d50;
  --blue: #4768b5;
  --gold: #f1bd4f;
  --green: #4c8d59;
  --runner-x: 8%;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: #22324a;
  color: var(--ink);
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

a {
  color: inherit;
  text-decoration: none;
}

.sentence-app {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(350px, 28vw, 450px);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(116, 190, 203, 0.42), transparent 46%),
    #22324a;
}

.sentence-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 18px;
}

.stage-hud {
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 260px) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-bottom: 14px;
}

.objective-chip,
.score-strip,
.stage-feedback {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.92);
  box-shadow: 0 14px 34px rgba(13, 21, 34, 0.18);
  backdrop-filter: blur(10px);
}

.objective-chip {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
}

.objective-chip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.objective-chip strong {
  color: #263145;
  font-size: clamp(1rem, 1.5vw, 1.38rem);
  line-height: 1.05;
}

.progress-rail {
  height: 13px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.6);
}

.progress-rail span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  transition: width 260ms ease;
}

.score-strip {
  display: flex;
  gap: 7px;
  padding: 7px;
}

.score-strip span {
  min-width: 78px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
}

.stage-feedback {
  grid-column: 1 / -1;
  min-height: 42px;
  margin: -2px 0 0;
  padding: 10px 12px;
  color: #263145;
  font-size: clamp(0.9rem, 1vw, 1rem);
  font-weight: 780;
  line-height: 1.28;
}

.stage-feedback.is-correct {
  border-color: rgba(45, 155, 136, 0.52);
  background: rgba(232, 250, 244, 0.95);
}

.stage-feedback.is-wrong {
  border-color: rgba(223, 93, 80, 0.5);
  background: rgba(255, 238, 234, 0.95);
}

.stage-feedback.is-try {
  border-color: rgba(241, 189, 79, 0.72);
  background: rgba(255, 248, 218, 0.96);
}

.bridge-scene {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #99d4de 0%, #eef0c6 49%, #d7ac6b 100%);
  box-shadow: 0 28px 80px rgba(13, 21, 34, 0.34);
  isolation: isolate;
}

.scene-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 17% 16%, rgba(255, 248, 234, 0.8) 0 54px, transparent 56px),
    linear-gradient(115deg, rgba(255, 255, 255, 0.22) 0 13%, transparent 13.5% 35%, rgba(255, 255, 255, 0.16) 35.5% 45%, transparent 45.5%),
    transparent;
}

.scene-art {
  position: absolute;
  right: clamp(18px, 5vw, 70px);
  top: clamp(82px, 13vh, 130px);
  z-index: 1;
  width: min(24vw, 230px);
  max-height: 230px;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(24, 34, 52, 0.2));
}

.coach-bubble {
  position: absolute;
  left: 22px;
  top: 22px;
  z-index: 4;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: min(520px, calc(100% - 44px));
  min-height: 86px;
  padding: 10px 14px 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.92);
  box-shadow: 0 16px 36px rgba(13, 21, 34, 0.16);
  backdrop-filter: blur(10px);
}

.coach-bubble img {
  width: 66px;
  height: 66px;
  border-radius: 999px;
  object-fit: cover;
  object-position: 50% 8%;
  background: #e4f6ef;
}

.coach-bubble span,
.prototype-title p {
  color: #116b59;
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.coach-bubble strong {
  display: block;
  margin-top: 4px;
  color: #263145;
  font-size: clamp(1rem, 1.8vw, 1.38rem);
  line-height: 1.1;
}

.answer-slots {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 22%;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(var(--slot-count), minmax(0, 1fr));
  gap: clamp(6px, 1vw, 12px);
}

.answer-slot {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: clamp(46px, 7vh, 66px);
  padding: 8px;
  border: 2px dashed rgba(24, 34, 52, 0.28);
  border-radius: 8px;
  background: rgba(255, 251, 239, 0.72);
  color: rgba(24, 34, 52, 0.42);
  font-size: clamp(0.95rem, 1.45vw, 1.28rem);
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
  backdrop-filter: blur(6px);
}

.answer-slot.is-filled {
  border-style: solid;
  border-color: rgba(71, 104, 181, 0.46);
  background: #fffdf6;
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(13, 21, 34, 0.14);
}

.bridge-track {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 9%;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(var(--step-count), minmax(0, 1fr));
  gap: clamp(6px, 1vw, 14px);
  transform: perspective(620px) rotateX(54deg);
  transform-origin: center bottom;
}

.bridge-track::before {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  top: 50%;
  height: 16px;
  border-radius: 999px;
  background: rgba(113, 80, 49, 0.28);
  transform: translateY(-50%);
}

.bridge-step {
  position: relative;
  min-height: clamp(54px, 9vh, 82px);
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent),
    #c78f5a;
  box-shadow: 0 18px 32px rgba(82, 48, 27, 0.24);
}

.bridge-step.is-filled {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent),
    var(--gold);
}

.runner-avatar {
  position: absolute;
  left: var(--runner-x);
  bottom: 10%;
  z-index: 6;
  width: clamp(74px, 8vw, 112px);
  height: clamp(118px, 14vw, 180px);
  object-fit: contain;
  transform: translateX(-50%);
  filter: drop-shadow(0 14px 16px rgba(13, 21, 34, 0.24));
  transition: left 230ms ease;
}

.runner-shadow {
  position: absolute;
  left: var(--runner-x);
  bottom: 8%;
  z-index: 4;
  width: clamp(66px, 7vw, 104px);
  height: 18px;
  border-radius: 999px;
  background: rgba(24, 34, 52, 0.18);
  transform: translateX(-50%);
  transition: left 230ms ease;
}

.next-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
}

.next-overlay.is-hidden {
  display: none;
}

.next-round-button {
  display: grid;
  place-items: center;
  gap: 4px;
  min-width: min(260px, 78vw);
  min-height: 104px;
  padding: 20px 34px;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 20%, rgba(241, 189, 79, 0.9), transparent 38%),
    linear-gradient(135deg, rgba(228, 246, 239, 0.98), rgba(255, 248, 234, 0.98));
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(13, 21, 34, 0.28);
  pointer-events: auto;
}

.next-round-button span {
  color: #116b59;
  font-size: 0.86rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-round-button strong {
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  line-height: 0.95;
}

.sentence-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px clamp(22px, 2vw, 32px);
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.96), rgba(232, 246, 241, 0.96)),
    var(--paper);
  box-shadow: -20px 0 50px rgba(13, 21, 34, 0.16);
}

.prototype-title h1,
.panel-heading h2,
.round-card h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

.prototype-title p {
  margin: 0 0 7px;
}

.prototype-title h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.prototype-title span,
.round-card p {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.avatar-block,
.round-card,
.word-bank,
.collected-board {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(24, 34, 52, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.panel-word-bank {
  display: none;
}

.stage-word-bank {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 6;
  width: min(780px, calc(100% - 110px));
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%);
}

.stage-word-bank .panel-heading {
  justify-content: center;
  margin-bottom: 4px;
}

.stage-word-bank .panel-heading h2,
.stage-word-bank .panel-heading span {
  border: 1px solid rgba(255, 255, 255, 0.54);
  box-shadow: 0 10px 22px rgba(13, 21, 34, 0.1);
  backdrop-filter: blur(10px);
}

.stage-word-bank .panel-heading h2 {
  margin: 0;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.88);
  color: #263145;
  font-size: 0.82rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stage-word-bank .panel-heading span {
  background: rgba(24, 34, 52, 0.92);
}

.stage-word-bank .word-tiles {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.stage-word-bank .word-tile {
  min-height: clamp(50px, 6vh, 64px);
  border-color: rgba(71, 104, 181, 0.24);
  background: rgba(255, 253, 246, 0.92);
  font-size: clamp(1.02rem, 1.5vw, 1.34rem);
  box-shadow: 0 14px 28px rgba(13, 21, 34, 0.13);
  backdrop-filter: blur(8px);
}

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

.panel-heading span {
  min-width: 32px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

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

.avatar-option {
  display: grid;
  place-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 82px;
  padding: 8px 5px;
  border: 1px solid rgba(24, 34, 52, 0.12);
  border-radius: 8px;
  background: #fffdf6;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 900;
}

.avatar-option img {
  width: 38px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 5px 6px rgba(13, 21, 34, 0.12));
}

.avatar-option.is-selected {
  border-color: #152238;
  background: #e4f6ef;
  box-shadow: inset 0 0 0 2px rgba(21, 34, 56, 0.12);
}

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

.word-tile {
  min-width: 0;
  min-height: 46px;
  padding: 10px 11px;
  border: 1px solid rgba(24, 34, 52, 0.14);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 930;
  line-height: 1.08;
  text-align: center;
  overflow-wrap: anywhere;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.word-tile:hover:not(:disabled),
.word-tile:focus-visible,
.primary-action:hover:not(:disabled),
.secondary-action:hover:not(:disabled),
.prototype-links a:hover,
.prototype-links a:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(13, 21, 34, 0.13);
  outline: none;
}

.word-tile:disabled {
  background: #ece3cf;
  color: rgba(24, 34, 52, 0.42);
}

.completed-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 40px;
}

.completed-list span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(24, 34, 52, 0.1);
  color: #263145;
  font-size: 0.8rem;
  font-weight: 850;
}

.completed-list .empty-sentence {
  color: var(--muted);
  font-weight: 760;
}

.panel-actions,
.completion-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.completion-actions {
  grid-template-columns: 1fr 1fr;
}

.primary-action,
.secondary-action,
.prototype-links a {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 900;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-action {
  background: var(--ink);
  color: #fff8ea;
}

.secondary-action,
.prototype-links a {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.prototype-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  padding-top: 15px;
  border-top: 1px solid rgba(24, 34, 52, 0.14);
}

.prototype-links > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.prototype-links a {
  display: grid;
  place-items: center;
  min-height: 38px;
  background: rgba(255, 255, 255, 0.56);
  color: #3a4657;
  font-size: 0.9rem;
  text-align: center;
}

.completion-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(19, 28, 43, 0.54);
  backdrop-filter: blur(6px);
}

.completion-panel.is-hidden {
  display: none;
}

.completion-card {
  width: min(94vw, 520px);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.98), rgba(231, 247, 241, 0.98)),
    #fff;
  box-shadow: 0 28px 80px rgba(13, 21, 34, 0.34);
}

.completion-card p {
  margin: 0 0 7px;
  color: #116b59;
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.completion-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.02;
}

.completion-card > span {
  display: block;
  color: var(--muted);
}

.completion-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 20px 0;
}

.completion-stats strong,
.completion-stats span {
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(24, 34, 52, 0.1);
  font-weight: 900;
  text-align: center;
}

.completion-stats strong {
  color: #2d7f65;
}

.bridge-scene.is-shaking .answer-slots {
  animation: shake 240ms ease;
}

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

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

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 980px) {
  .sentence-app {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .sentence-stage {
    min-height: 660px;
  }

  .sentence-panel {
    min-height: 0;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.42);
    box-shadow: none;
  }

  .stage-word-bank {
    display: none;
  }

  .panel-word-bank {
    display: grid;
  }
}

@media (max-width: 720px) {
  .sentence-stage {
    min-height: 690px;
    padding: 10px;
  }

  .stage-hud {
    grid-template-columns: 1fr;
  }

  .score-strip {
    justify-content: stretch;
  }

  .score-strip span {
    flex: 1;
  }

  .coach-bubble {
    left: 12px;
    top: 12px;
    width: calc(100% - 24px);
    grid-template-columns: 56px minmax(0, 1fr);
    min-height: 76px;
  }

  .coach-bubble img {
    width: 56px;
    height: 56px;
  }

  .scene-art {
    top: 112px;
    right: 16px;
    width: min(42vw, 170px);
    max-height: 150px;
  }

  .answer-slots {
    left: 9%;
    right: 9%;
    bottom: 27%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-slot {
    min-height: 46px;
    background: rgba(255, 251, 239, 0.94);
  }

  .bridge-track {
    left: 12%;
    right: 12%;
    bottom: 12%;
    gap: 5px;
  }

  .bridge-step {
    min-height: 54px;
  }

  .runner-avatar {
    width: 78px;
    height: 126px;
  }

  .runner-shadow {
    width: 76px;
  }

  .sentence-panel {
    padding: 18px;
  }

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

@media (max-width: 440px) {
  .word-tiles,
  .panel-actions,
  .prototype-links {
    grid-template-columns: 1fr;
  }
}
