:root {
  --ink: #182234;
  --muted: #5d6879;
  --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;
  --floor: #d3a165;
  --wall: #f4d691;
  --lane-x: 0px;
  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%;
  background: #233044;
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

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

.wordhall-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;
  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;
}

.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);
}

.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));
  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;
}

.hallway {
  --depth: min(74vw, 880px);
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #9fd5df 0%, #f7df9f 29%, #eeb973 56%, #af7149 100%);
  box-shadow: 0 28px 80px rgba(13, 21, 34, 0.34);
  isolation: isolate;
}

.hall-ceiling {
  position: absolute;
  inset: 0 0 auto;
  height: 40%;
  background:
    linear-gradient(92deg, transparent 0 14%, rgba(255, 255, 255, 0.28) 14.3% 15%, transparent 15.3% 34%, rgba(255, 255, 255, 0.22) 34.3% 35%, transparent 35.3% 65%, rgba(255, 255, 255, 0.22) 65.3% 66%, transparent 66.3% 85%, rgba(255, 255, 255, 0.28) 85.3% 86%, transparent 86.3%),
    linear-gradient(180deg, #e9b969, #f5da9a);
  clip-path: polygon(14% 0, 86% 0, 66% 100%, 34% 100%);
  opacity: 0.9;
}

.exit-door {
  position: absolute;
  top: 10%;
  left: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(76px, 10vw, 118px);
  height: clamp(96px, 13vw, 148px);
  border: 5px solid #7c573a;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent 38%),
    #3c736c;
  color: #fff8ea;
  font-size: 0.73rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: translateX(-50%);
  box-shadow: inset 0 -18px 0 rgba(0, 0, 0, 0.08), 0 10px 24px rgba(92, 54, 28, 0.26);
}

.side-wall {
  position: absolute;
  top: 16%;
  bottom: 0;
  z-index: 0;
  width: 34%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 30%),
    repeating-linear-gradient(90deg, rgba(60, 61, 71, 0.12) 0 2px, transparent 2px 44px),
    #ebc273;
  opacity: 0.92;
}

.side-wall-left {
  left: 0;
  clip-path: polygon(0 0, 100% 21%, 72% 100%, 0 100%);
}

.side-wall-right {
  right: 0;
  clip-path: polygon(0 21%, 100% 0, 100% 100%, 28% 100%);
}

.floor-grid {
  position: absolute;
  inset: 31% 7% 0;
  z-index: 1;
  background:
    linear-gradient(90deg, transparent 0 32%, rgba(255, 248, 234, 0.32) 32.3% 33%, transparent 33.3% 66.4%, rgba(255, 248, 234, 0.32) 66.7% 67.4%, transparent 67.7%),
    repeating-linear-gradient(180deg, rgba(255, 248, 234, 0.28) 0 3px, transparent 3px 52px),
    linear-gradient(180deg, #f0c173, #b6784a 70%, #82543e);
  clip-path: polygon(34% 0, 66% 0, 100% 100%, 0 100%);
}

.floor-lights {
  position: absolute;
  left: 50%;
  bottom: 4%;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(12, minmax(10px, 1fr));
  gap: clamp(3px, 0.45vw, 8px);
  width: min(70%, 650px);
  transform: translateX(-50%);
}

.floor-light {
  height: clamp(8px, 1.1vw, 13px);
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.46);
  box-shadow: inset 0 0 0 1px rgba(24, 34, 52, 0.1);
}

.floor-light.is-on {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(241, 189, 79, 0.82);
}

.focus-target {
  position: absolute;
  left: clamp(72px, 7.4%, 138px);
  top: 8.2%;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: clamp(230px, 28vw, 390px);
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.94);
  box-shadow: 0 16px 36px rgba(44, 31, 20, 0.18);
  color: #263145;
  pointer-events: none;
}

.focus-target span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.focus-target strong {
  color: #263145;
  font-size: clamp(1.1rem, 1.9vw, 1.7rem);
  line-height: 1;
}

.word-lanes {
  position: absolute;
  left: 50%;
  top: 31%;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(132px, 1fr));
  gap: clamp(10px, 2vw, 26px);
  width: min(76%, 760px);
  perspective: 780px;
  transform: translateX(-50%);
}

.word-card {
  position: relative;
  display: grid;
  min-height: clamp(120px, 17vh, 172px);
  padding: clamp(12px, 1.6vw, 18px);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 248, 234, 0.96)),
    #fff;
  color: var(--ink);
  box-shadow: 0 20px 36px rgba(44, 31, 20, 0.25);
  opacity: 0.78;
  text-align: left;
  transform: translateY(-92px) scale(0.76);
  transform-origin: center bottom;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease, filter 180ms ease;
}

.word-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: var(--card-color, var(--teal));
}

.word-card:disabled {
  cursor: default;
}

.word-lanes.is-approaching .word-card {
  animation: approachCards 1180ms cubic-bezier(0.2, 0.82, 0.24, 1) forwards;
  pointer-events: none;
}

.word-lanes.is-approaching .word-card:nth-child(2) {
  animation-delay: 80ms;
}

.word-lanes.is-approaching .word-card:nth-child(3) {
  animation-delay: 150ms;
}

