:root {
  font-family: ui-rounded, "Avenir Next", Avenir, system-ui, sans-serif;
  color: #f2f6fc;
  background: #060b18;
  font-synthesis: none;
  --gold: #ffc86b;
  --mint: #83efdb;
  --muted: #a4b7cc;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid white;
  outline-offset: 5px;
}
button {
  color: inherit;
}
#game {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 320px;
  overflow: hidden;
  background: #080e20;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
}
#screen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: auto;
}
#screen > * {
  pointer-events: auto;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: clamp(56px, 8vw, 116px);
  font-weight: 950;
  line-height: 0.9;
  letter-spacing: -0.055em;
  text-shadow: 0 5px 40px #0007;
}
h1 span {
  color: var(--gold);
}
h2 {
  font-size: clamp(26px, 4vw, 48px);
  letter-spacing: -0.04em;
  line-height: 1.08;
}
h3 {
  font-size: 22px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--mint);
}
.title-layout {
  min-height: 100%;
  display: flex;
  align-items: center;
  padding: 5% 8%;
  background: linear-gradient(90deg, #060d20dc, transparent 77%);
}
.title-copy {
  width: 48%;
  max-width: 590px;
}
.title-copy .eyebrow {
  margin-bottom: 22px;
}
.subtitle {
  color: #bacbdd;
  line-height: 1.7;
  margin: 24px 0;
  max-width: 330px;
  font-size: 16px;
}
.menu-stack {
  display: grid;
  gap: 10px;
  width: 270px;
  margin-top: 28px;
}
.btn {
  border: 1px solid #6b829744;
  background: #142438e8;
  border-radius: 12px;
  padding: 15px 22px;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.07em;
  min-height: 48px;
  transition:
    background 0.15s,
    transform 0.15s;
}
.btn:hover {
  background: #263d58;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--gold);
  color: #142031;
  border-color: var(--gold);
  box-shadow: 0 5px 24px #efaa3022;
}
.btn.primary:hover {
  background: #ffdb97;
}
.btn.small {
  padding: 10px 14px;
}
.menu-row {
  display: flex;
  gap: 8px;
}
.menu-row .btn {
  flex: 1;
  font-size: 10px;
  padding: 12px 8px;
}
.footer-note {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: #8396ad;
  margin-top: 26px;
}
.panel-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #050b18ad;
  backdrop-filter: blur(8px);
}
.panel {
  width: min(790px, 100%);
  background: linear-gradient(145deg, #182b42f5, #0c172bf5);
  border: 1px solid #617e9755;
  border-radius: 24px;
  box-shadow: 0 25px 80px #0007;
  padding: 36px;
}
.panel > .eyebrow {
  margin-bottom: 12px;
}
.panel > p {
  color: #b6c7d9;
  line-height: 1.7;
  margin: 18px 0;
}
.panel .buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}
.slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 28px;
}
.slot {
  text-align: left;
  min-height: 190px;
  padding: 20px;
  letter-spacing: 0;
}
.slot b,
.slot span {
  display: block;
}
.slot b {
  font-size: 18px;
  margin: 20px 0 12px;
}
.slot span {
  font-size: 12px;
  line-height: 1.7;
  color: #b7c9db;
}
.slot .slot-number {
  color: var(--mint);
  font-size: 11px;
  letter-spacing: 0.13em;
}
.map-ui {
  min-height: 100%;
  padding: 35px 5%;
  display: flex;
  flex-direction: column;
  pointer-events: none !important;
}
.map-ui button {
  pointer-events: auto;
}
.map-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
}
.map-header h2 {
  font-size: 34px;
  margin-top: 8px;
}
.map-header .part-count {
  font-size: 13px;
  border: 1px solid #8bdcca55;
  border-radius: 30px;
  padding: 12px 20px;
  color: var(--mint);
  background: #0c1c2bd9;
}
.map-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 15px;
}
.map-hint {
  max-width: 320px;
  color: #afc3da;
  font-size: 13px;
  line-height: 1.6;
}
.planet-buttons {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.planet-hit {
  position: absolute;
  transform: translate(-50%, -50%);
  background: none;
  border: 0;
  width: 100px;
  height: 110px;
  padding-top: 70px;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 750;
  text-shadow: 0 2px 6px black;
  pointer-events: auto;
  white-space: nowrap;
}
.planet-hit.moon {
  color: var(--gold);
  width: 154px;
  height: 125px;
  padding-top: 83px;
}
.planet-hit small {
  display: block;
  color: #8ddfce;
  font-size: 9px;
  margin-top: 4px;
}
.planet-hit:hover {
  filter: brightness(1.5);
}
#hud {
  position: absolute;
  left: 24px;
  right: 24px;
  top: max(20px, env(safe-area-inset-top));
  display: flex;
  gap: 20px;
  align-items: start;
  pointer-events: none;
}
#hud[hidden],
#touch[hidden],
#dialogue[hidden] {
  display: none;
}
.hud-left {
  min-width: 180px;
}
.stats {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 6px;
  text-shadow: 0 2px 6px #000;
}
.stats #hearts {
  color: #ff858e;
  font-size: 23px;
  letter-spacing: 3px;
}
.stats #stars {
  color: var(--gold);
  font-weight: 800;
  font-size: 17px;
}
.objective {
  margin: auto;
  background: #0b172ae0;
  border: 1px solid #8ca6c62b;
  padding: 12px 20px;
  border-radius: 12px;
  max-width: 480px;
}
.objective .eyebrow {
  display: block;
  font-size: 9px;
  margin-bottom: 5px;
}
.objective strong {
  font-size: 13px;
}
.icon-button {
  border: 1px solid #8aa6c24d;
  background: #142438e8;
  border-radius: 12px;
  min-width: 46px;
  min-height: 46px;
  pointer-events: auto;
}
#dialogue {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 70%);
  background: #101f33f5;
  border: 1px solid #7cd4d571;
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  box-shadow: 0 12px 50px #0007;
  z-index: 5;
}
.avatar {
  flex: none;
  width: 48px;
  height: 48px;
  border: 2px solid #6aecd7;
  border-radius: 14px;
  background: #224b59;
  display: grid;
  place-items: center;
  font-size: 24px;
  box-shadow: inset 0 0 16px #75ead833;
}
.dialogue-copy {
  flex: 1;
}
.dialogue-copy b {
  display: block;
  color: var(--mint);
  font-size: 11px;
  letter-spacing: 0.16em;
  margin-bottom: 5px;
}
.dialogue-copy p {
  font-size: 14px;
  line-height: 1.5;
}
.dialogue-next {
  border: 0;
  background: #294254;
  color: var(--mint);
  border-radius: 9px;
  min-width: 44px;
  min-height: 44px;
  font-size: 22px;
}
#toast {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: #182e43f2;
  color: var(--gold);
  border: 1px solid #ffc76b77;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  text-align: center;
  z-index: 12;
}
#toast.visible {
  opacity: 1;
}
#context {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.12em;
  background: #091627c9;
  border-radius: 20px;
  padding: 10px 18px;
  pointer-events: none;
  white-space: nowrap;
}
#context:empty {
  display: none;
}
#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#joystick {
  position: absolute;
  bottom: max(25px, env(safe-area-inset-bottom));
  left: 30px;
  width: 120px;
  height: 120px;
  border: 2px solid #e5f2ff40;
  background: #08152850;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
}
#joystick:before,
#joystick:after {
  content: "";
  position: absolute;
  background: #e5f2ff15;
}
#joystick:before {
  left: 50%;
  top: 10%;
  width: 1px;
  height: 80%;
}
#joystick:after {
  top: 50%;
  left: 10%;
  height: 1px;
  width: 80%;
}
#stick {
  position: absolute;
  width: 50px;
  height: 50px;
  left: 33px;
  top: 33px;
  background: #b8d2e376;
  border: 2px solid #d9f4ff99;
  border-radius: 50%;
  pointer-events: none;
}
#action {
  position: absolute;
  right: 30px;
  bottom: 36px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: #ffc86bec;
  border: 5px solid #fff3;
  color: #142333;
  font-size: 11px;
  font-weight: 900;
  pointer-events: auto;
  touch-action: none;
}
#portrait {
  display: none;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: #c1d3e5;
  pointer-events: none;
}
#save-status {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-size: 10px;
  color: #94b3bc;
  pointer-events: none;
}
.puzzle-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #081522;
  border: 1px solid #45617466;
  border-radius: 16px;
  padding: 20px;
  margin: 22px 0;
}
.symbol {
  display: inline-grid;
  place-items: center;
  font-size: 32px;
  min-width: 40px;
  height: 46px;
}
.symbol.blue {
  color: #79c9ff;
}
.symbol.gold {
  color: #ffd077;
}
.symbol.pink {
  color: #e593c4;
}
.symbol-key {
  min-width: 76px;
  min-height: 70px;
  border-radius: 13px;
  background: #1b3049;
  border: 1px solid #57748b;
}
.puzzle-keys {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.answer-box {
  border: 1px dashed #6e8aa4;
  border-radius: 9px;
  min-width: 40px;
  text-align: center;
}
.hint {
  color: var(--mint) !important;
  min-height: 46px;
  font-size: 14px;
}
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 25px 0;
  font-size: 14px;
  line-height: 1.9;
  color: #bed0e2;
}
.help-grid b {
  color: #fff;
}
.story-step {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.15em;
  margin: 15px 0;
}
.story-visual {
  height: 100px;
  display: flex;
  justify-content: center;
  gap: 32px;
  align-items: center;
  font-size: 55px;
  margin: 20px 0;
}
.success h2 {
  color: var(--gold);
}
.success .big-part {
  font-size: 70px;
  text-align: center;
  margin: 20px;
  color: var(--mint);
}
@media (max-height: 650px) {
  .title-layout {
    padding: 3% 7%;
  }
  .title-copy .eyebrow {
    margin-bottom: 12px;
  }
  .subtitle {
    margin: 14px 0;
  }
  .menu-stack {
    margin-top: 16px;
    gap: 7px;
  }
  .btn {
    padding: 12px 19px;
  }
  .footer-note {
    margin-top: 15px;
  }
  .panel {
    padding: 24px;
  }
  .map-ui {
    padding: 24px 4%;
  }
  .map-header h2 {
    font-size: 27px;
  }
  .puzzle-sequence {
    margin: 15px 0;
    padding: 12px;
  }
  #dialogue {
    bottom: 16px;
  }
}
@media (pointer: coarse) {
  #dialogue {
    bottom: 20px;
    width: calc(100% - 330px);
    min-width: 330px;
  }
  #context {
    bottom: 18px;
  }
  .dialogue-copy p {
    font-size: 13px;
  }
}
@media (max-width: 700px) {
  .title-copy {
    width: 75%;
  }
  .title-copy h1 {
    font-size: 66px;
  }
  .slots {
    grid-template-columns: 1fr;
    gap: 9px;
  }
  .slot {
    min-height: 95px;
    padding: 15px;
  }
  .slot b {
    margin: 6px 0;
  }
  .panel-wrap {
    padding: 15px;
  }
  .map-header h2 {
    font-size: 25px;
  }
  .map-header .part-count {
    font-size: 10px;
    padding: 10px;
  }
  .planet-hit {
    width: 66px;
    font-size: 9px;
  }
  .hud-left {
    min-width: 110px;
  }
  .hud-left .eyebrow {
    font-size: 8px;
  }
  .stats {
    gap: 8px;
  }
  .stats #hearts {
    font-size: 17px;
  }
  .objective {
    padding: 9px;
    max-width: 230px;
  }
  .objective strong {
    font-size: 11px;
  }
  #hud {
    left: 12px;
    right: 12px;
    gap: 8px;
  }
  .help-grid {
    grid-template-columns: 1fr;
  }
  .symbol {
    font-size: 25px;
    min-width: 28px;
  }
  .puzzle-sequence {
    gap: 4px;
  }
  #dialogue {
    width: 90%;
    bottom: 170px;
    min-width: 0;
  }
  .map-hint {
    max-width: 210px;
    font-size: 11px;
  }
}
@media (orientation: portrait) and (pointer: coarse) {
  #portrait {
    display: block;
  }
  .title-copy {
    width: 100%;
  }
  .map-footer {
    padding-bottom: 22px;
  }
}

