/* Rats Market — dark navy & cheese-gold, a fixed brand look (not theme-adaptive). */
:root {
  --bg: #0b1024;
  --bg-2: #141b3a;
  --card: #151c3c;
  --card-2: #1b2348;
  --ink: #f2eede;
  --muted: #98a0c6;
  --line: #2b3462;
  --cheese: #ffcb3a;
  --cheese-dark: #e2a300;
  --teal: #35d0c0;
  --teal-dark: #1fa89a;
  --good: #4cc27d;
  --bad: #ef5876;
  --you: rgba(255, 203, 58, 0.14);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(255, 203, 58, 0.08), transparent),
    var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

h1, h2, .big-code, .lot-value, .bal {
  font-family: "Baloo 2", "Nunito", -apple-system, sans-serif;
}
h1 {
  font-size: 2.9rem; margin: 4px 0; letter-spacing: -0.01em; font-weight: 800;
  color: var(--cheese);
  text-shadow:
    0 1px 0 #a86a00,
    0 2px 0 #a86a00,
    0 3px 0 #a86a00,
    0 4px 10px rgba(0, 0, 0, 0.45);
}
h2 { font-size: 1.15rem; margin: 0 0 12px; font-weight: 700; }
/* One continuous wallpaper behind an entire screen (fixed to the viewport, not the
   scrolling column), so illustrations and content read as one designed screen
   instead of a picture stacked on top of a separate block. Each screen supplies
   its own <img class="page-bg"> + <div class="page-scrim">; whichever screen is
   active is the only one painted, via the existing .screen display toggle. */
.page-bg {
  position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  object-fit: cover; object-position: center 30%; z-index: -4;
}
.page-scrim {
  position: fixed; inset: 0; z-index: -3; pointer-events: none;
  background: linear-gradient(180deg, rgba(11, 16, 36, 0.55) 0%, rgba(11, 16, 36, 0.15) 22%, rgba(11, 16, 36, 0.25) 55%, rgba(11, 16, 36, 0.85) 100%);
}
#screen-lobby .page-bg, #screen-game .page-bg { object-position: center 35%; }
#screen-lobby .page-scrim, #screen-game .page-scrim {
  background: linear-gradient(180deg, rgba(11, 16, 36, 0.55) 0%, rgba(11, 16, 36, 0.45) 100%);
}
/* Sits above the market wallpaper once the round is won, at the same z-index tier
   so toggling .hidden fully swaps one wallpaper for the other. */
.finish-bg { z-index: -2; }
.finish-scrim {
  z-index: -1;
  background: linear-gradient(180deg, rgba(11, 16, 36, 0.25) 0%, rgba(11, 16, 36, 0.1) 30%, rgba(11, 16, 36, 0.55) 70%, rgba(11, 16, 36, 0.92) 100%);
}

.hero { text-align: center; padding: 20px 0 4px; }
.hero-logo { width: 82%; max-width: 320px; height: auto; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.55)); }
.hero .tagline { color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7); margin: 10px 0 0; }

/* A frosted panel that lets the wallpaper show through instead of a solid card. */
.card.glass {
  background: rgba(9, 13, 28, 0.6);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  border-color: rgba(255, 255, 255, 0.14);
}

