/* Phaethon: The Fall of the Sun — marble, gold and ember */
@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --gold: #e8c37c;
  --gold-hi: #f9e6b8;
  --gold-dim: #9c7a3c;
  --ink: #07080f;
  --ink-2: #0d1020;
  --paper: #f4ecdd;
  --muted: rgba(232, 226, 210, 0.62);
  --line: rgba(232, 195, 124, 0.28);
  --ember: #ff8b52;
  --serif: "Cinzel", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #05060c;
  color: var(--paper);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #131a33 0%, #080a14 55%, #04050a 100%);
}

/* --------------------------------- screens -------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.screen.on { display: block; opacity: 1; }

/* ---------------------------------- menu ---------------------------------- */
#screenMenu { overflow: hidden; }
.menu-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}

.menu-glow {
  position: absolute;
  left: 50%;
  top: 16%;
  width: min(72vw, 620px);
  height: min(72vw, 620px);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 224, 160, 0.22) 0%, rgba(255, 170, 90, 0.06) 42%, transparent 68%);
  filter: blur(6px);
  pointer-events: none;
}

.menu-wrap {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 24px;
  text-align: center;
}

.crest { width: 76px; height: 76px; margin-bottom: 10px; opacity: 0.95; }
.crest svg { width: 100%; height: 100%; overflow: visible; }

.eyebrow {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(232, 195, 124, 0.72);
  margin: 0 0 16px;
}

h1.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(48px, 9.2vw, 104px);
  line-height: 0.92;
  margin: 0;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff7e2 0%, #f2d79b 34%, #c99b4e 62%, #8a6427 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 22px 60px rgba(255, 190, 110, 0.18);
}

.title-sub {
  font-family: var(--serif);
  font-size: clamp(13px, 1.7vw, 17px);
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: rgba(244, 236, 221, 0.60);
  margin: 14px 0 0;
}

.rule {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, 76vw);
  margin: 22px 0 20px;
  color: rgba(232, 195, 124, 0.55);
}
.rule:before, .rule:after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 195, 124, 0.45), transparent);
}
.rule i { font-style: normal; font-size: 12px; letter-spacing: 0.2em; }

