/* Bark Blast — the look follows Puppy Pileup (puppy-pileup/style.css) */
:root {
  color-scheme: light;
  --bg: #fff3e4;
  --bg-deep: #ffe2c4;
  --ink: #3d2a1f;
  --muted: #8a6f5c;
  --card: rgba(255, 255, 255, 0.78);
  --line: #efd8c1;
  --accent: #ff7a59;
  --accent-deep: #d95a3b;
  --font: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg) 40%, var(--bg-deep) 100%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { margin: 0; font-size: clamp(24px, 7vw, 32px); font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.logo span { color: var(--accent); }
.logo small {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); vertical-align: super;
}
.buttons { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 0; border-radius: 14px;
  background: var(--card);
  box-shadow: inset 0 0 0 1.5px var(--line), 0 2px 0 var(--line);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:active { translate: 0 1px; box-shadow: inset 0 0 0 1.5px var(--line); }
.icon-btn:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .no, .icon-btn.off .on { display: none; }
.icon-btn.off .no { display: block; }

.stats { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 8px; }
.stat {
  display: flex; flex-direction: column; justify-content: center;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: inset 0 0 0 1.5px var(--line);
  min-width: 0;
}
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.value { font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
/* The score, and the button to save it to the leaderboard mid-game (game.js, saveScore) */
.stat.score { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; padding-right: 8px; }
.stat.score > div { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.stat.score .value { overflow: hidden; white-space: nowrap; }
.save-btn {
  flex: none; padding: 5px 11px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-deep);
  font: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.save-btn:active { translate: 0 1px; box-shadow: 0 1px 0 var(--accent-deep); }
.save-btn:disabled { background: var(--line); color: var(--muted); box-shadow: none; cursor: default; translate: none; }
.save-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.value.bump { animation: bump 0.3s ease-out; }
@keyframes bump { 40% { scale: 1.18; } }

/* resize() in game.js sizes the canvas to fit the space the board has */
.board { flex: 1; min-height: 0; display: grid; place-items: start center; }
.stage { position: relative; }
#game { display: block; touch-action: none; }

.toast {
  position: absolute; top: 38%; left: 50%;
  padding: 8px 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(61, 42, 31, 0.18);
  font-weight: 700; font-size: 20px; white-space: nowrap;
  opacity: 0; translate: -50% calc(-50% - 8px);
  pointer-events: none;
  transition: opacity 0.25s, translate 0.25s;
}
.toast.show { opacity: 1; translate: -50% -50%; }

.over {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(61, 42, 31, 0.28);
  border-radius: 20px;
}
.over[hidden] { display: none; }
.card {
  width: min(300px, calc(100% - 32px));
  padding: 22px 22px 24px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 16px 48px rgba(61, 42, 31, 0.3);
  text-align: center;
  animation: pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.card h2 { margin: 0 0 6px; font-size: 30px; }
.final { margin: 0; font-size: 18px; color: var(--muted); }
.final strong { display: block; font-size: 44px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.final-best { margin: 2px 0 18px; color: var(--muted); font-weight: 600; }
.final-best.new { color: var(--accent); }
.btn {
  font: inherit; font-size: 19px; font-weight: 700;
  padding: 12px 30px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 0 var(--accent-deep);
  cursor: pointer;
}
.btn:active { translate: 0 2px; box-shadow: 0 2px 0 var(--accent-deep); }
@keyframes pop { from { scale: 0.7; opacity: 0; } }
.btn.small { font-size: 16px; padding: 8px 18px; box-shadow: 0 3px 0 var(--accent-deep); }
.btn.small:active { box-shadow: 0 1px 0 var(--accent-deep); }
.btn.quiet { background: var(--bg); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line), 0 3px 0 var(--line); }
.btn.quiet:active { box-shadow: inset 0 0 0 1.5px var(--line), 0 1px 0 var(--line); }
.btn:disabled { opacity: 0.55; cursor: default; translate: none; }

/* Where the game just over came on the leaderboard, or the offer to put it there (game.js, cardBoard) */
.board-link {
  display: block; width: 100%;
  margin: -8px 0 16px; padding: 4px;
  border: 0; background: none;
  font: inherit; font-size: 15px; font-weight: 600;
  color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.board-link[hidden] { display: none; }
.board-link:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* The leaderboard and the name picker (js/board.js) */
.sheet {
  width: min(380px, calc(100% - 32px));
  max-height: min(660px, calc(100dvh - 32px));
  padding: 16px 18px 18px;
  border: 0; border-radius: 24px;
  background: #fff; color: var(--ink);
  box-shadow: 0 16px 48px rgba(61, 42, 31, 0.3);
  font-family: var(--font);
  overflow: auto; overscroll-behavior: contain;
}
.sheet[open] {
  display: flex; flex-direction: column; gap: 12px;
  animation: pop 0.3s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.sheet::backdrop { background: rgba(61, 42, 31, 0.36); }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet h2 { margin: 0; font-size: 26px; }
.sheet button:focus-visible, .board-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.howto { margin: 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15px; line-height: 1.35; }
.note { margin: 0; font-size: 14px; line-height: 1.35; color: var(--muted); text-wrap: pretty; }
.note a { color: var(--accent-deep); font-weight: 600; }
.note.msg { padding: 14px 4px; text-align: center; }
.note.msg[hidden] { display: none; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; border-radius: 999px;
  background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--line);
}
.tabs button {
  padding: 7px; border: 0; border-radius: 999px;
  background: none; color: var(--muted);
  font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 2px 0 var(--line), inset 0 0 0 1.5px var(--line); }

#lb-panel { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.rows li {
  display: grid; grid-template-columns: 2.2em 24px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: 12px;
  font-weight: 600;
}
.rows li:nth-child(odd) { background: #fff8f0; }
.rows b { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rows .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .sc { font-variant-numeric: tabular-nums; }
.rows li.me { background: #ffe9dd; box-shadow: inset 0 0 0 1.5px var(--accent); }
.rows li.me b { color: var(--accent-deep); }
.rows li.gap { display: block; padding: 0; background: none; text-align: center; color: var(--muted); line-height: 1; }

.you {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 12px; border-top: 1.5px solid var(--line);
}
.you p { margin: 0; min-width: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.you .btn { flex: none; }

.name-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.name-list .note { grid-column: 1 / -1; padding: 14px 4px; text-align: center; }
.name-list button {
  padding: 10px 8px; border: 0; border-radius: 14px;
  background: var(--bg); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line);
  font: inherit; font-size: 15px; font-weight: 600; overflow-wrap: anywhere;
  cursor: pointer;
}
.name-list button:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.name-list button:active { translate: 0 1px; }
.initials { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; }
.initials input {
  width: 4.2em; padding: 8px 10px; border: 0; border-radius: 12px;
  background: var(--bg); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line);
  font: inherit; font-size: 18px; text-align: center; text-transform: uppercase; letter-spacing: 0.08em;
  -webkit-user-select: text; user-select: text;
}
.initials input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.initials input::placeholder { color: var(--line); }
#initials-eg { margin-top: -8px; }

#save .final { text-align: center; }
.save-choices { display: grid; gap: 10px; }

.link-btn {
  align-self: center; padding: 4px; border: 0; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn[hidden] { display: none; }
.link-btn.sure { color: #c0392b; }
/* Leaving just this game's board, or every game's (js/board.js) */
.leave-choices { display: grid; gap: 8px; }
.leave-choices[hidden] { display: none; }
/* The name shared with the other games, offered back to a player who left just this one */
.name-list button.shared { grid-column: 1 / -1; box-shadow: inset 0 0 0 2px var(--accent); }

/* The person check (js/board.js). Turnstile's box is empty and takes no room until it wants a tap; then this
   becomes a card at the bottom of the screen around it. */
.human {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 10;
  translate: -50% 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none;
}
.human p { display: none; margin: 0; font-size: 15px; font-weight: 600; text-align: center; text-wrap: pretty; }
.human.asking {
  width: min(280px, calc(100vw - 32px));
  padding: 14px 16px 16px; border-radius: 20px;
  background: #fff; box-shadow: 0 10px 36px rgba(61, 42, 31, 0.3);
  pointer-events: auto;
}
.human.asking p { display: block; }

/* The privacy page */
body.doc { height: auto; -webkit-user-select: text; user-select: text; overscroll-behavior: auto; }
.doc main { max-width: 640px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px 48px; line-height: 1.55; }
.doc h1 { margin: 0 0 16px; font-size: clamp(30px, 8vw, 40px); line-height: 1.1; }
.doc h2 { margin: 28px 0 8px; font-size: 22px; }
.doc p, .doc ul { margin: 0 0 12px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--accent-deep); font-weight: 600; }
.doc .back { display: inline-block; margin-bottom: 18px; }

@media (prefers-reduced-motion: reduce) {
  .card, .sheet[open], .value.bump { animation: none; }
  .toast { transition: none; }
}
