:root {
  --physics-green: #22c670;
  --deep-green: #119655;
  --night-green: #061914;
  --ink: #122033;
  --white: #ffffff;
  --soft-mint: #f4fbf7;
  --line-green: #d4e9dd;
  --gold: #f5c542;
  --coral: #dc4c55;
  --blue: #3da5ff;
  --shadow: 0 18px 45px rgba(6, 25, 20, 0.18);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 50% 0%, #e7fff2 0%, #f7fbfa 38%, #dfeee7 100%);
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  background: linear-gradient(180deg, #f9fffc 0%, #edf8f2 46%, #dceee6 100%);
  overflow: hidden;
}

.top-hud {
  grid-column: 1;
  min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 8px;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(220px, 0.55fr) 38px 38px 38px;
  grid-template-areas:
    "brand hud guide sound pause";
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid rgba(17, 150, 85, 0.14);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  z-index: 5;
}

.brand-lockup {
  grid-area: brand;
  display: grid;
  gap: 1px;
  min-width: 0;
  line-height: 1.05;
}

.brand-mark {
  color: var(--deep-green);
  font-size: 0.72rem;
  font-weight: 800;
}

.brand-lockup strong {
  font-size: clamp(0.92rem, 3vw, 1.08rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-cluster {
  grid-area: hud;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.hud-pill {
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
  box-shadow: 0 5px 16px rgba(18, 32, 51, 0.06);
}

.hud-pill span {
  display: block;
  color: #587066;
  font-size: 0.56rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hud-pill strong {
  display: block;
  font-size: 0.88rem;
}

.icon-button,
.secondary-action,
.primary-action,
.shop-card,
.tower-action,
.power-button,
.segmented-control button,
.map-choice {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  grid-area: pause;
  width: 38px;
  background: var(--night-green);
  color: var(--white);
  font-weight: 900;
}

.guide-button {
  grid-area: guide;
}

.sound-button {
  grid-area: sound;
  font-size: 1.05rem;
}

.sound-button[aria-pressed="true"] {
  background: #6b7c75;
  color: #e8efec;
}

.game-stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  grid-column: 1;
  grid-row: 2;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#gameCanvas.legacy-canvas-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.game-stage > canvas.phaser-battlefield {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.route-banner {
  position: absolute;
  left: 12px;
  right: 74px;
  top: 10px;
  min-height: 36px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34, 198, 112, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #244438;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(6, 25, 20, 0.1);
  backdrop-filter: blur(12px);
}

.control-panel {
  position: absolute;
  top: var(--hud-height, 58px);
  right: 0;
  bottom: 0;
  width: clamp(270px, 38vw, 330px);
  max-height: calc(100dvh - var(--hud-height, 58px));
  min-height: 0;
  padding: 10px calc(env(safe-area-inset-right) + 10px) calc(env(safe-area-inset-bottom) + 10px) 10px;
  overflow-y: auto;
  border-top: 0;
  border-left: 1px solid rgba(17, 150, 85, 0.16);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -14px 35px rgba(6, 25, 20, 0.12);
  z-index: 9;
  transform: translateX(calc(100% + 8px));
  transition: transform 180ms ease;
  overscroll-behavior: contain;
}

.app-shell.panel-open .control-panel {
  transform: translateX(0);
}

.panel-scrim {
  position: absolute;
  inset: var(--hud-height, 58px) 0 0;
  z-index: 7;
  display: none;
  border: 0;
  background: rgba(6, 25, 20, 0.2);
  backdrop-filter: blur(1px);
}

.app-shell.panel-open .panel-scrim {
  display: block;
}

.quick-tower-rail {
  position: absolute;
  top: calc(var(--hud-height, 58px) + 8px);
  right: max(6px, env(safe-area-inset-right));
  z-index: 8;
  display: grid;
  width: 58px;
  max-height: calc(100dvh - var(--hud-height, 58px) - 16px);
  gap: 5px;
  align-content: start;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid rgba(212, 233, 221, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 32px rgba(6, 25, 20, 0.18);
  backdrop-filter: blur(12px);
  transition: opacity 120ms ease, transform 180ms ease;
}

.app-shell.panel-open .quick-tower-rail {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.quick-tower-button,
.quick-panel-button,
.quick-wave-button {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  padding: 3px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(18, 32, 51, 0.08);
}

.quick-tower-button img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.quick-tower-button.selected {
  border-color: var(--physics-green);
  outline: 2px solid rgba(34, 198, 112, 0.24);
  background: #edfff5;
}

.quick-tower-button.locked,
.quick-tower-button:disabled {
  opacity: 0.45;
}

.quick-tower-cost {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 23px;
  padding: 2px 3px;
  border-radius: 6px;
  background: var(--night-green);
  color: #ffffff;
  font-size: 0.55rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.quick-panel-button,
.quick-wave-button {
  min-height: 42px;
  height: 42px;
  font-size: 1.1rem;
  font-weight: 900;
}

.quick-wave-button {
  background: var(--physics-green);
  color: #04110d;
}

.quick-divider {
  height: 1px;
  margin: 1px 3px;
  background: var(--line-green);
}

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

.panel-close-button {
  flex: 0 0 38px;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #edf8f2;
  color: var(--night-green);
  font-size: 1.2rem;
  font-weight: 900;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-title-row p {
  margin: 0;
  color: #587066;
  font-size: 0.78rem;
}

.panel-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 5px;
  margin-bottom: 8px;
  padding: 4px;
  border: 1px solid rgba(17, 150, 85, 0.16);
  border-radius: 8px;
  background: #f7fffa;
}

.panel-tabs button {
  min-height: 30px;
  padding: 5px 6px;
  border: 0;
  background: transparent;
  color: #587066;
  font-size: 0.68rem;
  font-weight: 900;
}

.panel-tabs button.active {
  background: #ffffff;
  color: var(--night-green);
  box-shadow: 0 4px 10px rgba(18, 32, 51, 0.08);
}

.guide-card,
.build-advice,
.wave-result,
.wave-intel,
.wave-forecast,
.wave-help-card {
  margin-bottom: 8px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 7px 18px rgba(18, 32, 51, 0.05);
}

.guide-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
}

.guide-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #e8fff2;
  overflow: hidden;
}

.guide-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.guide-card strong,
.forecast-top strong,
.wave-help-card strong {
  display: block;
  font-size: 0.78rem;
}

.wave-help-card {
  display: grid;
  gap: 5px;
  padding: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fffa 100%);
}

.wave-help-card p,
.wave-help-card em {
  margin: 0;
  color: #587066;
  font-size: 0.7rem;
  font-style: normal;
  line-height: 1.2;
}

.wave-help-card em {
  color: var(--deep-green);
  font-weight: 850;
}

.guide-card p {
  margin: 1px 0 0;
  color: #587066;
  font-size: 0.7rem;
  line-height: 1.22;
}

.reward-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.reward-strip span,
.reward-strip strong {
  min-width: 0;
  padding: 6px 5px;
  border-radius: 8px;
  background: #e8f8ef;
  color: var(--night-green);
  font-size: 0.66rem;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.unlock-stack {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.unlock-notice {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(34, 198, 112, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, #fafffc 0%, #eafff2 100%);
  box-shadow: 0 7px 18px rgba(18, 32, 51, 0.05);
}

.unlock-notice.enemy {
  border-color: rgba(220, 76, 85, 0.22);
  background: linear-gradient(180deg, #ffffff 0%, #fff3f4 100%);
}

.unlock-notice img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(18, 32, 51, 0.12));
}

.unlock-notice strong,
.unlock-notice em {
  display: block;
}

.unlock-notice strong {
  font-size: 0.76rem;
}

.unlock-notice em {
  color: #587066;
  font-size: 0.66rem;
  font-style: normal;
  line-height: 1.18;
}

.wave-result {
  display: grid;
  gap: 7px;
  padding: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fffdf4 100%);
}

.wave-result-top,
.wave-intel-row {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: space-between;
}

.wave-result-top span,
.wave-intel-row span {
  color: #587066;
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
}

.wave-result-top strong {
  font-size: 0.78rem;
  text-align: right;
}

.wave-result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.wave-result-grid span {
  min-width: 0;
  padding: 5px;
  border-radius: 8px;
  background: #fff7d8;
  color: #4e3b0f;
  font-size: 0.64rem;
  font-weight: 850;
  text-align: center;
}

.wave-result-grid strong {
  display: block;
  font-size: 0.82rem;
}

.wave-result p,
.wave-result em {
  margin: 0;
  color: #587066;
  font-size: 0.68rem;
  font-style: normal;
  line-height: 1.22;
}

.wave-result em {
  color: var(--deep-green);
  font-weight: 850;
}

.wave-forecast {
  padding: 8px;
}

.forecast-top {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.forecast-top span {
  color: #587066;
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.forecast-scale {
  margin: -2px 0 6px;
  color: var(--deep-green);
  font-size: 0.7rem;
  font-weight: 850;
}

.forecast-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.forecast-badge {
  padding: 4px 6px;
  border: 1px solid rgba(16, 24, 32, 0.1);
  border-radius: 8px;
  background: #eefaf3;
  color: #244438;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1;
}

.forecast-badge.hidden,
.forecast-badge.shift {
  background: #ecf7ff;
  color: #155e75;
}

.forecast-badge.shield {
  background: #f3edff;
  color: #5b21b6;
}

.forecast-badge.event {
  background: #fff7d8;
  color: #6f4e05;
}

.forecast-action {
  margin: 0 0 6px;
  color: #244438;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.2;
}

.row-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.row-chip {
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(220, 76, 85, 0.12);
  color: #9c1f2a;
  font-size: 0.66rem;
  font-weight: 900;
}

.wave-forecast ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wave-forecast li {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  color: #587066;
  font-size: 0.7rem;
}

.wave-forecast li strong {
  color: var(--ink);
}

.map-trait-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.map-trait {
  display: inline-grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  max-width: 100%;
  padding: 4px 6px;
  border: 1px solid rgba(17, 150, 85, 0.18);
  border-radius: 8px;
  background: #f7fffa;
  color: #244438;
  font-size: 0.64rem;
  font-weight: 850;
  line-height: 1.1;
}

.map-trait img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.debug-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  align-items: center;
  margin-bottom: 8px;
  padding: 6px;
  border: 1px dashed rgba(16, 24, 32, 0.2);
  border-radius: 8px;
  background: #fffdf4;
}

.debug-strip strong,
.debug-strip button {
  min-width: 0;
  min-height: 30px;
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
}

.debug-strip strong {
  display: grid;
  place-items: center;
  color: #6f4e05;
  text-align: center;
}

.debug-strip button {
  padding: 5px 3px;
  border: 1px solid rgba(111, 78, 5, 0.18);
  background: #ffffff;
  color: #244438;
}

.build-advice {
  display: grid;
  gap: 7px;
  padding: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f4fff8 100%);
}

.build-advice-main {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.build-advice-main img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(18, 32, 51, 0.14));
}

.build-advice-main strong {
  display: block;
  font-size: 0.8rem;
}

.build-advice-main em,
.build-advice-alt {
  display: block;
  color: #587066;
  font-size: 0.67rem;
  font-style: normal;
  line-height: 1.2;
}

.build-advice .secondary-action {
  min-height: 38px;
}

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

.shop-card,
.tower-action {
  padding: 9px;
  border: 1px solid var(--line-green);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 7px 18px rgba(18, 32, 51, 0.07);
}

.shop-card {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.shop-card img {
  width: 31px;
  height: 31px;
  object-fit: contain;
}

.shop-card-body {
  display: block;
  min-width: 0;
}

.shop-card.selected {
  border-color: var(--physics-green);
  outline: 2px solid rgba(34, 198, 112, 0.18);
}

.shop-card.locked {
  background: #f7f9f8;
}

.shop-card.locked img {
  filter: grayscale(0.85) opacity(0.72);
}

.shop-card:disabled,
.tower-action:disabled,
.power-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.shop-card.locked:disabled {
  opacity: 0.72;
}

.shop-card strong,
.tower-action strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.88rem;
}

.shop-note,
.tower-action span {
  display: block;
  color: #587066;
  font-size: 0.72rem;
  line-height: 1.24;
}

.shop-cost {
  display: block;
  margin-top: 7px;
  color: var(--deep-green);
  font-weight: 900;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.primary-action,
.secondary-action {
  padding: 0 14px;
  font-weight: 900;
}

.primary-action {
  background: var(--physics-green);
  color: #04110d;
  box-shadow: 0 10px 24px rgba(34, 198, 112, 0.28);
}

.secondary-action {
  border: 1px solid var(--line-green);
  background: #ffffff;
  color: var(--ink);
}

.power-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.wave-intel {
  display: grid;
  gap: 7px;
  padding: 8px;
  background: #f7fffa;
}

.wave-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dceee6;
}

.wave-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--physics-green), var(--gold));
}

.wave-intel-row strong {
  font-size: 0.78rem;
}

.wave-intel-row.muted em {
  color: #244438;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 850;
  text-align: right;
}

.power-primer {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
}

.power-primer span {
  color: #587066;
  font-size: 0.66rem;
  line-height: 1.18;
}

.power-primer strong {
  color: var(--ink);
}

.power-button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  padding: 7px 6px;
  background: var(--night-green);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.power-button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.power-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.power-button em {
  padding: 3px 4px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.62rem;
  font-style: normal;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  background: rgba(6, 25, 20, 0.36);
  backdrop-filter: blur(8px);
}

.overlay.visible {
  display: grid;
}

.overlay-panel {
  width: min(100%, 520px);
  max-height: calc(100dvh - 30px);
  overflow: auto;
  border: 1px solid rgba(212, 233, 221, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.start-panel,
.summary-panel {
  padding: 18px;
}

.question-panel {
  padding: 14px;
  display: grid;
  gap: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--deep-green);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 10vw, 3.8rem);
  line-height: 0.95;
}

.lede {
  margin: 10px 0 16px;
  color: #456158;
  line-height: 1.45;
}

.chooser-block {
  margin-top: 14px;
}

.chooser-block h2 {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.segmented-control button {
  padding: 0 6px;
  border: 1px solid var(--line-green);
  background: #ffffff;
  color: #334b42;
  font-size: 0.74rem;
  font-weight: 900;
}

.segmented-control button.active,
.map-choice.active {
  border-color: var(--physics-green);
  background: #e7fff2;
  color: #032016;
}

.map-choice-grid {
  display: grid;
  gap: 8px;
}

.map-choice {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line-green);
  background: #ffffff;
  text-align: left;
}

.map-choice img {
  width: 88px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
}

.map-choice strong {
  display: block;
  margin-bottom: 2px;
}

.map-choice em {
  display: block;
  color: #587066;
  font-size: 0.78rem;
  font-style: normal;
  line-height: 1.25;
}

.small-print {
  margin: 10px 0 0;
  color: #657a72;
  font-size: 0.75rem;
}

.question-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--deep-green);
  font-size: 0.8rem;
  font-weight: 900;
  margin-bottom: 8px;
}

