/*
  Drop — visual system.

  Deliberately single-theme. This is an arcade cabinet, not a document: the
  orb ladder is a hue sweep that only reads against a dark ground, and a light
  variant would flatten the one piece of information the palette carries.
  Every colour is therefore painted explicitly rather than inherited, so the
  page holds up wherever it is embedded.
*/

:root {
  --ink:        #0A0C12;
  --ink-2:      #10141F;
  --vessel:     #141926;
  --line:       #262F44;
  --line-soft:  #1B2233;
  --text:       #E8EBF2;
  --muted:      #78829A;
  --amber:      #F5A524;
  --amber-dim:  #6B4A15;
  --danger:     #F2565B;

  --col:  clamp(300px, 100vw, 460px);
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;

  --f-display: "Archivo Black", "Arial Black", system-ui, sans-serif;
  --f-body:    "IBM Plex Sans", system-ui, -apple-system, Segoe UI, sans-serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--f-body);
  /* A game is a direct-manipulation surface: text selection and the iOS
     double-tap zoom both fight the controls rather than helping. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* A very faint vignette so the jar sits in a space rather than on a flat fill. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 0%, #1A2133 0%, transparent 60%),
    radial-gradient(100% 60% at 50% 100%, #131A29 0%, transparent 55%);
  opacity: 0.75;
  z-index: 0;
}

.frame {
  position: relative;
  z-index: 1;
  width: var(--col);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    max(10px, env(safe-area-inset-top)) 12px
    max(10px, env(safe-area-inset-bottom));
  gap: 10px;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; }

/* The mark is the game in one glyph: a small orb merging into a larger one. */
.mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #6FE3C4, #17A87E 62%, #0C7357);
  box-shadow:
    0 0 0 2px #0A0C12,
    -9px 3px 0 -4px #F5A524,
    0 4px 12px rgba(23, 168, 126, 0.45);
}

