/* Chonk: one canvas fills the screen (the world), the HUD on top (the menu button and your mass), the leaderboard on
   the right, the minimap bottom left, Split and Feed bottom right, the results card over it. The title screen and the
   sheets are shared/mainmenu.js (menu.css, loaded after this); only their colors are set here (--sg-*). */
:root {
  --bg: #f3e3c4; --ink: #3a2a1c; --accent: #e0603a; --accent-ink: #fff;
  --sheet: #fff8ec; --sheet-ink: #2e241c; --sheet-soft: #7a6a58;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
* { touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body { font-family: "Baloo 2", ui-rounded, system-ui, sans-serif; color: var(--ink); background: var(--bg); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
.app { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.stage { position: absolute; inset: 0; touch-action: none; }
#cv { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---- the HUD ---- */
.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5; pointer-events: none;
  display: flex; gap: 10px; align-items: start;
  padding: var(--sg-corner-top, 12px) max(12px, env(safe-area-inset-right)) 4px var(--sg-corner-left, 12px);
}
.hud > .sg-corner-slot { pointer-events: auto; }
.pill { height: 44px; display: flex; align-items: center; padding: 3px 14px 0; border-radius: 999px;
  background: rgba(46, 32, 22, 0.66); color: #fff6e6; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.16); font-weight: 800; font-size: 19px;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.board { position: absolute; z-index: 5; right: max(12px, env(safe-area-inset-right)); top: var(--sg-corner-top, 12px);
  margin: 0; padding: 6px 10px 4px; list-style: none; border-radius: 14px; background: rgba(46, 32, 22, 0.55); color: #fff6e6;
  font-weight: 700; font-size: 13px; line-height: 1.35; pointer-events: none; width: 150px; }
.board li { display: flex; align-items: center; gap: 5px; }
.board li.you { color: #ffe070; }
.board .rk { width: 16px; flex: none; opacity: 0.75; font-variant-numeric: tabular-nums; }
.board .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board b { font-variant-numeric: tabular-nums; }
.board .gap { opacity: 0.5; justify-content: center; }
.minimap { position: absolute; z-index: 5; left: max(12px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom));
  width: 96px; height: 96px; border-radius: 12px; background: rgba(46, 32, 22, 0.35); pointer-events: none; }
.acts { position: absolute; z-index: 6; right: max(14px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 12px; }
.act { border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-weight: 800; color: #fff;
  -webkit-tap-highlight-color: transparent; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25), inset 0 -4px 0 rgba(0, 0, 0, 0.12); }
.act.split { width: 84px; height: 84px; font-size: 20px; background: #e0603a; }
.act.feed { width: 62px; height: 62px; font-size: 16px; background: #3a8ad0; }
.act:active, .act.down { transform: translateY(3px) scale(0.96); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.net { position: absolute; z-index: 7; left: 50%; top: 42%; transform: translate(-50%, -50%); margin: 0; padding: 10px 18px 8px;
  border-radius: 16px; background: rgba(46, 32, 22, 0.75); color: #fff6e6; font-weight: 800; font-size: 17px; text-align: center; pointer-events: none; }
.hud .conn { position: absolute; top: calc(var(--sg-corner-top, 12px) + 50px); left: calc(var(--sg-corner-left, 12px) + 54px); height: 26px; display: flex; align-items: center; gap: 6px; padding: 2px 10px 0; border-radius: 999px;
  background: rgba(46, 32, 22, 0.55); color: #fff6e6; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud .conn::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #9a9a9a; }
.hud .conn[data-q="good"]::before { background: #5ad06a; }
.hud .conn[data-q="ok"]::before { background: #f0c83a; }
.hud .conn[data-q="bad"]::before { background: #ff5a4a; }
body.title .hud .conn { display: none; }
body.solo-off .acts, body.title .acts, body.title .board, body.title .minimap, body.title .hud .pill { display: none; }

/* ---- the results card ---- */
.over { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(40, 26, 16, 0.4); }
.over-card { width: min(340px, 100%); border-radius: 26px; padding: 18px 18px 16px; text-align: center; animation: rise 0.25s ease-out;
  background: var(--sheet); color: var(--sheet-ink); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6), inset 0 -4px 0 rgba(0, 0, 0, 0.06); }
.over-kicker { margin: 0 0 2px; font-weight: 800; font-size: 26px; line-height: 1.1; color: #7a6a58; }
.over-score { margin: 0; font-weight: 800; font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.over-line { margin: 6px 0 0; font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--sheet-soft); }
.over-line.best { color: #c04a1c; }
.over-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.over-list li { display: grid; padding: 6px 8px 4px; border-radius: 12px; background: rgba(46, 36, 28, 0.06); font-weight: 700; font-size: 13px; color: var(--sheet-soft); }
.over-list li b { font-size: 19px; color: var(--sheet-ink); font-variant-numeric: tabular-nums; }
.over-new { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.over-new li { padding: 6px 10px 4px; border-radius: 12px; background: #e4f4d4; color: #2c5a1c; font-weight: 800; font-size: 15px; }
.over-av { width: 100%; margin-top: 10px; display: flex; align-items: center; gap: 10px; text-align: left; padding: 6px 14px 4px 6px; border-radius: 18px; }
.over-av img { flex: none; width: 44px; height: 44px; border-radius: 50%; }
.over-av span { display: grid; min-width: 0; }
.over-av b { font-size: 16px; line-height: 1.2; }
.over-av small { font-size: 13px; font-weight: 700; color: var(--sheet-soft); line-height: 1.25; }
.over-btns { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 14px; }
.btn { min-height: 52px; border: 0; border-radius: 999px; padding: 4px 12px 2px; cursor: pointer; background: rgba(46, 36, 28, 0.1); color: var(--sheet-ink); font-weight: 800; font-size: 17px; -webkit-tap-highlight-color: transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #a0401c; }
.btn:active { transform: translateY(2px); }
.toast { position: fixed; left: 50%; top: calc(var(--sg-corner-top, 12px) + 58px); z-index: 30; transform: translate(-50%, -8px); margin: 0;
  max-width: calc(100% - 32px); padding: 8px 16px 6px; border-radius: 16px; background: #fff8ec; color: var(--sheet-ink); font-weight: 800; font-size: 15px;
  text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.5); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- sheets ---- */
.ck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ck-pick { min-height: 112px; border: 0; border-radius: 16px; padding: 8px 4px 6px; display: grid; justify-items: center; align-content: start; gap: 2px; cursor: pointer;
  background: rgba(46, 36, 28, 0.07); color: var(--sheet-ink); font-weight: 800; font-size: 14px; line-height: 1.15; -webkit-tap-highlight-color: transparent; }
.ck-pick .face { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; }
.ck-pick .face img { width: 100%; height: 100%; display: block; }
.ck-pick small { font-weight: 700; font-size: 12px; color: var(--sheet-soft); }
.ck-pick.on { background: #ffe6c0; box-shadow: inset 0 0 0 3px #e0803a; }
.ck-pick.locked { opacity: 0.5; filter: grayscale(0.8); cursor: default; }
.ck-note { margin: 0 0 10px; font-weight: 700; color: var(--sheet-soft); }
.ck-ach { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ck-ach li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(46, 36, 28, 0.06); font-weight: 700; font-size: 15px; line-height: 1.25; }
.ck-ach li b { display: block; font-size: 16px; }
.ck-ach li.no { opacity: 0.55; }
.ck-ach .dot { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f4b44e; color: #6b3a0c; font-weight: 800; }
.ck-ach li.no .dot { background: rgba(46, 36, 28, 0.14); color: transparent; }
.ck-how p { margin: 0 0 10px; line-height: 1.4; }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: radial-gradient(120% 90% at 50% 12%, #fff4dc 0%, #f3d9a8 55%, #d8a868 100%);
  --sg-ink: #3a2a1c; --sg-ink-soft: #6a4e34;
  --sg-title: #e2542a; --sg-title-shadow: 0 3px 0 #7a2a10, 0 6px 14px rgba(80, 40, 10, 0.3);
  --sg-accent: var(--accent); --sg-accent-ink: #fff;
  --sg-card: #fffaf0; --sg-card-ink: var(--sheet-ink); --sg-line: rgba(58, 42, 28, 0.22);
}
#mm .ck-title-art { display: block; width: 300px; max-width: 86vw; height: auto; aspect-ratio: 300 / 180; border-radius: 22px; box-shadow: 0 10px 26px -12px rgba(80, 40, 10, 0.6); }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--sheet-ink); --sg-accent: #c0501c; --sg-accent-ink: #fff; --sg-ink-soft: var(--sheet-soft); }

@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .over-card { animation: none; }
}