#questionTitle {
  margin-bottom: 12px;
  font-size: clamp(1.15rem, 5vw, 1.55rem);
  line-height: 1.2;
}

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

.answer-option {
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.answer-option.correct {
  border-color: var(--physics-green);
  background: #e8fff3;
}

.answer-option.incorrect {
  border-color: var(--coral);
  background: #fff0f1;
}

.feedback-box {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: var(--soft-mint);
  color: #244438;
  line-height: 1.35;
}

@media (max-height: 520px) and (orientation: landscape) {
  .overlay {
    padding: 6px;
  }

  .question-panel {
    width: min(96vw, 760px);
    max-height: calc(100dvh - 12px);
    overflow: hidden;
    padding: 10px;
  }

  .question-topline {
    margin-bottom: 5px;
    font-size: 0.72rem;
  }

  #questionTitle {
    margin: 0 0 8px;
    font-size: clamp(0.92rem, 3.2vw, 1.14rem);
    line-height: 1.12;
  }

  .answer-grid {
    gap: 6px;
  }

  .answer-option {
    min-height: 42px;
    padding: 8px 9px;
    font-size: 0.78rem;
    line-height: 1.16;
  }

  .feedback-box {
    max-height: 58px;
    margin: 6px 0 0;
    padding: 7px 8px;
    overflow: auto;
    font-size: 0.72rem;
    line-height: 1.22;
  }
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.stat-tile {
  padding: 10px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: var(--soft-mint);
}

.stat-tile span {
  display: block;
  color: #587066;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-tile strong {
  display: block;
  margin-top: 3px;
  font-size: 1.15rem;
}

.leaderboard-card {
  grid-column: 1 / -1;
  padding: 10px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
}

.leaderboard-card h3 {
  margin: 0 0 7px;
  font-size: 0.9rem;
}

.leaderboard-card ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-card li {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  color: #587066;
  font-size: 0.74rem;
  font-weight: 800;
}

.leaderboard-card li strong {
  color: var(--ink);
}

.summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.summary-actions #shareBtn {
  grid-column: 1 / -1;
}

