/* style.css — all styling */
:root {
  color-scheme: dark;
  --ink: #f4f0e7;
  --muted: #a5aca3;
  --faint: #707b73;
  --paper: #0e1513;
  --surface: #17211d;
  --surface-2: #202c26;
  --surface-3: #26362e;
  --line: rgba(224, 213, 183, .16);
  --line-strong: rgba(224, 213, 183, .3);
  --gold: #d4a65b;
  --gold-bright: #f0cd83;
  --sage: #91b096;
  --danger: #dc9078;
  --shadow: 0 28px 90px rgba(0, 0, 0, .3);
  --radius: 4px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ink: #202721;
    --muted: #69736b;
    --faint: #8a948c;
    --paper: #f0eee6;
    --surface: #fffdf7;
    --surface-2: #f4f0e5;
    --surface-3: #ebe5d6;
    --line: rgba(48, 59, 50, .15);
    --line-strong: rgba(48, 59, 50, .28);
    --gold: #a8792d;
    --gold-bright: #bd8e3d;
    --sage: #59755f;
    --danger: #ae6752;
    --shadow: 0 28px 80px rgba(66, 57, 39, .13);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f0e7;
  --muted: #a5aca3;
  --faint: #707b73;
  --paper: #0e1513;
  --surface: #17211d;
  --surface-2: #202c26;
  --surface-3: #26362e;
  --line: rgba(224, 213, 183, .16);
  --line-strong: rgba(224, 213, 183, .3);
  --gold: #d4a65b;
  --gold-bright: #f0cd83;
  --sage: #91b096;
  --danger: #dc9078;
  --shadow: 0 28px 90px rgba(0, 0, 0, .3);
}

html[data-theme="light"] {
  color-scheme: light;
  --ink: #202721;
  --muted: #69736b;
  --faint: #8a948c;
  --paper: #f0eee6;
  --surface: #fffdf7;
  --surface-2: #f4f0e5;
  --surface-3: #ebe5d6;
  --line: rgba(48, 59, 50, .15);
  --line-strong: rgba(48, 59, 50, .28);
  --gold: #a8792d;
  --gold-bright: #bd8e3d;
  --sage: #59755f;
  --danger: #ae6752;
  --shadow: 0 28px 80px rgba(66, 57, 39, .13);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 82% -5%, rgba(212, 166, 91, .13), transparent 34rem),
    radial-gradient(ellipse at -10% 70%, rgba(91, 128, 103, .08), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color .35s ease, color .35s ease;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 100% 5px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.shell {
  width: min(1260px, 100%);
  min-height: 100dvh;
  margin: auto;
  padding: clamp(22px, 4vw, 54px) clamp(16px, 5vw, 68px) calc(56px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: clamp(25px, 4vw, 48px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: arrive .7s both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  color: var(--gold);
  filter: drop-shadow(0 0 12px rgba(212,166,91,.18));
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.eyebrow,
.section-label,
.panel-label,
.kicker,
.footer {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 9px;
}

h1 {
  margin: 0;
  color: var(--ink);
  font: 600 clamp(17px, 2vw, 21px)/1.1 Georgia, serif;
  letter-spacing: .02em;
}

.mission-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .13em;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--sage);
  border-radius: 50%;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--sage) 16%, transparent);
  animation: pulse 2.8s ease-in-out infinite;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, .9fr);
  gap: clamp(28px, 6vw, 94px);
  align-items: center;
  animation: arrive .8s .08s both;
}

.intro-panel {
  padding: 10px 0;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  margin-bottom: 20px;
}

.kicker-line {
  display: inline-block;
  width: 26px;
  height: 1px;
  background: var(--gold);
}

h2 {
  margin: 0 0 25px;
  color: var(--ink);
  font: 500 clamp(38px, 6vw, 73px)/.97 Georgia, serif;
  letter-spacing: -.06em;
}

h2 em {
  color: var(--gold-bright);
  font-style: italic;
}

.intro-copy {
  max-width: 480px;
  margin: 0 0 25px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.72;
}

.rule {
  width: 100%;
  max-width: 480px;
  height: 1px;
  margin-bottom: 20px;
  background: linear-gradient(90deg, var(--line-strong), var(--line), transparent);
}

.objective {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 450px;
  margin: 13px 0;
}

.objective-number {
  color: var(--gold);
  font: 600 13px ui-monospace, monospace;
}

.objective strong,
.objective span {
  display: block;
}

.objective strong {
  margin-bottom: 3px;
  font-size: 12px;
}

.objective div span {
  color: var(--muted);
  font-size: 12px;
}

.start-button {
  min-height: 52px;
  margin-top: 25px;
  padding: 0 19px 0 21px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  color: var(--paper);
  background: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 23px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  box-shadow: 0 9px 24px rgba(212, 166, 91, .13);
  transition: transform .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}

