{
  box-sizing: border-box;
}

:root {
  --bg: #000000;
  --panel: #181413;
  --panel-soft: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --muted: #ffffff;
  --accent: #d2a86d;
  --danger: #cf3b3b;
  --safe: #4fa36d;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #000000;
  color: var(--text);
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.hud {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(160, 160, 160, 0.45);
}

#shared-header {
  transition:
    opacity 320ms ease,
    transform 320ms ease,
    border-color 320ms ease;
}

.hud-slot {
  min-height: 72px;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.boss-slot {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 18px 22px;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: transparent;
}

.boss-slot.active {
  color: var(--danger);
  text-shadow: none;
}

.title-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  text-align: center;
}

.shared-title-slot {
  justify-content: center;
}

.header-title-stack {
  display: grid;
  place-items: center;
  width: 100%;
}

.header-title {
  grid-area: 1 / 1;
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text);
  transition:
    opacity 320ms ease,
    transform 320ms ease,
    color 180ms ease;
}

.rules-header-title {
  opacity: 1;
  transform: translateY(0);
}

.game-header-title {
  opacity: 0;
  transform: translateY(4px);
}

.subhead {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.score-slot {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 14px 18px;
  text-align: right;
  min-width: 0;
  transition:
    opacity 320ms ease,
    transform 320ms ease,
    color 180ms ease;
}

#header-score-slot {
  opacity: 0;
  transform: translateY(6px);
}

.score-value {
  display: inline-block;
  min-width: 3ch;
  text-align: right;
  font-size: clamp(1.72rem, 2.8vw, 2.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.18em;
  color: var(--danger);
  opacity: 0;
  transition: opacity 220ms ease;
  will-change: opacity;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.score-value.has-strikes {
  opacity: 1;
}

.game-board {
  display: flex;
  justify-content: center;
  width: 100%;
}

.board-screen {
  width: min(100%, 1100px);
  min-height: 68vh;
}

.hidden-screen {
  display: none !important;
}

.rules-screen {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 2px 0 0;
}

.rules-content {
  width: 100%;
  transition: opacity 320ms ease, transform 320ms ease;
}

.rules-copy {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  color: var(--text);
  text-align: center;
}

.rules-title {
  margin: 0 0 28px;
  text-align: center;
  font-size: clamp(2rem, 3.4vw, 2.85rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.05;
  text-transform: none;
}

.rules-copy p {
  margin: 0 0 18px;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.7;
  text-align: center;
}

.rules-lines {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 820px;
}

.rules-lines p {
  margin: 0;
}

.rules-actions {
  display: flex;
  justify-content: center;
  margin-top: 34px;
}

#limbo-rules-screen .rules-actions {
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#rules-advance,
#limbo-rules-advance,
#limbo-restart,
#limbo-quit {
  min-width: 220px;
  background: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  font-weight: 700;
}

#rules-advance:hover,
#rules-advance:focus-visible,
#limbo-rules-advance:hover,
#limbo-rules-advance:focus-visible,
#limbo-restart:hover,
#limbo-restart:focus-visible,
#limbo-quit:hover,
#limbo-quit:focus-visible {
  background: #ffffff;
  color: #000000;
  filter: brightness(0.96);
}

#phase-clear-advance,
#victory-play-again {
  min-width: 220px;
  background: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  font-weight: 700;
  transition:
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

#phase-clear-advance:hover,
#phase-clear-advance:focus-visible,
#phase-clear-advance:active,
#victory-play-again:hover,
#victory-play-again:focus-visible,
#victory-play-again:active {
  background: #000000;
  color: #ffffff;
  border-color: #ffffff;
  filter: none;
}

#phase-clear-advance:active,
#victory-play-again:active {
  transform: scale(0.98);
}

.phase-clear-screen {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(28px, 6vh, 64px) 0 0;
}

.phase-clear-copy {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  color: var(--text);
  text-align: center;
}

.phase-clear-kicker {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.phase-clear-title {
  margin: 0 0 18px;
  text-align: center;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.phase-clear-text {
  margin: 0 0 24px;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.7;
  text-align: center;
}

.phase-clear-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.phase-clear-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.phase-clear-stat-label {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.phase-clear-stat-value {
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.phase-clear-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 36px;
}

.phase-overall-summary {
  margin-top: 30px;
}

.phase-overall-title {
  margin: 0 0 18px;
  text-align: center;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#phase-clear-screen .phase-clear-title,
#phase-clear-screen .phase-clear-stat,
#victory-screen .phase-clear-title,
#victory-screen .phase-clear-stat,
#phase-clear-screen .phase-clear-actions .primary-button,
#victory-screen .phase-clear-actions .primary-button,
#phase-clear-screen .phase-overall-summary,
#victory-screen .phase-overall-summary {
  opacity: 0;
  transform: translateY(14px);
  animation: phase-clear-fade-in 420ms ease forwards;
}

#phase-clear-screen .phase-clear-actions,
#victory-screen .phase-clear-actions {
  opacity: 1;
  transform: none;
  animation: none;
}

#phase-clear-screen .phase-clear-title,
#victory-screen .phase-clear-title {
  animation-delay: 0ms;
}

#phase-clear-screen .phase-clear-stat:nth-child(1),
#victory-screen .phase-clear-stat:nth-child(1) {
  animation-delay: 180ms;
}

