/* ==========================================================================
   Humanity First – Aid Stack Challenge · Stylesheet
   Visual language shared with mow.humanityfirst.de: deep navy ground, a slow
   sunburst behind everything, Luckiest Guy headlines and chunky pill buttons
   with a hard dark shadow.
   ========================================================================== */
:root {
  /* --- accents and outlines from mow.humanityfirst.de, on a bright ground --- */
  --ink: #0A2C4A;
  --ink-2: #123E63;
  --ink-3: #1E5480;
  --shadow: #001B31;
  --sky-pale: #DFF0FA;
  --sand: #F7E7C8;
  --sand-high: #FDF3E1;
  --sun: #F39200;
  --sun-dark: #C87500;
  --sky: #0069B4;
  --sky-light: #35A0E4;
  --lime: #17775C;
  --lime-light: #1E9673;
  --coral: #B81867;
  --red: #E30613;
  --cream: #FFFFFF;
  --cream-dim: #5C7B93;
  --cream-soft: #3F5D77;

  --display: 'Luckiest Guy', 'Arial Black', Impact, sans-serif;
  --body: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;

  --radius-xl: clamp(20px, 3vmin, 34px);
  --btn-size: clamp(48px, 7vmin, 74px);
  --btn-gap: clamp(8px, 1.4vmin, 16px);
  --controls-w: calc(3 * var(--btn-size) + 2 * var(--btn-gap) + 40px);
  --edge: clamp(5px, 0.55vmin, 7px);          /* chunky border width */
  --drop: clamp(6px, 0.85vmin, 10px);         /* hard shadow offset */
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--sky-pale);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 500;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

img { -webkit-user-drag: none; pointer-events: none; }
button { font-family: inherit; cursor: pointer; touch-action: manipulation; border: 0; background: none; color: inherit; }
button:focus { outline: none; }
button:focus-visible { outline: 3px solid var(--sun); outline-offset: 4px; }

.app { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.game-canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.is-hidden { display: none !important; }

/* ==========================================================================
   Chunky controls
   ========================================================================== */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  font-family: var(--display);
  letter-spacing: 0.05em;
  border-radius: 999px;
  border: var(--edge) solid var(--shadow);
  box-shadow: 0 var(--drop) 0 var(--shadow);
  transition: transform 0.09s ease, box-shadow 0.09s ease, background 0.18s;
  white-space: nowrap;
  max-width: 100%;
}
.btn-primary:active,
.btn-secondary:active {
  transform: translateY(var(--drop));
  box-shadow: 0 0 0 var(--shadow);
}

.btn-primary {
  margin-top: clamp(6px, 1.4vmin, 16px);
  padding: 0 clamp(30px, 5vmin, 74px);
  min-height: clamp(62px, 9vmin, 104px);
  background: var(--sun);
  color: var(--shadow);
  font-size: clamp(22px, 3.6vmin, 42px);
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); box-shadow: 0 calc(var(--drop) + 4px) 0 var(--shadow); }
}
.btn-primary:active { animation: none; }
.btn-compact {
  min-height: clamp(54px, 7.5vmin, 84px);
  padding: 0 clamp(26px, 4.4vmin, 58px);
  animation: none;
  margin-top: 0;
}

.btn-secondary {
  min-height: clamp(50px, 7vmin, 74px);
  padding: 0 clamp(18px, 3vmin, 34px);
  background: var(--cream);
  color: var(--ink);
  font-size: clamp(14px, 2.1vmin, 24px);
}
.btn-secondary .icon { width: 1.25em; height: 1.25em; }
.btn-toggle .toggle-dot {
  position: relative; width: 1.7em; height: 0.95em; border-radius: 999px;
  background: #C3D4E1; transition: background 0.2s;
}
.btn-toggle .toggle-dot::after {
  content: ''; position: absolute; top: 0.11em; left: 0.13em;
  width: 0.72em; height: 0.72em; border-radius: 50%; background: var(--cream);
  box-shadow: 0 1px 2px rgba(0, 27, 49, 0.35);
  transition: left 0.2s, background 0.2s;
}
.btn-toggle.on { background: var(--sun); color: var(--shadow); }
.btn-toggle.on .toggle-dot::after { left: 0.85em; background: var(--cream); }
.btn-toggle.on .toggle-dot { background: var(--shadow); }

/* round icon buttons, top right */
.controls {
  position: absolute;
  top: clamp(14px, 2.6vmin, 30px);
  right: clamp(16px, 3vmin, 40px);
  display: flex;
  gap: var(--btn-gap);
  z-index: 20;
}
.icon-btn {
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: 50%;
  background: var(--cream);
  border: 3px solid var(--shadow);
  box-shadow: 0 4px 0 var(--shadow);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: clamp(13px, 2vmin, 20px);
  letter-spacing: 0.04em;
  transition: transform 0.12s ease, background 0.2s, color 0.2s;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); background: var(--sun); }
