/* Fonts are self-hosted: no requests to third parties (privacy, and a strict CSP). */
@font-face{ font-family:"Lilita One"; font-style:normal; font-weight:400; font-display:swap; src:url(/fonts/lilita-one-latin-400-normal.woff2) format("woff2"); }
@font-face{ font-family:"Nunito"; font-style:normal; font-weight:700; font-display:swap; src:url(/fonts/nunito-latin-700-normal.woff2) format("woff2"); }
@font-face{ font-family:"Nunito"; font-style:normal; font-weight:900; font-display:swap; src:url(/fonts/nunito-latin-900-normal.woff2) format("woff2"); }

:root{
  --bg:#dde8ef; --fg:#0b3d5c; --muted:#4d6b80; --btn:#0b3d5c; --btnfg:#e9f6d0;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){ --bg:#06141f; --fg:#d6ecf7; --muted:#7f9db2; --btn:#9cc417; --btnfg:#06141f; }
}
:root[data-theme="dark"]{ --bg:#06141f; --fg:#d6ecf7; --muted:#7f9db2; --btn:#9cc417; --btnfg:#06141f; }
html{ scroll-padding-top:env(safe-area-inset-top,0px); }
html,body{ height:100%; margin:0; }
body{
  background:var(--bg); color:var(--fg);
  font-family:"Nunito", system-ui, sans-serif;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  overflow:hidden; touch-action:none; user-select:none; -webkit-user-select:none;
}
canvas{ display:block; border-radius:14px; box-shadow:0 10px 40px rgba(0,30,50,.35); outline:none; }
/* Line below the game (as wide as the game): copyright on the left, keyboard hints in the middle */
.foot{ display:flex; align-items:baseline; gap:12px; margin-top:8px; box-sizing:border-box; }
.hint{ flex:1; font-size:13px; color:var(--muted); text-align:center; }
.copyright{ flex:none; font-size:12px; color:var(--muted); opacity:.75; white-space:nowrap; }
body{ overscroll-behavior:none; }
.pad{ display:none; gap:10px; align-items:center; }
.pad button{
  height:70px; min-width:70px; border:0; border-radius:18px; background:var(--btn); color:var(--btnfg);
  font-family:"Lilita One", Impact, sans-serif; font-size:26px; touch-action:none;
  -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; user-select:none; -webkit-user-select:none;
  transition:transform .06s;
}
.pad button.small{ height:46px; min-width:46px; font-size:18px; border-radius:14px; opacity:.85; }
.pad button.jump{ min-width:112px; }
.pad button.held{ filter:brightness(1.25); transform:scale(.95); }
body.touch{
  display:grid; align-content:center; justify-content:center; justify-items:center;
  grid-template-columns:1fr 1fr; grid-template-areas:"game game" "foot foot" "l r"; row-gap:12px;
  padding:0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px)); box-sizing:border-box;
}
body.touch .stage{ grid-area:game; }
body.touch .hint{ display:none; }
body.touch .foot{ grid-area:foot; justify-self:center; margin:0; }
body.touch .pad{ display:flex; }
body.touch #padL{ grid-area:l; justify-self:start; }
body.touch #padR{ grid-area:r; justify-self:end; }
@media (orientation:landscape){
  body.touch{ grid-template-columns:auto auto auto; grid-template-areas:"l game r" ". foot ."; row-gap:6px; column-gap:16px; }
  body.touch #padL{ justify-self:end; }
  body.touch #padR{ justify-self:start; flex-direction:column; }
}

