/* LAST DROP: as little interface as possible. The scene is the game; text sits straight on it (no panels), the few
   controls are small round icons in a corner, and every screen but the shop and the boards is "tap to go". */


:root {
  --ink: #f8f1e6;
  --ink-2: rgba(248, 241, 230, 0.78);
  --ink-3: rgba(248, 241, 230, 0.5);
  --sun: #f3bd6e;
  --shade: 0 1px 2px rgba(30, 16, 6, 0.35), 0 2px 18px rgba(30, 16, 6, 0.4);
  /* the big words (title, distance, Paused): a tight edge plus a wide, soft glow of shade, so they hold up over
     bright sand and sky without a panel behind them */
  --shade-big: 0 1px 2px rgba(30, 16, 6, 0.35), 0 3px 10px rgba(30, 16, 6, 0.25), 0 6px 44px rgba(30, 16, 6, 0.45);
  /* the shade every veil is made of: a warm, deep brown (a cool grey or black over sand reads as dirty haze) */
  --v: 34, 18, 7;
  /* how screens come and go */
  --fade: 0.38s;
  /* Dropline: the game's own typeface (css/font.css, tools/font/build-font.mjs); anything it lacks falls back */
  --display: 'Dropline', system-ui, -apple-system, sans-serif;
  --text: 'Dropline', system-ui, -apple-system, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a110a; color: var(--ink); font-family: var(--text); -webkit-font-smoothing: antialiased; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
body.clean #screens, body.clean #veil, body.clean #hud, body.clean #transit { display: none !important; }
.ico { width: 1em; height: 1em; flex: none; }
button { font: inherit; color: inherit; }

/* The shading behind each screen's text, only where the text is, so the scene keeps its colour everywhere else.
   One layer per kind of screen; main.js screen() names the one that's up (data-s) and they cross-fade. */
#veil { position: fixed; inset: 0; pointer-events: none; }
#veil i { position: absolute; inset: 0; opacity: 0; transition: opacity 0.6s ease; }
#veil[data-s=menu] .v-menu, #veil[data-s=pause] .v-pause, #veil[data-s=end] .v-end, #veil[data-s=full] .v-full { opacity: 1; }
/* menu: the title card sits in the lower third, so it's shaded from below; a breath of shade at the very top */
.v-menu { background: linear-gradient(180deg, rgba(var(--v), 0.14) 0%, rgba(var(--v), 0) 14%, rgba(var(--v), 0) 46%, rgba(var(--v), 0.3) 64%, rgba(var(--v), 0.5) 100%); }
/* paused: the world held and dimmed a little */
.v-pause { background: rgba(var(--v), 0.3); }
/* the end: a soft pool of shade behind the number and the upgrades (the damp spot below stays in the light) */
.v-end { background: radial-gradient(ellipse 95% 46% at 50% 36%, rgba(var(--v), 0.5), rgba(var(--v), 0.3) 55%, rgba(var(--v), 0) 100%),
  linear-gradient(180deg, rgba(var(--v), 0) 80%, rgba(var(--v), 0.3) 100%); }
@media (min-aspect-ratio: 1/1) { .v-end { background: radial-gradient(ellipse 52% 62% at 50% 44%, rgba(var(--v), 0.5), rgba(var(--v), 0.28) 55%, rgba(var(--v), 0) 100%); } }
/* the shop, the boards, the dev menu: more to read, so the scene steps right back */
.v-full { background: rgba(var(--v), 0.62); }

/* ---- the run: a distance, a pause button, and the rare big moment */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: var(--shade); transition: opacity var(--fade) ease, display var(--fade) allow-discrete; }
#hud.hidden { opacity: 0; }
@starting-style { #hud:not(.hidden) { opacity: 0; } }
#hud-dist { position: absolute; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); display: flex; align-items: baseline; gap: 4px; }
#hud-dist b { font: 700 28px/1 var(--display); letter-spacing: 0.01em; text-shadow: var(--shade-big); }
#hud-dist span { font: 600 13px/1 var(--display); color: var(--ink-2); letter-spacing: 0.08em; text-transform: uppercase; }
#hud-dist.best b { color: var(--sun); }
#hud .icon-btn { pointer-events: auto; }
#btn-pause { position: absolute; right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t)); opacity: 0.75; }
#btn-cam { position: absolute; right: calc(64px + var(--safe-r)); top: calc(10px + var(--safe-t)); opacity: 0.6; }
#hud-moment { position: absolute; left: 0; right: 0; top: 24%; text-align: center; opacity: 0; transform: translateY(8px); transition: opacity 0.5s ease, transform 0.5s ease; }
#hud-moment.show { opacity: 1; transform: none; }
#hud-moment b { display: block; font: 800 clamp(30px, 7vw, 50px)/1 var(--display); letter-spacing: 0.02em; text-shadow: var(--shade-big); }
#hud-moment small { display: block; margin-top: 6px; font: 600 13px/1.3 var(--text); color: var(--ink-2); letter-spacing: 0.02em; }
/* the next flower's beam is off screen: a warm chevron at that edge points to it */
#hud-guide { position: absolute; top: 46%; right: calc(4px + var(--safe-r)); font-size: 46px; color: var(--sun); opacity: 0; transition: opacity 0.4s ease;
  filter: drop-shadow(0 0 10px rgba(255, 180, 80, 0.95)); }
