/* Inga Dinga: a cosy wizard's-tower look. Night sky outside, parchment and candlelight inside,
   played back off a worn 80s VHS tape: faded colour, scanlines, tape noise and stained old-module parchment. */
:root {
  --night: #171230;
  --plum: #8b3fe0;
  --plum-2: #5a1fa8;
  --paper: #f3e5c6;
  --paper-2: #e2cb9c;
  --edge: #b8955a;
  --ink: #2a1f2e;
  --ink-soft: #6e5a63;
  --gold: #e9c46a;
  --gold-hi: #ffe08a;
  --crimson: #a8283a;
  --serif: 'Alegreya', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --display: 'Cinzel', 'Trajan Pro', 'Palatino Linotype', Palatino, Georgia, serif;
  /* age stains and paper fibre, drawn as SVG noise so there are no image files */
  --stain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='380' height='380'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='.011' numOctaves='4' seed='5' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42 0 0 0 0 .25 0 0 0 0 .08 1.15 0 0 0 -.52'/></filter><rect width='100%' height='100%' filter='url(%23s)'/></svg>");
  --fibre: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.85 .55' numOctaves='2' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32 0 0 0 0 .2 0 0 0 0 .08 .55 0 0 0 -.2'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  --parchment:
    var(--stain), var(--fibre),
    radial-gradient(ellipse at 12% 0%, rgba(255, 255, 255, .4), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(150, 100, 40, .16), transparent 60%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  --frame: inset 0 0 0 3px rgba(243, 229, 198, .75), inset 0 0 0 4px rgba(150, 110, 55, .45), inset 0 0 26px rgba(110, 62, 18, .22), inset 0 0 4px 1px rgba(95, 52, 14, .26);
  --chroma: -1px 0 rgba(255, 60, 200, .3), 1px 0 rgba(40, 220, 255, .3);
}
* { box-sizing: border-box; }
html { background: var(--night); }
html, body { margin: 0; }
body { min-height: 100vh; font: 16px/1.4 var(--serif); color: var(--ink); -webkit-font-smoothing: antialiased; }
/* tape noise over everything, jittering like a paused VHS */
body::after {
  content: ''; position: fixed; inset: -90px; pointer-events: none; z-index: 100; opacity: .065; mix-blend-mode: overlay;
  animation: tapenoise .9s steps(6) infinite;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- the sky ---------- */
#sky {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 45% at 9% 10%, rgba(255, 226, 170, .16), transparent 70%),
    radial-gradient(ellipse 70% 40% at 50% 100%, rgba(255, 190, 90, .55), transparent 70%),
    linear-gradient(180deg, #0c0630 0%, #22105a 28%, #4d1778 48%, #8e1f86 63%, #d4387c 76%, #ff7a4e 88%, #ffb35c 100%);
}
/* a slow rainbow swirl through the sky, like an 80s fantasy poster */
#sky .swirl { position: absolute; left: 50%; top: 28%; width: 170vmax; height: 170vmax; margin: -85vmax 0 0 -85vmax; opacity: .4; mix-blend-mode: screen;
  background: conic-gradient(from 0deg, #ff2fa8, #8a3cff, #2fc8ff, #45ffb4, #ffe14d, #ff7a2f, #ff2fa8);
  -webkit-mask-image: radial-gradient(closest-side, #000 10%, rgba(0, 0, 0, .55) 45%, transparent 75%); mask-image: radial-gradient(closest-side, #000 10%, rgba(0, 0, 0, .55) 45%, transparent 75%);
  animation: swirl 150s linear infinite; }
@keyframes swirl { to { transform: rotate(360deg); } }
#sky .stars { position: absolute; inset: 0; }
#sky .tw { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff8e6; box-shadow: 0 0 6px 1px rgba(255, 248, 230, .7);
  animation: twinkle var(--d) ease-in-out var(--w) infinite alternate; }
#sky .moon {
  position: absolute; left: 4vw; top: 5vh; width: 88px; height: 88px; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 62%, rgba(190, 160, 110, .32) 0 8px, transparent 9px),
    radial-gradient(circle at 63% 70%, rgba(190, 160, 110, .25) 0 5px, transparent 6px),
    radial-gradient(circle at 60% 34%, rgba(190, 160, 110, .2) 0 6px, transparent 7px),
    radial-gradient(circle at 40% 35%, #fffaf0, #f0dfb4 72%);
  box-shadow: 0 0 40px 8px rgba(255, 236, 190, .3), 0 0 90px 28px rgba(255, 70, 200, .2), 0 0 170px 70px rgba(60, 200, 255, .13);
}
#sky .mist { position: absolute; left: -30%; width: 160%; height: 34vh; background: radial-gradient(ellipse at center, rgba(255, 110, 220, .14), transparent 65%);
  animation: mist 48s ease-in-out infinite alternate; }