@media (pointer: fine) {
  #touch {
    display: none;
  }
}
@keyframes part-found {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.6) rotate(-12deg);
  }
  65% {
    opacity: 1;
    transform: translateY(-4px) scale(1.08) rotate(3deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0);
  }
}
.success .big-part {
  animation: part-found 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  text-shadow: 0 0 32px #83efdb70;
}
@media (prefers-reduced-motion: reduce) {
  .success .big-part {
    animation: none;
  }
}
/* Phase 2: the overlay itself must never intercept menu clicks.
   #screen > * otherwise wins over the old .planet-buttons rule. */
#screen > .planet-buttons {
  pointer-events: none;
}
.planet-buttons > button {
  pointer-events: auto;
}
.planet-hit.available {
  color: var(--gold);
}
.planet-hit.completed {
  color: var(--mint);
}
.map-hint {
  font-size: 16px;
  max-width: 470px;
}
.map-header .part-count {
  font-size: 18px;
}
#dialogue {
  width: min(960px, calc(100% - 48px));
  min-width: 0;
  bottom: 28px;
  padding: 26px 30px;
  gap: 22px;
  border: 2px solid #8af0d8;
  border-radius: 22px;
  background: #102339;
  box-shadow: 0 12px 60px #000b;
}
.dialogue-copy p {
  font-size: clamp(22px, 2.1vw, 28px);
  line-height: 1.45;
  color: #fff;
}
.dialogue-copy b {
  font-size: 18px;
  letter-spacing: 0.14em;
  margin-bottom: 10px;
}
.avatar {
  width: 64px;
  height: 64px;
  font-size: 36px;
}
.dialogue-next {
  min-width: 64px;
  min-height: 64px;
  font-size: 36px;
  background: #295c65;
}
#dialogue[data-speaker="alien"] {
  border-color: #eac582;
}
#dialogue[data-speaker="alien"] .dialogue-copy b {
  color: #ffdc95;
}
.has-dialogue #context {
  display: none;
}
.has-dialogue #touch {
  visibility: hidden;
}
.objective {
  max-width: 580px;
  padding: 15px 20px;
  background: #0b192ded;
  border: 1px solid #839cab66;
}
.objective strong {
  font-size: clamp(18px, 1.8vw, 24px);
  line-height: 1.35;
  display: block;
}
.objective .eyebrow {
  font-size: 12px;
}
#toast {
  top: 130px;
  font-size: clamp(19px, 2vw, 24px);
  padding: 17px 26px;
  width: max-content;
  max-width: calc(100% - 40px);
  background: #12283e;
  border: 2px solid #ffd68b;
}
#context {
  font-size: 16px;
  font-weight: 800;
  background: #0a182cef;
  letter-spacing: 0.03em;
}
#action {
  font-size: 13px;
}
.help-button {
  padding: 0 10px;
  color: var(--mint);
  font-weight: 900;
}
.help-button[hidden] {
  display: none;
}
.save-panel {
  width: min(1040px, 100%);
}
.slot {
  border: 1px solid #6a8ba566;
  border-radius: 16px;
  background: #0b1a2b;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.slot b {
  margin: 5px 0;
}
.slot span {
  font-size: 16px;
}
.slot p {
  font-size: 18px;
  line-height: 1.5;
}
.slot .btn {
  width: 100%;
  padding: 12px 8px;
}
.slot .slot-active {
  font-size: 14px;
  color: var(--mint);
}
.slot .reset-button {
  margin-top: auto;
  color: #ffc6b9;
  background: #332c39;
}
.panel > p {
  font-size: 18px;
  line-height: 1.5;
}
.hint {
  font-size: 19px;
}
.thermal-panel {
  width: min(950px, 100%);
}
.thermal-chambers {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 20px 0;
}
.chamber {
  border: 2px solid #516f85;
  border-radius: 14px;
  background: #0b1a2d;
  padding: 15px 22px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.chamber.selected {
  border-color: #ffcf7d;
  box-shadow: 0 0 0 3px #ffcf7d33;
}
.chamber > b {
  font-size: 13px;
  letter-spacing: 0.07em;
}
.thermometer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 72px;
}
.meter-cell {
  height: 15px;
  border-radius: 3px;
  background: #334052;
  color: #98ffd9;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}
.meter-cell.filled {
  background: #eeaa66;
}
.meter-cell.target {
  outline: 2px solid #91ebbb;
  padding-left: 78px;
}
.chamber > span:last-child {
  font-size: 27px;
  min-height: 36px;
}
.thermal-value {
  font-size: 11px;
}
.thermal-cards {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.energy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  flex: 1;
  letter-spacing: 0;
}
.energy strong {
  font-size: 30px;
}
.energy span {
  font-size: 15px;
}
.energy small {
  font-size: 9px;
}
.energy.warm {
  color: #ffcc88;
}
.energy.cold {
  color: #9fdaff;
}
@media (max-width: 1100px) {
  #hud {
    gap: 10px;
    left: 18px;
    right: 18px;
  }
  .hud-left {
    min-width: 145px;
  }
  .objective {
    max-width: 480px;
  }
  #dialogue {
    padding: 22px 24px;
    gap: 18px;
  }
}
@media (max-height: 680px) {
  #dialogue {
    bottom: 18px;
    padding: 18px 22px;
  }
  .dialogue-copy p {
    font-size: 21px;
  }
  .thermal-chambers {
    margin: 12px 0;
    gap: 12px;
  }
  .chamber {
    padding: 10px 18px;
    gap: 6px;
  }
  .meter-cell {
    height: 12px;
  }
  .panel > p {
    margin: 12px 0;
  }
}
@media (max-width: 700px) {
  #dialogue {
    width: calc(100% - 24px);
    bottom: 30px;
    gap: 12px;
    padding: 18px;
  }
  .avatar {
    display: none;
  }
  .dialogue-copy p {
    font-size: 20px;
  }
  .dialogue-copy b {
    font-size: 16px;
  }
  .dialogue-next {
    min-width: 50px;
    min-height: 60px;
  }
  .objective strong {
    font-size: 17px;
  }
  .hud-left {
    min-width: 105px;
  }
  .objective {
    padding: 10px;
    max-width: 290px;
  }
  .objective .eyebrow {
    font-size: 10px;
  }
  #context {
    font-size: 12px;
    max-width: calc(100% - 40px);
    white-space: normal;
    text-align: center;
  }
  .map-hint {
    font-size: 13px;
    max-width: 240px;
  }
  .map-header .part-count {
    font-size: 13px;
  }
  .thermal-chambers {
    gap: 6px;
  }
  .chamber {
    min-width: 0;
    flex: 1;
    padding: 10px 4px;
  }
  .thermometer {
    width: 40px;
  }
  .meter-cell.target {
    padding-left: 42px;
    font-size: 9px;
  }
  .energy {
    padding: 12px 5px;
  }
  .energy span {
    font-size: 12px;
  }
  .energy small {
    display: none;
  }
}
.touch-preview #touch:not([hidden]) {
  display: block;
}
.meter-cell.target {
  padding-left: 0;
  text-align: center;
  font-size: 10px;
  color: #ccffe4;
}
.meter-cell.target.filled {
  background: #8ce0b1;
  color: #102c22;
}
