/* Bottle Match: a cozy tabletop. Warm parchment table by day, lamplit wood by night.
   Physical scene: friends on a sofa passing a phone around, or one person killing five
   minutes on the bus. Warm, tactile, readable at arm's length. */

:root {
  --bg: oklch(94.5% 0.025 78);
  --bg-weave: oklch(91% 0.03 75);
  --table: oklch(90.5% 0.03 74);
  --card: oklch(96.4% 0.036 86);
  --frame: url(../img/kenney/frame.svg);
  --ink: oklch(27% 0.035 50);
  --muted: oklch(49% 0.035 55);
  --line: oklch(86% 0.03 72);
  --accent: oklch(55% 0.13 155);
  --accent-deep: oklch(43% 0.11 155);
  --accent-ink: oklch(98.5% 0.01 150);
  --good: oklch(56% 0.15 150);
  --bad: oklch(57% 0.18 33);
  --tip: oklch(56% 0.12 245);
  --gold: oklch(78% 0.15 78);
  --wood: oklch(47% 0.085 55);
  --wood-hi: oklch(53% 0.09 58);
  --wood-dk: oklch(35% 0.07 50);
  --plank: oklch(63% 0.085 66);
  --plank-dk: oklch(50% 0.08 60);
  --shadow: 0 1px 0 oklch(100% 0 0 / .6) inset, 0 1px 2px oklch(30% 0.05 50 / .08), 0 6px 18px oklch(30% 0.05 50 / .08);
  --display: "Titan One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --p0: #e23b3b; --p1: #2f6fe0; --p2: #c99500; --p3: #2fa84f; --p4: #8b4fd6; --p5: #e8701a; --p6: #e0509a; --p7: #0f9a9a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(21% 0.02 55); --bg-weave: oklch(23% 0.022 55); --table: oklch(29% 0.025 55); --card: oklch(26% 0.022 55); --frame: url(../img/kenney/frame-dark.svg);
    --ink: oklch(94% 0.015 78); --muted: oklch(73% 0.03 70); --line: oklch(36% 0.025 55);
    --accent: oklch(72% 0.14 155); --accent-deep: oklch(58% 0.12 155); --accent-ink: oklch(20% 0.04 155);
    --good: oklch(74% 0.15 150); --bad: oklch(70% 0.16 38); --tip: oklch(72% 0.11 245);
    --wood: oklch(38% 0.07 52); --wood-hi: oklch(43% 0.075 55); --wood-dk: oklch(27% 0.05 50); --plank: oklch(47% 0.07 62); --plank-dk: oklch(36% 0.06 58);
    --shadow: 0 1px 0 oklch(100% 0 0 / .04) inset, 0 2px 4px oklch(0% 0 0 / .25), 0 8px 22px oklch(0% 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: oklch(21% 0.02 55); --bg-weave: oklch(23% 0.022 55); --table: oklch(29% 0.025 55); --card: oklch(26% 0.022 55); --frame: url(../img/kenney/frame-dark.svg);
  --ink: oklch(94% 0.015 78); --muted: oklch(73% 0.03 70); --line: oklch(36% 0.025 55);
  --accent: oklch(72% 0.14 155); --accent-deep: oklch(58% 0.12 155); --accent-ink: oklch(20% 0.04 155);
  --good: oklch(74% 0.15 150); --bad: oklch(70% 0.16 38); --tip: oklch(72% 0.11 245);
  --wood: oklch(38% 0.07 52); --wood-hi: oklch(43% 0.075 55); --wood-dk: oklch(27% 0.05 50); --plank: oklch(47% 0.07 62); --plank-dk: oklch(36% 0.06 58);
  --shadow: 0 1px 0 oklch(100% 0 0 / .04) inset, 0 2px 4px oklch(0% 0 0 / .25), 0 8px 22px oklch(0% 0 0 / .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 16px/1.45 var(--body); min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-tap-highlight-color: transparent;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(0deg, color-mix(in oklch, var(--bg-weave) 45%, transparent) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, color-mix(in oklch, var(--bg-weave) 45%, transparent) 0 1px, transparent 1px 3px);
}
a { color: var(--accent-deep); }
h1, h2 { font-family: var(--display); font-weight: 400; letter-spacing: .2px; margin: 0; line-height: 1.12; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
p { margin: 0; }
kbd { font: 700 .7em var(--body); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: .6; margin-left: 4px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--card); padding: 8px 12px; border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.strong { font-weight: 800; }
.good { color: var(--good); }
.center { text-align: center; }
.big-emoji { font-size: 2.8rem; line-height: 1; }
.wobble { animation: wobble 1.6s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 50% { transform: rotate(-8deg) scale(1.05); } }

/* ---------- chrome ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); box-shadow: 0 1px 0 var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar-in { max-width: 720px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-family: var(--display); font-size: 1.2rem; }
.brand svg { width: 13px; height: 28px; }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav > a, .iconbtn { display: grid; place-items: center; min-width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; text-decoration: none; font-size: 1.15rem; cursor: pointer; color: var(--ink); }
.topnav > a:hover, .iconbtn:hover, .topnav > a[aria-current] { background: var(--table); }
.iconbtn:disabled { opacity: .3; cursor: default; }
.me-chip { display: flex !important; gap: 6px; padding: 0 10px 0 5px; font-size: .9rem !important; font-weight: 700; }
.me-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 800 .9rem var(--body); text-transform: uppercase; box-shadow: inset 0 -2px 0 oklch(0% 0 0 / .18); }
.c0 { --pc: var(--p0); } .c1 { --pc: var(--p1); } .c2 { --pc: var(--p2); } .c3 { --pc: var(--p3); }
.c4 { --pc: var(--p4); } .c5 { --pc: var(--p5); } .c6 { --pc: var(--p6); } .c7 { --pc: var(--p7); }
.avatar[class*=" c"] { background: var(--pc); color: oklch(99% 0.01 80); }

.view { max-width: 720px; margin: 0 auto; padding: 16px 16px 56px; outline: none; display: flex; flex-direction: column; gap: 18px; animation: viewin .35s var(--ease); }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } }
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; max-width: 60ch; }
.prose p + p { margin-top: 8px; }

/* ---------- surfaces & buttons ---------- */
.card { background: var(--card); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; color: var(--ink); text-decoration: none; }
.card.center { align-items: center; text-align: center; }
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.card-head.between { justify-content: space-between; align-items: center; }
.banner { display: block; border-radius: 16px; padding: 14px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; box-shadow: 0 4px 0 var(--accent-deep); }
.ico { font-size: 1.6rem; line-height: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 18px;
  font: 800 1rem var(--body); cursor: pointer; background: var(--table); color: var(--ink); text-decoration: none; min-height: 46px;
  box-shadow: 0 3px 0 var(--line); transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 var(--accent-deep); }
.btn.primary:active { box-shadow: 0 0 0 var(--accent-deep); transform: translateY(4px); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn.ghost:active { transform: translateY(1px); }
.btn.small { padding: 8px 14px; min-height: 38px; font-size: .92rem; }
.btn.big { padding: 15px 24px; font-size: 1.08rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
:is(.btn, .iconbtn, .topnav a, .variant, .mode, .ticket, .more a, .card, .react):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px; font-size: .9rem; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.center-actions { margin-bottom: 4px; animation: viewin .4s var(--ease); }
.pill { display: inline-block; background: var(--table); color: var(--muted); border-radius: 999px; padding: 4px 11px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.pill.tiny { font-size: .62rem; padding: 1px 6px; vertical-align: middle; }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; margin: 0 0 6px; }

.opts { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; font-size: .94rem; color: var(--muted); font-weight: 600; }
.opts label, .settings label { display: flex; align-items: center; gap: 8px; }
select, input[type="text"], input:not([type]) {
  font: 700 .96rem var(--body); padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); min-height: 42px;
}
input:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); }
.switch { cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.settings { display: flex; flex-direction: column; gap: 12px; color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.field input { width: 100%; font-size: 1.15rem; }
.seg, .tabs { display: inline-flex; background: var(--table); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button, .tabs button { border: 0; background: transparent; color: var(--muted); font: 700 .9rem var(--body); padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"], .tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px oklch(30% 0.05 50 / .15); }
.tabs { align-self: flex-start; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 20px 0 6px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.hero-shelf { display: flex; gap: 8px; justify-content: center; align-items: flex-end; padding: 0 18px; border-bottom: 10px solid var(--plank); border-radius: 2px; box-shadow: 0 6px 0 var(--plank-dk), 0 14px 18px oklch(30% 0.05 50 / .15); }
.hero-shelf span { width: 38px; animation: hop 3.4s var(--ease) infinite; animation-delay: calc(var(--i) * .22s); transform-origin: 50% 100%; }
.hero-shelf svg { width: 100%; display: block; }
@keyframes hop { 0%, 70%, 100% { transform: none; } 78% { transform: translateY(-12px) rotate(-4deg); } 86% { transform: translateY(0) rotate(2deg); } }
.title { font-size: clamp(2.4rem, 11vw, 3.4rem); margin-top: 8px; }
.lede { color: var(--muted); max-width: 34ch; font-size: 1.05rem; }
.play-btn { font: 400 1.6rem var(--display); padding: 16px 52px; border-radius: 22px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 0 var(--accent-deep), 0 14px 24px oklch(45% 0.12 155 / .3); margin-top: 6px; animation: breathe 2.6s ease-in-out infinite; }
.play-btn:active { transform: translateY(6px); box-shadow: 0 0 0 var(--accent-deep); animation: none; }
@keyframes breathe { 50% { transform: scale(1.04); } }

.ticket { display: grid; grid-template-columns: 1fr auto; border-radius: 20px; text-decoration: none; color: oklch(98% 0.01 80); background: var(--wood); box-shadow: 0 5px 0 var(--wood-dk), var(--shadow); overflow: hidden; transition: transform .15s var(--ease); }
.ticket:hover { transform: translateY(-2px); }
.ticket-main { padding: 18px; display: flex; flex-direction: column; gap: 4px; background: repeating-linear-gradient(180deg, transparent 0 30px, oklch(0% 0 0 / .07) 30px 32px); }
.ticket-k { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; opacity: .8; }
.ticket-main b { font: 400 1.7rem var(--display); }
.ticket-main span:last-child { opacity: .9; font-size: .95rem; }
.ticket-stub { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px 18px; border-left: 3px dashed oklch(100% 0 0 / .35); background: oklch(0% 0 0 / .12); min-width: 110px; }
.ticket-go { background: var(--gold); color: oklch(28% 0.06 60); font: 400 1.15rem var(--display); padding: 8px 18px; border-radius: 12px; box-shadow: 0 3px 0 oklch(55% 0.13 70); }
.ticket-stub small { opacity: .8; font-size: .75rem; }
.streak { font-weight: 800; font-size: .95rem; }

.friends h2 { margin-bottom: 10px; }
.friends-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; }
.mode { border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.mode b { font: 400 1.2rem var(--display); }
.mode > span:not(.mode-art) { color: var(--muted); font-size: .92rem; }
.mode-art { font-size: 2rem; line-height: 1; }
.mode-party { background: color-mix(in oklch, var(--gold) 28%, var(--card)); transition: transform .15s var(--ease); }
.mode-party:hover { transform: translateY(-2px); }
.mode-online { background: var(--card); }
.mode-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.join { display: flex; gap: 6px; flex: 1; min-width: 160px; }
.join input { flex: 1; min-width: 0; width: 6ch; text-transform: uppercase; letter-spacing: .25em; font: 800 1rem var(--body); text-align: center; }
.more { display: flex; flex-direction: column; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.more a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: var(--ink); text-decoration: none; }
.more a + a { border-top: 1px solid var(--line); }
.more a:hover { background: var(--table); }
.more-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--table); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.more a > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.more small { color: var(--muted); }
.more i { font-style: normal; font-size: 1.5rem; color: var(--muted); }

/* ---------- the board ---------- */
.solver { display: flex; flex-direction: column; gap: 14px; position: relative; }
.scoreboard { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: stretch; }
.sb-hits { position: relative; background: var(--card); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.sb-k { grid-column: 1 / -1; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: var(--muted); }
.sb-hitnum { font: 400 1.5rem var(--display); color: var(--good); font-variant-numeric: tabular-nums; }
.sb-mini { background: var(--card); border-radius: 16px; padding: 8px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 68px; }
.sb-mini b { font: 400 1.35rem var(--display); font-variant-numeric: tabular-nums; }
.sb-mini span { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; color: var(--muted); }
.pips { display: flex; gap: 5px; flex-wrap: wrap; }
.pips i { width: 16px; height: 16px; border-radius: 50%; background: var(--table); box-shadow: inset 0 2px 2px oklch(0% 0 0 / .12); }
.pips i.on { background: var(--good); box-shadow: inset 0 -2px 0 oklch(0% 0 0 / .2); animation: pip .45s var(--ease) backwards; animation-delay: calc(var(--i) * 60ms); }
@keyframes pip { from { transform: scale(0); } }
.float-delta { position: absolute; right: 12px; top: -6px; font: 400 1.4rem var(--display); animation: floatd 1.2s var(--ease) forwards; pointer-events: none; }
.float-delta.up { color: var(--good); }
.float-delta.down { color: var(--bad); }
@keyframes floatd { from { transform: translateY(10px) scale(.6); opacity: 0; } 25% { transform: translateY(-4px) scale(1.15); opacity: 1; } to { transform: translateY(-24px); opacity: 0; } }
.limit { height: 8px; border-radius: 8px; background: var(--table); overflow: hidden; margin-top: -4px; }
.limit i { display: block; height: 100%; background: var(--accent); transition: width .3s linear; border-radius: 8px; }
.limit i.warn { background: var(--bad); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }

/* Corky the commentator */
.caster { display: flex; align-items: flex-end; gap: 10px; min-height: 56px; }
.caster:empty { display: none; }
.caster-face { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--card); box-shadow: var(--shadow); }
.caster-text { position: relative; background: var(--card); border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-weight: 700; box-shadow: var(--shadow); max-width: 60ch; }
.caster[data-mood="cheer"] .caster-text { background: color-mix(in oklch, var(--good) 16%, var(--card)); }
.caster[data-mood="boo"] .caster-text { background: color-mix(in oklch, var(--bad) 14%, var(--card)); }
.caster[data-mood="tip"] .caster-text { background: color-mix(in oklch, var(--tip) 14%, var(--card)); }
.caster.pop .caster-text { animation: speak .45s var(--ease); transform-origin: 0 100%; }
.caster.pop .caster-face { animation: nod .5s var(--ease); }
@keyframes speak { from { transform: scale(.7); opacity: 0; } }
@keyframes nod { 30% { transform: rotate(-12deg) scale(1.1); } 60% { transform: rotate(6deg); } }

.table { position: relative; display: flex; flex-direction: column; gap: 6px; }
.crate {
  position: relative; border-radius: 16px; padding: 30px 12px 12px;
  background:
    radial-gradient(circle at 14px 14px, var(--wood-dk) 0 2.5px, transparent 3px),
    radial-gradient(circle at calc(100% - 14px) 14px, var(--wood-dk) 0 2.5px, transparent 3px),
    repeating-linear-gradient(180deg, var(--wood-hi) 0 2px, var(--wood) 2px 30px, var(--wood-dk) 30px 32px);
  box-shadow: inset 0 -8px 0 oklch(0% 0 0 / .2), inset 0 2px 0 oklch(100% 0 0 / .12), 0 6px 14px oklch(30% 0.05 50 / .2);
}
.plaque { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); background: oklch(82% 0.06 75); color: oklch(32% 0.06 55); font: 800 .66rem var(--body); text-transform: uppercase; letter-spacing: .14em; padding: 2px 10px; border-radius: 6px; box-shadow: inset 0 -2px 0 oklch(0% 0 0 / .15); white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.crate .posrow .pos { color: oklch(100% 0 0 / .7); }
.arrow-hint { text-align: center; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); opacity: .8; }
.solver.solved .arrow-hint { visibility: hidden; }
.shelf { background: var(--card); border-radius: 18px 18px 6px 6px; padding: 20px 10px 0; border-bottom: 14px solid var(--plank); box-shadow: 0 5px 0 var(--plank-dk), 0 12px 18px oklch(30% 0.05 50 / .14); transition: box-shadow .3s; }
.shelf.mini { padding: 10px 8px 2px; border-bottom-width: 8px; box-shadow: 0 3px 0 var(--plank-dk); }
.shelf.flash-up { animation: flashup .9s var(--ease); }
.shelf.flash-down { animation: flashdown .9s var(--ease); }
.shelf.flash-same { animation: flashsame .5s var(--ease); }
@keyframes flashup { 20% { box-shadow: 0 5px 0 var(--plank-dk), 0 0 0 6px color-mix(in oklch, var(--good) 45%, transparent); } }
@keyframes flashdown { 20% { box-shadow: 0 5px 0 var(--plank-dk), 0 0 0 6px color-mix(in oklch, var(--bad) 45%, transparent); } 30%, 50% { transform: translateX(-4px); } 40% { transform: translateX(4px); } }
@keyframes flashsame { 30% { transform: scale(.99); } }
.row { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; align-items: end; justify-items: center; }
.cell { width: 100%; max-width: 66px; display: flex; justify-content: center; position: relative; }
.cell[data-mark="ok"]::after, .cell[data-mark="no"]::after { position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font: 800 11px var(--body); color: oklch(99% 0 0); box-shadow: 0 1px 2px oklch(0% 0 0 / .3); }
.cell[data-mark="ok"]::after { content: "✓"; background: var(--good); }
.cell[data-mark="no"]::after { content: "✕"; background: oklch(45% 0.02 50); }
.cell.drop .bottle { transform: translateY(-8px) scale(.92); opacity: .55; }
.bottle { border: 0; background: transparent; padding: 0; width: 100%; cursor: grab; transition: transform .22s var(--ease), filter .22s; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.bottle:not(:disabled):not(.sel):hover { transform: translateY(-4px); }
.bottle:disabled { cursor: default; }
.bottle.static { cursor: default; }
.bottle svg { width: 100%; height: auto; display: block; pointer-events: none; }
.bottle:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
.bottle.sel { transform: translateY(-20px) rotate(-4deg); filter: drop-shadow(0 12px 8px oklch(30% 0.05 50 / .35)); }
.picking .bottle:not(.sel):not(:disabled) { animation: pickme 1.1s ease-in-out infinite; }
.picking .cell:nth-child(2n) .bottle:not(.sel) { animation-delay: -.5s; }
@keyframes pickme { 50% { transform: translateY(-5px); } }
.bottle.dragging { transition: none; z-index: 5; position: relative; cursor: grabbing; filter: drop-shadow(0 14px 10px oklch(30% 0.05 50 / .4)); animation: none !important; }
.lid { width: 100%; aspect-ratio: 40 / 96; border-radius: 12px; background: linear-gradient(180deg, oklch(0% 0 0 / .42), oklch(0% 0 0 / .26)); display: grid; place-items: center; color: oklch(100% 0 0 / .75); font-family: var(--display); font-size: 1.5rem; box-shadow: inset 0 3px 6px oklch(0% 0 0 / .35), 0 1px 0 oklch(100% 0 0 / .12); animation: rattle 6s ease-in-out infinite; animation-delay: calc(var(--i) * -1.3s); }
@keyframes rattle { 0%, 92%, 100% { transform: none; } 94% { transform: rotate(-3deg); } 96% { transform: rotate(3deg); } 98% { transform: rotate(-1deg); } }
.reveal .cell { animation: pop .5s var(--ease) backwards; animation-delay: calc(var(--i) * 90ms); }
@keyframes pop { from { transform: translateY(24px) scale(.6); opacity: 0; } }
.solver.solved .crate { box-shadow: inset 0 -8px 0 oklch(0% 0 0 / .2), 0 0 0 4px var(--gold), 0 0 30px color-mix(in oklch, var(--gold) 60%, transparent); }
.posrow { padding: 4px 0 6px; }
.pos { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 800; }
.cd { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in oklch, var(--bg) 72%, transparent); border-radius: 18px; z-index: 4; }
.cd-num { font-family: var(--display); font-size: 5rem; color: var(--accent); animation: cd 1s var(--ease) infinite; }
@keyframes cd { from { transform: scale(1.6); opacity: .1; } 35% { transform: scale(1); opacity: 1; } }
.hint { min-height: 1.4em; text-align: center; font-weight: 700; color: var(--muted); }
.hint.win { color: var(--good); font-family: var(--display); font-weight: 400; font-size: 1.3rem; }
.controls { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.controls:has(> :nth-child(3)) { grid-template-columns: 1fr auto auto; }
.check-btn { flex-direction: column; gap: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 5px 0 var(--accent-deep); padding: 10px 18px; min-height: 62px; }
.check-btn:active { box-shadow: 0 0 0 var(--accent-deep); transform: translateY(5px); }
.cb-main { font: 400 1.45rem var(--display); line-height: 1.1; }
.cb-sub { font-size: .72rem; font-weight: 700; opacity: .85; }
.check-btn.nudge { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { box-shadow: 0 5px 0 var(--accent-deep), 0 0 0 0 color-mix(in oklch, var(--accent) 50%, transparent); } 50% { box-shadow: 0 5px 0 var(--accent-deep), 0 0 0 10px transparent; } }
.undo-btn { flex-direction: column; gap: 0; font-size: 1.3rem; min-width: 74px; }
.undo-btn span { font-size: .72rem; }
.hist-wrap { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 4px 12px; }
.hist-wrap summary { cursor: pointer; font-weight: 800; padding: 8px 0; list-style-position: inside; }
.hist { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; padding-bottom: 10px; }
.h { display: flex; align-items: center; gap: 10px; border-radius: 12px; padding: 6px 8px; font-size: .88rem; background: var(--table); animation: viewin .3s var(--ease); flex-wrap: wrap; }
.h.win { background: color-mix(in oklch, var(--good) 18%, var(--card)); }
.h-no { color: var(--muted); min-width: 26px; font-variant-numeric: tabular-nums; font-weight: 700; }
.h-who { font-weight: 800; min-width: 54px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h .pips { margin-left: auto; gap: 3px; }
.h .pips i { width: 10px; height: 10px; animation: none; }
.delta { font-weight: 800; font-size: .8rem; min-width: 26px; text-align: right; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
.dots .d { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 -2px 0 oklch(0% 0 0 / .18); }

.result { align-items: center; text-align: center; animation: viewin .4s var(--ease); }
.result-score { display: flex; flex-direction: column; align-items: center; }
.result-score b { font-family: var(--display); font-weight: 400; font-size: 2.8rem; color: var(--good); line-height: 1.1; }
.start-card p { max-width: 42ch; }
.share-grid { font: 1.1rem/1.2 ui-monospace, monospace; margin: 0; letter-spacing: 1px; }
.copybox { width: 100%; min-height: 120px; font: .9rem ui-monospace, monospace; }

/* ---------- tutorial ---------- */
.learn-head { display: flex; justify-content: space-between; align-items: center; }
.coach { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); min-height: 84px; }
.coach .caster-face { background: var(--table); box-shadow: none; }
.coach p { font-size: 1.05rem; font-weight: 600; }
.coach .btn { margin-top: 10px; }
.coach.pop { animation: speak .45s var(--ease); }
.spot { position: relative; z-index: 3; box-shadow: 0 0 0 4px var(--gold), 0 0 0 10px color-mix(in oklch, var(--gold) 30%, transparent) !important; border-radius: 16px; animation: spot 1.5s ease-in-out infinite; }
@keyframes spot { 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 0 16px transparent; } }
.hand { position: absolute; bottom: -34px; left: 50%; font-size: 2rem; pointer-events: none; animation: tapme 1.2s var(--ease) infinite; z-index: 6; transform-origin: 50% 0; }
@keyframes tapme { 0%, 100% { transform: translate(-30%, 0); } 50% { transform: translate(-30%, -12px) scale(.9); } }
.check-btn .hand { bottom: -36px; }

/* ---------- leaderboards / stats ---------- */
.lb { width: 100%; border-collapse: collapse; font-size: .94rem; }
.lb th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--line); }
.lb td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.lb .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb .rank { width: 44px; font-weight: 800; }
.lb .name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb tr.you td { background: color-mix(in oklch, var(--accent) 14%, transparent); }
.lb tr.gap td { text-align: center; color: var(--muted); padding: 2px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats.s3 { grid-template-columns: repeat(3, 1fr); }
.stats.s5 { grid-template-columns: repeat(5, 1fr); }
.stat { background: var(--table); border-radius: 14px; padding: 10px 4px; text-align: center; min-width: 0; }
.stat b { display: block; font: 400 1.35rem var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat span { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.stat.hit b { color: var(--good); }
.calendar { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.cal { aspect-ratio: 1; border-radius: 5px; background: var(--table); }
.cal.on { background: var(--accent); }
.cal.today { box-shadow: 0 0 0 2px var(--ink); }
.modes-list { padding-left: 18px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.demo { display: flex; flex-direction: column; gap: 6px; max-width: 320px; align-self: center; width: 100%; }

/* ---------- party & lobby choices ---------- */
.variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.variant { text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: transform .15s var(--ease), border-color .15s; }
.variant:hover:not(:disabled) { transform: translateY(-2px); }
.variant b { font: 400 1.08rem var(--display); }
.variant span:last-child { color: var(--muted); font-size: .86rem; }
.variant[aria-checked="true"] { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 10%, var(--card)); box-shadow: 0 3px 0 var(--accent-deep); }
.variant[aria-checked="true"] b::after { content: " ✓"; color: var(--accent-deep); font-family: var(--body); font-weight: 800; }
.variant:disabled { cursor: default; }
.variant:disabled:not([aria-checked="true"]) { opacity: .55; }
.players-edit { display: flex; flex-direction: column; gap: 8px; }
.pe { display: flex; gap: 8px; align-items: center; }
.pe input { flex: 1; min-width: 0; }
.party-head, .room-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.party-head h1, .room-head h1 { font-size: 1.45rem; margin-top: 4px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 3px 12px 3px 3px; font-size: .9rem; }
.chip .avatar { width: 26px; height: 26px; font-size: .78rem; }
.turn-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: color-mix(in oklch, var(--pc, var(--accent)) 16%, var(--card)); box-shadow: var(--shadow); animation: viewin .35s var(--ease); }
.turn-banner b { display: block; font: 400 1.25rem var(--display); }
.turn-banner span:not(.avatar) { color: var(--muted); font-size: .9rem; }
.turn-banner .avatar { width: 44px; height: 44px; font-size: 1.15rem; }
.curtain { padding: 44px 18px; gap: 14px; }
.curtain h2 { font-size: 1.7rem; }
.final h1, .final h2 { font-size: 1.9rem; }
.podium { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 6px; counter-reset: p; }
.podium li { counter-increment: p; display: flex; align-items: center; gap: 10px; background: var(--table); border-radius: 14px; padding: 9px 12px; text-align: left; animation: viewin .4s var(--ease) backwards; }
.podium li:nth-child(2) { animation-delay: .08s; } .podium li:nth-child(3) { animation-delay: .16s; } .podium li:nth-child(n+4) { animation-delay: .24s; }
.podium li::before { content: counter(p); font-family: var(--display); color: var(--muted); width: 22px; }
.podium li b { flex: 1; }
.podium li span:last-child { color: var(--muted); font-size: .86rem; }
.podium li.first { background: color-mix(in oklch, var(--gold) 30%, var(--card)); transform: scale(1.03); }
.podium li.first::before { content: "👑"; }

/* ---------- online ---------- */
.code-chip { border: 0; cursor: pointer; background: var(--card); box-shadow: var(--shadow); border-radius: 12px; padding: 8px 12px; font: 700 .85rem var(--body); color: var(--muted); }
.code-chip b { color: var(--ink); letter-spacing: .15em; font-size: 1rem; }
.conn { background: var(--bad); color: oklch(99% 0 0); text-align: center; border-radius: 12px; padding: 6px; font-weight: 800; font-size: .9rem; }
.players-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pcard { position: relative; overflow: hidden; display: flex; align-items: center; gap: 8px; background: var(--card); box-shadow: var(--shadow); border-radius: 16px; padding: 8px 10px; }
.pcard.me { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow); }
.pcard.away { opacity: .5; }
.pcard.done { background: color-mix(in oklch, var(--good) 14%, var(--card)); }
.pinfo { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.pinfo b { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinfo span { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pscore { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.pscore .rk { font-family: var(--display); font-size: .95rem; }
.pscore small { color: var(--muted); font-size: .7rem; white-space: nowrap; }
.pbar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--good); transition: width .4s var(--ease); }
.invite { flex-direction: row; align-items: center; gap: 18px; flex-wrap: wrap; }
.invite > div:last-child { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
.invite .row-actions { justify-content: flex-start; }
.qr { width: 132px; height: 132px; background: oklch(99% 0.005 80); padding: 8px; border-radius: 14px; flex: none; }
.qr svg { width: 100%; height: 100%; display: block; }
.code-big { font-family: var(--display); font-size: 2.6rem; letter-spacing: .2em; line-height: 1; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plist li { display: flex; align-items: center; gap: 10px; animation: viewin .3s var(--ease); }
.plist li b { flex: 1; }
.lobby { display: flex; flex-direction: column; gap: 16px; }
.reactions { display: flex; justify-content: center; gap: 2px; flex-wrap: nowrap; position: sticky; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--card); box-shadow: var(--shadow), 0 6px 20px oklch(30% 0.05 50 / .18); border-radius: 999px; padding: 4px; align-self: center; z-index: 10; max-width: 100%; }
.react { border: 0; background: transparent; font-size: 1.3rem; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; transition: transform .15s var(--ease); flex: none; }
.react:hover { background: var(--table); transform: translateY(-3px); }
.react:active { transform: scale(1.4); }
.float-emoji { position: fixed; bottom: 90px; z-index: 60; font-size: 2.6rem; pointer-events: none; display: flex; flex-direction: column; align-items: center; animation: floatup 2.4s var(--ease) forwards; }
.float-emoji small { font: 800 .75rem var(--body); background: var(--card); color: var(--ink); border-radius: 999px; padding: 2px 8px; box-shadow: var(--shadow); }
@keyframes floatup { to { transform: translateY(-55vh) scale(1.2); opacity: 0; } }
.watch { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.wcard { gap: 8px; padding: 12px; }
.wcard.done { box-shadow: inset 0 0 0 2px var(--good), var(--shadow); }
.wtop { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.wstat { font-size: .8rem; color: var(--muted); }
.wrow .cell { max-width: 40px; }
.hide-card .crate { margin-top: 4px; padding-top: 14px; }

/* ---------- overlays ---------- */
#toasts { position: fixed; left: 50%; top: calc(66px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 700; font-size: .94rem; box-shadow: 0 8px 22px oklch(0% 0 0 / .25); animation: viewin .3s var(--ease); text-align: center; }
.toast.bad { background: var(--bad); color: oklch(99% 0 0); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: .3s; }
.modal { border: 0; border-radius: 22px; padding: 0; background: var(--card); color: var(--ink); width: min(92vw, 400px); box-shadow: 0 20px 60px oklch(0% 0 0 / .35); }
.modal::backdrop { background: oklch(20% 0.03 50 / .5); }
.modal form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }

@media (max-width: 520px) {
  .friends-grid { grid-template-columns: 1fr; }
  .me-name { display: none; }
  .me-chip { padding: 0 4px !important; }
  .lb th:nth-child(4), .lb td:nth-child(4) { display: none; }
  .row { gap: 4px; }
  .crate, .shelf { padding-inline: 6px; }
  .code-big { font-size: 2.1rem; }
  .qr { width: 110px; height: 110px; }
  .stats.s5 { grid-template-columns: repeat(3, 1fr); }
  .stat b { font-size: 1.15rem; }
  .sb-mini { min-width: 58px; padding: 8px 10px; }
  .pips i { width: 13px; height: 13px; }
  .react { width: 36px; height: 36px; font-size: 1.12rem; }
  .ticket-main b { font-size: 1.45rem; }
  .ticket-stub { min-width: 96px; padding: 12px; }
}
@media (hover: none) { kbd { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- Kenney skin ----------
   Frames, buttons, icons and sprites from Kenney's UI Pack, UI Pack (Adventure), Game Icons,
   Board Game Icons and Particle Pack (CC0, kenney.nl). Frames are border-image 9-slices with a
   transparent centre, so each surface keeps its own (tinted) background underneath. */
:is(.card, .more, .mode, .sb-hits, .sb-mini, .hist-wrap, .coach, .pcard, .turn-banner, .caster-text, .modal) {
  border: var(--fw, 9px) solid transparent; border-image: var(--frame) 8 / var(--fw, 9px) stretch;
  background-clip: padding-box; border-radius: 10px; box-shadow: 0 3px 0 oklch(30% 0.05 50 / .16);
}
.card { padding: 12px; }
.more { overflow: visible; }
.more a { border-radius: 3px; }
.mode { padding: 12px; }
.sb-hits { padding: 4px 8px; }
.sb-mini { padding: 2px 8px; }
.hist-wrap { padding: 0 6px; }
.coach { padding: 8px 10px; }
.pcard { padding: 2px 4px; overflow: visible; }
.pbar { bottom: -3px; border-radius: 3px; }
.pcard.me { box-shadow: 0 0 0 3px var(--accent), 0 3px 0 oklch(30% 0.05 50 / .16); }
.turn-banner { padding: 4px 8px; }
.caster-text { padding: 4px 8px; border-radius: 10px; }
.modal form { padding: 14px; }
.wcard.done { box-shadow: 0 0 0 3px var(--good), 0 3px 0 oklch(30% 0.05 50 / .16); }

/* buttons: Kenney UI Pack depth buttons */
.btn {
  border: solid transparent; border-width: 5px 5px 8px; border-image: url(../img/kenney/btn-grey.svg) 6 6 10 6 fill / 5px 5px 8px stretch;
  background: none; box-shadow: none; border-radius: 8px; padding: 7px 13px 4px; color: oklch(27% 0.035 50);
}
.btn:active { transform: translateY(3px); box-shadow: none; filter: brightness(.95); }
.btn.primary, .check-btn, .play-btn { border-image-source: url(../img/kenney/btn-green.svg); color: #fff; text-shadow: 0 1px 0 oklch(30% 0.08 155 / .55); }
.btn.primary:active, .check-btn:active, .play-btn:active { transform: translateY(3px); box-shadow: none; }
.btn.ghost { border: 0; border-image: none; box-shadow: inset 0 0 0 2px var(--line); color: var(--ink); padding: 12px 18px; }
.btn.small { padding: 4px 10px 2px; }
.btn.big { padding: 10px 20px 7px; }
.play-btn { padding: 10px 46px 7px; border-radius: 14px; box-shadow: 0 14px 24px oklch(45% 0.12 155 / .25); }
.check-btn { padding: 4px 16px 2px; }
@keyframes nudge { 50% { transform: scale(1.04); filter: brightness(1.08); } }
.ticket-go { background: none; box-shadow: none; border: solid transparent; border-width: 4px 4px 7px; border-image: url(../img/kenney/btn-yellow.svg) 6 6 10 6 fill / 4px 4px 7px stretch; padding: 4px 14px 1px; }

/* the crate: wooden planks inside a metal-cornered Kenney frame, with a hanging banner */
.crate {
  border: 16px solid transparent; border-image: url(../img/kenney/crate.svg) 16 / 16px stretch; border-radius: 10px; padding: 16px 0 0;
  background: repeating-linear-gradient(180deg, var(--wood-hi) 0 2px, var(--wood) 2px 30px, var(--wood-dk) 30px 32px) border-box;
}
.plaque {
  top: -14px; padding: 6px 24px 9px; border-radius: 0; box-shadow: none; color: #fff; text-shadow: 0 1px 0 #8e3f38;
  background: url(../img/kenney/banner.svg) center / 100% 100% no-repeat;
}
.hide-card .crate { padding-top: 12px; }

/* icons: Kenney glyphs used as masks so they take the text colour */
.ki { display: inline-block; flex: none; width: 1.15em; height: 1.15em; vertical-align: -.2em; background: currentColor; -webkit-mask: var(--ki) center / contain no-repeat; mask: var(--ki) center / contain no-repeat; }
.ki-trophy { --ki: url(../img/kenney/icon-trophy.png); }
.ki-sound { --ki: url(../img/kenney/icon-audioOn.png); }
.ki-mute { --ki: url(../img/kenney/icon-audioOff.png); }
.ki-stats { --ki: url(../img/kenney/icon-leaderboardsComplex.png); }
.ki-info { --ki: url(../img/kenney/icon-information.png); }
.ki-home { --ki: url(../img/kenney/icon-home.png); }
.ki-undo { --ki: url(../img/kenney/icon-undo.png); }
.ki-timer { --ki: url(../img/kenney/icon-hourglass.png); }
.ki-book { --ki: url(../img/kenney/icon-book.png); }
.more-ico, .caster-face, .coach .caster-face { background: url(../img/kenney/round.svg) center / 100% no-repeat; box-shadow: none; border-radius: 50%; color: #6d4b27; }
.undo-btn .ki { width: 1.1em; height: 1.1em; }

/* star rating on results */
.stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
.stars i { width: 42px; aspect-ratio: 64 / 60; background: url(../img/kenney/star-empty.svg) center / contain no-repeat; }
.stars i:nth-child(2) { width: 54px; margin-bottom: 8px; }
.stars i.on { background-image: url(../img/kenney/star.svg); animation: starpop .55s var(--ease) backwards; animation-delay: calc(var(--i) * .16s + .15s); }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } 60% { transform: scale(1.25) rotate(8deg); opacity: 1; } }

@media (max-width: 520px) {
  .crate { border-width: 12px; border-image-width: 12px; padding: 12px 0 0; }
  .crate .plaque { top: -11px; }
}

/* ---------- portal-friendly landscape (16:9 iframes down to 821x462) ----------
   Board screens become two columns: the table (crate + shelf) on the left, everything else
   stacked on the right. Bottles scale with the viewport height so the table always fits. */
.hint-btn { flex-direction: column; gap: 0; font-size: 1.2rem; min-width: 74px; }
.hint-btn span { font-size: .72rem; }
.controls:has(> :nth-child(4)) { grid-template-columns: 1fr auto auto auto; }
.peek { animation: pop .5s var(--ease); filter: drop-shadow(0 0 10px var(--gold)); }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, .share-grid, .copybox { -webkit-user-select: text; user-select: text; }

@media (min-width: 700px) and (min-aspect-ratio: 5/4) and (max-height: 820px) {
  .topbar-in { max-width: 1200px; padding: 3px 16px; }
  .topnav > a, .iconbtn { height: 36px; min-width: 36px; }
  .view { max-width: 1200px; padding: 8px 18px 8px; gap: 10px; }
  .page { gap: 10px; }
  h1 { font-size: 1.45rem; }

  .page:has(.solver) {
    display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(290px, 1fr); grid-template-rows: repeat(14, auto);
    column-gap: 20px; row-gap: 0; align-items: start;
  }
  .page:has(.solver) :is(#board, #main, .solver) { display: contents; }
  .page:has(.solver) > *, .page:has(.solver) .solver > *, .page:has(.solver) #main > * { grid-column: 2; margin-bottom: 7px; min-width: 0; }
  .page:has(.solver) .solver > .table { grid-column: 1; grid-row: 1 / -1; margin: 0; position: sticky; top: 52px; }
  .page:has(.solver) .page-head, .page:has(.solver) .arrow-hint, .page:has(.solver) .party-head .pill, .page:has(.solver) .room-head .pill { display: none; }
  .page:has(.solver) > .opts { flex-wrap: nowrap; gap: 8px; font-size: .84rem; white-space: nowrap; }
  .page:has(.solver) > .opts select { min-height: 34px; padding: 4px 6px; }
  .page:has(.solver) > .opts .btn.small { min-height: 34px; padding: 6px 10px; }
  .page:has(.solver) > .opts .switch span { overflow: hidden; text-overflow: ellipsis; max-width: 11ch; }
  .page.room:has(.solver) > .reactions { position: fixed; left: 18px; bottom: 8px; margin: 0; z-index: 10; }
  .page.room:has(.solver) > p.center { display: none; }
  .page:has(.solver) .party-head .btn.small { min-height: 32px; padding: 4px 10px; }
  .page:has(.solver) .chips { display: none; }
  .page:has(.solver) .hist-wrap summary { padding: 6px 0; }
  .page:has(.solver) .page-head h1 { font-size: 1.3rem; }
  .table .cell { max-width: clamp(28px, calc((100dvh - 190px) * .2083), 66px); }
  .table .row { justify-content: center; grid-template-columns: repeat(var(--n), minmax(0, clamp(28px, calc((100dvh - 190px) * .2083), 66px))); }
  .table .crate { padding-top: 26px; }
  .table .shelf { padding-top: 14px; }
  .scoreboard .sb-k { display: none; }
  .sb-hits { padding: 6px 10px; }
  .sb-hitnum { font-size: 1.25rem; }
  .sb-mini { padding: 6px 10px; min-width: 60px; }
  .sb-mini b { font-size: 1.15rem; }
  .caster { min-height: 0; }
  .caster-face { width: 38px; height: 38px; font-size: 1.3rem; }
  .caster-text { padding: 6px 10px; font-size: .88rem; }
  .hint { font-size: .9rem; text-align: left; }
  .check-btn { min-height: 48px; padding: 4px 14px; }
  .undo-btn, .hint-btn { min-height: 48px; padding: 4px 10px; }
  .cb-main { font-size: 1.25rem; }
  .hist { max-height: 26dvh; }
  .turn-banner { padding: 8px 12px; }
  .turn-banner .avatar { width: 34px; height: 34px; }
  .turn-banner b { font-size: 1.05rem; }
  .party-head h1, .room-head h1 { font-size: 1.15rem; }
  .chips .chip { font-size: .8rem; }
  .players-strip { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .pcard { padding: 6px 8px; }
  .coach { min-height: 0; padding: 10px 12px; }
  .coach p { font-size: .95rem; }
  .reactions { position: static; }

  /* home: hero on the left, choices on the right */
  .view-home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); column-gap: 28px; align-items: start; }
  .view-home > * { grid-column: 2; }
  .view-home > .hero { grid-column: 1; grid-row: 1 / span 6; position: sticky; top: 60px; padding-top: 8px; }
  .view-home .friends-grid { grid-template-columns: 1fr; }
  .title { font-size: 2.6rem; }
}
@media (min-width: 700px) and (min-aspect-ratio: 5/4) and (max-height: 820px) {
  /* online rooms float the emoji bar under the table, so leave it room */
  .page.room .table .cell { max-width: clamp(26px, calc((100dvh - 250px) * .2083), 66px); }
  .page.room .table .row { grid-template-columns: repeat(var(--n), minmax(0, clamp(26px, calc((100dvh - 250px) * .2083), 66px))); }
}
@media (min-width: 700px) and (min-aspect-ratio: 5/4) and (max-height: 820px) {
  /* thinner Kenney frames so the board still fits short portal iframes */
  :root { --fw: 6px; }
  .sb-hits { padding: 2px 6px; }
  .sb-mini { padding: 0 6px; }
  .coach { padding: 4px 8px; }
  .turn-banner { padding: 2px 6px; }
  .pcard { padding: 1px 3px; }
  .check-btn { padding: 2px 12px 0; }
  .undo-btn, .hint-btn { padding: 2px 8px 0; }
  .table .crate { border-width: 12px; border-image-width: 12px; padding-top: 12px; }
  .table .crate .plaque { top: -11px; }
  .page:has(.solver) > .opts .btn.small { padding: 2px 6px 0; }
  .sb-hits { column-gap: 6px; }
  .sb-hits .pips { gap: 3px; }
  .sb-hits .pips i { width: 12px; height: 12px; }
}