#sky .mist.m1 { bottom: 4vh; }
#sky .mist.m2 { bottom: 26vh; opacity: .7; filter: hue-rotate(-120deg); animation-duration: 64s; animation-direction: alternate-reverse; }
#sky .candle {
  position: absolute; width: 7px; height: 28px; border-radius: 2px 2px 3px 3px; transform-origin: 50% 100%;
  background: linear-gradient(90deg, #e2d3b2, #fffaf0 42%, #d6c5a0);
  animation: bob var(--d) ease-in-out var(--w) infinite alternate; scale: var(--s); opacity: .9;
}
#sky .candle::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px; background: linear-gradient(rgba(255, 210, 120, .45), transparent); border-radius: 2px; }
#sky .candle::before {
  content: ''; position: absolute; left: 50%; top: -12px; width: 7px; height: 11px; margin-left: -3.5px;
  border-radius: 50% 50% 45% 45% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 72%, #fffbe0 0 22%, #ffd36e 45%, rgba(255, 150, 40, 0) 76%);
  box-shadow: 0 0 10px 3px rgba(255, 205, 110, .55), 0 0 34px 12px rgba(255, 190, 90, .16);
  animation: flicker 1.4s ease-in-out var(--w) infinite alternate; transform-origin: 50% 100%;
}
#sky .ff { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #fff2a8; box-shadow: 0 0 8px 3px rgba(255, 232, 140, .55);
  animation: drift var(--d) ease-in-out var(--w) infinite alternate, blink 3.2s ease-in-out var(--w) infinite alternate; }