#phase-clear-screen .phase-clear-stat:nth-child(2),
#victory-screen .phase-clear-stat:nth-child(2) {
  animation-delay: 320ms;
}

#phase-clear-screen .phase-clear-stat:nth-child(3),
#victory-screen .phase-clear-stat:nth-child(3) {
  animation-delay: 460ms;
}

#phase-clear-screen .phase-clear-stat:nth-child(4),
#victory-screen .phase-clear-stat:nth-child(4) {
  animation-delay: 600ms;
}

#phase-clear-screen .phase-clear-actions .primary-button,
#victory-screen .phase-clear-actions .primary-button {
  animation-delay: 760ms;
}

#phase-clear-screen .phase-overall-summary,
#victory-screen .phase-overall-summary {
  animation-delay: 900ms;
}

.question-card {
  position: relative;
  width: min(100%, 1100px);
  min-height: 68vh;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 8px 0 0;
}

.question-number {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
  will-change: opacity;
}

.next-button {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffffff;
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, color 180ms ease;
  will-change: opacity;
}

.next-button:focus,
.next-button:focus-visible {
  outline: none;
  box-shadow: none;
}

.next-button:hover,
.next-button:focus-visible {
  color: rgba(255, 255, 255, 0.8);
}

.next-button.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.prompt {
  min-height: 72px;
  margin-top: 28px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-align: center;
  color: var(--text);
  font-size: clamp(1.45rem, 2.6vw, 2.35rem);
  font-weight: 600;
  line-height: 1.2;
}

.prompt.is-sentry,
.prompt.is-greater-boss {
  width: min(100%, 940px);
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(1.28rem, 1.95vw, 1.58rem);
  font-weight: 400;
  line-height: 1.44;
}

.choices {
  display: grid;
  gap: 14px;
}

.choice-button {
  width: min(100%, 760px);
  justify-self: center;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ffffff;
  border-radius: 14px;
  background: #000000;
  color: var(--text);
  padding: 18px 22px;
  text-align: center;
  font-size: clamp(1.15rem, 1.8vw, 1.55rem);
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.choice-button:hover:not(:disabled),
.choice-button:focus-visible:not(:disabled),
.choice-button:active:not(:disabled) {
  transform: translateY(-1px);
  border-color: #ffffff;
  background: #ffffff;
  color: #000000;
  outline: none;
}

.choice-button.is-selected:not(.correct):not(.wrong),
.choice-button.is-selected:not(.correct):not(.wrong):disabled {
  transform: translateY(-1px);
  border-color: #ffffff;
  background: #ffffff;
  color: #000000;
  opacity: 1;
}

.choice-button:disabled {
  cursor: default;
  opacity: 1;
  background: #000000;
}

.choice-button.correct {
  border-color: #1f8f3a;
  background: #1f8f3a;
  color: #ffffff;
}

.choice-button.wrong {
  border-color: #c43a3d;
  background: #c43a3d;
  color: #000000;
}

.feedback {
  min-height: 56px;
  margin-top: 18px;
  color: var(--text);
  font-size: 1rem;
  text-align: center;
}

.feedback.positive {
  color: var(--text);
}

.feedback.warning {
  color: var(--text);
}

.feedback.danger {
  color: var(--text);
}

.question-transition-fade-out {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 420ms ease, transform 420ms ease;
}

.question-transition-fade-in {
  opacity: 0;
  transform: translateY(14px);
  animation: question-content-fade-in 560ms ease forwards;
}

.secondary-button,
.primary-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}

.secondary-button {
  background: transparent;
  color: var(--text);
}

.primary-button {
  background: var(--accent);
  color: #1b1209;
  border-color: transparent;
  font-weight: 700;
}

.primary-button:hover,
.secondary-button:hover {
  filter: brightness(1.04);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 4, 0.72);
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.modal {
  width: min(720px, 100%);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(23, 18, 16, 0.98), rgba(12, 10, 9, 0.98));
  box-shadow: var(--shadow);
  padding: 28px;
}

