@import url(/static/fonts/fonts.css);

/* Colours follow the classic box and deck: royal blue table, red logo with
   white outline, yellow accents; numbers 1–4 blue, 5–8 green, 9–12 red. */
:root {
  --table-hi: #2c6be0;
  --table: #1548b4;
  --table-lo: #0a2a72;
  --navy: #0a2361;
  --red: #e2231a;
  --red-dark: #a3120c;
  --yellow: #ffcc00;
  --orange: #ff8a00;
  --c-blue: #1062d6;
  --c-blue-dk: #0a3a8a;
  --c-green: #12a03c;
  --c-green-dk: #0a6526;
  --c-red: #e3141b;
  --c-red-dk: #8f0c10;
  --paper: #ffffff;
  --ink: #14204a;
  --muted: #5e6a8a;
  --line: #dbe2f2;
  --good: #12a03c;
  --bad: #e2231a;
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--table-lo); }
body {
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 900px at 50% 300px, var(--table-hi) 0%, var(--table) 45%, var(--table-lo) 100%) var(--table-lo);
  color: var(--ink); font-family: Montserrat, system-ui, sans-serif; font-size: 15px; line-height: 1.45;
}
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-weight: 800; color: var(--navy); }
p { margin: 0 0 .5rem; }
a { color: var(--c-blue); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.center-text { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- logo */
.logo {
  display: inline-flex; align-items: baseline; font-weight: 900; font-style: italic; letter-spacing: -.02em; line-height: 1;
  transform: rotate(-4deg); white-space: nowrap;
}
.logo span { -webkit-text-stroke: .16em #fff; paint-order: stroke fill; text-shadow: .05em .09em 0 var(--navy), .05em .09em .1em rgba(0,0,0,.35); }
.logo-bo { color: var(--yellow); font-size: 1.1em; }
.logo-skip { color: var(--red); margin-left: .04em; }
.hero-logo { font-size: clamp(3.4rem, 15vw, 7rem); }
.brand-logo { font-size: 1.55rem; }
.gbar-logo { font-size: 1.2rem; }

/* ---------------------------------------------------------------- topbar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(6, 22, 70, .55); color: #fff; flex-wrap: wrap; backdrop-filter: blur(6px); }
.topbar a, .topbar .linkbtn { color: #fff; text-decoration: none; font-weight: 600; }
.brand { display: flex; align-items: center; padding: 2px 6px; }
.topbar nav { margin-left: auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 4px; color: var(--navy); }
input, select { width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 204, 0, .35); }
button, .btn { font: inherit; font-weight: 800; border: 0; border-radius: 12px; padding: 11px 18px; cursor: pointer; background: var(--c-blue); color: #fff; text-decoration: none; display: inline-block; box-shadow: 0 3px 0 var(--c-blue-dk); transition: transform .08s, filter .15s; }
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--c-blue-dk); }
button:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--c-blue); }
.btn-accent { background: var(--red); box-shadow: 0 3px 0 var(--red-dark); }
.btn-accent:active { box-shadow: 0 1px 0 var(--red-dark); }
.btn-ghost { background: #fff; color: var(--navy); box-shadow: inset 0 0 0 2px var(--line); }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 900; font-size: 1.4rem; text-align: center; }

/* ---------------------------------------------------------------- layout */
.panel { background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 30px rgba(3, 15, 50, .35), inset 0 -4px 0 rgba(10, 35, 97, .08); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.notice { padding: 12px 14px; border-radius: 10px; background: #fff; border-left: 5px solid var(--c-blue); }
.notice.err { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--good); }
.pill { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #e8eefb; color: var(--navy); margin-right: 4px; }
.pill.off { background: #f3f3f3; color: #888; }
.pill.gold { background: var(--yellow); color: var(--navy); }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.15); }
.copybox { display: flex; gap: 6px; }
.copybox input { font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; border-left: 5px solid var(--yellow); z-index: 2000; max-width: calc(100vw - 32px); font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toast-in .25s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.spinner { width: 14px; height: 14px; border: 3px solid rgba(255,255,255,.35); border-top-color: var(--yellow); border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 8px; animation: spin 0.9s linear infinite; }
.panel .spinner { border-color: var(--line); border-top-color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }
.wait { color: var(--muted); font-weight: 600; }

/* confetti (ui.js) */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 3000; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }

/* ---------------------------------------------------------------- home */
.hero { text-align: center; margin: 10px 0 26px; color: #fff; }
.hero-cards { display: flex; justify-content: center; height: 140px; margin: 10px 0 -6px; --cw: 82px; }
.hero-cards .card { margin: 0 -14px; transform-origin: 50% 120%; animation: hero-in .7s cubic-bezier(.2,.8,.3,1.2) backwards; }
.hero-cards .tilt-l { transform: rotate(-24deg) translateY(16px); animation-delay: .05s; }
.hero-cards .tilt-m { transform: rotate(-12deg) translateY(4px); animation-delay: .12s; }
.hero-cards .tilt-c { transform: translateY(-4px); z-index: 2; animation-delay: .19s; }
.hero-cards .tilt-n { transform: rotate(12deg) translateY(4px); animation-delay: .26s; }
.hero-cards .tilt-r { transform: rotate(24deg) translateY(16px); animation-delay: .33s; }
@keyframes hero-in { from { opacity: 0; transform: translateY(80px) rotate(0); } }
.subtitle { font-size: 1.1rem; font-weight: 600; color: #dfe8ff; margin-top: 10px; }
.rules { padding-left: 1.3rem; margin: 0; }
.rules li { margin-bottom: .55rem; }
.rules li::marker { color: var(--red); font-weight: 900; }

/* ---------------------------------------------------------------- cards */
.card {
  --w: var(--cw, 80px);
  position: relative; width: var(--w); aspect-ratio: 5 / 7; flex: none;
  border-radius: calc(var(--w) * .1); container-type: inline-size; user-select: none; -webkit-user-select: none;
  background: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 2px 5px rgba(3, 15, 50, .35);
}
.card.face::before { content: ''; position: absolute; inset: 6cqw; border-radius: 7cqw; border: 2.4cqw solid var(--c); opacity: .9; }
.card.face::after { content: ''; position: absolute; inset: 14cqw 14cqw; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 14%, #fff) 0%, #fff 72%); }
.c-blue { --c: var(--c-blue); --cd: var(--c-blue-dk); }
.c-green { --c: var(--c-green); --cd: var(--c-green-dk); }
.c-red { --c: var(--c-red); --cd: var(--c-red-dk); }
.card .cn {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 1;
  font-weight: 900; font-style: italic; font-size: 60cqw; letter-spacing: -.06em; color: var(--c);
  -webkit-text-stroke: 1.6cqw #fff; paint-order: stroke fill; text-shadow: 2.5cqw 3cqw 0 var(--cd);
}
.card[data-v="10"] .cn, .card[data-v="11"] .cn, .card[data-v="12"] .cn { font-size: 46cqw; }
.card .ci { position: absolute; z-index: 1; font-weight: 900; font-size: 15cqw; line-height: 1; color: var(--c); }
.card .tl { left: 10cqw; top: 10cqw; }
.card .tr { right: 10cqw; top: 10cqw; }
.card .bl { left: 10cqw; bottom: 10cqw; transform: rotate(180deg); }
.card .br { right: 10cqw; bottom: 10cqw; transform: rotate(180deg); }

/* the BoSkip joker */
.card.joker { --c: var(--red); background: #fff; overflow: hidden; }
.card.joker::before { border-color: var(--orange); }
.card.joker::after { display: none; }
.joker-burst { position: absolute; inset: 9cqw; border-radius: 6cqw; background:
  repeating-conic-gradient(from 0deg at 50% 50%, #ffd84d 0deg 10deg, #ffb300 10deg 20deg); opacity: .95; }
.card .card-logo { position: absolute; z-index: 1; left: 50%; top: 50%; font-size: 21cqw; transform: translate(-50%, -50%) rotate(-28deg); }
.card.joker .ci { color: var(--red); font-size: 14cqw; z-index: 2; }
.joker-as { position: absolute; z-index: 2; right: 12cqw; top: 38cqw; display: none; }
.card.joker .tl, .card.joker .br { background: #fff; border-radius: 50%; width: 22cqw; height: 22cqw; display: grid; place-items: center; left: 6cqw; top: 6cqw; }
.card.joker .br { left: auto; top: auto; right: 6cqw; bottom: 6cqw; }

/* back */
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 4cqw, transparent 4cqw 8cqw),
    radial-gradient(circle at 50% 45%, #3a7cf0 0%, #1548b4 55%, #0a2a72 100%);
  box-shadow: inset 0 0 0 4cqw #fff, 0 1px 0 rgba(0,0,0,.08), 0 2px 5px rgba(3, 15, 50, .35);
}
.back-ring { position: absolute; inset: 22cqw 12cqw; border-radius: 50%; background: radial-gradient(ellipse, #1d5fd1 55%, var(--navy) 100%); box-shadow: 0 0 0 2.5cqw var(--yellow), 0 0 0 4cqw var(--red); }
.card.back .card-logo { font-size: 20cqw; }

/* empty place */
.card.slot { background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); display: grid; place-items: center; }
.card.slot span { color: rgba(255,255,255,.55); font-weight: 900; font-style: italic; font-size: 40cqw; }

/* ---------------------------------------------------------------- lobby */
.lobby { margin-top: 8px; }
.code-text { font-size: clamp(2.4rem, 10vw, 3.4rem); font-weight: 900; font-style: italic; letter-spacing: .18em; color: var(--red); -webkit-text-stroke: 3px var(--navy); paint-order: stroke fill; text-shadow: 3px 4px 0 var(--navy); }
.qr { width: 180px; height: 180px; display: block; margin: 0 auto; border-radius: 12px; border: 6px solid #fff; box-shadow: 0 0 0 3px var(--yellow); }
.players .tags { margin-top: 2px; }
.lobby-wrap main { padding-bottom: 40px; }

/* ---------------------------------------------------------------- table */
body.in-game { overflow: hidden; overscroll-behavior: none; }
.table {
  --cw: min(16.4vw, 9.2svh, 118px);
  --ch: calc(var(--cw) * 1.4);
  --sw: calc(var(--cw) * .5);
  height: 100svh; display: flex; flex-direction: column; color: #fff; max-width: 900px; margin: 0 auto;
  padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.gbar { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 4px 6px; flex: none; }
.gcode { font-weight: 900; letter-spacing: .15em; background: rgba(255,255,255,.15); border-radius: 8px; padding: 2px 8px; font-size: .85rem; }
.ground { font-size: .8rem; opacity: .85; font-weight: 600; }
.icon-btn { margin-left: auto; background: rgba(255,255,255,.15); box-shadow: none; padding: 6px 12px; font-size: 1.1rem; }

.badge { position: absolute; z-index: 5; right: -6px; bottom: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--yellow); color: var(--navy); font-weight: 900; font-size: 12px; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* opponents */
.opps { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; flex: none; scrollbar-width: none; }
.opps::-webkit-scrollbar { display: none; }
.opp { --cw: var(--sw); flex: 1 0 auto; min-width: max-content; background: rgba(5, 20, 70, .35); border-radius: 12px; padding: 6px 8px 8px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); transition: box-shadow .3s, background .3s; }
.opp.active { background: rgba(255, 204, 0, .16); box-shadow: inset 0 0 0 2px var(--yellow), 0 0 18px rgba(255, 204, 0, .35); }
.opp.offline { opacity: .6; }
.opp-head { display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; margin-bottom: 5px; }
.opp-head .dot { width: 10px; height: 10px; }
.opp-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-hand { opacity: .75; font-weight: 600; margin-left: auto; padding-left: 6px; }
.opp-row { display: flex; gap: 8px; align-items: flex-start; }
.opp-discards { display: flex; gap: 3px; }
.opp .badge { min-width: 16px; height: 16px; font-size: 10px; right: -4px; bottom: -4px; padding: 0 4px; }

/* stock + discard piles */
.stock { position: relative; width: var(--cw); }
.stock .under { position: absolute; left: 0; top: 0; transform: translate(calc(var(--u) * -1.5px), calc(var(--u) * 2px)); }
.stock > .card:not(.under) { position: relative; z-index: 1; }
.dpile { position: relative; width: var(--cw); height: calc(var(--ch) * (1 + var(--step) * max(var(--n) - 1, 0))); border-radius: calc(var(--cw) * .1); }
.opp .dpile { height: auto; }
.dpile .card { position: absolute; left: 0; top: calc(var(--ch) * var(--step) * var(--k, 0)); }
.opp .dpile .card { position: relative; top: 0; }

/* centre */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: calc(var(--ch) + 30px); }
.center-row { display: flex; gap: calc(var(--cw) * .28); align-items: flex-start; }
.deck { position: relative; width: var(--cw); }
.deck .under { position: absolute; left: 0; top: 0; transform: translate(calc(var(--u) * -2px), calc(var(--u) * 2px)); }
.deck > .card:not(.under) { position: relative; }
.deck.shake { animation: shake .5s; }
@keyframes shake { 20% { transform: rotate(-6deg); } 40% { transform: rotate(5deg) translateY(-3px); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
.builds { display: flex; gap: calc(var(--cw) * .12); }
.bpile { position: relative; border-radius: calc(var(--cw) * .1); }
.bpile .under-card { position: absolute; inset: 0; border-radius: inherit; background: #fff; transform: translate(-2px, 3px) rotate(-2deg); box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.need { display: block; text-align: center; font-size: .72rem; font-weight: 800; opacity: .7; margin-top: 4px; height: 1em; }
.ticker { margin-top: 8px; font-size: .78rem; opacity: .85; text-align: center; max-width: 100%; padding: 0 8px; animation: fade-in .4s; }
@keyframes fade-in { from { opacity: 0; } }

/* targets */
.target { cursor: pointer; }
.target::after { content: ''; position: absolute; inset: -5px; border-radius: calc(var(--cw) * .14); box-shadow: 0 0 0 3px var(--yellow), 0 0 22px 4px rgba(255, 204, 0, .6); animation: glow 1s ease-in-out infinite alternate; pointer-events: none; z-index: 6; }
.bpile.target::after { bottom: calc(1em + 0px); }
.drop-over::after { box-shadow: 0 0 0 5px #fff, 0 0 30px 8px rgba(255, 255, 255, .8); }
@keyframes glow { from { opacity: .55; } to { opacity: 1; } }

/* status line */
.status { flex: none; text-align: center; font-size: .82rem; font-weight: 600; padding: 6px 10px; margin: 4px auto 6px; border-radius: 999px; background: rgba(5, 20, 70, .4); display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; max-width: 100%; }
.status.mine { background: var(--yellow); color: var(--navy); box-shadow: 0 4px 14px rgba(255, 204, 0, .35); animation: pop .35s; }
.status.mine strong { font-weight: 900; text-transform: uppercase; letter-spacing: .03em; }

/* my area */
.mine { flex: none; background: rgba(5, 20, 70, .35); border-radius: 18px; padding: 8px 8px 10px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); transition: box-shadow .3s; }
.mine.active { box-shadow: inset 0 0 0 2px var(--yellow), 0 0 26px rgba(255, 204, 0, .3); }
.mine-row { display: flex; gap: calc(var(--cw) * .2); justify-content: center; align-items: flex-start; }
.mine-stock .label { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .75; margin-bottom: 3px; text-align: center; }
.mine-stock { padding-top: 0; }
.mine-discards { display: flex; gap: calc(var(--cw) * .08); padding-top: calc(.7rem * 1.45 + 3px); }
.hand { display: flex; justify-content: center; margin-top: 10px; min-height: var(--ch); gap: calc(var(--cw) * .06); }
.hand .card { transform: rotate(calc((var(--i) - 2) * 3deg)) translateY(calc(max(var(--i) - 2, 2 - var(--i)) * 3px)); transition: transform .18s; }

/* picking cards */
.pickable { cursor: grab; touch-action: none; }
.pickable.can::before { border-color: var(--c); }
.pickable.can { box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 4px 10px rgba(3, 15, 50, .45); }
.card.sel, .hand .card.sel { transform: translateY(-16%) scale(1.06); box-shadow: 0 0 0 3px var(--yellow), 0 12px 24px rgba(0,0,0,.45); z-index: 7; }
@media (hover: hover) {
  .hand .pickable:hover { transform: translateY(-8%); }
}
.lifted { opacity: .25; }
.incoming { visibility: hidden; }
.landed { animation: pop .35s ease-out; }
.flip-in { animation: flip-in .3s ease-out; }
@keyframes pop { 0% { transform: scale(1.18); } 100% { transform: none; } }
@keyframes flip-in { from { transform: rotateY(90deg); } }

/* flying cards */
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1500; }
.flying { position: fixed !important; margin: 0; z-index: 1500; will-change: transform; }
.ghost { position: fixed; left: 0; top: 0; z-index: 1600; pointer-events: none; box-shadow: 0 18px 34px rgba(0,0,0,.5); }

/* menu + overlays */
.menu { position: fixed; right: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 44px); z-index: 1200; background: #fff; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; min-width: 220px; box-shadow: 0 12px 30px rgba(0,0,0,.4); animation: pop .2s; }
.menu button { background: none; box-shadow: none; color: var(--navy); text-align: left; padding: 10px 12px; font-weight: 700; }
.menu button:hover { background: #eef3ff; }
.overlay { position: fixed; inset: 0; z-index: 1300; background: rgba(3, 12, 40, .6); display: grid; place-items: center; padding: 16px; animation: fade-in .3s; backdrop-filter: blur(3px); }
.modal { width: min(460px, 100%); max-height: calc(100svh - 32px); overflow: auto; color: var(--ink); animation: pop .35s; }
.over { text-align: center; }
.over h2 { font-size: 1.8rem; font-weight: 900; font-style: italic; color: var(--red); }
.over-cards { display: flex; justify-content: center; --cw: 70px; height: 104px; margin-top: -4px; }
.over-cards .tilt-l { transform: rotate(-12deg) translateX(10px); }
.over-cards .tilt-r { transform: rotate(12deg) translateX(-10px); }
.over-points { display: inline-block; background: var(--yellow); color: var(--navy); font-weight: 900; padding: 4px 14px; border-radius: 999px; margin-bottom: 12px; }
.scores li { text-align: left; }
.scores li.win { background: #fff8d6; border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.score { color: var(--navy); white-space: nowrap; }

/* wider screens: more room for the cards */
@media (min-width: 700px) and (min-height: 700px) {
  .table { --cw: min(13vw, 10svh, 118px); }
  .opp { --cw: calc(var(--sw) * 1.1); }
  .status { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
