* { box-sizing: border-box; }
html { height: 100%; overflow: hidden; }
/* Pin the page to the visible viewport. On phones 100vh includes the space behind the
   browser toolbars, which makes the page scroll; the dynamic unit (dvh) does not. */
body { margin: 0; position: fixed; inset: 0; height: 100vh; height: 100dvh; width: 100%; overflow: hidden;
  overscroll-behavior: none; background: #062a4f; color: #fff;
  font-family: "Baloo 2", "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

.screen { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(94vw, 720px); max-height: 94vh; max-height: 94dvh; overflow-y: auto;
  background: rgba(6, 30, 60, 0.82); border: 3px solid rgba(255,255,255,0.25); border-radius: 28px;
  padding: 20px 28px; text-align: center; backdrop-filter: blur(6px); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
#screen-ready, #screen-winner { top: auto; bottom: max(4vh, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(92vw, 560px); }

h1 { font-size: clamp(28px, 6vw, 44px); margin: 0 0 12px; text-shadow: 0 3px 0 rgba(0,0,0,0.3); }
.hint { font-size: 20px; opacity: 0.9; margin: 4px 0 12px; }
.huge { font-size: clamp(40px, 10vw, 72px); font-weight: 800; margin: 8px 0 16px; }
.muted { opacity: 0.7; margin: 6px 0; }
.row { display: flex; justify-content: center; flex-wrap: wrap; }

button.big { font: inherit; font-size: 22px; font-weight: 700; padding: 14px 26px; min-height: 56px;
  border-radius: 999px; border: 0; background: rgba(255,255,255,0.15); color: #fff; cursor: pointer; margin: 6px; }
button.big:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
button.primary { background: #ff8c42; color: #1a1a1a; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.roster { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0 10px; }
.jelly-card { font: inherit; font-size: 18px; font-weight: 700; color: #fff; background: rgba(255,255,255,0.06);
  border: 3px solid transparent; border-radius: 20px; padding: 6px 8px 8px; width: 104px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform 0.15s; }
.jelly-card canvas { width: 84px; height: 84px; display: block; }
.jelly-card span { max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jelly-card:hover { background: rgba(255,255,255,0.12); }
.jelly-card.selected { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.7); }
.jelly-card.current { border-color: #fff; transform: scale(1.06); box-shadow: 0 0 0 4px var(--ring, #fff); }
.jelly-card .badge { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  background: #ff8c42; color: #1a1a1a; font-size: 16px; line-height: 28px; text-align: center; }
.jelly-card { position: relative; }
.add-row { display: flex; gap: 8px; justify-content: center; align-items: center; margin-bottom: 8px; }
#player-name { font: inherit; font-size: 20px; padding: 10px 14px; border-radius: 16px; border: 0;
  width: min(60%, 260px); text-align: center; }
#player-name:focus { outline: none; box-shadow: 0 0 0 4px #ff8c42; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 12px; }
.swatch { width: 52px; height: 52px; border-radius: 50%; border: 4px solid transparent; cursor: pointer; padding: 0; }
.swatch.selected { border-color: #fff; transform: scale(1.15); }
.swatch:disabled { opacity: 0.2; cursor: not-allowed; }

#player-list, #results { list-style: none; padding: 0; margin: 8px 0; text-align: left; }
#player-list li, #results li { display: flex; align-items: center; gap: 12px; font-size: 22px; padding: 6px 10px; }
.dot { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,0.3); }
.remove { margin-left: auto; background: transparent; border: 0; color: #fff; opacity: 0.6; font-size: 20px; cursor: pointer; }
#results li .time { margin-left: auto; font-variant-numeric: tabular-nums; }
#results li.winner { background: rgba(255,255,255,0.14); border-radius: 12px; font-weight: 800; }

fieldset { border: 2px solid rgba(255,255,255,0.2); border-radius: 16px; margin: 12px 0; padding: 8px 12px; }
fieldset label { display: inline-block; margin: 4px 8px; font-size: 20px; cursor: pointer; }

.corner { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); font: inherit; font-size: 18px; font-weight: 700;
  padding: 10px 18px; min-height: 44px; border-radius: 999px; border: 2px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.35); color: #fff; cursor: pointer; touch-action: manipulation; }
.corner:hover { background: rgba(0,0,0,0.55); }

/* Phones: pack the start screen so Start is visible without scrolling. */
@media (max-width: 600px) {
  .screen { padding: 12px 12px 14px; border-radius: 22px; }
  h1 { font-size: 26px; margin-bottom: 4px; }
  .muted { font-size: 14px; margin: 2px 0; }
  .roster { gap: 6px; margin: 4px 0 6px; }
  .jelly-card { width: 78px; padding: 2px 4px 4px; border-radius: 14px; font-size: 14px; }
  .jelly-card canvas { width: 58px; height: 58px; }
  .jelly-card span { max-width: 70px; }
  .jelly-card .badge { width: 22px; height: 22px; font-size: 13px; line-height: 22px; top: -6px; right: -6px; }
  .add-row { margin-bottom: 4px; }
  #player-name { font-size: 16px; padding: 8px 12px; }
  button.big { font-size: 17px; padding: 8px 18px; min-height: 40px; margin: 4px; }
  .swatches { gap: 6px; margin-bottom: 4px; }
  .swatch { width: 34px; height: 34px; border-width: 3px; }
  fieldset { margin: 6px 0; padding: 2px 8px 6px; }
  fieldset label { font-size: 15px; margin: 2px 6px; }
  legend { font-size: 14px; }
}