.icon-btn .icon { width: 54%; height: 54%; }
.icon-btn .icon-sound-off { display: none; }
.icon-btn.muted .icon-sound-on { display: none; }
.icon-btn.muted .icon-sound-off { display: block; }
.icon-btn.muted { color: #8AA2B5; }

/* ==========================================================================
   In-game HUD – figures sit at the left and right edge without any box,
   so the middle of the screen belongs to the crane alone.
   ========================================================================== */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: clamp(10px, 2vmin, 26px) clamp(16px, 3vmin, 40px) 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 5;
}
.hud-side { display: flex; flex-direction: column; min-width: 0; }
.hud-left { align-items: flex-start; }
.hud-right { align-items: flex-end; margin-right: var(--controls-w); }
.hud-row { display: flex; align-items: flex-start; gap: clamp(18px, 3vmin, 46px); }
.hud-item { display: flex; flex-direction: column; min-width: 0; }
.hud-right .hud-item { align-items: flex-end; }

.hud-label {
  font-family: var(--body);
  font-size: clamp(11px, 1.5vmin, 17px);
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--ink-3);
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}
.hud-value {
  font-family: var(--display);
  font-size: clamp(30px, 6vmin, 72px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--cream);
  -webkit-text-stroke: clamp(1.5px, 0.24vmin, 3px) var(--shadow);
  paint-order: stroke fill;
  text-shadow: 0 clamp(3px, 0.45vmin, 5px) 0 var(--shadow);
  transition: transform 0.15s ease;
}
.hud-value-accent { color: var(--sun); }
.hud-value.bump { transform: scale(1.14); }

.hud-combo {
  margin-top: 2px;
  font-family: var(--display);
  font-size: clamp(13px, 2vmin, 23px);
  letter-spacing: 0.1em;
  color: var(--sun);
  -webkit-text-stroke: 2px var(--shadow);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 var(--shadow);
  min-height: 1.4em;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
}
.hud-combo.show { opacity: 1; transform: translateY(0); }

/* status labels: no box either, just outlined type */
.hud-powerups { display: flex; gap: clamp(10px, 1.6vmin, 20px); margin-top: 4px; flex-wrap: wrap; }
.pu-chip {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(11px, 1.6vmin, 18px);
  letter-spacing: 0.06em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: chip-in 0.3s ease;
}
.pu-chip svg, .pu-chip img { width: 1.25em; height: 1.25em; }
@keyframes chip-in { from { opacity: 0; transform: translateY(-8px) scale(0.9); } to { opacity: 1; transform: none; } }

.game-badges { display: flex; gap: clamp(10px, 1.6vmin, 20px); margin-top: 3px; pointer-events: none; }
.game-badge {
  font-family: var(--display);
  letter-spacing: 0.14em;
  font-size: clamp(11px, 1.55vmin, 17px);
  white-space: nowrap;
  -webkit-text-stroke: 2px var(--shadow);
  paint-order: stroke fill;
}
.game-badge-kids { color: var(--sun); }
.game-badge-speed { color: var(--cream); }

/* ==========================================================================
   Screens
   ========================================================================== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: screen-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(92vw, 900px);
  gap: clamp(5px, 1.2vmin, 14px);
  animation: inner-in 0.55s cubic-bezier(0.2, 0.9, 0.2, 1);
}
@keyframes inner-in { from { opacity: 0; transform: translateY(22px) scale(0.98); } to { opacity: 1; transform: none; } }

.screen-start {
  /* the demo tower keeps sitting behind, blurred back so it reads as depth */
  background: radial-gradient(ellipse at 50% 45%, rgba(238, 248, 253, 0.72) 0%, rgba(232, 244, 251, 0.84) 55%, rgba(250, 240, 222, 0.90) 100%);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  padding-bottom: clamp(40px, 5.5vmin, 74px);
}
.logo-wrap { margin-bottom: clamp(2px, 0.6vmin, 10px); }
.logo {
  height: clamp(70px, 13vmin, 156px);
  width: auto;
  display: block;
  filter: drop-shadow(0 5px 6px rgba(0, 27, 49, 0.22));
}
.logo-fallback {
  display: inline-flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--cream); font-family: var(--display); letter-spacing: 0.1em;
  font-size: clamp(18px, 3vmin, 30px);
}
.logo-fallback .mark {
  width: clamp(80px, 15vmin, 160px); height: clamp(56px, 10vmin, 112px);
  border-radius: 50%; background: var(--cream);
  display: grid; place-items: center; color: var(--sky); font-size: clamp(30px, 6vmin, 62px);
}
.brandline {
  font-family: var(--display);
  font-size: clamp(11px, 1.5vmin, 17px);
  letter-spacing: 0.36em;
  color: var(--sun);
}

