/* Spiral Drop: the spiral stair of a stone lighthouse at dusk. The world is drawn in WebGL
   (script.js); this sheet styles the brass and ember instruments laid over it. */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,600;0,9..144,700;1,9..144,600&family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap");

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #f4e7cf;            /* lamp-lit limestone, for text on the dusk */
  --brass: #e2b264;
  --brass-hi: #f8dfa6;
  --ember: #ff7a2e;
  --dusk: #110e18;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  /* shared toy chrome: brass lamp light on the dusk indigo of the stairwell */
  --tc-accent: #eab063;
  --tc-on: #2a1506;
  --tc-display: var(--display);
  --tc-ground: #0e0b15;
}

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0; height: 100%; overflow: hidden;
  background: var(--dusk);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none; overscroll-behavior: none;
  color: var(--ink);
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  cursor: grab; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  touch-action: none; outline: none;
}
#canvas:active { cursor: grabbing; }

/* a soft dark lens around the edges: cheaper here than in the shader */
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(130% 92% at 50% 44%, rgba(0, 0, 0, 0) 52%, rgba(6, 4, 10, 0.55) 100%);
}

/* ---------- the level bar: two brass medallions on a rail ---------- */
html.tc .hud.hud {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: max(12px, env(safe-area-inset-top));
  z-index: 5; display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 999px; pointer-events: none;
  background: linear-gradient(180deg, rgba(30, 22, 30, 0.72), rgba(14, 10, 18, 0.78));
  border: 1px solid rgba(234, 176, 99, 0.36);
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 230, 180, 0.12);
}
.lv {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font: 600 13px/1 "Geist Mono", ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums;
}
.lv--now {
  color: #2a1506;
  background: radial-gradient(120% 120% at 35% 25%, #fff0c8 0%, #eab063 45%, #9c6a26 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 14px rgba(234, 176, 99, 0.35);
}
.lv--next {
  color: rgba(248, 223, 166, 0.78);
  background: rgba(10, 8, 14, 0.7);
  box-shadow: inset 0 0 0 1px rgba(234, 176, 99, 0.45);
}
.bar {
  position: relative; width: clamp(110px, 34vw, 190px); height: 8px; border-radius: 999px; overflow: hidden;
  background: rgba(0, 0, 0, 0.55); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(234, 176, 99, 0.18);
}
.bar i {
  position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, #a86f28, #eab063 60%, #ffe2a4);
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* the running score, engraved in the display face under the rail */
.score {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 5; pointer-events: none;
  top: calc(max(12px, env(safe-area-inset-top)) + 46px);
  font: 700 clamp(38px, 11vw, 54px)/1 var(--display); font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -0.01em; color: #fbe9c4;
  text-shadow: 0 2px 0 rgba(60, 30, 10, 0.6), 0 6px 22px rgba(0, 0, 0, 0.65), 0 0 28px rgba(234, 176, 99, 0.25);
  transition: color 200ms ease;
}
.score.is-hot { color: #ffb36b; text-shadow: 0 2px 0 rgba(90, 20, 0, 0.6), 0 0 26px rgba(255, 110, 40, 0.6); }
.score.is-bump { animation: bump 240ms cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes bump { 0% { transform: translateX(-50%) scale(1.14); } 100% { transform: translateX(-50%) scale(1); } }

/* +points float up from the ball */
.pops { position: fixed; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font: 700 22px/1 var(--display); color: #fff1cf;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75), 0 0 16px rgba(234, 176, 99, 0.5);
  animation: rise 820ms cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
.pop.is-hot { color: #ffc37a; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 18px rgba(255, 100, 30, 0.85); }
.pop.is-big { font-size: 28px; font-style: italic; letter-spacing: 0.01em; }
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  14% { opacity: 1; transform: translate(-50%, -60%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -240%) scale(1); }
}

/* level banner */
.banner {
  position: fixed; left: 50%; top: 62%; z-index: 6; pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%) scale(0.92); text-align: center; white-space: nowrap;
  font: 700 clamp(34px, 10vw, 56px)/1.05 var(--display); color: #fff0cc;
  text-shadow: 0 3px 0 rgba(70, 36, 10, 0.55), 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 40px rgba(234, 176, 99, 0.45);
  transition: opacity 260ms ease, transform 420ms cubic-bezier(0.2, 0.9, 0.25, 1);
}
.banner small {
  display: block; margin-top: 8px; font: 500 12px/1.3 "Geist Mono", ui-monospace, Menlo, monospace;
  letter-spacing: 0.24em; text-transform: uppercase; color: rgba(248, 223, 166, 0.82); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}
.banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* the dusk crossfade between lighthouses */
.fade {
  position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 90% at 50% 45%, #2a1e2a 0%, #0c0910 70%);
  transition: opacity 360ms ease;
}
.fade.is-on { opacity: 1; }

/* ---------- top button: a brass lamp switch ---------- */
.topbtns {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  z-index: 7; display: inline-flex; align-items: center; gap: 8px;
}
.iconbtn {
  appearance: none; cursor: pointer; width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid rgba(234, 176, 99, 0.5);
  background: linear-gradient(180deg, rgba(40, 28, 34, 0.85), rgba(16, 12, 20, 0.9));
  color: var(--brass-hi);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 225, 170, 0.14), 0 8px 18px -10px rgba(0, 0, 0, 0.9);
  transition: border-color 140ms ease, color 140ms ease, transform 120ms ease;
}
.iconbtn:hover { border-color: var(--brass-hi); color: #fff3d6; }
.iconbtn:active { transform: translateY(1px); }
.iconbtn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dusk), 0 0 0 4px var(--brass-hi); }
.iconbtn .mute { display: none; }
.iconbtn[aria-pressed="false"] { color: rgba(248, 223, 166, 0.42); }
.iconbtn[aria-pressed="false"] .wave { display: none; }
.iconbtn[aria-pressed="false"] .mute { display: inline; }

/* ---------- the card ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 42%, rgba(14, 10, 18, 0.32), rgba(6, 4, 10, 0.78));
  transition: opacity 260ms ease;
}
.overlay.is-hidden { opacity: 0; pointer-events: none; }
.panel { animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
html.tc .overlay .panel.panel {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 80px rgba(234, 150, 70, 0.14),
    inset 0 1px 0 rgba(255, 230, 180, 0.1);
}
html.tc .overlay .panel__title {
  font-weight: 700; font-size: clamp(38px, 11vw, 50px); line-height: 1.02; letter-spacing: -0.015em;
  padding-bottom: 3px;
  background-image: linear-gradient(176deg, #fff6df 0%, #f6d491 38%, #d0913f 72%, #8f5a1f 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 3px 16px rgba(234, 160, 80, 0.28));
}
html.tc .overlay .panel__title.is-lose {
  background-image: linear-gradient(176deg, #fff0e2 0%, #ffbd84 36%, #ff6a2a 70%, #a8260c 100%);
  filter: drop-shadow(0 3px 18px rgba(255, 90, 30, 0.38));
}
.panel__text .newbest { color: #ffd88f; font-weight: 600; }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(244, 231, 207, 0.5);
}
.frame__corner--tl { top: max(22px, calc(env(safe-area-inset-top) + 10px)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner--tr { display: none; } /* top-right holds the sound switch */
.frame__corner--bl { bottom: max(14px, calc(env(safe-area-inset-bottom) + 4px)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: var(--brass-hi); }
.frame__corner a:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 3px; border-radius: 3px; }

.hint {
  position: fixed; bottom: max(15px, calc(env(safe-area-inset-bottom) + 4px)); left: 50%; transform: translateX(-50%); z-index: 4; margin: 0;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; color: rgba(244, 231, 207, 0.66);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none; white-space: nowrap; transition: opacity 400ms ease; max-width: 92vw; text-align: center;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 620px) {
  .frame__corner--bl { display: none; }
  .hint { font-size: 0.66rem; letter-spacing: 0.02em; }
}
@media (max-width: 430px) {
  .hint { white-space: normal; line-height: 1.4; bottom: max(10px, calc(env(safe-area-inset-bottom) + 2px)); }
  .frame__corner--tl { font-size: 0.62rem; }
}

/* the tip jar and full-screen badges dock bottom-right, off the stair */
.opt-tipjar.opt-tipjar { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs { top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 54px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge { animation: none; }

/* the score bar steps aside while a card is up */
.hud, .score { transition: opacity 220ms ease; }
body.is-card .hud, body.is-card .score { opacity: 0; }

/* ---------- short landscape (a phone on its side) ----------
   The card goes two columns, as a grid: the words on the left, every action on the right. */
@media (orientation: landscape) and (max-height: 500px) {
  .score { top: calc(max(8px, env(safe-area-inset-top)) + 40px); font-size: 32px; }
  html.tc .hud.hud { top: max(8px, env(safe-area-inset-top)); }
  .banner { top: 50%; }
  .hint { white-space: normal; max-width: min(46vw, 360px); line-height: 1.4; }
  html.tc #overlay > .panel.panel {
    width: min(100%, 660px); max-width: 660px; padding: 16px 24px 14px; text-align: left;
    display: grid; grid-template-columns: 1.08fr 1fr; column-gap: 26px; align-content: start; grid-auto-flow: dense;
  }
  html.tc #overlay > .panel > * { grid-column: 2; }
  html.tc #overlay > .panel > .panel__lede { grid-column: 1; grid-row: 1 / span 12; }
  html.tc #overlay > .panel > .play-btn { max-width: none; margin: 4px 0 0; }
  html.tc #overlay > .panel > .panel__keys { text-align: center; }
  html.tc .overlay .panel__title { font-size: 36px; margin-bottom: 6px; }
  html.tc #overlay .panel__text { margin-bottom: 4px; font-size: 13.5px; }
  html.tc #overlay .panel .mg { margin-top: 10px; }
  html.tc #overlay .panel .opt-share { margin-top: 8px; }
}

@keyframes popfade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .panel, .score.is-bump { animation: none; }
  .pop { animation: popfade 800ms linear forwards; }
  .overlay, .hint, .banner, .fade, .bar i { transition: none; }
}