.tagline {
  max-width: 430px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
  margin: 0 0 26px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 208px;
  padding: 13px 26px;
  border-radius: 3px;
  border: 1px solid rgba(232, 195, 124, 0.42);
  background: rgba(10, 12, 22, 0.6);
  color: var(--gold-hi);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  transition: transform 0.18s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s;
  overflow: hidden;
}
.btn:hover { border-color: rgba(249, 230, 184, 0.8); background: rgba(28, 24, 32, 0.85); transform: translateY(-1px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.btn:active { transform: translateY(0) scale(0.995); }

.btn.gold {
  background: linear-gradient(180deg, #f7e3b1 0%, #e2bd78 46%, #b98f45 100%);
  color: #241a08;
  border-color: rgba(255, 240, 200, 0.9);
  box-shadow: 0 12px 40px rgba(214, 164, 86, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn.gold:hover { box-shadow: 0 16px 50px rgba(214, 164, 86, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
.btn.gold:after {
  content: "";
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg);
  animation: sheen 4.6s ease-in-out infinite;
}
@keyframes sheen {
  0%, 62% { left: -60%; }
  82%, 100% { left: 130%; }
}
.btn small {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  opacity: 0.65;
  margin-top: 2px;
}
.btn .lbl { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }

.menu-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.menu-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.menu-row .btn { min-width: 132px; padding: 11px 18px; font-size: 10.5px; letter-spacing: 0.18em; }

.menu-progress {
  margin-top: 22px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(232, 226, 210, 0.45);
}

.menu-foot {
  position: absolute;
  left: 0; right: 0; bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(232, 226, 210, 0.3);
  z-index: 3;
}
.menu-foot a { color: inherit; text-decoration: none; }
.menu-foot a:hover { color: var(--gold); }

/* ---------------------------------- map ----------------------------------- */
#screenMap {
  background: linear-gradient(180deg, #080b16, #0a0d18 60%, #06070e);
  overflow-y: auto;
}
.map-wrap { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }
.map-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 8px;
}
.map-head h2 {
  font-family: var(--serif);
  font-size: clamp(22px, 3.4vw, 34px);
  letter-spacing: 0.08em;
  margin: 0;
  color: var(--gold-hi);
  font-weight: 600;
}
.map-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.map-back {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 8px 14px; border-radius: 3px; font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
}
.map-back:hover { color: var(--gold-hi); border-color: var(--gold); }

.map-act {
  display: flex; align-items: center; gap: 12px;
  margin: 26px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(232, 195, 124, 0.14);
}
.map-num {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--gold);
  border: 1px solid var(--line);
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  flex: none;
}
.map-act b { font-family: var(--serif); font-size: 16px; letter-spacing: 0.06em; color: #f0e6d2; font-weight: 600; }
.map-act small { display: block; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(232, 226, 210, 0.4); margin-top: 2px; }

.map-row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.map-node {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 11px 4px 9px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  color: #ded6c6;
  transition: 0.2s;
}
.map-node:hover:not(:disabled) { border-color: var(--gold); background: rgba(232, 195, 124, 0.08); transform: translateY(-2px); }
.map-node .mn { font-family: var(--serif); font-size: 17px; color: var(--gold); }
.map-node .mt { font-size: 8.5px; letter-spacing: 0.04em; text-align: center; color: rgba(232, 226, 210, 0.55); height: 22px; overflow: hidden; }
.map-node .ms { font-size: 9px; color: var(--gold); letter-spacing: 0.1em; height: 12px; }
.map-node.locked { opacity: 0.3; }
.map-node.locked .mn { color: #94949f; }
.map-node.locked .mt { color: rgba(232, 226, 210, 0.28); }
.map-node.locked:after {
  content: "·"; position: absolute; top: 3px; right: 7px;
  font-size: 12px; opacity: 0.5; color: rgba(232, 226, 210, 0.4);
}
.map-node.boss { border-color: rgba(255, 139, 82, 0.4); box-shadow: inset 0 0 22px rgba(255, 110, 50, 0.12); }

/* --------------------------------- stage ---------------------------------- */
#screenPlay { background: #05060c; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#game:active { cursor: grabbing; }

.hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(3, 4, 9, 0.72), transparent);
}
.hud-left { display: flex; flex-direction: column; gap: 3px; }
.hud-kicker { font-size: 9.5px; letter-spacing: 0.3em; text-transform: uppercase; color: rgba(232, 195, 124, 0.85); }
.hud-title {
  font-family: var(--serif); font-size: 17px; letter-spacing: 0.06em; color: #f4ecdd;
  max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-act, .hud-kicker { max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-act { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(232, 226, 210, 0.42); }

.hud-right { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.hud-score { text-align: right; font-family: var(--serif); font-size: 22px; color: var(--gold-hi); line-height: 1; }
.hud-score span { display: block; font-family: var(--sans); font-size: 8.5px; letter-spacing: 0.24em; color: rgba(232, 226, 210, 0.4); margin-top: 4px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(232, 195, 124, 0.28);
  background: rgba(8, 10, 18, 0.55);
  color: var(--gold-hi);
  display: grid; place-items: center;
  font-size: 13px;
  backdrop-filter: blur(8px);
}
.icon-btn:hover { border-color: var(--gold); background: rgba(24, 22, 28, 0.8); }

.hud-lives { display: flex; gap: 4px; align-items: center; }
.hud-lives i {
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff6d8, #ffcf7a 52%, #d98b3c);
  box-shadow: 0 0 12px rgba(255, 190, 110, 0.6);
  display: block;
  transition: 0.3s;
}
.hud-lives i.off { background: rgba(255, 255, 255, 0.1); box-shadow: none; transform: scale(0.75); }

.hud-depth {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 34vh;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.hud-depth i {
  position: absolute; top: 0; left: 0; width: 100%; height: 0%;
  background: linear-gradient(180deg, rgba(255, 240, 200, 0.95), rgba(232, 195, 124, 0.4));
  box-shadow: 0 0 12px rgba(255, 210, 140, 0.7);
  transition: height 0.2s linear;
}
.hud-depth-num {
  position: absolute; left: 26px; top: 50%; transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(232, 226, 210, 0.45);
}

.hud-combo {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  text-align: right;
  opacity: 0; transition: opacity 0.25s;
}
.hud-combo.on { opacity: 1; }
.hud-combo b {
  display: block;
  font-family: var(--serif); font-size: 34px; line-height: 1;
  color: #fff3cc;
  text-shadow: 0 0 24px rgba(255, 190, 100, 0.65);
}
.hud-combo span { font-size: 8.5px; letter-spacing: 0.24em; text-transform: uppercase; color: rgba(232, 195, 124, 0.7); }

.hint {
  position: absolute; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(8px);
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(244, 236, 221, 0.72);
  background: rgba(6, 8, 14, 0.5);
  border: 1px solid rgba(232, 195, 124, 0.18);
  padding: 8px 16px; border-radius: 999px;
  opacity: 0; transition: 0.4s;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.hint.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------------------------------- overlays -------------------------------- */
.overlay {
  position: absolute; inset: 0; z-index: 8;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(90% 70% at 50% 40%, rgba(8, 10, 20, 0.55), rgba(3, 4, 9, 0.88));
  backdrop-filter: blur(10px);
}
.overlay.on { display: flex; animation: fadein 0.35s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.panel {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 34px 30px 26px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(23, 22, 30, 0.92), rgba(10, 11, 18, 0.96));
  border: 1px solid rgba(232, 195, 124, 0.32);
  border-radius: 4px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 240, 200, 0.14);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise { from { transform: translateY(16px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
.panel:before, .panel:after {
  content: ""; position: absolute; left: 14px; right: 14px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 195, 124, 0.4), transparent);
}
.panel:before { top: 8px; } .panel:after { bottom: 8px; }

.panel .kicker {
  font-size: 9.5px; letter-spacing: 0.34em; text-transform: uppercase;
  color: rgba(232, 195, 124, 0.8); margin: 0 0 12px;
}
.panel h2 {
  font-family: var(--serif); font-weight: 600; letter-spacing: 0.04em;
  font-size: clamp(26px, 5vw, 36px); line-height: 1.1;
  margin: 0 0 12px; color: #f8efdc;
}
.panel .line {
  font-size: 14px; line-height: 1.8; color: rgba(236, 229, 214, 0.7);
  margin: 0 auto 18px; max-width: 400px;
  font-style: italic;
}
.panel .goal {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(232, 195, 124, 0.66);
  margin: 0 0 14px;
}
.stars { display: flex; justify-content: center; gap: 12px; margin: 6px 0 20px; min-height: 26px; }
.star {
  font-size: 24px; color: rgba(255, 255, 255, 0.14);
  transition: 0.3s;
}
.star.lit {
  color: #ffe4a6;
  text-shadow: 0 0 18px rgba(255, 200, 110, 0.8);
  animation: starPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes starPop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.result-stats { display: flex; justify-content: center; gap: 26px; margin: 4px 0 22px; }
.result-stats div { display: flex; flex-direction: column; gap: 3px; }
.result-stats b { font-family: var(--serif); font-size: 20px; color: var(--gold-hi); font-weight: 600; }
.result-stats span { font-size: 8.5px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(232, 226, 210, 0.4); }

.panel .actions { display: flex; flex-direction: column; gap: 9px; align-items: stretch; }
.panel .actions .btn { width: 100%; min-width: 0; }
.panel .ghost {
  background: none; border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(236, 229, 214, 0.6);
}
.panel .ghost:hover { color: var(--gold-hi); border-color: rgba(232, 195, 124, 0.4); }

.how { text-align: left; }
.how li { font-size: 13px; line-height: 1.7; color: rgba(236, 229, 214, 0.74); margin: 0 0 9px; }
.how b { color: var(--gold-hi); font-weight: 600; }
.how .keys { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
.kbd {
  font: 11px/1 var(--sans); letter-spacing: 0.1em;
  border: 1px solid rgba(255, 255, 255, 0.18); border-bottom-width: 2px;
  border-radius: 4px; padding: 6px 9px; color: rgba(244, 236, 221, 0.8);
  background: rgba(255, 255, 255, 0.04);
}

.pause-stats { font-size: 11px; letter-spacing: 0.1em; color: rgba(232, 226, 210, 0.45); margin: -4px 0 18px; }

@media (max-width: 480px) {
  .menu-foot { font-size: 9px; letter-spacing: 0.1em; gap: 10px; padding: 0 10px; }
  .menu-foot span:last-child { display: none; }
}
@media (max-width: 760px) {
  .map-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hud-depth { height: 26vh; }
  .panel { padding: 28px 20px 22px; }
  .result-stats { gap: 18px; }
}
@media (max-height: 620px) {
  .title { font-size: clamp(38px, 7vw, 64px) !important; }
  .rule { margin: 14px 0; }
  .tagline { display: none; }
  .menu-progress { margin-top: 12px; }
}