#hud-guide .ico { stroke-width: 2.8; }
#hud-guide.on { opacity: 1; animation: nudge 1.1s ease-in-out infinite; }
#hud-guide.left { right: auto; left: calc(6px + var(--safe-l)); transform: scaleX(-1); --out: -1; }
@keyframes nudge { 0%, 100% { translate: 0 0; } 50% { translate: calc(5px * var(--out, 1)) 0; } }
#hud-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18vh + var(--safe-b)); width: max-content; max-width: min(86vw, 520px);
  padding: 10px 18px; border-radius: 16px; background: rgba(var(--v), 0.46); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(248, 241, 230, 0.08) inset; text-shadow: 0 1px 2px rgba(30, 16, 6, 0.4);
  text-align: center; text-wrap: balance; font: 600 17px/1.3 var(--text); color: var(--ink); transition: opacity 0.6s ease; pointer-events: none; }
#hud-hint:empty { display: none; }

/* between stretches: one word over a warm fade */
#transit { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 214, 160, 0.55), rgba(196, 120, 60, 0.82));
  transition: opacity 0.45s ease, display 0.5s allow-discrete; }
#transit.hidden { opacity: 0; transition-duration: 0.5s; }
@starting-style { #transit:not(.hidden) { opacity: 0; } }
#transit-title { font: 800 clamp(48px, 12vw, 110px)/1 var(--display); letter-spacing: 0.02em; color: #fffaf1; text-shadow: 0 2px 30px rgba(120, 56, 10, 0.45); animation: rise 0.8s ease both; }

/* ---- screens */
#screens { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) calc(20px + var(--safe-r)) calc(24px + var(--safe-b)) calc(20px + var(--safe-l)); text-shadow: var(--shade);
  transition: opacity var(--fade) ease, display var(--fade) allow-discrete; }
/* Screens cross-fade: a screen being hidden keeps showing while it fades out (display is held by the transition),
   and one being shown fades in from nothing (@starting-style). Browsers without these just cut, as before.
   Nothing that's on its way out can be tapped. */