.start-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.38fr);
  gap: 8px;
}

.guide-panel {
  width: min(100%, 760px);
  padding: 14px;
}

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

.guide-heading .icon-button {
  grid-area: auto;
  flex: 0 0 38px;
}

.guide-content {
  display: grid;
  gap: 12px;
}

.guide-section h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

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

.guide-tip {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(61, 126, 99, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7fff9 0%, #edf8f1 100%);
}

.guide-tip strong {
  display: block;
  margin-bottom: 3px;
  color: var(--night-green);
  font-size: 0.74rem;
}

.guide-tip p {
  margin: 0;
  color: #587066;
  font-size: 0.64rem;
  line-height: 1.25;
}

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

.guide-entry {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  background: #ffffff;
}

.guide-entry img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(18, 32, 51, 0.15));
}

.guide-entry strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.84rem;
}

.guide-entry p {
  margin: 0;
  color: #587066;
  font-size: 0.7rem;
  line-height: 1.24;
}

.guide-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.guide-tags span {
  padding: 3px 5px;
  border-radius: 7px;
  background: #e8f8ef;
  color: var(--night-green);
  font-size: 0.6rem;
  font-weight: 900;
  line-height: 1.1;
}

@media (max-width: 720px) and (orientation: landscape) {
  .guide-tips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (orientation: portrait) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100dvh;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(300px, 42dvh) auto;
  }

  .top-hud {
    grid-template-columns: minmax(112px, 1fr) minmax(112px, 0.7fr) 36px 36px 36px;
    gap: 5px;
  }

  .game-stage {
    grid-column: 1;
    grid-row: 2;
    min-height: 300px;
    opacity: 0.45;
    pointer-events: none;
  }

  .game-stage::after {
    content: "Rotate to landscape to play the defence grid";
    position: absolute;
    inset: 16px;
    display: grid;
    place-items: center;
    padding: 18px;
    border: 1px solid rgba(17, 150, 85, 0.22);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
    backdrop-filter: blur(10px);
  }

  .control-panel {
    position: static;
    grid-column: 1;
    grid-row: 3;
    width: auto;
    max-height: none;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid rgba(17, 150, 85, 0.16);
    transform: none;
  }

  .quick-tower-rail,
  .panel-scrim,
  .app-shell.panel-open .panel-scrim {
    display: none;
  }

  .overlay {
    align-items: start;
    padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
    overflow: auto;
  }

  .overlay-panel {
    max-height: none;
  }

  .start-panel {
    padding: 14px;
  }

  .start-actions,
  .summary-actions {
    grid-template-columns: 1fr;
  }

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

  .map-choice-grid {
    grid-template-columns: 1fr;
  }

  .guide-panel {
    width: min(100%, 560px);
  }

  .guide-tips {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1000px) {
  body {
    display: grid;
    place-items: center;
    overflow: auto;
    padding: 18px;
  }

  .app-shell {
    width: min(1120px, 100vw);
    height: min(720px, calc(100dvh - 36px));
    border: 1px solid rgba(17, 150, 85, 0.22);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
}

@media (pointer: coarse) {
  .top-hud,
  .route-banner,
  .panel-scrim,
  .quick-tower-rail,
  .game-stage::after {
    backdrop-filter: none;
  }

  .route-banner,
  .quick-tower-rail {
    background: rgba(255, 255, 255, 0.97);
  }

  .quick-tower-rail {
    box-shadow: 0 7px 18px rgba(6, 25, 20, 0.14);
  }
}

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