:root {
  --cream: #f7ead3;
  --gold: #f4c56d;
  --ink: #0b0814;
  --muted: rgba(247, 234, 211, 0.72);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1b1033;
  color: var(--cream);
  font-family: "Nunito Sans", system-ui, sans-serif;
  user-select: none;
  touch-action: manipulation;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

#game.playing {
  pointer-events: auto;
  touch-action: none;
}

.panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  z-index: 20;
  pointer-events: auto;
}

.panel h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(3.2rem, 14vw, 4.6rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  margin: 0 0 4px;
  text-indent: 0.18em;
}

.panel h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2rem;
  margin: 0 0 8px;
}

.eyebrow {
  letter-spacing: 0.42em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
  margin: 0;
}

.tagline {
  margin: 0 0 12px;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: 1px solid rgba(247, 234, 211, 0.22);
  background: rgba(11, 8, 20, 0.42);
  color: var(--cream);
  border-radius: 999px;
  padding: 14px 18px;
  font: 700 1rem/1 "Nunito Sans", system-ui, sans-serif;
  min-height: 48px;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  position: relative;
  z-index: 21;
}

.btn.primary {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--cream);
}

.btn.ghost {
  background: transparent;
}

.btn.mini {
  min-width: 108px;
  padding: 10px 14px;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  padding: 6px 2px;
}

select {
  background: rgba(11, 8, 20, 0.5);
  color: var(--cream);
  border: 1px solid rgba(247, 234, 211, 0.22);
  border-radius: 999px;
  padding: 10px 12px;
  font: 700 0.95rem/1 "Nunito Sans", system-ui, sans-serif;
}

.hidden {
  display: none !important;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#boot-error {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: #3a1020;
  color: #ffd0c8;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
}

#hud-level,
#hud-dist {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

#hud-level {
  left: 18px;
}

#hud-dist {
  right: 72px;
}

.btn-pause {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(247, 234, 211, 0.28);
  border-radius: 12px;
  background: rgba(11, 8, 20, 0.45);
  color: var(--cream);
  font: 700 0.85rem/1 "Nunito Sans", system-ui, sans-serif;
  letter-spacing: 0.12em;
  pointer-events: auto;
  cursor: pointer;
  z-index: 6;
}

#hud-hint {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  color: var(--gold);
  letter-spacing: 0.08em;
}

#splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 3rem;
  letter-spacing: 0.12em;
  z-index: 3;
  pointer-events: none;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.card {
  background: linear-gradient(180deg, rgba(27, 16, 51, 0.72), rgba(11, 8, 20, 0.78));
  border: 1px solid rgba(244, 197, 109, 0.28);
  border-radius: 24px;
  padding: 28px 22px;
  backdrop-filter: blur(10px);
}

.panel.map-panel {
  width: min(440px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  gap: 6px;
  padding: 18px 14px 14px;
}

#map-title {
  font-size: 1.45rem;
  margin: 0;
}

#map-hint {
  margin: 0 0 4px;
}

.level-map {
  position: relative;
  height: 1000px;
  min-height: 1000px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 78% 8%, rgba(255, 215, 137, 0.45), transparent 28%),
    linear-gradient(180deg, #2a1548 0%, #c45c28 55%, #f0b45a 100%);
}

.map-trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(247, 234, 211, 0.72);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 2.2 1.6;
  pointer-events: none;
}

.map-sun {
  position: absolute;
  right: 10%;
  top: 4%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffd789;
  box-shadow: 0 0 22px 8px rgba(255, 170, 80, 0.45);
  pointer-events: none;
}

#level-map {
  position: absolute;
  inset: 0;
}

.map-node {
  appearance: none;
  position: absolute;
  z-index: 1;
  width: 36px;
  height: 36px;
  margin: 0;
  border-radius: 50%;
  border: 2px solid rgba(247, 234, 211, 0.35);
  background: rgba(11, 8, 20, 0.72);
  color: var(--cream);
  font: 700 0.95rem/1 "Nunito Sans", system-ui, sans-serif;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  transform: translate(-50%, -50%);
}

.map-node.unlocked {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--gold);
}

.map-node.done {
  box-shadow: inset 0 0 0 2px rgba(196, 92, 40, 0.45);
}

.map-node.current {
  box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(244, 197, 109, 0.55);
}

.map-node.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.map-node.endless {
  width: auto;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.map-node:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.96);
}