/* ---------- menu: stacked in the middle of the game, sized with the canvas (--s = canvas scale) ---------- */
body{ font-weight:700; }
.stage{ position:relative; --s:1; }
.menu{
  position:absolute; left:50%; top:60.3%; transform:translate(-50%, -50%);
  display:flex; flex-direction:column; align-items:stretch; gap:calc(10px * var(--s));
  width:calc(230px * var(--s)); min-width:150px;
}
.stage[data-screen="title"] .menu{ top:47.9%; }      /* buttons centred at y = 326 of 680 */
.stage[data-screen="over"] .menu{ top:73.5%; }
.stage[data-screen="pause"] .menu{ top:57.4%; }
.stage[data-screen="play"] .menu, .stage[data-screen="dying"] .menu{ display:none; }
.mbtn{
  height:calc(44px * var(--s)); min-height:28px; padding:0 12px; border:0; border-radius:calc(14px * var(--s)); cursor:pointer;
  background:#0b3d5c; color:#e9f6d0;
  font-family:"Lilita One", Impact, sans-serif; font-size:max(13px, calc(19px * var(--s))); letter-spacing:.01em;
  box-shadow:0 3px 0 rgba(0,20,35,.45), 0 0 0 2px rgba(255,255,255,.18);
  transition:transform .06s, filter .12s;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  -webkit-tap-highlight-color:transparent;
}
.mbtn:hover{ filter:brightness(1.15); }
.mbtn:active{ transform:translateY(2px); box-shadow:0 1px 0 rgba(0,20,35,.45), 0 0 0 2px rgba(255,255,255,.18); }
.mbtn.play{ background:#9cc417; color:#06202f; }
.stage[data-screen="over"] .menu{ animation:menuIn .25s ease-out; }
@keyframes menuIn{ from{ opacity:0; transform:translate(-50%, -40%); } }
/* ---------- prize competition on the start screen (sizes in game units x --s) ---------- */
.contest{
  position:absolute; left:calc(82px * var(--s)); top:calc(465px * var(--s)); width:calc(356px * var(--s));
  display:flex; align-items:flex-start; gap:calc(13px * var(--s));
  color:#fff; font:700 max(11px, calc(16px * var(--s)))/1.125 "Nunito", system-ui, sans-serif;   /* readable on small phones */
}
.stage:not([data-screen="title"]) .contest{ display:none; }
/* game drawn small (e.g. phone in landscape): the minimum font sizes make the text larger than in
   the design, so use the full width between the walls and start right below the buttons */
.stage.compact .contest{ left:calc(42px * var(--s)); top:calc(418px * var(--s)); width:calc(396px * var(--s)); gap:calc(8px * var(--s)); }
.stage.compact .contest-icon{ width:calc(40px * var(--s)); }
.stage.compact .contest-text p{ margin-bottom:0.5em; }
.stage.compact .contest-text br{ display:none; }   /* the design's line break after "by" only fits the full layout */
.contest[hidden]{ display:none; }
.contest-icon{ flex:none; width:calc(57px * var(--s)); height:auto; margin-top:calc(1px * var(--s)); }
/* the gift box wiggles in short bursts: a quick shake, then a pause (3.5 s per cycle) */
.contest-icon{ transform-origin:50% 92%; animation:gift-wiggle 3.5s ease-in-out 1s infinite; }
@keyframes gift-wiggle{
  0%, 22%, 100% { transform:rotate(0); }
  3%  { transform:rotate(-9deg); }
  7%  { transform:rotate(8deg); }
  11% { transform:rotate(-6deg); }
  15% { transform:rotate(4deg); }
  19% { transform:rotate(-2deg); }
}
.contest-text p{ margin:0 0 1.125em; }
.contest-text p.contest-small{ font-size:max(9px, calc(10px * var(--s))); line-height:1.3; margin:calc(4px * var(--s)) 0 0; }
.contest-text a{ color:#fff; text-decoration-thickness:1px; text-underline-offset:0.15em; }
.contest time{ white-space:nowrap; }      /* date, time and zone stay on one line */

button:focus-visible, a:focus-visible, input:focus-visible, canvas:focus-visible{ outline:3px solid #ffd166; outline-offset:2px; }
canvas:focus{ outline:none; }

/* ---------- dialogs: same navy panels as the in-game overlays ---------- */
dialog{
  width:min(400px, calc(100vw - 32px)); max-height:calc(100dvh - 32px); overflow:auto; box-sizing:border-box;
  border:0; border-radius:20px; padding:26px 24px 22px; margin:auto; inset:0;
  background:#0a2a40; color:#e3f2fb; box-shadow:0 18px 60px rgba(0,10,20,.55), inset 0 0 0 2px rgba(156,196,23,.35);
  font-family:"Nunito", system-ui, sans-serif; font-size:15px; line-height:1.45;
  user-select:text; -webkit-user-select:text; touch-action:auto;
}
dialog.wide{ width:min(480px, calc(100vw - 32px)); }
dialog::backdrop{ background:rgba(3,16,26,.62); }
dialog h2{ font-family:"Lilita One", Impact, sans-serif; font-weight:400; font-size:30px; line-height:1.1; margin:0 36px 8px 0; color:#9cc417; }
dialog h3{ font-family:"Lilita One", Impact, sans-serif; font-weight:400; font-size:22px; margin:6px 0; color:#ffe66d; }
dialog .lead{ margin:0 0 16px; color:#cfe6f3; }
dialog .close{
  position:absolute; top:12px; right:12px; width:36px; height:36px; border:0; border-radius:12px;
  background:rgba(255,255,255,.08); color:#e3f2fb; font-size:24px; line-height:1; cursor:pointer;
}
dialog .close:hover{ background:rgba(255,255,255,.16); }
dialog label{ display:block; font-weight:900; margin:12px 0 4px; }
dialog input[type=email], dialog input:not([type]){
  width:100%; box-sizing:border-box; height:44px; padding:0 12px; border-radius:12px;
  border:2px solid #2d5a78; background:#f4f9fc; color:#06202f; font:700 16px "Nunito", system-ui, sans-serif;
}
dialog input:focus{ border-color:#9cc417; }
dialog .help{ margin:4px 0 0; font-size:13px; color:#93b4c8; }
dialog label.check{ display:flex; gap:10px; align-items:flex-start; font-weight:700; margin:16px 0 4px; cursor:pointer; }
dialog label.check input{ width:20px; height:20px; margin:1px 0 0; accent-color:#9cc417; flex:none; }
dialog a{ color:#ffe66d; }
dialog .primary, dialog .danger{
  height:44px; padding:0 18px; border:0; border-radius:14px; cursor:pointer;
  font-family:"Lilita One", Impact, sans-serif; font-size:18px;
}
dialog .primary{ background:#9cc417; color:#06202f; }
dialog form .primary, #authDone .primary{ width:100%; margin-top:18px; }
dialog .primary:disabled{ background:#3b5566; color:#8aa3b3; cursor:not-allowed; }
dialog .danger{ background:transparent; color:#ffb4a2; box-shadow:inset 0 0 0 2px #ef476f; }
dialog .danger:hover{ background:rgba(239,71,111,.15); }
dialog .row{ display:flex; gap:10px; flex-wrap:wrap; }
dialog .switch{ margin:12px 0 0; font-size:14px; text-align:center; color:#93b4c8; }
dialog .error{ margin:12px 0 0; color:#ffb4a2; font-weight:900; }
dialog .error:empty{ display:none; }

.tabs{ display:flex; gap:4px; background:rgba(0,0,0,.25); padding:4px; border-radius:14px; margin-bottom:4px; }
.tabs [role=tab]{
  flex:1; height:38px; border:0; border-radius:10px; background:transparent; color:#b7d3e3; cursor:pointer;
  font:900 15px "Nunito", system-ui, sans-serif;
}
.tabs [role=tab][aria-selected=true]{ background:#0b3d5c; color:#fff; box-shadow:inset 0 -3px 0 #9cc417; }

.tablewrap{ overflow:auto; max-height:min(60dvh, 520px); margin:6px -6px 0; }
dialog table{ width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
dialog th{ position:sticky; top:0; background:#0a2a40; text-align:left; font-size:13px; color:#93b4c8; padding:6px; }
dialog td{ padding:7px 6px; border-top:1px solid rgba(255,255,255,.07); }
dialog td:nth-child(1){ width:2.5em; color:#93b4c8; }
dialog td:nth-child(2){ max-width:12em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
dialog th:nth-child(n+3), dialog td:nth-child(n+3){ text-align:right; }
dialog td:nth-child(3){ font-family:"Lilita One", Impact, sans-serif; font-size:17px; color:#ffe66d; }
dialog tbody tr:nth-child(-n+3) td:nth-child(1){ color:#ffe66d; font-weight:900; }
dialog tr.me td{ background:rgba(156,196,23,.18); }

#toast{
  position:fixed; left:50%; bottom:calc(16px + env(safe-area-inset-bottom, 0px)); transform:translateX(-50%);
  max-width:min(440px, calc(100vw - 32px)); padding:12px 18px; border-radius:14px;
  background:#0a2a40; color:#e3f2fb; box-shadow:0 10px 30px rgba(0,10,20,.45), inset 0 0 0 2px rgba(156,196,23,.4);
  font-size:15px; z-index:10;
}
@media (prefers-reduced-motion:reduce){ .mbtn, .pad button{ transition:none; } .menu, .contest-icon{ animation:none !important; } }
@media (max-width:420px){
  body.touch .pad button{ min-width:60px; height:64px; }
  body.touch .pad button.small{ min-width:42px; height:42px; }
  body.touch .pad button.jump{ min-width:96px; }
}
