/* Wordstead: storybook frontier valley at dusk. Parchment cards, ink text, hard sticker shadows. */
:root {
  --sky0: #1b1240; --sky1: #3a1a5c; --sky2: #7a2d6b; --glow: #ff9a4d;
  --paper: #fbf0d9; --paper2: #f3e2bd; --ink: #2a1a3a; --ink2: #5e4a63;
  --edge: #2a1a3a; --gold: #ffc83d; --gold-ink: #3a2400;
  --text: #fff6e6; --muted: #e3cfe8;
  --good: #2f7d4a; --good-hi: #5fe08f; --bad: #d9344f; --bad-hi: #ff7b8f; --pink: #c93a6e;
  --r0: #a65a22; --r1: #b83b27; --r2: #6f63c4; --r3: #b07f0c; --r4: #13817e;
  --bar-h: 56px;
  --shadow: 0 4px 0 var(--edge);
  --display: "Bricolage Grotesque", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  --body: "Nunito", ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--sky0); }
html, body { margin: 0; color: var(--text); }
body {
  font: 600 17px/1.4 var(--body);
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: none; overflow-x: hidden;
  background:
    radial-gradient(120% 40% at 50% 104%, rgba(255, 154, 77, .5), transparent 62%),
    radial-gradient(1.5px 1.5px at 12% 3%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 9%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 2%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 7%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 84% 4%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 11%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 14%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 38% 13%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 16%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1px 1px at 18% 22%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 20%, #fff 50%, transparent 51%),
    linear-gradient(180deg, var(--sky0) 0%, var(--sky1) 45%, var(--sky2) 85%, #9c3d66 100%);
}
h1, h2, h3, p { margin: 0; }
h1, h2, #letter, #timer, #off-timer, #room-code, .score-val, .vp, .cnt, .myvp, .rank { font-family: var(--display); }

/* ---------- top bar ---------- */
#bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  background: rgba(27, 18, 64, .94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--edge); font-size: 14px;
}
#bar .brand { font-family: var(--display); font-weight: 800; font-size: 18px; margin-right: auto; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#bar .brand b { color: var(--gold); letter-spacing: 2px; margin-left: 4px; }
.myvp { font-weight: 800; color: var(--gold-ink); background: var(--gold); border: 2px solid var(--edge); border-radius: 999px; padding: 2px 10px; font-size: 16px; box-shadow: 0 2px 0 #000; white-space: nowrap; }
.myvp small { color: var(--gold-ink); font-weight: 700; font-size: 11px; }
.net { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.net i { width: 9px; height: 9px; border-radius: 50%; background: var(--bad-hi); display: inline-block; }
.net.ok i { background: var(--good-hi); }
.net.warn { color: var(--gold); }

#app {
  max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

/* ---------- type ---------- */
h2 { font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: -.5px; }
h3 { font-family: var(--display); font-size: 15px; color: var(--gold); text-transform: uppercase; letter-spacing: 2px; font-weight: 800; margin-top: 4px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; align-self: center; }
.break { word-break: break-all; }
.err { color: var(--bad-hi); text-align: center; min-height: 1.4em; font-weight: 800; }

/* ---------- parchment cards ---------- */
.card {
  background: var(--paper); color: var(--ink); border: 3px solid var(--edge); border-radius: 22px;
  padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 6px 0 var(--edge);
}
.card .muted { color: var(--ink2); }
.card h2 { color: var(--ink); }
.card.center { align-self: stretch; align-items: center; }

/* ---------- home hero ---------- */
.hero { text-align: center; padding: 22px 0 6px; position: relative; isolation: isolate; }
.hero::before {
  content: ""; position: absolute; left: 50%; top: -10px; width: 260px; height: 260px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 61, .6), rgba(255, 154, 77, .2) 48%, transparent 70%);
  z-index: -1;
}
.skyline { display: flex; justify-content: center; align-items: flex-end; gap: 2px; font-size: 36px; line-height: 1; }
.skyline span { display: inline-block; animation: pop .5s cubic-bezier(.3,1.6,.5,1) both; filter: drop-shadow(0 3px 0 rgba(0,0,0,.35)); }
.skyline span:nth-child(2) { animation-delay: .08s; font-size: 44px; }
.skyline span:nth-child(3) { animation-delay: .16s; font-size: 62px; }
.skyline span:nth-child(4) { animation-delay: .24s; font-size: 44px; }
.skyline span:nth-child(5) { animation-delay: .32s; }
.hero h1 {
  font-family: var(--display); font-size: 66px; line-height: .9; font-weight: 800; letter-spacing: -2px;
  margin: 0 auto; padding-top: 12px; border-top: 8px solid #4f8f37; max-width: 340px; color: var(--paper);
  -webkit-text-stroke: 6px var(--edge); paint-order: stroke fill; text-shadow: 0 5px 0 var(--edge);
}
.hero h1 span { color: var(--gold); }
.tagline { margin-top: 14px; font-size: 18px; font-weight: 800; color: var(--text); }
.resrow { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.resrow span {
  width: 48px; height: 48px; display: grid; place-items: center; font-size: 26px;
  border: 3px solid var(--edge); border-radius: 14px; box-shadow: var(--shadow); transform: rotate(-5deg);
}
.resrow span:nth-child(even) { transform: rotate(5deg) translateY(-3px); }
.resrow span:nth-child(1) { background: var(--r0); } .resrow span:nth-child(2) { background: var(--r1); }
.resrow span:nth-child(3) { background: var(--r2); } .resrow span:nth-child(4) { background: var(--r3); }
.resrow span:nth-child(5) { background: var(--r4); }

/* ---------- fields ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld span { font-size: 13px; color: var(--ink2); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; }
.fld.row { flex-direction: row; align-items: center; justify-content: space-between; }
input, select {
  font: inherit; font-size: 18px; font-weight: 700; color: var(--ink); background: #fffaf0;
  border: 3px solid var(--edge); border-radius: 14px; padding: 10px 14px; width: 100%; min-width: 0; min-height: 52px;
  outline: none; box-shadow: inset 0 3px 0 rgba(42, 26, 58, .12);
}
input::placeholder { color: #8a7680; }
select { width: auto; min-width: 90px; }
input:focus, select:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(201, 58, 110, .3); }
input:disabled { opacity: .6; }
#code { text-transform: uppercase; letter-spacing: 10px; font-family: var(--display); font-weight: 800; text-align: center; font-size: 28px; }

/* ---------- buttons ---------- */
button {
  font: inherit; font-weight: 800; border: 3px solid var(--edge); border-radius: 16px; padding: 12px 18px; min-height: 54px;
  color: var(--ink); background: var(--paper2); cursor: pointer; width: 100%; touch-action: manipulation;
  box-shadow: 0 5px 0 var(--edge); transition: transform .07s, box-shadow .07s; position: relative;
}
button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
button:disabled { background: #cbbfc2 !important; color: #4f4550 !important; box-shadow: 0 2px 0 rgba(42,26,58,.5) !important; border-style: dashed; cursor: not-allowed; }
button.primary { background: var(--gold); color: var(--gold-ink); font-family: var(--display); font-size: 20px; }
button.ghost { background: var(--paper); }
button.link { background: none; border: 0; box-shadow: none; color: var(--muted); text-decoration: underline; min-height: 44px; padding: 8px; width: auto; font-weight: 700; font-size: 14px; }
.card button.link { color: var(--ink2); }
button.link:active:not(:disabled) { transform: none; box-shadow: none; opacity: .7; }
button.slim { width: auto; min-height: 44px; padding: 8px 14px; flex: none; }

/* ---------- lobby ---------- */
.codecard { background: var(--gold); }
.card.codecard .muted { color: var(--gold-ink); }
#room-code { font-size: 76px; font-weight: 800; letter-spacing: 12px; color: var(--ink); line-height: 1; padding-left: 12px; }
#player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#player-list li { background: #fffaf0; border: 2px solid var(--edge); border-radius: 12px; padding: 10px 12px; font-weight: 800; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
#player-list li.off { opacity: .55; }
#player-list em { font-style: normal; font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--paper); background: var(--ink); border-radius: 6px; padding: 2px 7px; margin-left: 4px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; border: 2px solid var(--edge); flex: none; vertical-align: -1px; }
details summary { font-family: var(--display); font-weight: 800; font-size: 18px; cursor: pointer; min-height: 32px; }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--ink2); font-size: 15px; }
.rules b { color: var(--ink); }

/* ---------- round ---------- */
.roundhead {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top)); z-index: 4;
  margin: -16px -16px 0; padding: 10px 16px 12px;
  background: rgba(27, 18, 64, .96); border-bottom: 3px solid var(--edge);
}
.roundhead > div:first-child { min-width: 0; }
.roundhead h2 { font-size: 38px; color: var(--gold); -webkit-text-stroke: 4px var(--edge); paint-order: stroke fill; }
#letter {
  font-size: 84px; font-weight: 800; line-height: .9; color: var(--gold);
  -webkit-text-stroke: 6px var(--edge); paint-order: stroke fill; text-shadow: 0 5px 0 var(--edge);
}
#timer, #off-timer {
  font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--paper); border: 3px solid var(--edge); border-radius: 50%;
  width: 94px; height: 94px; display: grid; place-items: center; flex: none; box-shadow: 0 5px 0 #000; line-height: 1;
}
#off-timer { font-size: 32px; }
#timer.hot, #off-timer.hot { color: #fff; background: var(--bad); animation: pulse .8s ease-in-out infinite; }
.cats { display: flex; flex-direction: column; gap: 14px; }
.cat {
  display: flex; flex-direction: column; gap: 8px; background: var(--paper); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 18px; padding: 12px; box-shadow: 0 5px 0 var(--edge);
}
.catline { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; line-height: 1.2; }
.r0 { --rc: var(--r0); } .r1 { --rc: var(--r1); } .r2 { --rc: var(--r2); } .r3 { --rc: var(--r3); } .r4 { --rc: var(--r4); }
.chip {
  flex: none; color: #fff; background: var(--rc, var(--ink)); border: 2px solid var(--edge); border-radius: 10px; padding: 3px 8px; font-size: 14px;
  font-weight: 800; box-shadow: 0 2px 0 var(--edge); white-space: nowrap;
}
.cat.boom {
  background: linear-gradient(135deg, #fff3b0, var(--gold) 60%, #ffab2e);
  box-shadow: 0 5px 0 var(--edge), 0 0 0 4px rgba(255, 200, 61, .35), 0 0 28px rgba(255, 200, 61, .6);
  animation: shimmer 2.4s ease-in-out infinite;
}
.cat.boom .chip { background: var(--ink); color: var(--gold); }
.offcats { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 8px; font-weight: 800; font-size: 18px; }

/* ---------- reveal ---------- */
.revealhead {
  display: flex; gap: 14px; align-items: center; background: var(--paper); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 22px; padding: 14px; box-shadow: 0 6px 0 var(--edge);
}
.revealhead .muted { color: var(--ink2); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 800; font-size: 12px; }
.bigres { font-size: 40px; width: 66px; height: 66px; display: grid; place-items: center; flex: none; background: var(--sky1); border: 3px solid var(--edge); border-radius: 18px; box-shadow: 0 4px 0 var(--edge); }
#reveal-category { text-align: left; padding: 2px 0 0; font-size: 26px; overflow-wrap: anywhere; }
.revealhead.boom { background: linear-gradient(135deg, #fff3b0, var(--gold) 60%, #ffab2e); box-shadow: 0 6px 0 var(--edge), 0 0 0 4px rgba(255, 200, 61, .35), 0 0 34px rgba(255, 200, 61, .7); animation: shimmer 2.4s ease-in-out infinite; }
.revealhead.boom .muted { color: var(--gold-ink); }
.revealhead.boom .bigres { background: var(--ink); animation: wobble 1.2s ease-in-out infinite; }
.revealhead > div { min-width: 0; }
.rows { display: flex; flex-direction: column; gap: 10px; }
.answer-row {
  display: flex; align-items: center; gap: 10px; background: var(--paper); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 16px; padding: 10px 12px; box-shadow: 0 4px 0 var(--edge);
}
.answer-row .who { width: 82px; flex: none; font-size: 13px; color: var(--ink2); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.answer-row .ans { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.answer-text { font-family: var(--display); font-size: 21px; font-weight: 800; overflow-wrap: anywhere; line-height: 1.15; }
.tag { font-size: 12px; color: var(--good); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.answer-row.mine { box-shadow: 0 4px 0 var(--edge), inset 6px 0 0 var(--pink); }
.answer-row.under { background: #fff1b8; }
.answer-row.under .tag { color: #7a4e00; }
.answer-row.dup, .answer-row.struck, .answer-row.bad, .answer-row.empty { background: #e2d6cf; }
.answer-row.dup .answer-text, .answer-row.struck .answer-text, .answer-row.bad .answer-text { text-decoration: line-through 3px; color: #5f5159; }
.answer-row.dup .tag, .answer-row.struck .tag, .answer-row.bad .tag, .answer-row.empty .tag { color: #9c1f34; }
.btn-challenge { width: auto; min-height: 44px; padding: 6px 10px; font-size: 13px; background: var(--pink); color: #fff; flex: none; box-shadow: 0 3px 0 var(--edge); }
.challenge {
  background: var(--sky1); border: 3px solid var(--gold); border-radius: 20px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 6px 0 var(--edge);
}
.challenge .big { font-family: var(--display); font-size: 26px; font-weight: 800; color: var(--gold); }
.votebtns { display: flex; gap: 10px; }
.votebtns button { min-width: 0; }
button.keep { background: var(--good-hi); color: #062b13; }
button.strike { background: var(--bad-hi); color: #3d0010; }
.verdict { border: 3px solid var(--edge); border-radius: 16px; padding: 12px; text-align: center; font-weight: 800; box-shadow: 0 4px 0 var(--edge); }
.verdict.bad { background: var(--bad-hi); color: #3d0010; }
.verdict.good { background: var(--good-hi); color: #062b13; }

/* ---------- scoreboard (legacy) ---------- */
#scoreboard { gap: 8px; }
.score-row { display: flex; align-items: center; gap: 12px; background: #fffaf0; border: 2px solid var(--edge); border-radius: 12px; padding: 12px 14px; }
.score-row.mine { outline: 3px solid var(--pink); }
.score-row:first-child { background: #fff1b8; }
.rank { width: 28px; flex: none; font-weight: 800; }
.nm { flex: 1; min-width: 0; font-weight: 800; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delta { color: var(--ink2); font-size: 14px; }
.score-val { font-size: 28px; font-weight: 800; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.trophy { font-size: 64px; line-height: 1; }

/* ---------- market ---------- */
.harvest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.harvest .gain {
  display: inline-flex; align-items: center; gap: 4px; font-size: 18px; background: var(--paper); color: var(--ink);
  border: 2px solid var(--edge); border-radius: 999px; padding: 2px 10px 2px 6px; box-shadow: 0 3px 0 var(--edge);
  animation: pop .45s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i, 0) * 90ms);
}
.harvest .gain b { font-family: var(--display); color: var(--good); }
#inv { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.res {
  background: var(--rc); color: #fff; border: 3px solid var(--edge); border-radius: 16px; padding: 8px 2px 6px;
  text-align: center; display: flex; flex-direction: column; align-items: center; box-shadow: 0 4px 0 var(--edge); min-width: 0;
}
.res .e { font-size: 24px; line-height: 1.1; }
.res .cnt { font-size: 28px; line-height: 1; -webkit-text-stroke: 4px var(--edge); paint-order: stroke fill; }
.res small { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.res.zero { background: #4a3a5e; color: #d9cde2; }
.res.zero .e { opacity: .5; }
.builds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.btn-build { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px 6px; font-size: 13px; min-height: 0; min-width: 0; border-radius: 16px; background: var(--paper); }
.btn-build b { font-family: var(--display); font-size: 14px; }
.btn-build .be { font-size: 28px; line-height: 1.1; }
.btn-build .cost { font-size: 13px; letter-spacing: -1px; max-width: 100%; overflow-wrap: anywhere; line-height: 1.2; }
.btn-build em { font-style: normal; color: #fff; background: var(--good); border-radius: 999px; padding: 0 6px; font-size: 11px; margin-top: 2px; }
.btn-build:disabled em { background: #6a5f68; }
.btn-build:disabled .be { opacity: .55; }
.btn-build.raid { background: #3a2342; color: var(--paper); }
.btn-build.raid em { background: var(--pink); }
.btn-build.raid.on { background: var(--pink); color: #fff; animation: wobble .9s ease-in-out infinite; }
.btn-build.raid.on em { background: var(--ink); }
.raidhint { text-align: center; font-family: var(--display); font-weight: 800; font-size: 15px; color: var(--gold); }
.players { display: flex; flex-direction: column; gap: 8px; }
.pl {
  display: flex; align-items: center; gap: 8px; background: var(--paper); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 16px; padding: 8px 10px; width: 100%; min-height: 54px;
  font-weight: 800; text-align: left; box-shadow: 0 4px 0 var(--edge);
}
.pl.mine { background: #fff1b8; }
.pl.off { opacity: .55; }
.pl .plname { display: block; min-width: 0; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; flex: none; }
.pl .town { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 20px; display: block; }
.pl .plmeta { display: flex; align-items: center; gap: 6px; flex: none; }
.pl .cards { font-size: 13px; color: var(--ink2); }
.pl .vp { font-size: 20px; background: var(--gold); border: 2px solid var(--edge); border-radius: 10px; padding: 0 7px; min-width: 32px; text-align: center; }
.pl.raid-target { background: #ffe0ea; border-color: var(--pink); box-shadow: 0 4px 0 var(--pink); }
.composer .side { display: flex; align-items: center; gap: 8px; }
.composer .lbl { width: 50px; white-space: nowrap; flex: none; font-size: 12px; color: var(--ink2); text-transform: uppercase; font-weight: 800; letter-spacing: .5px; line-height: 1.1; }
.picks { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; flex: 1; min-width: 0; }
.pick { min-height: 48px; padding: 2px; font-size: 22px; border-radius: 12px; box-shadow: 0 3px 0 var(--edge); background: #fffaf0; min-width: 0; }
.pick.on { background: var(--gold); transform: translateY(-2px); box-shadow: 0 5px 0 var(--edge); }
.pick b {
  position: absolute; top: -9px; right: -6px; font-family: var(--display); font-size: 13px; color: #fff; background: var(--pink);
  border: 2px solid var(--edge); border-radius: 999px; min-width: 22px; height: 22px; line-height: 18px; text-align: center; padding: 0 4px;
}
.composer .votebtns { flex-wrap: wrap; }
.composer .votebtns #btn-offer { flex: 1 1 100%; }
.composer .votebtns #btn-bank { flex: 1; }
.offers { display: flex; flex-direction: column; gap: 8px; }
.offer {
  display: flex; align-items: center; gap: 8px; background: var(--paper); color: var(--ink);
  border: 3px solid var(--edge); border-radius: 16px; padding: 8px 10px; box-shadow: 0 4px 0 var(--edge); min-width: 0;
}
.offer.mine { background: #fff1b8; }
.offer .oname { display: block; font-size: 14px; max-width: 32%; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: none; }
.offer .odeal { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; font-size: 18px; }
.offer .odeal span { overflow-wrap: anywhere; }
.offer i { font-style: normal; color: var(--ink2); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.btn-accept { width: auto; min-height: 44px; background: var(--good-hi); color: #062b13; padding: 6px 14px; flex: none; font-family: var(--display); }
.log { display: flex; flex-direction: column; gap: 2px; }
.log p { font-size: 13px; color: var(--muted); }
.log p:first-child { color: var(--text); }

/* ---------- table / final ---------- */
#table { display: flex; flex-direction: column; gap: 16px; }
.stead {
  background: var(--paper); color: var(--ink); border: 3px solid var(--edge); border-radius: 22px;
  padding: 12px 12px 14px; box-shadow: 0 6px 0 var(--edge); display: flex; flex-direction: column; gap: 10px;
  border-top: 10px solid var(--c, var(--edge));
}
.stead.mine { box-shadow: 0 6px 0 var(--edge), 0 0 0 4px var(--pink); }
.stead.lead { background: #fff1b8; }
.steadhead { display: flex; align-items: center; gap: 10px; }
.steadhead .rank { width: 32px; height: 32px; display: grid; place-items: center; background: var(--ink); color: var(--paper); border-radius: 50%; font-size: 16px; }
.stead.lead .rank { background: var(--gold); color: var(--ink); border: 2px solid var(--edge); }
.steadhead .cards { font-size: 13px; color: var(--ink2); flex: none; }
.land {
  position: relative; border-radius: 14px; border: 3px solid var(--edge); padding: 10px 10px 12px; overflow: hidden;
  background:
    linear-gradient(180deg, transparent 64%, #6fb24a 64%, #4f8f37 82%, #3d7330 100%),
    linear-gradient(180deg, #ffd29c, #ff9f7a);
}
.town { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px; }
.town.big { font-size: 34px; min-height: 48px; line-height: 1; position: relative; }
.bld { display: inline-block; animation: pop .5s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i, 0) * 110ms + 150ms); filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.vpbar { height: 12px; background: #e2d2b8; border: 2px solid var(--edge); border-radius: 999px; overflow: hidden; }
.vpbar i { display: block; height: 100%; background: var(--c, var(--gold)); }

#final {
  background: radial-gradient(circle at 50% 0%, #fff8d6, var(--gold) 70%); padding: 26px 18px 22px; gap: 4px;
  box-shadow: 0 8px 0 var(--edge), 0 0 0 6px rgba(255, 200, 61, .35), 0 0 60px rgba(255, 154, 77, .7);
  animation: pop .6s cubic-bezier(.3,1.6,.5,1) both; position: relative; z-index: 11;
}
#final .trophy { font-size: 76px; animation: wobble 1.6s ease-in-out infinite; filter: drop-shadow(0 4px 0 rgba(0,0,0,.3)); }
#final .muted { color: var(--gold-ink); text-transform: uppercase; letter-spacing: 3px; font-weight: 800; font-size: 13px; }
#final h2 { font-size: 54px; line-height: 1; overflow-wrap: anywhere; color: var(--ink); }
.wintext { font-family: var(--display); font-size: 22px; font-weight: 800; color: var(--gold-ink); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 160px); background: var(--gold); color: var(--gold-ink); font-weight: 800; font-size: 16px;
  padding: 12px 20px; border: 3px solid var(--edge); border-radius: 999px; box-shadow: 0 5px 0 var(--edge);
  width: max-content; max-width: calc(100vw - 32px); text-align: center; transition: transform .3s cubic-bezier(.3,1.5,.5,1);
}
#toast.show { transform: translate(-50%, 0); }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i { position: absolute; top: -50px; font-style: normal; font-size: 26px; animation: fall 4s linear infinite; }

/* ---------- motion ---------- */
@keyframes fall { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(115vh) rotate(540deg); } }
@keyframes pop { 0% { transform: scale(.2) translateY(10px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); box-shadow: 0 5px 0 #000, 0 0 0 8px rgba(217, 52, 79, .4); } }
@keyframes wobble { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes shimmer { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.07); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .confetti { display: none; }
}
@media (max-width: 370px) {
  .hero h1 { font-size: 56px; }
  #letter { font-size: 72px; }
  #timer, #off-timer { width: 84px; height: 84px; font-size: 40px; }
  .btn-build b { font-size: 12px; }
}

/* --- look-gate fixes --- */
.confetti { z-index: 3; }
@media (max-width: 380px) { #bar .brand { font-size: 15px; } #bar .brand b { letter-spacing: 0; margin-left: 2px; } }
.btn-build:disabled { background: #d8cfc6; box-shadow: none; transform: translateY(3px); }
.btn-build:disabled b, .btn-build:disabled .cost { opacity: .5; }