#sky .castle { position: absolute; left: 0; bottom: 0; width: 100%; height: 34vh; }
#sky .castle .win { filter: drop-shadow(0 0 3px #ffcf6a); animation: windowglow 7s ease-in-out var(--w) infinite alternate; }
@keyframes twinkle { from { opacity: .15; transform: scale(.7); } to { opacity: 1; transform: scale(1.2); } }
@keyframes bob { from { transform: translateY(-7px) rotate(-1.5deg); } to { transform: translateY(7px) rotate(1.5deg); } }
@keyframes flicker { 0% { transform: scale(1, 1) skewX(0); } 40% { transform: scale(.9, 1.1) skewX(3deg); } 100% { transform: scale(1.06, .94) skewX(-3deg); } }
@keyframes drift { from { transform: translate(0, 0); } to { transform: translate(var(--dx), var(--dy)); } }
@keyframes blink { from { opacity: .08; } to { opacity: .95; } }
@keyframes mist { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
@keyframes windowglow { 0%, 60% { opacity: 1; } 100% { opacity: .45; } }

/* ---------- basics ---------- */
.ico { width: 1.1em; height: 1.1em; fill: currentColor; vertical-align: -.18em; flex: none; display: inline-block; }
button {
  font: 600 15px/1.2 var(--display); letter-spacing: .3px; cursor: pointer; border-radius: 8px; padding: 9px 14px;
  color: #fbf1da; border: 1px solid #f2c45a; background: linear-gradient(180deg, #a547e8 0%, #6a24c2 55%, #4d1a9a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -2px 0 rgba(0, 0, 0, .18), 0 2px 6px rgba(20, 10, 40, .35);
  text-shadow: var(--chroma), 0 1px 1px rgba(0, 0, 0, .35); transition: filter .15s, transform .15s, box-shadow .15s;
}
button:hover:not(:disabled) { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translateY(1px); }
button.ghost { background: linear-gradient(180deg, #f6ebd3, #e2cfa6); color: var(--ink); border-color: var(--edge); text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 4px rgba(60, 35, 10, .18); }
button.on { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 16px rgba(255, 224, 138, .7); }
button:disabled { opacity: .45; cursor: default; filter: saturate(.6); }
button.small { padding: 5px 9px; font-size: 12px; }
button.big { padding: 12px 16px; font-size: 17px; }
button.icon { background: transparent; border: 0; box-shadow: none; padding: 2px 4px; font-size: 18px; color: #e9dcc0; }
button.icon:hover { color: var(--gold-hi); }
input, select {
  font: 16px var(--serif); padding: 9px 11px; border-radius: 8px; border: 1px solid #c4a774; background: #fdf8ec; color: var(--ink);
  box-shadow: inset 0 1px 3px rgba(120, 80, 30, .15);
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233, 196, 106, .4); }
input[type=checkbox] { accent-color: var(--plum-2); width: 16px; height: 16px; }
a { color: var(--plum-2); }
.muted { color: var(--ink-soft); font-size: 14px; }
.small { font-size: 12.5px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.card, .pop, .bottombar, .player { text-shadow: 0 0 .7px rgba(60, 35, 20, .45); }
.card { background: var(--parchment); border: 1px solid var(--edge); border-radius: 10px; padding: 15px 16px; box-shadow: var(--frame), 0 10px 28px rgba(6, 3, 18, .55); }
h3 { margin: 0 0 8px; font: 700 12px var(--display); text-transform: uppercase; letter-spacing: 2px; color: #7a5a3a; }
h3::before { content: '✦'; color: #c49a4a; margin-right: 7px; }
.badge { font: 700 10px var(--display); letter-spacing: .6px; text-transform: uppercase; background: var(--plum-2); color: #f6ecd6; padding: 2px 6px; border-radius: 5px; vertical-align: middle; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font: 700 14px var(--display);
  border: 2px solid #f6ecd6; box-shadow: 0 0 0 1px rgba(42, 31, 46, .6), 0 2px 4px rgba(0, 0, 0, .3); flex: none; vertical-align: middle;
  background-image: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .38), transparent 62%); text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.avatar.empty { background-color: #e2d2ae; color: var(--ink-soft); text-shadow: none; border-style: dashed; border-color: #b8955a; }
.pn.lt { background: #3a2d4a; padding: 0 5px; border-radius: 4px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; vertical-align: 0; margin-right: 6px; box-shadow: 0 0 0 2px rgba(255, 246, 224, .35), 0 0 8px currentColor; }
.chip {
  --c: #888; display: inline-grid; place-items: center; width: 20px; height: 26px; border-radius: 5px; margin: 0 1px; vertical-align: middle; color: #fffaf0;
  background: radial-gradient(circle at 50% 28%, rgba(255, 255, 255, .32), transparent 70%), var(--c);
  border: 1px solid rgba(40, 25, 30, .4); box-shadow: inset 0 0 0 1px rgba(255, 240, 200, .35);
}
.chip .ico { width: 14px; height: 14px; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .3)); }
.ldie { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: linear-gradient(#fffaf0, #ecdcb9); border: 1px solid #a8875a;
  font: 700 12px var(--display); color: #3a2440; margin: 0 1px; vertical-align: middle; }

/* ---------- join + lobby ---------- */
.lobby { max-width: 460px; margin: 9vh auto 40px; padding: 0 16px; }
.lobby.wide { max-width: 880px; }
.lobby h1 {
  display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 -40px 6px; white-space: nowrap; font: 700 54px/1.05 'Cinzel Decorative', var(--display);
  background: linear-gradient(180deg, #fff6d0, #ecc96f 55%, #b8862e); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(-1.5px 0 0 rgba(255, 60, 200, .45)) drop-shadow(1.5px 0 0 rgba(40, 220, 255, .4)) drop-shadow(0 0 18px rgba(233, 196, 106, .35)) drop-shadow(0 2px 2px rgba(0, 0, 0, .5));
  animation: tapeglitch 13s steps(1) infinite;
}
.logo { width: 54px; height: 54px; flex: none; }
.lobby .tag { color: #d3c6ee; font-style: italic; font-size: 19px; text-align: center; margin: 0 0 26px; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.lobbygrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 760px) { .lobbygrid { grid-template-columns: 1fr; } .lobby h1 { font-size: min(40px, 10.5vw); margin-inline: 0; } .logo { width: 42px; height: 42px; } }
.code { font: 800 38px var(--display); letter-spacing: 9px; color: var(--plum-2); text-shadow: -1px 0 rgba(200, 40, 70, .28), 1px 0 rgba(30, 150, 210, .28), 0 1px 0 rgba(255, 255, 255, .5); }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed rgba(184, 149, 90, .35); }
.plist li:last-child { border-bottom: 0; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.settings label.check { justify-content: flex-start; flex-wrap: wrap; }
.settings select { min-width: 116px; }

/* ---------- game layout ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 12px; height: 100vh; }
.boardarea { grid-column: 1; grid-row: 1; position: relative; display: flex; flex-direction: column; min-height: 0; }
.bottombar {
  grid-column: 1; grid-row: 2; background: var(--parchment); border: 1px solid var(--edge); border-radius: 12px; padding: 10px 12px; display: flex; gap: 12px;
  align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: var(--frame), 0 10px 28px rgba(6, 3, 18, .55);
}
.rightcol { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.logcard { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.log { flex: 1; overflow-y: auto; font-size: 14.5px; line-height: 1.75; scrollbar-color: #c9ae7c transparent; }
.log > div { border-bottom: 1px dashed rgba(184, 149, 90, .22); }
.chatcard { padding: 10px 12px; }
.chat { height: 110px; overflow-y: auto; font-size: 14.5px; margin-bottom: 6px; scrollbar-color: #c9ae7c transparent; }
#chatinput { width: 100%; padding: 7px 9px; font-size: 15px; }
.status {
  align-self: center; display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; text-align: center; max-width: 100%;
  color: #f6ecd6; font: 600 17px var(--display); letter-spacing: .3px; padding: 6px 10px 6px 20px; margin-top: 2px; text-shadow: var(--chroma);
  background: rgba(22, 8, 44, .62); border: 1px solid rgba(255, 120, 220, .5); border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35), inset 0 0 18px rgba(233, 196, 106, .08); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.status .ico { color: var(--gold-hi); }
.boardbox { flex: 1; min-height: 0; display: flex; }
svg.board { width: 100%; height: 100%; overflow: visible; }
svg.board text { font-family: var(--display); }
.tmr { font: 600 13px var(--display); font-variant-numeric: tabular-nums; background: rgba(20, 14, 40, .55); color: #f6ecd6; border-radius: 6px; padding: 1px 7px;
  border: 1px solid rgba(233, 196, 106, .35); }
.tmr:empty { display: none; }
.tmr.low { background: var(--crimson); border-color: #ff9a9a; }

@media (max-width: 1000px) {
  .game { grid-template-columns: 1fr; grid-template-rows: auto; height: auto; }
  .boardarea, .bottombar, .rightcol { grid-column: 1; grid-row: auto; }
  .boardbox { height: 62vh; flex: none; }
  .logcard { max-height: 260px; }
}
@media (max-width: 600px) {
  .game { padding: 10px; gap: 10px; }
  .status { font-size: 14px; border-radius: 16px; padding: 5px 8px 5px 14px; gap: 6px; }
  #sky .moon { width: 60px; height: 60px; }
}

/* ---------- players ---------- */
.player {
  display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--parchment); border: 1px solid var(--edge);
  box-shadow: inset 0 0 0 2px rgba(246, 236, 214, .85), 0 4px 14px rgba(6, 3, 18, .45);
}
.player.turn { border-color: #d9b45a; box-shadow: inset 0 0 0 2px rgba(246, 236, 214, .85), 0 0 0 2px var(--gold-hi), 0 0 22px rgba(255, 214, 120, .55); }
.player.off { opacity: .6; }
.player .name { font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.player .name .ico { color: var(--crimson); }
.player .stats { font-size: 13.5px; color: var(--ink-soft); display: flex; gap: 10px; margin-top: 2px; }
.player .stats span { display: inline-flex; align-items: center; gap: 3px; }
.player .stats .ico { color: #7d5fa8; width: 14px; height: 14px; }
.player .stats .award { color: var(--ink); background: linear-gradient(#f2d27c, #d4a645); border-radius: 6px; padding: 0 5px; box-shadow: 0 0 8px rgba(233, 196, 106, .6); }
.player .stats .award .ico { color: var(--ink); }
.player .vp { font: 800 24px var(--display); color: var(--plum-2); min-width: 38px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 2px; }
.player .vp .ico { width: 13px; height: 13px; color: #d4a645; filter: drop-shadow(0 0 3px rgba(233, 196, 106, .7)); }
/* 5-6 players: tighter player cards so everyone fits */
.compact > * + * { margin-top: 6px; }
.compact .player { padding: 4px 9px; gap: 8px; }
.compact .player .avatar { width: 26px; height: 26px; font-size: 12px; }
.compact .player .vp { font-size: 20px; }
.bankrow { display: flex; gap: 10px; flex-wrap: wrap; font-size: 14.5px; align-items: center; }
.bankrow > span { display: inline-flex; align-items: center; gap: 3px; }
.bankrow .ico { color: #7d5fa8; }

/* ---------- hand + actions ---------- */
.hand { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.sep { width: 1px; align-self: stretch; background: linear-gradient(transparent, #c9ae7c, transparent); margin: 0 4px; }
.rcard {
  --c: #888; width: 50px; height: 70px; border-radius: 8px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: radial-gradient(ellipse at 50% 28%, rgba(255, 255, 255, .34), transparent 62%), linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, .2)), var(--c);
  color: #fffaf0; border: 1px solid rgba(40, 25, 30, .5); box-shadow: inset 0 0 0 2px rgba(255, 240, 200, .45), 0 3px 8px rgba(30, 15, 40, .3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45); cursor: default; font-family: var(--display);
}
.rcard .i { line-height: 0; }
.rcard .i .ico { width: 27px; height: 27px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.rcard .n { font-size: 18px; font-weight: 700; }
.rcard.empty { opacity: .4; filter: saturate(.5); }
.rcard.pickable { cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 240, 200, .6), 0 0 0 2px var(--gold-hi), 0 0 14px rgba(255, 224, 138, .6); }
.rcard.pickable:hover { transform: translateY(-4px); }
.rcard.mini { width: 34px; height: 46px; font-size: 14px; flex-direction: row; gap: 0; }
.rcard.mini .ico { width: 18px; height: 18px; }
.dcard {
  width: 60px; height: 70px; border-radius: 8px; padding: 4px 3px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(ellipse at 50% 25%, rgba(255, 120, 230, .4), transparent 60%), radial-gradient(ellipse at 50% 110%, rgba(60, 210, 255, .35), transparent 60%), linear-gradient(170deg, #4a1f86, #1f0f45);
  color: #f3dfa6; border: 1px solid #c9a55a; box-shadow: inset 0 0 0 2px #221a40, inset 0 0 0 3px rgba(233, 196, 106, .45), 0 3px 8px rgba(20, 10, 40, .35);
  font: 600 10px/1.1 var(--display); text-shadow: none;
}
.dcard .i { line-height: 0; }
.dcard .i .ico { width: 24px; height: 24px; filter: drop-shadow(0 0 4px rgba(233, 196, 106, .55)); }
.dcard .lbl { color: #efe2c4; }
.dcard .cnt { position: absolute; top: -7px; right: -7px; background: var(--gold); color: var(--ink); border-radius: 10px; padding: 1px 6px; font: 700 11px var(--display); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.dcard:disabled { opacity: .62; filter: none; }
.actions { display: flex; gap: 5px; align-items: stretch; flex-wrap: wrap; }
.act {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 62px; padding: 5px 7px 4px; gap: 3px;
  background: linear-gradient(180deg, #f8eed8, #e4d1aa); color: var(--ink); border: 1px solid var(--edge); text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 2px 4px rgba(60, 35, 10, .18);
}
.act .i { line-height: 0; }
.act .i .ico { width: 22px; height: 22px; color: var(--plum-2); }
.act .lbl { font: 600 10.5px var(--display); letter-spacing: 0; white-space: nowrap; }
.act .cost { line-height: 0; }
.act .cost .chip { width: 12px; height: 16px; margin: 0 .5px; border-radius: 3px; }
.act .cost .chip .ico { width: 9px; height: 9px; }
.act.on { background: linear-gradient(180deg, #fff3c4, #f0cf73); box-shadow: 0 0 0 2px var(--gold-hi), 0 0 16px rgba(255, 224, 138, .7); }
.bigact { min-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 16px; padding: 8px 14px; }
.bigact.idle { background: linear-gradient(180deg, #f3e6c9, #e2cfa6); border: 1px solid var(--edge); border-radius: 8px; color: var(--ink-soft); font: 600 13px var(--display); }
.bigact .dice { display: flex; gap: 5px; line-height: 0; }
.die { width: 28px; height: 28px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.die.dim { opacity: .55; }
.shake { animation: shake .5s; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-18deg) scale(1.1); } 50% { transform: rotate(14deg); } 75% { transform: rotate(-8deg); } }

/* ---------- popups over the board ---------- */
.overlay { position: absolute; left: 0; right: 0; bottom: 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.pop {
  pointer-events: auto; background: var(--parchment); border: 1px solid var(--edge); border-radius: 12px; padding: 14px 16px;
  box-shadow: var(--frame), 0 14px 36px rgba(6, 3, 18, .6); max-width: min(560px, 96%); display: flex; flex-direction: column; gap: 8px;
}
.pop.offer { border-color: #d9b45a; box-shadow: var(--frame), 0 0 0 2px var(--gold-hi), 0 0 26px rgba(255, 224, 138, .45), 0 14px 36px rgba(6, 3, 18, .6); }
.pop h2 { margin: 0; text-align: center; font: 700 26px var(--display); color: var(--plum-2); display: flex; align-items: center; justify-content: center; gap: 8px; }
.pop h2 .ico { color: #d4a645; filter: drop-shadow(0 0 6px rgba(233, 196, 106, .7)); }
.pickrow { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; min-height: 30px; }
.tside { background: rgba(255, 250, 235, .55); border: 1px dashed rgba(184, 149, 90, .6); border-radius: 8px; padding: 8px; }
.hint { font-size: 12.5px; }
.responses { display: flex; flex-direction: column; gap: 4px; }
.resp { display: flex; align-items: center; gap: 8px; }
.resp button { margin-left: auto; padding: 4px 10px; }
.resp .no { margin-left: auto; color: var(--crimson); font-weight: 700; }
.resp .muted { margin-left: auto; }
.counter { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: #fff5d6; border: 1px solid #e3c27a; border-radius: 8px; padding: 6px; }
.victim { display: flex; flex-direction: column; align-items: center; gap: 4px; background: linear-gradient(180deg, #f8eed8, #e4d1aa); color: var(--ink); border: 2px solid var(--c); text-shadow: none; }
.victim .muted { display: inline-flex; align-items: center; gap: 3px; }
.pop.over { min-width: 340px; }
.score { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.score td, .score th { padding: 5px 6px; text-align: center; border-bottom: 1px dashed rgba(184, 149, 90, .5); }
.score th { color: #7d5fa8; }
.score td:first-child { text-align: left; white-space: nowrap; }
.score .ico { color: #d4a645; }
.hist { display: flex; gap: 4px; align-items: flex-end; height: 110px; padding-top: 14px; }
.hist .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.hist .fill { width: 100%; background: linear-gradient(180deg, #8f6bd0, #4a3175); border-radius: 4px 4px 0 0; min-height: 2px; }
.hist .fill.seven { background: linear-gradient(180deg, #c24557, #6b1624); }
.hist .cnt { position: absolute; top: -2px; font-size: 11px; }
.hist .lbl { font: 700 12px var(--display); }

#toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -8px); z-index: 20; pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s;
  display: flex; align-items: center; gap: 6px; max-width: calc(100vw - 32px);
  background: linear-gradient(180deg, #3a2a63, #251b45); color: #f6ecd6; padding: 10px 18px; border-radius: 10px; border: 1px solid rgba(233, 196, 106, .6);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 0 18px rgba(233, 196, 106, .2); font: 600 15px var(--display);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast .pn.lt { background: rgba(255, 255, 255, .12); }
.hit { cursor: pointer; }
.pulse { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .45; } to { opacity: 1; } }
.float { animation: float 1.6s ease-in-out infinite alternate; }
@keyframes float { from { transform: translateY(-2px); } to { transform: translateY(2.5px); } }

/* ---------- the VHS tape look ---------- */
/* Separate top-level layers so each blend mode reaches the page underneath. */
.vhs { position: fixed; inset: 0; pointer-events: none; }
.vhs.lift { z-index: 96; background: #0c0811; mix-blend-mode: screen; }          /* slightly washed-out tape blacks */
.vhs.warm { z-index: 97; mix-blend-mode: soft-light;                                /* psychedelic colour cast that slowly drifts */
  background: linear-gradient(125deg, rgba(255, 40, 180, .4), rgba(150, 60, 255, .14) 38%, rgba(40, 210, 255, .16) 64%, rgba(255, 150, 40, .34));
  animation: huedrift 40s ease-in-out infinite alternate; }
@keyframes huedrift { from { filter: hue-rotate(-30deg); } to { filter: hue-rotate(40deg); } }
.vhs.lines { z-index: 98;                                                            /* scanlines */
  background: radial-gradient(ellipse 90% 80% at 50% 45%, transparent 60%, rgba(20, 0, 40, .3)), repeating-linear-gradient(to bottom, rgba(10, 6, 20, .2) 0 1px, transparent 1px 3px); opacity: .3; }
.vhs.track {                                                                          /* a soft tracking band that rolls past now and then */
  z-index: 99; inset: 0 0 auto; height: 70px; mix-blend-mode: screen; opacity: .26;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='70' preserveAspectRatio='none'><filter id='t'><feTurbulence type='fractalNoise' baseFrequency='.004 .9' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1.6 0 0 0 -.9'/></filter><rect width='100%' height='100%' filter='url(%23t)'/></svg>") center / 100% 100%,
    linear-gradient(to bottom, transparent, rgba(200, 210, 255, .07) 45%, rgba(200, 210, 255, .1) 55%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 65%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 65%, transparent);
  animation: tracking 16s linear infinite;
}
@keyframes tracking { 0% { transform: translateY(-80px); } 24% { transform: translateY(105vh); } 100% { transform: translateY(105vh); } }
@keyframes tapenoise { 0% { transform: translate(0, 0); } 20% { transform: translate(-34px, 21px); } 40% { transform: translate(27px, -40px); } 60% { transform: translate(-52px, -12px); } 80% { transform: translate(41px, 33px); } 100% { transform: translate(-9px, 48px); } }
@keyframes tapeglitch {
  0%, 100% { transform: none; }
  90% { transform: translateX(-4px) skewX(-7deg); }
  90.8% { transform: translateX(3px); }
  91.5% { transform: translateX(-1.5px) skewX(3deg); }
  92.2% { transform: none; }
}

/* VCR on-screen display, title screens only */
#osd { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 95; font: 400 30px/1 'VT323', ui-monospace, Menlo, monospace; letter-spacing: 1px;
  color: #eef2ff; text-shadow: -1.5px 0 rgba(255, 50, 95, .65), 1.5px 0 rgba(45, 215, 255, .6), 0 0 8px rgba(200, 215, 255, .4); }
body[data-screen=join] #osd, body[data-screen=lobby] #osd { display: block; }
#osd .play { position: absolute; top: 22px; right: 30px; opacity: 0; animation: osdplay 6s steps(1) forwards; }
#osd .ctr { position: absolute; left: 30px; bottom: 22px; opacity: .5; }
@keyframes osdplay { 0% { opacity: .9; } 85% { opacity: 0; } }
@media (max-width: 600px) { #osd { font-size: 21px; } #osd .play { top: 14px; right: 16px; } #osd .ctr { left: 16px; bottom: 14px; } }

@media (prefers-reduced-motion: reduce) {
  #sky *, #sky *::before, .float, .shake, body::after, .vhs, #osd *, .lobby h1 { animation: none !important; }
  .vhs.warm { filter: none; }
  .vhs.track { display: none; }
}