.modal-kicker {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-title {
  margin: 0 0 14px;
  color: var(--text);
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.modal-body {
  color: var(--text);
  line-height: 1.7;
}

.modal-body strong {
  color: var(--text);
}

.modal-body ul {
  margin: 12px 0 0;
  padding-left: 18px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.limbo-transition {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 900ms ease;
}

.limbo-transition.is-active {
  opacity: 0;
}

.limbo-transition.is-fading {
  opacity: 1;
}

.limbo-transition.is-exiting {
  opacity: 0;
  transition: opacity 320ms ease;
}

.limbo-transition .limbo-transition-title {
  color: #f5f1e8;
  font-size: clamp(2.2rem, 7vw, 5rem);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  opacity: 0;
  transform: translateY(-4vh) scale(0.92);
  text-shadow: none;
  transition:
    opacity 260ms ease,
    transform 260ms ease;
  user-select: none;
}

.limbo-transition.is-title-visible .limbo-transition-title,
.limbo-transition.is-exiting .limbo-transition-title {
  opacity: 1;
  transform: translateY(-4vh) scale(1);
}

body:has(#phase-clear-screen:not(.hidden-screen)) #shared-header,
body:has(#victory-screen:not(.hidden-screen)) #shared-header {
  display: none;
}

@keyframes phase-clear-fade-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes question-content-fade-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .app-shell {
    padding: 16px;
  }

  .hud {
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
  }

  .hud-slot {
    min-height: 68px;
  }

  .boss-slot {
    justify-content: flex-start;
    align-items: center;
    padding: 6px 4px;
    font-size: 2.5rem;
    text-align: left;
  }

  .title-slot,
  .shared-title-slot {
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    text-align: center;
  }

  .header-title {
    font-size: clamp(2.1rem, 9vw, 3.2rem);
    line-height: 1;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;
  }

  .score-slot {
    align-items: flex-end;
    justify-content: center;
    padding: 4px 4px;
    text-align: right;
    min-width: 0;
  }

  .score-value {
    min-width: 3ch;
    text-align: right;
    font-size: clamp(1.98rem, 8.2vw, 2.9rem);
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.18em;
    color: var(--danger);
    opacity: 0;
    transition: opacity 220ms ease;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .score-value.has-strikes {
    opacity: 1;
  }

  .rules-screen {
    padding-top: 8px;
  }

  .phase-clear-screen {
    padding: clamp(20px, 5vh, 36px) 0 0;
  }

  .rules-copy,
  .phase-clear-copy {
    max-width: 100%;
  }

  .rules-title {
    margin: 0 0 22px;
    font-size: clamp(1.9rem, 8vw, 2.45rem);
    line-height: 1.06;
  }

  .rules-lines {
    gap: 14px;
    max-width: 100%;
  }

  .rules-copy p {
    font-size: clamp(1rem, 4.3vw, 1.14rem);
    line-height: 1.58;
  }

  .rules-actions {
    margin-top: 24px;
  }

  .phase-clear-actions {
    margin-top: 28px;
  }

  .phase-clear-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .phase-overall-summary {
    margin-top: 24px;
  }

  .phase-overall-title {
    margin: 0 0 16px;
    font-size: clamp(1.8rem, 8vw, 2.45rem);
    line-height: 1.06;
  }

  .question-card {
    min-height: 0;
    padding-top: 12px;
  }

  .question-number {
    top: 8px;
    font-size: 1.5rem;
  }

  .prompt {
    min-height: 0;
    display: block;
    margin-top: 36px;
    margin-bottom: 8px;
    padding-bottom: 18px;
    padding-bottom: calc(56px - 1lh);
    font-size: clamp(1.55rem, 6vw, 2.2rem);
    line-height: 1.18;
    text-align: center;
  }

  .prompt.is-sentry {
    width: 100%;
    margin-bottom: 12px;
    padding-bottom: 6px;
    font-size: clamp(1.2rem, 4.2vw, 1.28rem);
    font-weight: 400;
    line-height: 1.38;
  }

  .prompt.is-greater-boss {
    width: 100%;
    margin-bottom: 12px;
    padding-bottom: 4px;
    font-size: clamp(1.2rem, 3.7vw, 1.12rem);
    font-weight: 400;
    line-height: 1.44;
  }

  .choices {
    gap: 8px;
  }

  .choice-button {
    width: 100%;
    min-height: 66px;
    font-size: clamp(1.2rem, 4.8vw, 1.65rem);
    line-height: 1.3;
    padding: 14px 16px;
  }

  .next-button {
    top: 8px;
    font-size: 1.3rem;
  }

  .limbo-transition .limbo-transition-title {
    font-size: clamp(2rem, 11vw, 3.8rem);
    letter-spacing: 0.12em;
    padding: 0 16px;
    transform: translateY(-6vh) scale(0.92);
  }

  .limbo-transition.is-title-visible .limbo-transition-title,
  .limbo-transition.is-exiting .limbo-transition-title {
    transform: translateY(-6vh) scale(1);
  }
}