.card {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.big { font-size: 1.4rem; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row.wrap { flex-wrap: wrap; }
.center-row { justify-content: center; }
.pill { background: var(--bg-2); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; color: var(--muted); }

label { display: block; font-weight: 600; margin: 8px 0 6px; }
input[type=text], input[type=number] {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
input:focus { border-color: var(--cheese-dark); }
.code-input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; text-align: center; }

.btn {
  font: inherit;
  font-family: "Baloo 2", "Nunito", -apple-system, sans-serif;
  font-weight: 600;
  border: 2px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: var(--cheese);
  border-color: var(--cheese-dark);
  color: #2a1c00;
  font-size: 1.05rem;
  padding: 14px;
  box-shadow: 0 4px 0 var(--cheese-dark);
}
.btn-primary:hover { background: #ffd65e; }
.btn-primary:active { transform: translateY(2px) scale(0.99); box-shadow: 0 2px 0 var(--cheese-dark); }
.btn-ghost { display: block; margin: 12px auto 0; background: transparent; border-color: transparent; color: var(--muted); }
.btn-small { padding: 8px 14px; font-size: 0.9rem; }
.btn-chip { padding: 6px 12px; font-size: 0.85rem; border-radius: 999px; }
.btn-danger { color: var(--bad); }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; margin: 20px 0 8px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.big-code { font-size: 3rem; font-weight: 800; letter-spacing: 0.25em; margin: 4px 0 12px; padding-left: 0.25em; color: var(--teal); }

.plist { list-style: none; padding: 0; margin: 0; }
.plist li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
}
.plist li:last-child { border-bottom: none; }
.plist li.me { background: var(--you); }
.plist .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .tag { font-size: 0.75rem; color: var(--muted); margin-left: 4px; }
.plist .off { color: var(--bad); font-size: 0.75rem; margin-left: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; }
.dot.off { background: var(--bad); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  object-fit: cover; background: var(--bg-2);
  box-shadow: 0 0 0 2px var(--card), 0 0 6px rgba(0, 0, 0, 0.35);
}

.plist.game li { flex-wrap: wrap; }
.plist.game .bal { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.plist.game .status { font-size: 0.8rem; min-width: 84px; text-align: right; }
.status.ok { color: var(--good); }
.status.wait { color: var(--muted); }
.bar { flex-basis: 100%; height: 6px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--cheese), var(--cheese-dark)); border-radius: 999px; transition: width 0.6s ease; }

.topbar { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; color: var(--muted); padding: 4px 4px 0; flex-wrap: wrap; }
.topbar b { color: var(--ink); }

.lot { display: flex; align-items: center; gap: 16px; background: linear-gradient(135deg, var(--teal-dark), #123a4a); color: #fff; border: none; }
.lot .muted { color: rgba(255,255,255,0.8); }
.crate { font-size: 3rem; }
.lot-value { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }

.bid-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.my-balance { color: var(--muted); }
.my-balance b { color: var(--ink); font-size: 1.2rem; }
.stepper { display: flex; gap: 6px; }
.stepper input { text-align: center; font-size: 1.5rem; font-weight: 800; min-width: 0; flex: 1; padding: 8px; }
.stepper .step { padding: 8px 10px; flex: none; }
.quick { margin-top: 10px; }
#bid-done p { margin: 8px 0; }

.bids { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.bids th, .bids td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.bids th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.bids td:nth-child(n+3), .bids th:nth-child(n+3) { text-align: right; }
.delta { font-size: 0.8rem; margin-left: 4px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.steps { padding-left: 20px; margin: 14px 0 0; }
.steps li { margin: 6px 0; }
.steps .fail { color: var(--muted); }

.history { list-style: none; padding: 0; margin: 10px 0 0; font-size: 0.9rem; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--line); }

details summary { cursor: pointer; font-weight: 700; }
.rules-list { padding-left: 20px; margin-bottom: 0; }
.rules-list li { margin: 8px 0; }

/* Text + buttons floating directly on the fixed .finish-bg wallpaper — no card. */
.finish { padding: 56px 16px 28px; }
.finish h2 { font-size: 1.8rem; margin: 0; color: var(--cheese); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65); }
.finish p { margin: 8px 0 0; color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75); }
.finish-actions { margin-top: 22px; }
.finish .btn-ghost { color: rgba(255, 255, 255, 0.85); }

.bid-art {
  display: block; width: 100%; max-height: 180px; object-fit: contain;
  margin: 4px 0 10px;
}
.reveal-art { width: 96px; height: 96px; object-fit: contain; display: block; margin: 0 auto 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #241a03; color: #fff; padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow); max-width: calc(100% - 32px); z-index: 10;
}
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--bad); color: #fff; text-align: center; padding: 8px; font-size: 0.9rem; z-index: 10; }

@media (max-width: 420px) {
  .stepper .step { padding: 8px 7px; }
  .bids th:first-child, .bids td:first-child { display: none; }
  .lot-value { font-size: 2rem; }
}

/* Timer */
.lot { position: relative; }
.timer { margin-left: auto; text-align: center; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer .small { font-size: 0.72rem; font-weight: 500; opacity: 0.85; }
.timer.urgent { color: #ffe08a; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.btn-chip.selected { background: var(--cheese); border-color: var(--cheese-dark); color: #2a1c00; }
.btn-chip:disabled { opacity: 1; cursor: default; }
.btn-chip:disabled:not(.selected) { opacity: 0.55; }

/* Result table */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.bids td { vertical-align: top; }
.bids .status-cell { text-align: left !important; font-size: 0.82rem; }
.bids th:nth-child(4) { text-align: left !important; }
.bids tr.st-winner td, .bids tr.st-free td { background: var(--you); font-weight: 700; }
.bids tr.st-lost td { color: var(--bad); }
.bids tr.st-bonus .status-cell { color: var(--good); font-weight: 600; }
.bids .tag { font-size: 0.72rem; color: var(--muted); font-weight: 400; }
.bad { color: var(--bad); font-weight: 600; }

/* Reveal modal */
.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(3, 5, 16, 0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade 0.2s ease;
}
.modal-box {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px;
  width: 100%; max-width: 620px; max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.pop { opacity: 0; animation: pop 0.45s ease forwards; animation-delay: var(--d, 0s); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pop { animation: none; opacity: 1; }
  .timer.urgent { animation: none; }
}
