/* Hootpot: dusk-fog light theme by default, night theme follows the system. */
:root {
  --fog: #e4e8ee;
  --card: #f4f6f9;
  --ink: #17203a;
  --muted: #566078;
  --line: #c9d0dd;
  --bark: #6b4f3a;
  --bark-deep: #4a3626;
  --shell: #fbf5e6;
  --shell-edge: #d6c9ab;
  --amber: #f4a51c;
  --amber-deep: #c77f00;
  --fern: #2f6a4b;
  --ember: #b83d28;
  --radius: 22px;
  --display: "Bagel Fat One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fog: #10162b;
    --card: #1a2240;
    --ink: #eef0f8;
    --muted: #a0a9c4;
    --line: #2b3659;
    --fern: #86cba3;
    --ember: #f29580;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fog: #10162b;
  --card: #1a2240;
  --ink: #eef0f8;
  --muted: #a0a9c4;
  --line: #2b3659;
  --fern: #86cba3;
  --ember: #f29580;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fog);
  color: var(--ink);
  font: 500 16px/1.5 var(--body);
  min-height: 100vh;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 10px; }

.demo-banner {
  background: var(--amber);
  color: #17203a;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 16px;
}

.top {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; }
.brand-name { font: 400 28px/1 var(--display); letter-spacing: 0.2px; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card h2 { font: 400 24px/1.15 var(--display); margin-bottom: 12px; }

/* ---------- stage ---------- */
.stage { text-align: center; padding-top: 4px; }
.status { color: var(--muted); font-weight: 600; min-height: 1.5em; }
.status b { color: var(--ink); }
.clock {
  font: 400 clamp(64px, 20vw, 112px)/1 var(--display);
  letter-spacing: 1px;
  margin: 2px 0 4px;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.clock.idle { color: var(--muted); opacity: 0.55; }
.clock.hot { color: var(--ember); }
.clock.done { color: var(--fern); }
.nest { width: 100%; height: auto; max-width: 640px; display: block; margin: 0 auto; overflow: visible; }
.seats { margin-top: 4px; font-weight: 700; }
.seats span { color: var(--muted); font-weight: 600; }

/* owl */
.lid { transition: transform 0.7s cubic-bezier(.3,.7,.2,1); transform-box: fill-box; transform-origin: center top; }
.pupil { transition: r 0.5s; }
.owl { transform-box: fill-box; transform-origin: center bottom; }
.nest.full .owl { animation: owl-bob 1.6s ease-in-out infinite; }
@keyframes owl-bob { 50% { transform: translateY(-5px); } }

/* eggs */
.egg { transform-box: fill-box; transform-origin: center bottom; }
.egg-body { transition: fill 0.4s, opacity 0.4s; }
.egg.empty .egg-body { fill: none; stroke: var(--bark); stroke-width: 2.5; stroke-dasharray: 5 6; opacity: 0.55; }
.egg.taken .egg-body { fill: var(--shell); stroke: var(--shell-edge); stroke-width: 2.5; }
.egg.mine .egg-ring { opacity: 1; }
.egg-ring { fill: none; stroke: var(--amber); stroke-width: 4; opacity: 0; }
.egg.just { animation: egg-pop 0.6s cubic-bezier(.3,1.6,.4,1); }
@keyframes egg-pop { from { transform: scale(0.2); } }
.egg-initials { font: 400 17px var(--display); fill: var(--bark); text-anchor: middle; pointer-events: none; }
.nest.hatching .egg { animation: egg-shake 0.5s ease-in-out 3; }
.nest.hatching .egg.dim { opacity: 0.28; animation: none; transition: opacity 0.6s; }
@keyframes egg-shake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.owlet { transform-box: fill-box; transform-origin: center bottom; animation: owlet-up 0.9s 1.4s both cubic-bezier(.3,1.5,.4,1); }
@keyframes owlet-up { from { transform: translateY(24px) scale(0.2); opacity: 0; } }
.shell-half { transform-box: fill-box; animation: shell-split 0.8s 1.3s both ease-out; }
.shell-half.l { transform-origin: left bottom; --rot: -28deg; --dx: -10px; }
.shell-half.r { transform-origin: right bottom; --rot: 28deg; --dx: 10px; }
@keyframes shell-split { to { transform: translateX(var(--dx)) rotate(var(--rot)); } }
.feather { opacity: 0; fill: var(--amber); animation: feather 2.6s ease-out forwards; transform-box: fill-box; }
@keyframes feather {
  0% { opacity: 0; transform: translate(0, 0) rotate(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--fx), var(--fy)) rotate(var(--fr)); }
}

/* ---------- action card ---------- */
.action { display: grid; gap: 14px; align-content: start; }
.action h2 { margin-bottom: 0; }
.entry { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.entry strong { font: 400 40px/1 var(--display); }
.entry span { color: var(--muted); font-weight: 600; }
.prize { background: var(--fog); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prize b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.prize span { color: var(--muted); font-weight: 600; }
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 18px;
  min-height: 56px;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, filter 0.12s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary { background: var(--amber); color: #17203a; box-shadow: 0 3px 0 var(--amber-deep); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.quiet { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.quiet:hover { border-color: var(--bark); }
.btn.good { background: var(--fern); color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.btn.warn { background: var(--ember); color: #fff; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 15px; border-radius: 12px; }
.btn-row { display: grid; gap: 10px; }
.note { color: var(--muted); font-size: 14px; font-weight: 600; }
.note b { color: var(--ink); }
.note.bad { color: var(--ember); }
.note a { text-decoration-thickness: 2px; }
.pending { background: var(--fog); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- wallet chip ---------- */
.wallet { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 6px 6px 14px; font-weight: 700; font-size: 14px;
}
.chip button { border: 0; background: var(--fog); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 700; font-size: 13px; }

/* ---------- split ---------- */
.bar { display: flex; height: 22px; border-radius: 999px; overflow: hidden; gap: 3px; }
.bar i { display: block; min-width: 6px; }
.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; }
.legend .dot { width: 14px; height: 14px; border-radius: 5px; }
.legend .pct { color: var(--muted); font-weight: 600; margin-left: 6px; }
.legend .amt { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- history ---------- */
.rows { list-style: none; margin: 0; padding: 0; display: grid; }
.rows li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows .who { font-weight: 700; word-break: break-all; }
.rows .when { color: var(--muted); font-size: 14px; font-weight: 600; }
.rows .won { font: 400 20px/1.2 var(--display); text-align: right; color: var(--fern); }
.rows .sub { color: var(--muted); font-size: 14px; font-weight: 600; text-align: right; }
.empty { color: var(--muted); font-weight: 600; }

.rules p + p { margin-top: 10px; }
.rules .fine { color: var(--muted); font-size: 14px; }

.foot { max-width: 1120px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); color: var(--muted); font-size: 14px; font-weight: 600; display: grid; gap: 4px; word-break: break-all; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--fog); padding: 12px 18px; border-radius: 14px;
  font-weight: 700; max-width: min(92vw, 460px); z-index: 20; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.toast.bad { background: var(--ember); color: #fff; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  main { grid-template-columns: minmax(0, 7fr) minmax(320px, 4fr); align-items: start; gap: 20px; }
  .stage { grid-row: span 2; padding-top: 12px; }
  .action { position: sticky; top: 16px; }
  .split, .history, .rules { grid-column: 1 / -1; }
  .split, .history { grid-column: auto; }
  .rules { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  main { grid-template-areas: "stage action" "stage token" "split history" "rules rules"; grid-template-rows: auto 1fr auto auto; }
  .stage { grid-area: stage; }
  .action { grid-area: action; }
  .token { grid-area: token; }
  .split { grid-area: split; }
  .history { grid-area: history; }
  .rules { grid-area: rules; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.demo-banner b { font-weight: 800; }
.split .note { margin-top: 10px; }
.token { display: grid; gap: 12px; align-content: start; }
.token h2 { margin-bottom: 0; }
.token .tk-sub { color: var(--muted); font-weight: 600; font-size: 15px; }
.token .tk-id { color: var(--muted); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.token .tk-id a { text-decoration-thickness: 2px; }
.token .btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.token .tk-tag { justify-self: start; background: var(--amber); color: #17203a; font-weight: 800; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.history .sample { color: var(--muted); font: 600 14px var(--body); margin-left: 6px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.social { color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: none; }
.social:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 520px) { .social { display: none; } }