.screen.hidden { opacity: 0; }
@starting-style { .screen:not(.hidden) { opacity: 0; } }
.hidden, .hidden * { pointer-events: none !important; }
.tap-to-go { cursor: pointer; }
.title-block { text-align: center; margin-top: -8vh; }
/* the menu is a title card: the drop up in the frame (main.js shifts the menu camera), the name in the lower third */
#s-menu { justify-content: flex-end; }
#s-menu .title-block { margin: 0 0 calc(25vh + var(--safe-b)); }
#s-menu .wordmark { font-size: clamp(48px, 13.5vw, 120px); }
@media (min-aspect-ratio: 1/1) { #s-menu .title-block { margin-bottom: 21vh; } }
/* paused: the word up over the horizon, the drop left in view below it */
#s-pause { justify-content: flex-start; }
#s-pause .title-block { margin: calc(20vh + var(--safe-t)) 0 0; }
.wordmark { margin: 0; font: 800 clamp(40px, 11.5vw, 112px)/0.9 var(--display); letter-spacing: 0; text-shadow: var(--shade-big); }
.big-word { margin: 0; font: 800 clamp(40px, 10vw, 84px)/1 var(--display); letter-spacing: 0.01em; text-shadow: var(--shade-big); }
.big-number { margin: 0; font: 800 clamp(64px, 18vw, 160px)/0.9 var(--display); letter-spacing: 0; text-shadow: var(--shade-big); }
.big-number small { font-size: 0.32em; font-weight: 600; color: var(--ink-2); letter-spacing: 0.06em; margin-left: 0.15em; }
.sub { margin: 12px 0 0; font: 600 16px/1.35 var(--text); color: var(--ink-2); }
.sub.faint { color: var(--ink-3); font-size: 14px; font-weight: 400; min-height: 1.35em; }
.sub .ico { color: var(--sun); vertical-align: -2px; margin-right: 5px; }
.sub.new { color: var(--sun); }
.seeds-line { margin: 14px 0 0; font: 700 22px/1 var(--display); letter-spacing: 0.04em; color: var(--sun); display: inline-flex; gap: 6px; align-items: center; text-shadow: var(--shade-big); }
.seeds-line .ico { filter: drop-shadow(0 1px 2px rgba(30, 16, 6, 0.5)); }
.seeds-line:empty { display: none; }
.tap-cue { position: absolute; left: 0; right: 0; bottom: calc(15vh + var(--safe-b)); margin: 0; text-align: center; font: 700 17px/1 var(--display); letter-spacing: 0.14em; color: var(--ink-2);
  animation: breathe 2.4s ease-in-out infinite; pointer-events: none; }

/* the loading line */
.loadline { width: min(220px, 50vw); height: 2px; margin: 26px auto 0; background: rgba(248, 241, 230, 0.2); overflow: hidden; border-radius: 1px; }
.loadline i { display: block; height: 100%; width: 8%; background: var(--ink); transition: width 0.3s ease; }

/* small round icon buttons, in a corner */
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px;
  border: 0; background: rgba(24, 14, 8, 0.28); color: var(--ink); cursor: pointer; font-size: 19px; text-shadow: none; transition: background 0.2s ease, transform 0.15s ease; }
.icon-btn:hover { background: rgba(24, 14, 8, 0.45); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.icon-btn b, .icon-btn .q { font: 700 16px/1 var(--display); letter-spacing: 0.04em; }
.icon-btn.ready::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 8px var(--sun); }
.corner-bar { position: absolute; left: 0; right: 0; bottom: calc(18px + var(--safe-b)); display: flex; justify-content: center; gap: 10px; }
.close { position: absolute; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); z-index: 2; }