.start-button:hover {
  transform: translateY(-2px);
  background: var(--gold-bright);
  box-shadow: 0 13px 30px rgba(212, 166, 91, .2);
}

.start-button:active {
  transform: translateY(0);
}

.start-button.restart {
  background: transparent;
  color: var(--gold-bright);
  box-shadow: none;
}

.button-arrow {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: transform .2s ease;
}

.start-button:hover .button-arrow {
  transform: translateX(3px);
}

.fine-print {
  margin: 12px 0 0;
  color: var(--faint);
  font-size: 11px;
}

.room-panel,
.game-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.room-panel {
  padding: 18px;
  border-radius: var(--radius);
}

.room-panel-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font: 10px ui-monospace, monospace;
  color: var(--faint);
}

.room-coordinates {
  color: var(--gold);
  text-align: right;
}

.room-illustration {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1.25;
  min-height: 220px;
  margin: 18px 0;
  isolation: isolate;
  border: 1px solid rgba(212, 166, 91, .24);
  background:
    radial-gradient(circle at 50% 50%, rgba(212, 166, 91, .2), transparent 36%),
    radial-gradient(circle at 23% 24%, rgba(145, 176, 150, .12), transparent 2px),
    #16201c;
}

.room-illustration::before,
.room-illustration::after {
  position: absolute;
  content: "";
  pointer-events: none;
  opacity: .35;
}

.room-illustration::before {
  inset: 0;
  background: linear-gradient(90deg, transparent 49.8%, rgba(212,166,91,.22) 50%, transparent 50.2%);
}

.room-illustration::after {
  inset: 10%;
  border: 1px solid rgba(212,166,91,.1);
  transform: rotate(45deg);
}

.axis {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  opacity: .45;
  background: var(--gold);
}

.axis-horizontal {
  width: 78%;
  height: 1px;
  transform: translate(-50%, -50%);
}

.axis-vertical {
  width: 1px;
  height: 78%;
  transform: translate(-50%, -50%);
}

.orbit {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(212, 166, 91, .45);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
}

.orbit-one {
  width: 45%;
  height: 75%;
}

.orbit-two {
  width: 68%;
  height: 45%;
  border-color: rgba(145, 176, 150, .45);
  transform: translate(-50%, -50%) rotate(42deg);
}

.orbit-three {
  width: 92%;
  height: 28%;
  border-color: rgba(212, 166, 91, .25);
  transform: translate(-50%, -50%) rotate(-8deg);
}

.sun-core {
  position: absolute;
  z-index: 4;
  left: calc(50% - 29px);
  top: calc(50% - 29px);
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 35px rgba(212, 166, 91, .2), inset 0 0 15px rgba(212, 166, 91, .1);
  animation: breathe 4s ease-in-out infinite;
}

.sun-core span {
  width: 19px;
  height: 19px;
  border: 2px solid var(--gold);
  border-radius: 50%;
}

.needle {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 42%;
  background: var(--gold-bright);
  transform-origin: 50% 0;
}

.needle-a {
  transform: rotate(27deg);
}

.needle-b {
  height: 31%;
  background: var(--sage);
  transform: rotate(-116deg);
}

.star {
  position: absolute;
  z-index: 4;
  width: 4px;
  height: 4px;
  border: 1px solid var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(240,205,131,.55);
}

.star-one {
  left: 19%;
  top: 29%;
}

.star-two {
  right: 21%;
  top: 20%;
  width: 3px;
  height: 3px;
}

.star-three {
  right: 15%;
  bottom: 28%;
}

.illustration-label {
  position: absolute;
  z-index: 5;
  color: var(--faint);
  font: 9px ui-monospace, monospace;
  letter-spacing: .18em;
}

.label-top {
  top: 13px;
  left: 16px;
}

.label-bottom {
  right: 16px;
  bottom: 13px;
}

.room-caption {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font: italic 13px Georgia, serif;
}

.caption-line {
  width: 28px;
  height: 1px;
  background: var(--gold);
}

.game-card {
  overflow: hidden;
  border-radius: var(--radius);
  animation: arrive .8s .16s both;
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(18px, 4vw, 34px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(212,166,91,.04), transparent 60%);
}

.section-label,
.panel-label {
  color: var(--muted);
}

.progress-dots {
  display: flex;
  gap: 7px;
  margin-top: 11px;
}

.progress-dot {
  width: clamp(20px, 5vw, 32px);
  height: 4px;
  background: var(--surface-3);
  transition: background .3s ease, transform .3s ease;
}

.progress-dot.active {
  background: var(--gold);
  transform: scaleY(1.5);
}

.progress-dot.complete {
  background: var(--sage);
}

.timer-block {
  text-align: right;
}

.timer-block strong {
  display: block;
  margin-top: 5px;
  color: var(--gold-bright);
  font: 500 clamp(23px, 4vw, 31px) ui-monospace, monospace;
  letter-spacing: .04em;
}