.title {
  margin: 0;
  display: flex;
  flex-direction: column;
  line-height: 0.92;
  font-family: var(--display);
  font-size: clamp(40px, 8.6vmin, 108px);
  letter-spacing: 0.015em;
  color: var(--cream);
  -webkit-text-stroke: clamp(4px, 0.7vmin, 9px) var(--shadow);
  paint-order: stroke fill;
  text-shadow: 0 clamp(6px, 0.95vmin, 12px) 0 var(--shadow);
}
.title-accent { color: var(--sun); }
.subtitle {
  margin: 0;
  font-size: clamp(17px, 2.9vmin, 34px);
  font-weight: 700;
  color: var(--ink-2);
}
.hint {
  margin: 0;
  font-size: clamp(13px, 2vmin, 22px);
  font-weight: 600;
  color: var(--cream-dim);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.program-chips {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: clamp(6px, 1vmin, 12px);
  margin-top: clamp(4px, 1vmin, 12px);
  max-width: 820px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  background: var(--cream);
  border: 2px solid var(--shadow);
  font-size: clamp(11px, 1.5vmin, 15px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.start-best {
  font-size: clamp(12px, 1.9vmin, 19px);
  font-weight: 700;
  color: var(--cream-dim);
  letter-spacing: 0.06em;
  min-height: 1.4em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.start-best strong { color: #C87500; font-family: var(--display); font-weight: 400; letter-spacing: 0.04em; }

.screen-footer {
  position: absolute;
  bottom: clamp(12px, 2.2vmin, 26px);
  font-family: var(--display);
  font-size: clamp(11px, 1.5vmin, 17px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(10, 44, 74, 0.42);
}

/* --- speed levels + mode row --- */
.speed-row {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(8px, 1.4vmin, 16px);
  margin-top: clamp(4px, 1vmin, 12px);
  flex-wrap: wrap;
}
.speed-label {
  font-family: var(--display);
  font-size: clamp(11px, 1.5vmin, 16px);
  letter-spacing: 0.22em;
  color: var(--cream-dim);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.speed-options {
  display: flex;
  padding: clamp(4px, 0.55vmin, 7px);
  border-radius: 999px;
  background: var(--cream);
  border: 3px solid var(--shadow);
  box-shadow: 0 4px 0 var(--shadow);
  gap: clamp(3px, 0.5vmin, 6px);
}
.speed-btn {
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  min-height: clamp(38px, 5.2vmin, 58px);
  padding: 0 clamp(14px, 2.4vmin, 32px);
  font-family: var(--display);
  font-size: clamp(12px, 1.8vmin, 21px);
  letter-spacing: 0.06em;
  transition: background 0.18s, color 0.18s, transform 0.1s ease;
}
.speed-btn:active { transform: scale(0.95); }
.speed-btn.on { background: var(--sun); color: var(--shadow); }
.speed-row.disabled { opacity: 0.4; pointer-events: none; }

.mode-row {
  display: flex; gap: clamp(10px, 1.6vmin, 18px);
  flex-wrap: wrap; justify-content: center;
  margin-top: clamp(4px, 1vmin, 12px);
}

/* ==========================================================================
   Cards on the dark ground
   ========================================================================== */
/* Corner information carries no box – outlined type on the open sky. */
.community-card,
.leaderboard-card {
  position: absolute;
  z-index: 11;
  animation: inner-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.community-card {
  top: clamp(10px, 2vmin, 26px);
  left: clamp(16px, 3vmin, 40px);
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vmin, 18px);
}
.community-tower { display: flex; flex-direction: column-reverse; gap: 2px; width: clamp(28px, 4vmin, 44px); align-items: center; }
.community-tower span { display: block; height: clamp(6px, 0.85vmin, 10px); border-radius: 2px; box-shadow: 0 0 0 1.5px var(--shadow); }
.community-body { display: flex; flex-direction: column; line-height: 1.05; }
.community-label { font-family: var(--display); font-size: clamp(10px, 1.35vmin, 15px); letter-spacing: 0.18em; color: #C87500; text-shadow: 0 1px 0 rgba(255,255,255,0.8); }
.community-value {
  font-family: var(--display); font-size: clamp(28px, 5.2vmin, 62px); color: var(--cream);
  -webkit-text-stroke: clamp(1.5px, 0.24vmin, 3px) var(--shadow); paint-order: stroke fill;
  text-shadow: 0 clamp(3px, 0.45vmin, 5px) 0 var(--shadow);
}
.community-unit { font-family: var(--display); font-size: clamp(11px, 1.5vmin, 17px); letter-spacing: 0.12em; color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,0.8); }
.community-total { margin-top: 4px; font-size: clamp(10px, 1.4vmin, 14px); font-weight: 800; color: var(--cream-dim); text-shadow: 0 1px 0 rgba(255,255,255,0.8); }

.leaderboard-card {
  right: clamp(16px, 3vmin, 40px);
  top: calc(clamp(10px, 2vmin, 26px) + var(--btn-size) + 18px);
  width: max-content;
  max-width: clamp(250px, 30vmin, 430px);
}
.leaderboard-head { text-align: right; }
.leaderboard-title { font-family: var(--display); font-size: clamp(11px, 1.45vmin, 16px); letter-spacing: 0.18em; color: #C87500; text-shadow: 0 1px 0 rgba(255,255,255,0.8); }
.leaderboard-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; }
.lb-row {
  display: grid; grid-template-columns: 1.4em minmax(3.4em, 1fr) 2.2em auto;
  max-width: 100%;
  align-items: baseline; gap: clamp(6px, 0.9vmin, 11px);
  font-size: clamp(11px, 1.6vmin, 17px); font-weight: 700; padding: 3px 4px;
  border-bottom: 1px solid rgba(10, 44, 74, 0.14);
  color: var(--cream-soft);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
.lb-row:last-child { border-bottom: 0; }
.lb-row.is-new { background: rgba(255, 214, 150, 0.55); border-radius: 8px; }
.lb-rank { font-family: var(--display); color: var(--cream-dim); }
.lb-row:nth-child(-n+3) .lb-rank { color: #C87500; }
.lb-name {
  color: var(--ink); letter-spacing: 0.02em; font-size: 0.95em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-height { font-family: var(--display); color: var(--sky); text-align: right; }
.lb-score { color: var(--cream-dim); font-weight: 700; font-size: 0.85em; text-align: right; }
.lb-kids { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--sun); color: var(--shadow); font-size: 0.7em; font-weight: 800; vertical-align: middle; }
.leaderboard-empty { margin: 8px 0 0; font-size: clamp(11px, 1.45vmin, 15px); color: var(--cream-dim); font-weight: 700; text-shadow: 0 1px 0 rgba(255,255,255,0.8); }

/* ==========================================================================
   Result panels
   ========================================================================== */
.screen-gameover, .screen-name { background: rgba(6, 38, 64, 0.42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.panel {
  background: var(--cream);
  color: var(--ink);
  border-radius: var(--radius-xl);
  border: var(--edge) solid var(--shadow);
  box-shadow: 0 var(--drop) 0 var(--shadow), 0 30px 70px rgba(0, 12, 24, 0.5);
  padding: clamp(22px, 3.6vmin, 46px) clamp(24px, 4.6vmin, 62px) clamp(20px, 3vmin, 36px);
  width: min(94vw, 1180px);
  max-height: 94vh;
  position: relative;
  overflow: hidden;
}
.panel-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(18px, 3.4vmin, 50px); align-items: center; }
.panel-main { display: flex; flex-direction: column; align-items: center; text-align: center; gap: clamp(5px, 1.2vmin, 14px); }
.panel-side { display: flex; flex-direction: column; gap: clamp(11px, 1.8vmin, 20px); text-align: left; min-width: 0; }

.eyebrow {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(14px, 2.1vmin, 24px);
  letter-spacing: 0.2em;
  color: var(--sky);
}
.big-number {
  font-family: var(--display);
  font-size: clamp(84px, 16vmin, 190px);
  line-height: 0.94;
  letter-spacing: 0.01em;
  color: var(--sky);
}
.big-label {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(16px, 2.6vmin, 30px);
  letter-spacing: 0.2em;
  color: var(--ink);
}
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.record-badge {
  padding: 5px 18px;
  border-radius: 999px;
  border: 3px solid var(--shadow);
  background: var(--sun);
  color: var(--shadow);
  font-family: var(--display);
  letter-spacing: 0.12em;
  font-size: clamp(12px, 1.9vmin, 20px);
  animation: badge-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes badge-pop { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
.rank-badge { background: var(--sky-light); color: var(--shadow); }
.kids-pill { background: var(--lime); color: var(--cream); }

.stats { display: flex; gap: clamp(26px, 6vmin, 84px); margin-top: clamp(4px, 1.2vmin, 14px); }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-label { font-size: clamp(11px, 1.6vmin, 17px); font-weight: 800; letter-spacing: 0.2em; color: #5B7A93; }
.stat-value { font-family: var(--display); font-size: clamp(30px, 5.2vmin, 60px); line-height: 1.1; color: var(--ink); }
.stat-value-accent { color: var(--sky); }
.message {
  margin: clamp(4px, 1vmin, 10px) 0 0;
  font-size: clamp(14px, 2.2vmin, 25px);
  font-weight: 600;
  color: #3F5D77;
}
.community-added {
  padding: 5px 16px;
  border-radius: 999px;
  border: 3px solid var(--shadow);
  background: var(--lime);
  color: var(--cream);
  font-family: var(--display);
  font-size: clamp(12px, 1.7vmin, 19px);
  letter-spacing: 0.06em;
}
.timeout-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: rgba(0, 27, 49, 0.14); }
.timeout-fill { height: 100%; width: 100%; background: var(--sun); transform-origin: left; }

/* side column: impact, fact, donation */
.side-title { margin: 0 0 6px; font-family: var(--display); font-size: clamp(11px, 1.55vmin, 17px); letter-spacing: 0.2em; color: #5B7A93; }
.impact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: clamp(6px, 1vmin, 12px); }
.impact-item { display: flex; align-items: center; gap: clamp(10px, 1.6vmin, 18px); }
.impact-number { font-family: var(--display); font-size: clamp(22px, 3.4vmin, 40px); color: var(--ink); line-height: 1; }
.impact-unit { font-size: clamp(12px, 1.8vmin, 20px); font-weight: 600; color: #3F5D77; }
.impact-note { margin: 4px 0 0; font-size: clamp(10px, 1.25vmin, 13px); color: #7B94A9; font-style: italic; }
.fact {
  background: #EEF4F9;
  border-radius: clamp(12px, 1.8vmin, 20px);
  padding: clamp(11px, 1.8vmin, 20px);
  border-left: 7px solid var(--accent, var(--sky));
}
.fact-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.fact-icon { width: clamp(30px, 4.2vmin, 46px); height: clamp(30px, 4.2vmin, 46px); }
.fact-program { font-family: var(--display); font-size: clamp(11px, 1.65vmin, 18px); letter-spacing: 0.14em; color: var(--accent, var(--sky)); }
.fact-text { margin: 0; font-size: clamp(13px, 2vmin, 21px); font-weight: 600; color: var(--ink); line-height: 1.32; }
.fact-source { margin: 6px 0 0; font-size: clamp(10px, 1.25vmin, 13px); color: #7B94A9; }
.donate { display: flex; align-items: center; gap: clamp(12px, 2vmin, 22px); }
.donate-qr {
  width: clamp(92px, 14vmin, 160px);
  height: clamp(92px, 14vmin, 160px);
  border-radius: 12px;
  border: 4px solid var(--shadow);
  image-rendering: pixelated;
  flex: none;
}
.donate-text { display: flex; flex-direction: column; gap: 4px; }
.donate-title { font-family: var(--display); font-size: clamp(12px, 1.8vmin, 20px); letter-spacing: 0.1em; color: var(--sky); }
.donate-hint { font-size: clamp(12px, 1.8vmin, 20px); font-weight: 600; color: #3F5D77; }
.donate-url { font-family: var(--display); font-size: clamp(13px, 1.9vmin, 21px); color: var(--ink); }

/* ==========================================================================
   Toasts, banners, attract mode
   ========================================================================== */
/* The milestone message hugs an edge so it never covers the drop zone. */
.milestone {
  position: absolute;
  top: clamp(118px, 20vmin, 250px);
  left: clamp(14px, 2.6vmin, 36px);
  right: auto;
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.7vmin, 20px);
  padding: clamp(8px, 1.4vmin, 16px) clamp(18px, 2.6vmin, 30px) clamp(8px, 1.4vmin, 16px) clamp(10px, 1.5vmin, 17px);
  background: var(--cream);
  border-radius: clamp(20px, 3vmin, 40px);
  border: var(--edge) solid var(--shadow);
  box-shadow: 0 var(--drop) 0 var(--shadow);
  z-index: 8;
  pointer-events: none;
  animation: toast-in-left 0.45s cubic-bezier(0.2, 1.2, 0.3, 1);
  max-width: min(42vw, 560px);
}
.milestone.on-right {
  left: auto;
  right: clamp(14px, 2.6vmin, 36px);
  animation-name: toast-in-right;
}
.milestone.leaving { animation: toast-out-left 0.35s ease forwards; }
.milestone.on-right.leaving { animation-name: toast-out-right; }
@keyframes toast-in-left { from { opacity: 0; transform: translateX(-34px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toast-in-right { from { opacity: 0; transform: translateX(34px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toast-out-left { to { opacity: 0; transform: translateX(-24px) scale(0.97); } }
@keyframes toast-out-right { to { opacity: 0; transform: translateX(24px) scale(0.97); } }
.milestone-icon { width: clamp(42px, 6.4vmin, 72px); height: clamp(42px, 6.4vmin, 72px); }
.milestone-text { display: flex; flex-direction: column; text-align: left; min-width: 0; }
.milestone-program { font-family: var(--display); font-size: clamp(11px, 1.7vmin, 19px); letter-spacing: 0.16em; color: var(--accent, var(--sky)); }
.milestone-quote { font-size: clamp(14px, 2.2vmin, 27px); font-weight: 700; color: var(--ink); line-height: 1.2; }

.banner {
  position: absolute;
  left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  padding: clamp(9px, 1.5vmin, 17px) clamp(24px, 3.6vmin, 44px);
  border-radius: 999px;
  border: var(--edge) solid var(--shadow);
  box-shadow: 0 var(--drop) 0 var(--shadow);
  background: var(--sky-light);
  color: var(--shadow);
  font-family: var(--display);
  font-size: clamp(18px, 3.2vmin, 40px);
  letter-spacing: 0.1em;
  pointer-events: none;
  z-index: 8;
  animation: banner-in 1.6s cubic-bezier(0.2, 1, 0.3, 1) forwards;
  white-space: nowrap;
}
.banner.gold { background: var(--sun); }
.banner.left { left: 25%; }
.banner.right { left: 75%; }
@keyframes banner-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.98); }
}

.attract { position: absolute; inset: 0; pointer-events: none; z-index: 9; }
.attract-badge {
  position: absolute;
  top: calc(clamp(12px, 2.4vmin, 30px) + clamp(60px, 10vmin, 118px));
  left: 50%; transform: translateX(-50%);
  padding: 3px 15px;
  border-radius: 999px;
  border: 3px solid var(--shadow);
  background: var(--cream);
  color: var(--ink-2);
  font-family: var(--display);
  font-size: clamp(11px, 1.5vmin, 16px);
  letter-spacing: 0.22em;
}
.attract-cta {
  position: absolute;
  left: 50%; bottom: clamp(56px, 13vmin, 170px);
  transform: translateX(-50%);
  padding: clamp(14px, 2.4vmin, 28px) clamp(36px, 6vmin, 84px);
  border-radius: 999px;
  border: var(--edge) solid var(--shadow);
  box-shadow: 0 var(--drop) 0 var(--shadow);
  background: var(--sun);
  color: var(--shadow);
  font-family: var(--display);
  font-size: clamp(24px, 4.6vmin, 58px);
  letter-spacing: 0.1em;
  white-space: nowrap;
  animation: cta-pulse 1.4s ease-in-out infinite;
}
@keyframes cta-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* ==========================================================================
   Duel
   ========================================================================== */
.hud-duel {
  position: absolute; top: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr 1fr;
  padding: clamp(12px, 2.4vmin, 30px) 0 0;
  pointer-events: none; z-index: 5;
}
.hud-half { display: flex; flex-direction: column; align-items: center; }
/* in landscape the round buttons sit top right, so player 2 moves clear of them */
@media (orientation: landscape) {
  .hud-duel .hud-half[data-slot="1"] { padding-right: var(--controls-w); }
}
.hud-player {
  font-family: var(--display); font-size: clamp(12px, 1.7vmin, 19px); letter-spacing: 0.2em;
  color: var(--sky); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}
.hud-half[data-slot="1"] .hud-player { color: #C87500; }
.hud-pair { display: flex; gap: clamp(20px, 4vmin, 60px); }
.hud-pair .hud-item { align-items: center; }
.hud-duel .hud-combo { position: static; }
.duel-divider {
  position: absolute; left: 50%; top: clamp(84px, 13vmin, 154px); bottom: 0; width: 3px;
  background: linear-gradient(180deg, rgba(0,27,49,0) 0%, rgba(0,27,49,0.20) 15%, rgba(0,27,49,0.20) 85%, rgba(0,27,49,0) 100%);
  z-index: 4; pointer-events: none;
}
.countdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 9; pointer-events: none; }
.countdown span {
  font-family: var(--display);
  font-size: clamp(120px, 28vmin, 300px);
  color: var(--sun);
  -webkit-text-stroke: clamp(6px, 1vmin, 12px) var(--shadow);
  paint-order: stroke fill;
  text-shadow: 0 clamp(8px, 1.4vmin, 16px) 0 var(--shadow);
  animation: count-pop 0.95s ease-out forwards;
}
@keyframes count-pop {
  0% { transform: scale(1.7); opacity: 0; } 18% { transform: scale(1); opacity: 1; }
  75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.85); }
}
.duel-status { position: absolute; top: 42%; width: 50%; text-align: center; pointer-events: none; z-index: 8; }
.duel-status[data-slot="0"] { left: 0; }
.duel-status[data-slot="1"] { left: 50%; }
.duel-status .out {
  display: inline-block; padding: 8px 28px; border-radius: 999px;
  border: var(--edge) solid var(--shadow); box-shadow: 0 var(--drop) 0 var(--shadow);
  background: var(--red); color: var(--cream);
  font-family: var(--display); font-size: clamp(22px, 3.8vmin, 46px); letter-spacing: 0.14em;
  animation: badge-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.duel-status .sub {
  display: block; margin-top: 12px; color: var(--ink); font-weight: 800;
  font-size: clamp(13px, 2vmin, 22px); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.duel-panel { width: min(94vw, 980px); display: flex; flex-direction: column; align-items: center; text-align: center; gap: clamp(5px, 1.2vmin, 14px); }
.duel-winner { font-family: var(--display); font-size: clamp(30px, 5.6vmin, 68px); color: var(--sky); }
.duel-columns { display: grid; grid-template-columns: 1fr auto 1fr; gap: clamp(14px, 2.6vmin, 36px); align-items: center; width: 100%; }
.duel-col { display: flex; flex-direction: column; align-items: center; padding: clamp(9px, 1.8vmin, 18px); border-radius: 20px; background: #EEF4F9; border: 4px solid transparent; }
.duel-col.winner { border-color: var(--sun); background: #FFF4E2; }
.duel-name { font-family: var(--display); font-size: clamp(12px, 1.8vmin, 20px); letter-spacing: 0.18em; color: #5B7A93; }
.duel-number { font-size: clamp(60px, 12vmin, 140px); }
.duel-score { font-family: var(--display); font-size: clamp(15px, 2.4vmin, 28px); color: #3F5D77; }
.duel-vs { font-family: var(--display); font-size: clamp(18px, 2.8vmin, 34px); color: #7B94A9; letter-spacing: 0.06em; }

/* ==========================================================================
   Name entry
   ========================================================================== */
.name-panel { width: min(94vw, 900px); display: flex; flex-direction: column; align-items: center; text-align: center; gap: clamp(7px, 1.3vmin, 15px); }
.name-rank { font-family: var(--display); font-size: clamp(22px, 3.8vmin, 46px); color: var(--sky); letter-spacing: 0.06em; }
.name-rank span:first-child { font-size: 1.4em; }
.name-prompt { margin: 0; font-size: clamp(13px, 1.9vmin, 21px); font-weight: 800; letter-spacing: 0.18em; color: #5B7A93; }
/* one continuous field – long names stay on a single line */
.name-field { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.name-box {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  width: min(100%, 760px);
  min-height: clamp(56px, 8.4vmin, 96px);
  padding: 0 clamp(14px, 2.2vmin, 26px);
  border-radius: 14px; background: #EEF4F9; border: 4px solid var(--sky);
  box-shadow: 0 0 0 4px rgba(0, 105, 180, 0.16);
  font-family: var(--display);
  font-size: clamp(20px, 3.4vmin, 46px);
  letter-spacing: 0.04em;
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
}
.name-text { min-width: 0; overflow: hidden; text-overflow: clip; }
.name-caret {
  flex: none; width: 3px; height: 0.95em; background: var(--sky);
  animation: blink 1s steps(2) infinite;
}
.name-count { font-size: clamp(11px, 1.5vmin, 16px); font-weight: 800; letter-spacing: 0.12em; color: #5B7A93; }
@keyframes blink { to { opacity: 0; } }
.keyboard { display: grid; grid-template-columns: repeat(9, 1fr); gap: clamp(5px, 0.9vmin, 11px); width: 100%; max-width: 840px; }
.key-space { grid-column: 1 / -1; letter-spacing: 0.4em; }
.key {
  min-height: clamp(46px, 7vmin, 78px); border-radius: 12px;
  background: var(--cream); color: var(--ink);
  border: 3px solid var(--shadow); box-shadow: 0 4px 0 var(--shadow);
  font-family: var(--display); font-size: clamp(17px, 2.8vmin, 32px);
  transition: transform 0.08s, box-shadow 0.08s;
}
.key:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); background: var(--sun); }
.key-delete { color: var(--sky); }
.name-actions { display: flex; gap: clamp(12px, 2vmin, 24px); align-items: center; margin-top: 6px; }
.name-actions .btn-secondary { background: #EEF4F9; color: var(--ink); }

/* ==========================================================================
   Logo badges + preloader
   ========================================================================== */
.logo-badge {
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--accent, var(--sky)); flex: none; overflow: hidden;
}
.logo-badge img { width: 62%; height: 62%; object-fit: contain; display: block; }
.chip .logo-badge { width: clamp(22px, 3vmin, 30px); height: clamp(22px, 3vmin, 30px); }
.impact-item .logo-badge { width: clamp(32px, 4.6vmin, 52px); height: clamp(32px, 4.6vmin, 52px); }

.preloader {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(22px, 3.6vmin, 44px);
  background: linear-gradient(180deg, #7CC7EC 0%, #B7E2F5 26%, #E6F4FB 52%, #FDF3E1 68%, #F7E7C8 100%);
  transition: opacity 0.4s ease;
}
.preloader.done { opacity: 0; pointer-events: none; }
.preloader-logo {
  height: clamp(100px, 20vmin, 230px); width: auto;
  filter: drop-shadow(0 6px 8px rgba(0, 27, 49, 0.25));
  animation: pre-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pre-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.preloader-bar {
  width: clamp(200px, 30vmin, 420px); height: clamp(12px, 1.5vmin, 18px);
  border-radius: 999px; background: var(--cream);
  border: 3px solid var(--shadow); overflow: hidden;
}
.preloader-fill {
  height: 100%; width: 100%; background: var(--sun);
  transform: scaleX(0.04); transform-origin: left; transition: transform 0.3s ease;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (orientation: portrait) {
  /* compact header: all three figures on one line, buttons top right, so the
     sky above the crane stays small and containers arrive from higher up */
  :root {
    --btn-size: clamp(38px, 10.5vw, 62px);
    --btn-gap: clamp(6px, 1.6vw, 12px);
  }
  .controls { top: clamp(8px, 1.6vh, 20px); right: clamp(10px, 2.6vw, 28px); }
  .hud {
    padding: clamp(8px, 1.6vh, 20px) 0 0 clamp(12px, 3vw, 30px);
    padding-right: var(--controls-w);
    justify-content: flex-start;
    gap: clamp(14px, 4.5vw, 40px);
  }
  .hud-row { gap: clamp(14px, 4.5vw, 40px); }
  .hud-right { margin-right: 0; align-items: flex-start; }
  .hud-right .hud-item { align-items: flex-start; }
  .hud-label { font-size: clamp(9px, 2.4vw, 15px); letter-spacing: 0.18em; }
  .hud-value { font-size: clamp(26px, 8vw, 52px); }
  .hud-combo { font-size: clamp(12px, 3.2vw, 20px); }
  .pu-chip, .game-badge { font-size: clamp(10px, 2.7vw, 16px); }
  .milestone { top: clamp(96px, 13vh, 200px); max-width: min(74vw, 460px); }
  .milestone-quote { font-size: clamp(13px, 3.4vw, 22px); }
  .milestone-icon { width: clamp(34px, 9vw, 58px); height: clamp(34px, 9vw, 58px); }
  .banner { top: 13%; font-size: clamp(15px, 4.4vw, 28px); padding: clamp(7px, 1.6vw, 12px) clamp(16px, 5vw, 32px); }
  .community-card { top: calc(clamp(8px, 1.6vh, 20px) + var(--btn-size) + 16px); left: 50%; transform: translateX(-50%); animation: none; }
  .leaderboard-card { top: auto; bottom: clamp(52px, 5vh, 82px); right: 50%; transform: translateX(50%); width: min(90vw, 720px); text-align: left; animation: none; }
  .leaderboard-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; }
  .leaderboard-head { text-align: left; }
  .panel-grid { grid-template-columns: 1fr; gap: clamp(13px, 2.2vmin, 24px); }
  .panel-side { border-top: 3px solid #D8E5EF; padding-top: clamp(12px, 2vmin, 22px); }
  .duel-columns { gap: 12px; }
}
@media (max-width: 980px) and (orientation: landscape) {
  .panel-grid { grid-template-columns: 1fr; gap: clamp(13px, 2.2vmin, 24px); }
}
/* narrower landscape screens: keep the centred block clear of the corner figures */
@media (max-width: 1400px) and (orientation: landscape) {
  .screen-inner { width: min(60vw, 800px); }
}
@media (max-width: 1150px) and (orientation: landscape) {
  .community-card, .leaderboard-card { display: none; }
  .screen-inner { width: min(92vw, 800px); }
}
/* short portrait screens (phones): the corner figures move to the foot of the
   start screen so they never run into the logo and the title */
@media (max-height: 1000px) and (orientation: portrait) {
  .community-card {
    top: auto;
    bottom: clamp(34px, 5.5vh, 64px);
    gap: clamp(8px, 2.4vw, 14px);
  }
  .community-body { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 0 8px; }
  .community-label { width: 100%; }
  .community-total { margin-top: 0; width: 100%; }
  .community-value { font-size: clamp(24px, 7vw, 40px); }
  .community-tower { width: clamp(22px, 6vw, 34px); }
}
@media (max-height: 1100px) and (orientation: portrait) {
  .leaderboard-card { display: none; }
  .fact { display: none; }
  .impact-list { flex-direction: row; flex-wrap: wrap; gap: 14px 24px; }
}
@media (max-height: 820px) and (orientation: landscape) { .fact { display: none; } }
@media (max-height: 700px) and (orientation: landscape) { .leaderboard-card { display: none; } }
@media (max-height: 620px) { .logo { height: 58px; } .program-chips { display: none; } }

/* ==========================================================================
   Name feedback + admin panel
   ========================================================================== */
.name-error {
  margin: 0;
  font-size: clamp(13px, 1.9vmin, 21px);
  font-weight: 800;
  color: var(--red);
}
.name-field.has-error .name-box {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.16);
  animation: shake 0.35s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  80% { transform: translateX(-3px); }
}

/* invisible corner hotspot that opens the admin panel */
.admin-hotspot {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 60;
  background: transparent;
  border: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.screen-admin { background: rgba(0, 20, 37, 0.82); z-index: 40; }
.admin-panel {
  width: min(96vw, 1080px);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vmin, 22px);
  padding: clamp(18px, 2.8vmin, 34px) clamp(18px, 3vmin, 38px);
  overflow: hidden;
}
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-title { font-family: var(--display); font-size: clamp(20px, 3.2vmin, 38px); letter-spacing: 0.18em; color: var(--sky); }
.admin-body { overflow-y: auto; display: flex; flex-direction: column; gap: clamp(14px, 2.2vmin, 26px); -webkit-overflow-scrolling: touch; }
.admin-block { display: flex; flex-direction: column; gap: 8px; }
.admin-columns { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(14px, 2.4vmin, 30px); }

.admin-stats { display: flex; gap: clamp(16px, 3vmin, 44px); flex-wrap: wrap; }
.admin-stat { display: flex; flex-direction: column; }
.admin-stat-value { font-family: var(--display); font-size: clamp(24px, 3.8vmin, 44px); color: var(--sky); line-height: 1.05; }
.admin-stat-label { font-size: clamp(11px, 1.5vmin, 15px); font-weight: 700; color: #5B7A93; }

.admin-list, .admin-words { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.admin-row, .admin-word {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: clamp(8px, 1.4vmin, 16px);
  padding: 6px 4px;
  border-bottom: 1px solid #E1EAF1;
}
.admin-word { grid-template-columns: 1fr auto; }
.admin-row:last-child, .admin-word:last-child { border-bottom: 0; }
.admin-row-name { font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-meta { font-size: 0.85em; font-weight: 700; color: #5B7A93; white-space: nowrap; }
.admin-empty { padding: 8px 4px; color: #7B94A9; font-weight: 600; }
.admin-del {
  width: clamp(30px, 4vmin, 40px);
  height: clamp(30px, 4vmin, 40px);
  border-radius: 50%;
  background: #FDE7E9;
  color: var(--red);
  border: 2px solid var(--red);
  font-weight: 900;
  line-height: 1;
  flex: none;
}
.admin-del:active { background: var(--red); color: #fff; }

.admin-toggle { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.admin-toggle input { width: 24px; height: 24px; accent-color: var(--sky); }
.admin-add { display: flex; gap: 10px; }
.admin-add input {
  flex: 1;
  min-width: 0;
  min-height: clamp(42px, 5.4vmin, 56px);
  padding: 0 14px;
  border-radius: 12px;
  border: 3px solid var(--shadow);
  background: #EEF4F9;
  font-family: var(--body);
  font-size: clamp(14px, 2vmin, 20px);
  font-weight: 700;
  color: var(--ink);
}
.admin-add input:focus { outline: none; border-color: var(--sky); }
.admin-add .btn-secondary { min-height: clamp(42px, 5.4vmin, 56px); }

.admin-actions { flex-direction: row; flex-wrap: wrap; gap: clamp(8px, 1.4vmin, 14px); }
.admin-actions .btn-secondary { min-height: clamp(42px, 5.4vmin, 58px); font-size: clamp(12px, 1.7vmin, 18px); }

.admin-pin { display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 1.8vmin, 20px); }
.admin-pin-field {
  min-width: clamp(140px, 22vmin, 240px);
  min-height: clamp(48px, 6.4vmin, 72px);
  display: grid; place-items: center;
  border-radius: 12px; background: #EEF4F9; border: 4px solid var(--sky);
  font-family: var(--display); font-size: clamp(24px, 4vmin, 44px); letter-spacing: 0.3em; color: var(--ink);
}
.admin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(6px, 1vmin, 12px); width: min(100%, 320px); }
.admin-pad .key { min-height: clamp(48px, 7vmin, 72px); }
.key-ok { color: var(--sky); }
.admin-pin-error { margin: 0; min-height: 1.4em; color: var(--red); font-weight: 800; }

@media (orientation: portrait), (max-width: 900px) {
  .admin-columns { grid-template-columns: 1fr; }
  .admin-actions { flex-direction: column; }
  .admin-actions .btn-secondary { width: 100%; }
}