.wordmark {
  font-family: var(--f-display);
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.daytag {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-2);
}
.daytag-n { font-family: var(--f-mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.daytag-l { font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.icon-btn {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}
.icon-btn:hover { color: var(--text); border-color: #3A4560; }
.icon-btn[aria-pressed="false"] { color: #4A5268; }

/* --------------------------------------------------------------------- hud */

.hud {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 62px;
}

.label {
  display: block;
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.score {
  display: block;
  font-family: var(--f-display);
  font-size: 40px;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
/* Fires on every score change; the class is removed on animationend. */
.score.bump { animation: bump 0.32s cubic-bezier(0.34, 1.7, 0.5, 1); }
@keyframes bump { 0% { transform: scale(1); } 38% { transform: scale(1.13); color: var(--amber); } 100% { transform: scale(1); } }

/* The orb budget sits under the score because it is the other half of the
   same fact: what you have made, and what you have left to make it with. */
.orbs {
  display: block;
  margin-top: 2px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s;
}
.orbs[data-low="true"] { color: var(--amber); }

.hud-chain { opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; }
.hud-chain[data-active="true"] { opacity: 1; transform: none; }
.chain {
  font-family: var(--f-display);
  font-size: 17px;
  color: var(--amber);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(245, 165, 36, 0.13);
  border: 1px solid rgba(245, 165, 36, 0.4);
}

.hud-next { text-align: right; }
.hud-next .label { margin-bottom: 2px; }
#nextCanvas { width: 42px; height: 42px; display: block; margin-left: auto; }

/* ------------------------------------------------------------------- stage */

/* The stage is only a centring box. The jar itself is the canvas, which JS
   sizes to the largest 420:700 rectangle that fits — a fixed world size is
   what makes the daily board a fair comparison between players. */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board {
  display: block;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-soft);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 18px 44px rgba(0, 0, 0, 0.5);
  /* Aiming is a drag on touch; without this the page pans instead. */
  touch-action: none;
}

/* --------------------------------------------------------------- overlays */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 10, 16, 0.86);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s;
}
.overlay[data-open="true"] { opacity: 1; visibility: visible; }

.panel {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  padding: 4px 2px;
}
.overlay[data-open="true"] .panel > * {
  animation: rise 0.44s cubic-bezier(0.2, 0.8, 0.25, 1) backwards;
}
/* Staged entrance — the panel assembles rather than appearing all at once. */
.overlay[data-open="true"] .panel > *:nth-child(1) { animation-delay: 0.02s; }
.overlay[data-open="true"] .panel > *:nth-child(2) { animation-delay: 0.07s; }
.overlay[data-open="true"] .panel > *:nth-child(3) { animation-delay: 0.12s; }
.overlay[data-open="true"] .panel > *:nth-child(4) { animation-delay: 0.17s; }
.overlay[data-open="true"] .panel > *:nth-child(5) { animation-delay: 0.22s; }
.overlay[data-open="true"] .panel > *:nth-child(6) { animation-delay: 0.27s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.kicker {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 10px;
}
.title {
  font-family: var(--f-display);
  font-size: clamp(48px, 17vw, 72px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 14px;
  line-height: 0.95;
}
.blurb {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 auto 12px;
  max-width: 30ch;
  text-wrap: balance;
}
.blurb.strong { color: var(--text); }

.final {
  font-family: var(--f-display);
  font-size: clamp(52px, 19vw, 78px);
  font-variant-numeric: tabular-nums;
  margin: 0 0 16px;
  line-height: 1;
}

.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat {
  padding: 9px 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--ink-2);
}
.stat-v {
  display: block;
  font-family: var(--f-mono);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-bottom: 3px;
}
.stat-l {
  display: block;
  font-family: var(--f-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.namerow { margin-bottom: 12px; text-align: left; }
.namerow .label { margin-bottom: 5px; }
#nameInput {
  width: 100%;
  font-family: var(--f-body);
  font-size: 15px;
  color: var(--text);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
#nameInput:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
#nameInput::placeholder { color: #4A5268; }

.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }

.btn {
  font-family: var(--f-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 18px;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.18s, background 0.18s;
}
.btn:hover { border-color: #3A4560; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.btn.primary {
  color: #1A1204;
  background: linear-gradient(180deg, #FFC65A, var(--amber));
  border-color: #C98615;
  box-shadow: 0 6px 18px rgba(245, 165, 36, 0.24);
}
.btn.primary:hover { box-shadow: 0 9px 24px rgba(245, 165, 36, 0.34); }

#playBtn { width: 100%; font-size: 16px; padding: 15px; }

.fineprint {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 0 0;
  min-height: 14px;
}

/* -------------------------------------------------------------- leaderboard */

.board { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); text-align: left; }
.board .label { margin-bottom: 9px; }
.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lb li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  font-size: 13px;
}
.lb li:nth-child(odd) { background: rgba(255,255,255,0.022); }
.lb li[data-you="true"] {
  background: rgba(245, 165, 36, 0.11);
  box-shadow: inset 0 0 0 1px rgba(245, 165, 36, 0.34);
}
.lb .r { font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .s { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.lb .empty { display: block; color: var(--muted); font-size: 13px; padding: 7px 9px; }

/* ------------------------------------------------------------------ ladder */

.ladder {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  height: 26px;
  padding-bottom: 2px;
}
.rung {
  border-radius: 50%;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.34, 1.6, 0.5, 1), box-shadow 0.45s;
  opacity: 0.17;
  filter: saturate(0.28);
}
.rung[data-lit="true"] { opacity: 1; filter: none; }
/* Applied for one animation when a tier is reached for the first time. */
.rung.pop { animation: rungPop 0.62s cubic-bezier(0.34, 1.7, 0.4, 1); }
@keyframes rungPop {
  0%   { transform: scale(1); }
  35%  { transform: scale(2.1); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  z-index: 40;
  padding: 10px 16px;
  border-radius: 999px;
  background: #1B2233;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgba(0,0,0,0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s, transform 0.24s, visibility 0.24s;
}
.toast[data-open="true"] { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- a11y, fit */

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

/* Short landscape phones: reclaim vertical space from the chrome so the jar
   keeps a playable height rather than collapsing to a letterbox. */
@media (max-height: 620px) {
  .score { font-size: 30px; }
  .hud { min-height: 50px; }
  .ladder { height: 18px; }
  .frame { gap: 7px; }
}