.timer-block strong.urgent {
  color: var(--danger);
  animation: timerPulse 1s ease-in-out infinite;
}

.puzzle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, .9fr);
  gap: clamp(25px, 5vw, 68px);
  padding: clamp(24px, 4vw, 40px) clamp(18px, 4vw, 44px);
}

.puzzle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 15px;
  color: var(--gold);
  font: 11px ui-monospace, monospace;
  letter-spacing: .08em;
}

.difficulty {
  color: var(--muted);
}

body[data-boss="true"] .difficulty {
  color: var(--danger);
}

body[data-boss="true"] .puzzle-meta {
  color: var(--danger);
}

h3 {
  margin: 0 0 13px;
  color: var(--ink);
  font: 500 clamp(27px, 4vw, 40px)/1.05 Georgia, serif;
  letter-spacing: -.035em;
}

.puzzle-copy > p {
  max-width: 570px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

blockquote {
  max-width: 570px;
  margin: 0;
  padding: 4px 0 4px 17px;
  border-left: 2px solid var(--gold);
  color: var(--ink);
  white-space: pre-line;
  font: italic 15px/1.6 Georgia, serif;
}

.hint-area {
  max-width: 570px;
  margin-top: 30px;
}

.hint-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .15em;
}

.hints {
  display: grid;
  gap: 7px;
}

.hint-button {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
  transition: border-color .2s ease, color .2s ease, background .2s ease, transform .2s ease;
}

.hint-button:not(:disabled):hover {
  border-color: var(--gold);
  background: var(--surface-3);
  color: var(--ink);
  transform: translateX(3px);
}

.hint-button:disabled {
  opacity: .92;
  cursor: default;
}

.answer-panel {
  align-self: center;
  width: 100%;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(212,166,91,.06), transparent 42%),
    var(--surface-2);
  text-align: center;
}

body[data-boss="true"] .answer-panel {
  border-color: color-mix(in srgb, var(--danger) 46%, var(--line));
}

.answer-seal {
  width: 58px;
  margin: 0 auto 22px;
  color: var(--gold);
  animation: floatSeal 5s ease-in-out infinite;
}

body[data-boss="true"] .answer-seal {
  color: var(--danger);
}

.answer-seal svg {
  width: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.answer-panel label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.answer-row {
  display: flex;
  gap: 8px;
}

.answer-row input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  font-size: 16px;
  letter-spacing: .12em;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.answer-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,166,91,.1);
}

.answer-row input:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.submit-button {
  min-width: 78px;
  min-height: 48px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: var(--gold);
  color: var(--paper);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .1em;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.submit-button:hover:not(:disabled) {
  background: var(--gold-bright);
  box-shadow: 0 8px 20px rgba(212,166,91,.16);
  transform: translateY(-1px);
}

.submit-button:active:not(:disabled) {
  transform: translateY(0);
}

.submit-button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.answer-help {
  margin: 12px 0 0;
  color: var(--faint);
  font-size: 11px;
}

.feedback {
  min-height: 20px;
  margin-top: 14px;
  color: var(--gold-bright);
  font-size: 12px;
  line-height: 1.4;
}

.feedback.has-message {
  animation: feedbackIn .25s ease both;
}

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
  padding-top: 2px;
  color: var(--faint);
}

.footer b {
  color: var(--gold);
  font-weight: 400;
}

.footer i {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 8px 2px;
  border-radius: 50%;
  background: var(--gold);
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: .7;
    transform: scale(.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes breathe {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes floatSeal {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes timerPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .65;
  }
}

@keyframes feedbackIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .shell {
    gap: 28px;
  }

  .topbar {
    align-items: flex-start;
  }

  .mission-status {
    padding-top: 5px;
    font-size: 8px;
  }

  .hero-grid,
  .puzzle-layout {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 20px;
  }

  .room-panel {
    order: -1;
  }

  .room-illustration {
    min-height: 190px;
  }

  .puzzle-layout {
    gap: 26px;
  }

  .answer-panel {
    max-width: 520px;
  }
}

@media (max-width: 390px) {
  .shell {
    gap: 22px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .mission-status {
    display: none;
  }

  h2 {
    font-size: 38px;
  }

  .room-panel {
    padding: 13px;
  }

  .room-illustration {
    min-height: 165px;
    margin: 13px 0;
  }

  .game-head {
    padding: 16px;
  }

  .puzzle-layout {
    padding: 22px 16px;
  }

  .answer-row {
    flex-direction: column;
  }

  .submit-button {
    min-height: 48px;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .shell {
    gap: 18px;
    padding-top: 16px;
  }

  .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 26px;
  }

  .room-panel {
    order: initial;
  }

  .room-illustration {
    min-height: 130px;
  }

  .intro-copy,
  .objective,
  .fine-print {
    display: none;
  }

  h2 {
    font-size: 35px;
  }

  .puzzle-layout {
    padding-top: 20px;
    padding-bottom: 20px;
  }
}

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