/* ---- the shop and the boards: one quiet sheet */
.sheet { width: min(440px, 100%); max-height: 100%; overflow-y: auto; text-align: left; }
.wallet { margin: 0 0 18px; display: flex; align-items: center; justify-content: center; gap: 8px; font: 800 40px/1 var(--display); color: var(--sun); }
.wallet .ico { font-size: 28px; }
.shop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.shop-list li { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 12px 12px 10px; border-radius: 16px; background: rgba(24, 14, 8, 0.32); }
.shop-list .up-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(248, 241, 230, 0.1); font-size: 20px; }
.shop-list .up-body b { display: block; font: 700 20px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.shop-list .up-line { display: block; margin-top: 4px; font-size: 13.5px; line-height: 1.3; color: var(--ink-2); }
.pips { display: flex; gap: 4px; margin-top: 7px; }
.pips i { width: 16px; height: 4px; border-radius: 2px; background: rgba(248, 241, 230, 0.26); }
.pips i.on { background: var(--sun); }
.buy { display: inline-flex; align-items: center; gap: 5px; height: 44px; min-width: 64px; justify-content: center; padding: 0 14px; border-radius: 20px; border: 0; background: var(--ink); color: #2a180a; font: 700 17px/1 var(--display); letter-spacing: 0.04em; cursor: pointer; text-shadow: none; }
.buy:disabled { background: rgba(248, 241, 230, 0.14); color: var(--ink-3); cursor: default; }
.shop-list li.max .buy { background: transparent; color: var(--sun); }

.tabs { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
/* (44 px tall to tap; the underline sits close under the word) */
.tab { border: 0; background: none; height: 44px; padding: 18px 8px 4px; font: 700 18px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { color: var(--ink); border-bottom-color: var(--sun); }
.tab:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; border-radius: 4px; }
.board-list { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.board-list li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 4px; border-bottom: 1px solid rgba(248, 241, 230, 0.1); }
.board-list li.me { color: var(--sun); }
.board-list li.gap { border: 0; padding: 2px; }
.board-list li.gap::before { content: '···'; grid-column: 1 / -1; text-align: center; color: var(--ink-3); }
.board-list .rk { font: 700 16px/1 var(--display); color: var(--ink-3); }
.board-list li.me .rk { color: var(--sun); }
.board-list .nm { font: 600 15px/1.2 var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .ds { font: 700 18px/1 var(--display); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.name-form { margin-top: 18px; display: flex; justify-content: center; }
#name-input { width: min(260px, 100%); height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid rgba(248, 241, 230, 0.25); background: rgba(24, 14, 8, 0.3);
  color: var(--ink); font: 600 15px var(--text); text-align: center; outline: none; user-select: text; -webkit-user-select: text; }
#name-input:focus { border-color: var(--sun); }
#name-input::placeholder { color: var(--ink-3); }

/* ---- the owner's dev menu (plain on purpose) */
#dev-tag { position: fixed; left: calc(10px + var(--safe-l)); top: calc(10px + var(--safe-t)); z-index: 6; font: 700 11px/1 var(--display); letter-spacing: 0.14em; color: #2a180a; background: var(--sun); padding: 4px 6px; border-radius: 4px; pointer-events: none; }
#fps { position: fixed; left: calc(10px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); z-index: 6; font: 600 12px/1 ui-monospace, monospace; color: var(--ink); text-shadow: var(--shade); pointer-events: none; }
.sheet.dev { width: min(480px, 100%); }
.dev-title { margin: 0 0 10px; font: 800 30px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--sun); }
.dev-knobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dev-knobs li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 0; border-bottom: 1px solid rgba(248, 241, 230, 0.08); }
.dev-knobs label { font: 600 14px/1.2 var(--text); }
.dev-knobs output { font: 700 15px/1.2 var(--display); color: var(--sun); text-align: right; }
.dev-knobs input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--sun); }
.dev-toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0; font: 600 14px var(--text); }
.dev-toggles label { display: inline-flex; gap: 6px; align-items: center; }
.dev-toggles input { accent-color: var(--sun); width: 18px; height: 18px; }
.dev-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dev-btn { height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid rgba(248, 241, 230, 0.25); background: rgba(24, 14, 8, 0.35); color: var(--ink); font: 600 13px var(--text); cursor: pointer; }
.dev-btn:active { transform: scale(0.96); }

