:root {
  --ink: #14204f;
  --butter: #ffd84d;
  --butter-d: #e0ae12;
  --pea: #74d12c;
  --pea-d: #45a51c;
  --tomato: #e8402f;
  --paper: #fff;
  --cobalt: #2d5bd7;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--cobalt); overflow: hidden; overscroll-behavior: none; font-family: var(--font); color: var(--ink); -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#game:focus-visible { outline: 4px solid var(--butter); outline-offset: -6px; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 4px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 8px var(--ink); }

.icon { width: 46px; height: 46px; padding: 9px; border: 3px solid var(--ink); border-radius: 50%; background: #fff; box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; }
.icon svg { width: 100%; height: 100%; fill: var(--ink); color: var(--ink); }
.icon:active { transform: translateY(3px); box-shadow: none; }
#btnMute { position: fixed; z-index: 30; right: 12px; bottom: calc(12px + var(--sab)); }
#btnMute .off { display: none; }
#btnMute.muted .on { display: none; }
#btnMute.muted .off { display: inline; }

/* in-game top bar */
#hud { position: fixed; inset: 0 0 auto 0; z-index: 10; padding: calc(8px + var(--sat)) 12px 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
#hudMid { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 800; color: #fff; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); font-size: 17px; }
#hudHearts { display: flex; gap: 3px; min-height: 18px; }
#hudHearts svg { width: 19px; height: 18px; display: block; }
#hudScore { justify-self: end; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 12px; font-weight: 900; font-size: 20px; box-shadow: 0 3px 0 var(--ink); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
#timeWrap { height: 14px; margin-top: 8px; border: 3px solid var(--ink); border-radius: 9px; background: #fff; overflow: hidden; }
#timeFill { height: 100%; width: 100%; background: var(--butter); transform-origin: left; }
#timeFill.low { background: var(--tomato); }
#hudCount { position: fixed; left: 0; right: 0; bottom: calc(14px + var(--sab)); text-align: center; font-weight: 900; font-size: 24px; color: #fff; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); pointer-events: none; }

#banner { position: fixed; z-index: 12; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-3deg); pointer-events: none; background: var(--butter); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); padding: 10px 22px; text-align: center; font-weight: 900; font-size: clamp(24px, 6vmin, 40px); line-height: 1.1; white-space: nowrap; opacity: 0; }
#banner small { display: block; font-size: .5em; font-weight: 800; margin-top: 4px; }
#banner.show { opacity: 1; }
#banner.bad { background: var(--tomato); color: #fff; }
#hint { position: fixed; z-index: 11; left: 50%; bottom: calc(58px + var(--sab)); transform: translateX(-50%); width: min(90vw, 460px); background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); padding: 8px 14px; text-align: center; font-weight: 800; font-size: 17px; line-height: 1.25; pointer-events: none; }
#hint small { display: block; font-weight: 600; font-size: 13px; margin-top: 2px; }

/* buttons */
.btn { display: block; width: 100%; border: 3px solid var(--ink); border-radius: 18px; background: var(--butter); box-shadow: 0 5px 0 var(--ink); padding: 11px 16px; font-weight: 900; font-size: 19px; line-height: 1.15; text-align: center; }
.btn:active { transform: translateY(5px); box-shadow: none; }
.btn.alt { background: #fff; }
.btn.pea { background: var(--pea); }
.btn .t { display: block; }
.btn .s { display: block; font-size: 13px; font-weight: 700; margin-top: 2px; }
.btn.big { font-size: 22px; padding: 12px 16px; }

/* title screen: stacked on phones, side by side when wide */
#menu { position: fixed; inset: 0; z-index: 5; display: grid; grid-template-rows: auto 1fr auto; padding: calc(10px + var(--sat)) 16px calc(16px + var(--sab)); gap: 6px; max-width: 520px; margin: 0 auto; pointer-events: none; }
#menu button { pointer-events: auto; }
.menu-side { text-align: center; }
.logo-wrap { margin: 0; font-size: 0; }
#logo { width: min(62vw, 300px, 30vh); aspect-ratio: 380 / 216; height: auto; }
#tagline { margin: 2px auto 0; max-width: 30ch; font-weight: 800; font-size: 17px; line-height: 1.25; color: #fff; text-shadow: 0 2px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); }
.menu-actions { display: grid; gap: 12px; }
#stage { min-height: 120px; }
#stats { margin: 0; font-weight: 800; font-size: 16px; color: #fff; text-shadow: 0 2px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); min-height: 1.2em; }
#byline { margin: -6px 0 0; font-weight: 700; font-size: 13px; color: #fff; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); padding: 0 56px; }

@media (min-aspect-ratio: 11/10) {
  #menu { max-width: none; grid-template-rows: 1fr auto 1fr; grid-template-columns: minmax(280px, 40%) 1fr; column-gap: 16px; padding: 16px 28px; }
  #menu .menu-side:first-child { grid-column: 1; grid-row: 1 / span 2; align-self: end; }
  #stage { grid-column: 2; grid-row: 1 / span 3; }
  .menu-actions { grid-column: 1; grid-row: 3; align-self: start; max-width: 420px; justify-self: center; width: 100%; }
  #logo { width: min(36vw, 400px, 46vh); }
  #tagline { font-size: clamp(15px, 3vh, 21px); }
  #hudCount { bottom: 10px; left: 14px; right: auto; font-size: 22px; }
  #hint { bottom: 14px; }
}
@media (min-aspect-ratio: 11/10) and (max-height: 460px) {
  #menu { padding: 8px 20px; grid-template-rows: auto auto 1fr; }
  #logo { width: min(30vw, 44vh, 240px); }
  #tagline { font-size: 14px; margin-top: 0; }
  .menu-actions { gap: 7px; }
  .btn.big { padding: 6px 12px; font-size: 17px; }
  .btn .s { display: none; }
  #stats { font-size: 13px; }
  #byline { margin: -2px 0 0; font-size: 12px; padding: 0 48px 0 0; }
  #btnPrivacy { padding: 0; }
  .icon { width: 40px; height: 40px; padding: 7px; }
  #hudMid { font-size: 14px; }
  #hudScore { font-size: 16px; }
  #timeWrap { height: 11px; margin-top: 4px; }
  .card { padding: 10px 16px; }
  .card h2 { font-size: 22px; }
  .big-num { font-size: 34px !important; }
  #pBtns { grid-template-columns: 1fr 1fr; }
}

/* panels */
#panel { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(20, 32, 79, .55); overflow: auto; }
.card { width: min(440px, 100%); background: #fff; border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink); padding: 18px 20px 16px; text-align: center; max-height: calc(100dvh - 32px); overflow: auto; }
.card h2 { margin: 0 0 6px; font-size: 30px; font-weight: 900; line-height: 1.1; }
#pBody p { margin: 4px 0; font-weight: 700; font-size: 16px; line-height: 1.3; }
.big-num { font-size: 52px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.big-num + .unit { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.grid { display: flex; justify-content: center; gap: 6px; margin: 8px 0; }
.sq { width: 34px; height: 34px; border-radius: 9px; border: 3px solid var(--ink); display: grid; place-items: center; }
.sq svg { width: 20px; height: 20px; fill: var(--ink); }
.sq.star { background: var(--butter); }
.sq.green { background: var(--pea); }
.sq.yellow { background: #fff09a; }
.sq.orange { background: #ff9d3d; }
.sq.red { background: var(--tomato); }
.badge { display: inline-block; background: var(--pea); border: 3px solid var(--ink); border-radius: 12px; padding: 2px 10px; font-weight: 900; }
#pBtns { display: grid; gap: 11px; margin-top: 12px; }
#pToast { margin: 8px 0 0; font-weight: 700; font-size: 14px; min-height: 1.2em; }
#pBtns .half { grid-column: span 1; padding-left: 8px; padding-right: 8px; font-size: 17px; }
#pBtns:has(.half) { grid-template-columns: 1fr 1fr; }
#pBtns:has(.half) > :not(.half) { grid-column: 1 / -1; }
.rank { background: #eaf9d9; border: 3px solid var(--ink); border-radius: 12px; padding: 5px 10px; margin: 6px 0 !important; font-weight: 900 !important; -webkit-user-select: text; user-select: text; }
.vs { font-weight: 900 !important; font-size: 19px !important; }
.link { background: none; border: 0; padding: 2px 0; font: inherit; font-weight: 800; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#byline .link { pointer-events: auto; }
#panel:has(.pv) { z-index: 40; } /* long text: nothing floats over it */
.pv { text-align: left; font-size: clamp(13px, 2.1dvh, 15px) !important; line-height: 1.25 !important; font-weight: 600 !important; margin: 6px 0 !important; }
.top { list-style: none; margin: 4px 0 8px; padding: 0; max-height: min(46dvh, 340px); overflow: auto; border: 3px solid var(--ink); border-radius: 12px; text-align: left; -webkit-overflow-scrolling: touch; }
.top li { display: grid; grid-template-columns: 2.4em 1fr auto; gap: 6px; padding: 4px 10px; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.top li:nth-child(even) { background: #f1f4fc; }
.top li.me { background: var(--butter); font-weight: 900; }
.top .r { text-align: right; }
@media (min-aspect-ratio: 11/10) and (max-height: 460px) {
  #pBtns { gap: 7px; margin-top: 8px; }
  #pBtns .btn { padding: 5px 8px; font-size: 15px; box-shadow: 0 3px 0 var(--ink); }
  #pBody p { margin: 2px 0; font-size: 14px; }
  .grid { margin: 4px 0; }
  .sq { width: 26px; height: 26px; }
  .sq svg { width: 15px; height: 15px; }
}
#pBody textarea { width: 100%; height: 88px; font: inherit; font-size: 14px; border: 2px solid var(--ink); border-radius: 10px; padding: 6px; margin-top: 6px; -webkit-user-select: text; user-select: text; }
.fine { font-size: 13px !important; font-weight: 600 !important; }

@media (prefers-reduced-motion: reduce) {
  .icon:active, .btn:active { transform: none; }
  * { transition: none !important; animation: none !important; }
}