.word-lanes.is-ready .word-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.word-lanes.is-complete .word-card {
  opacity: 0.48;
  transform: translateY(0) scale(1);
}

.word-lanes.is-ready .word-card:hover,
.word-lanes.is-ready .word-card:focus-visible {
  transform: translateY(-7px);
  box-shadow: 0 28px 48px rgba(44, 31, 20, 0.31);
  outline: 0;
}

.word-card.is-wrong {
  border-color: var(--coral);
  opacity: 0.62;
  animation: shake 190ms linear 1;
}

.word-card.is-correct {
  border-color: var(--teal);
  box-shadow: 0 0 0 5px rgba(45, 155, 136, 0.2), 0 28px 48px rgba(44, 31, 20, 0.24);
}

.word-card span {
  align-self: start;
  width: max-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(24, 34, 52, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.word-card strong {
  align-self: center;
  font-size: clamp(1.7rem, 3.2vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.word-card small {
  align-self: end;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
  line-height: 1.25;
}

.runner-shadow {
  position: absolute;
  left: calc(50% + var(--lane-x));
  bottom: 8.4%;
  z-index: 3;
  width: clamp(76px, 9vw, 118px);
  height: clamp(17px, 2vw, 25px);
  border-radius: 999px;
  background: rgba(45, 30, 22, 0.28);
  filter: blur(1px);
  transform: translateX(-50%);
  transition: left 210ms ease;
}

.player-avatar {
  position: absolute;
  left: calc(50% + var(--lane-x));
  bottom: 7%;
  z-index: 4;
  width: clamp(82px, 10vw, 130px);
  height: clamp(132px, 17vw, 204px);
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 16px 14px rgba(35, 28, 23, 0.26));
  transform: translateX(-50%);
  transition: left 210ms ease, transform 210ms ease;
}

.hallway.is-moving .player-avatar {
  transform: translateX(-50%) translateY(-4px);
}

.wordhall-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 24px clamp(20px, 2vw, 30px);
  overflow-y: auto;
  border-left: 1px solid rgba(255, 255, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 251, 239, 0.97), rgba(230, 241, 222, 0.95)),
    var(--paper);
  box-shadow: -22px 0 60px rgba(13, 21, 34, 0.2);
}

.prototype-title p,
.completion-card p {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

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

.prototype-title span,
.rule-board p,
.coach-note span,
.completion-card > span {
  color: var(--muted);
  line-height: 1.42;
}

.prototype-title span {
  display: block;
  margin-top: 8px;
}

.avatar-block,
.rule-board,
.collected-board {
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

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

.panel-heading h2 {
  font-size: 1.06rem;
}

.panel-heading span {
  flex: none;
  padding: 5px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
}

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

.avatar-option {
  display: grid;
  gap: 7px;
  place-items: center;
  min-width: 0;
  padding: 9px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 850;
}

.avatar-option img {
  width: 42px;
  height: 58px;
  object-fit: contain;
  object-position: bottom center;
}

.avatar-option.is-selected {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(45, 155, 136, 0.16);
}

.coach-note {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid rgba(24, 34, 52, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(230, 247, 241, 0.94), rgba(255, 240, 216, 0.9)),
    #fff;
}

.coach-note img {
  align-self: end;
  width: 64px;
  height: 88px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 9px 10px rgba(24, 34, 52, 0.16));
}

.coach-note strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.rule-board p {
  margin: 0;
}

.collected-words {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 40px;
}

.collected-words 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;
}

.collected-words .empty-word {
  color: var(--muted);
  font-weight: 760;
}

.panel-actions,
.completion-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 900;
}

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

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

.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 h2 {
  margin-bottom: 10px;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.completion-card > span {
  display: block;
}

.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;
}

@keyframes approachCards {
  0% {
    filter: blur(0.6px);
    opacity: 0.42;
    transform: translateY(-154px) translateZ(-90px) scale(0.48);
  }

  72% {
    filter: blur(0);
    opacity: 1;
    transform: translateY(8px) translateZ(0) scale(1.02);
  }

  100% {
    filter: blur(0);
    opacity: 1;
    transform: translateY(0) translateZ(0) scale(1);
  }
}

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

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

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

@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) {
  .wordhall-app {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .wordhall-stage {
    min-height: 650px;
  }

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

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

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

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

  .score-strip span {
    flex: 1;
  }

  .word-lanes {
    top: 32%;
    width: calc(100% - 24px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .focus-target {
    left: 14px;
    top: 7.5%;
    justify-content: flex-start;
    width: min(78%, 310px);
    min-width: 0;
    min-height: 38px;
    padding: 8px 12px;
  }

  .focus-target strong {
    font-size: clamp(1rem, 6vw, 1.35rem);
  }

  .word-card {
    min-height: 116px;
    padding: 10px 8px;
  }

  .word-card span {
    font-size: 0.62rem;
  }

  .word-card strong {
    font-size: clamp(1.15rem, 8vw, 1.85rem);
    overflow-wrap: anywhere;
  }

  .word-card small {
    font-size: 0.72rem;
  }

  .stage-feedback {
    font-size: 0.88rem;
  }

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

  .runner-shadow {
    width: 76px;
  }

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