/* ---- the end of a run: the upgrades are right there (picking one starts the next run), or play again */
#s-end .title-block { margin-top: -4vh; }
.end-pick { width: min(440px, 100%); margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 14px; animation: rise 0.5s 0.35s ease both; }
.end-wallet { margin: 0; display: inline-flex; align-items: center; gap: 6px; font: 700 17px/1 var(--display); letter-spacing: 0.04em; color: var(--ink); }
.end-wallet .ico { color: var(--sun); filter: drop-shadow(0 1px 2px rgba(30, 16, 6, 0.5)); }
.end-ups { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
/* each card is a piece of smoked glass: the scene blurred and darkened behind it, so it reads over bright sand,
   grass or white salt alike; one you can afford has a warm rim */
.up-card { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 15px 6px 13px; border-radius: 18px;
  border: 1px solid rgba(255, 200, 120, 0.6); background: rgba(var(--v), 0.58); color: var(--ink); cursor: pointer; text-shadow: none;
  backdrop-filter: blur(12px) saturate(1.15); -webkit-backdrop-filter: blur(12px) saturate(1.15);
  box-shadow: 0 0 0 1px rgba(255, 200, 120, 0.12) inset, 0 6px 22px rgba(var(--v), 0.3), 0 0 22px rgba(255, 180, 90, 0.16);
  transition: transform 0.15s ease, background 0.2s ease; }
.up-card:hover { background: rgba(var(--v), 0.72); }
.up-card:active { transform: scale(0.95); }
.up-card:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.up-card .up-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(248, 241, 230, 0.12); font-size: 19px; }
.up-card b { font: 700 16px/1 var(--display); letter-spacing: 0.05em; text-transform: uppercase; }
.up-card .pips i { background: rgba(248, 241, 230, 0.26); }
.up-card .pips i.on { background: var(--sun); }
.up-card .pips { margin-top: 0; gap: 3px; }
.up-card .pips i { width: 10px; }
.up-cost { display: inline-flex; align-items: center; gap: 4px; font: 700 16px/1 var(--display); letter-spacing: 0.04em; color: var(--sun); }
/* one you can't afford yet: the same glass without the rim, quieter, but still readable */
.up-card:disabled { border-color: rgba(248, 241, 230, 0.08); box-shadow: 0 6px 22px rgba(var(--v), 0.25); background: rgba(var(--v), 0.5); color: var(--ink-2); cursor: default; }
.up-card:disabled .up-icon { opacity: 0.7; }
.up-card:disabled .up-cost { color: var(--ink-3); }
.up-card.max { border-color: rgba(255, 200, 120, 0.3); }
.up-card.max .up-cost { color: var(--sun); }
.up-card kbd { position: absolute; top: 7px; right: 9px; font: 600 11px/1 var(--text); color: var(--ink-3); }
@media (hover: none) { .up-card kbd { display: none; } }
.again { display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 26px; border-radius: 25px; border: 0; background: var(--ink); color: #2a180a;
  font: 700 18px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; text-shadow: none; transition: transform 0.15s ease; }
.again:active { transform: scale(0.95); }
.again:focus-visible { outline: 2px solid var(--sun); outline-offset: 3px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

@media (max-height: 500px) {
  .title-block { margin-top: -14vh; }
  .wordmark { font-size: 52px; }
  .big-number { font-size: 80px; }
  .tap-cue { bottom: calc(80px + var(--safe-b)); }
  #s-menu .wordmark { font-size: 60px; }
  #s-menu .title-block { margin-bottom: calc(118px + var(--safe-b)); }
  #s-pause .title-block { margin-top: calc(12vh + var(--safe-t)); }
  .big-word { font-size: 56px; }
  #s-end .title-block { margin-top: 0; }
  #s-end .big-number { font-size: 64px; }
  .end-pick { margin-top: 12px; gap: 10px; }
  .up-card { flex-direction: row; justify-content: center; padding: 8px 6px; gap: 6px; }
  .up-card .up-icon, .up-card .pips { display: none; }
  .again { height: 42px; }
  .corner-bar { left: auto; right: calc(16px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); }
  .sheet { margin-top: 10px; }
}
/* (browsers without the discrete transitions above at least fade screens in, as before) */
@supports not (transition-behavior: allow-discrete) {
  .screen, #transit { animation: fadeIn 0.4s ease both; }
}
@media (prefers-reduced-motion: reduce) {
  .tap-cue { animation: none; opacity: 0.8; }
  #hud, #hud-moment, #transit, #transit-title, .screen, .end-pick, #veil i { transition: none; animation: none; }
  #hud-guide.on { animation: none; }
}
