/* Tiny Epic Galaxies — page furniture from the Lost Cities styles (deep space), planets, dice and the galaxy at the end. */
:root {
  --felt-glow: #5a3fae; /* the glow at the top of the home page */
  --sheet: #161236; /* pop-up window background */
  --felt: #1a1440;
  --felt-dark: #07051a;
  --gold: #f5b700;
  --gold-deep: #c98a00;
  --ink: #1d1d1f;
  --paper: #fffdf6;
  --panel: rgba(14, 10, 40, 0.86);
  --text: #f4f1e8;
  --muted: #b9c8bf;
  --cw: 70px;
  --ch: 100px;
  --pw: 64px;
  --ph: 92px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

input { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- shared bits ---------- */
#home, #lobby {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at 50% 20%, var(--felt-glow) 0%, var(--felt) 40%, var(--felt-dark) 100%);
}
.home-wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
.brand { text-align: center; margin: 8px 0 20px; }
.brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 44px; margin: 8px 0 0; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,.3); }

.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 16px; margin: 14px 0; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.panel h2 { margin: 0 0 8px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.field { display: block; margin: 8px 0 4px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; font-size: 20px; padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(255,255,255,.15); background: rgba(0,0,0,.3); color: var(--text); outline: none; }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-size: 17px; font-weight: 700; background: rgba(255,255,255,.12); }
.btn.gold:disabled { filter: grayscale(.8); opacity: .6; }
.btn.ghost { background: transparent; border: 2px solid rgba(255,255,255,.25); }
.btn.danger { background: #a3242f; }
.btn.small { padding: 8px 12px; font-size: 15px; }
.linkish { display: block; margin: 16px auto 0; background: none; border: 0; color: var(--gold); text-decoration: underline; font-size: 15px; }

.count-picker { display: flex; gap: 8px; margin: 8px 0 14px; }
.count-picker button { flex: 1; font-size: 22px; font-weight: 700; padding: 10px 0; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); }
.count-picker button.on { border-color: var(--gold); background: rgba(245,183,0,.2); color: var(--gold); }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #4be08c; box-shadow: 0 0 8px #4be08c; animation: pulse 1.6s infinite; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.game-item .code { font-family: ui-monospace, Menlo, Consolas, monospace; background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 6px; font-size: 13px; margin-left: 6px; }

.code-row { display: flex; align-items: baseline; justify-content: space-between; }
.code-row strong { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 30px; color: var(--gold); letter-spacing: 4px; }
.seat-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.seat-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.seat-list li.empty { opacity: .5; border: 2px dashed rgba(255,255,255,.2); background: transparent; }
.seat-list .tag { font-size: 12px; color: var(--muted); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 6px rgba(0,0,0,.4); flex: none; text-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* ---------- table ---------- */
#table { overflow: hidden; touch-action: none; }
.felt {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.10), transparent 60%),
    repeating-radial-gradient(circle at 30% 30%, rgba(0,0,0,.025) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 40%, #8a5530 0%, var(--felt) 45%, var(--felt-dark) 100%);
}
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 6px calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l)); z-index: 5; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.round-info { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.top-buttons { display: flex; gap: 6px; }
.icon-btn { height: 34px; min-width: 34px; padding: 0 8px; border-radius: 10px; border: 0; background: rgba(0,0,0,.35); font-size: 16px; display: flex; align-items: center; gap: 4px; }
.icon-btn span { font-size: 13px; font-weight: 700; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 12px; animation: fade .2s ease-out; }
.sheet.narrow { width: 420px; }
.sheet.wide { width: 900px; }
.sheet h2 { margin: 0 0 10px; font-family: Georgia, serif; }
.sheet .btn { margin-top: 8px; }
.sheet .btn.ghost, .sheet .btn.danger { width: 100%; }
.toggle { display: flex; gap: 10px; align-items: center; font-size: 15px; margin: 8px 0; }
.toggle input { width: 22px; height: 22px; }
.rules h3 { color: var(--text); margin: 0 0 4px; font-size: 15px; }
.rules p { margin: 4px 0; }
.claim-list { display: flex; flex-direction: column; gap: 8px; }
.claim-list button { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 0; background: rgba(255,255,255,.08); font-size: 17px; font-weight: 700; text-align: left; }

.score-table-wrap { overflow-x: auto; }
table.scores { border-collapse: collapse; width: 100%; font-size: 14px; }
table.scores th, table.scores td { padding: 5px 8px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
table.scores th { font-size: 13px; }
table.scores td.rd { color: var(--muted); text-align: left; }
table.scores tr.current td { background: rgba(245,183,0,.12); }
table.scores tr.total td { font-weight: 900; font-size: 16px; border-top: 2px solid rgba(255,255,255,.3); }
table.scores td.zero { color: #4be08c; font-weight: 800; }
table.scores td.leader { color: var(--gold); }
table.scores .th-name { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.result-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.05); margin-bottom: 6px; }
.result-row.out { background: rgba(245,183,0,.15); border: 1px solid rgba(245,183,0,.5); }
.result-row .who { width: 110px; flex: none; display: flex; align-items: center; gap: 6px; font-weight: 700; }
.result-row .who .avatar { width: 28px; height: 28px; font-size: 13px; }
.result-row .cards { flex: 1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.result-row .left { display: flex; gap: 3px; padding: 3px; border-radius: 6px; background: rgba(214,40,58,.25); outline: 1px dashed rgba(255,120,120,.6); }
.result-row .pts { width: 70px; text-align: right; font-weight: 900; font-size: 18px; }
.result-row .pts small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.winner-banner { text-align: center; font-size: 22px; margin: 4px 0 12px; }
.winner-banner .big { font-size: 48px; display: block; animation: float 1.4s ease-in-out infinite; }

.rotate { display: none; }
@media (orientation: portrait) {
  body.in-game .rotate { display: flex; position: fixed; inset: 0; z-index: 100; flex-direction: column; align-items: center; justify-content: center; background: var(--felt-dark); font-size: 20px; text-align: center; padding: 24px; }
  .rotate-phone { font-size: 80px; animation: turn 2s ease-in-out infinite; }
}

.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 90; background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 8px 20px rgba(0,0,0,.5); animation: rise .2s ease-out; max-width: 90vw; }

.your-turn-flash { position: absolute; inset: 0; z-index: 25; pointer-events: none; box-shadow: inset 0 0 60px 10px rgba(245,183,0,.7); animation: fadeOut 1.2s ease-out forwards; }

@keyframes glow { 0%,100% { box-shadow: 0 0 0 3px var(--gold), 0 0 10px 3px rgba(245,183,0,.6); } 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 22px 8px rgba(245,183,0,.95); } }
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }

.back-link { display: inline-block; text-decoration: none; font-weight: 700; font-size: 15px; padding: 4px 0; }
.back-link:active { color: var(--gold); }
.linkbtn { display: block; text-align: center; text-decoration: none; box-sizing: border-box; margin-top: 8px; }

/* Shell pieces copied from ud.css: the history list, its delete button (🗑), the lobby's bot rows, confetti */
.celebrate { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }
/* game history */
#historyBtn { margin-top: 4px; }
.win-tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.win-chip b { color: var(--gold); margin-left: 4px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { background: rgba(255,255,255,.06); border-radius: 12px; overflow: hidden; }
.history-item.open { background: rgba(255,255,255,.1); }
.history-item.incomplete .hi-title { color: var(--muted); }
.hi-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.hi-main { flex: 1; min-width: 0; }
.hi-date { font-size: 12px; color: var(--muted); }
.hi-title { font-size: 16px; margin: 2px 0; }
.hi-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-del { border: 0; background: rgba(0,0,0,.25); border-radius: 10px; width: 36px; height: 36px; font-size: 16px; flex: none; }
.hi-detail { padding: 0 12px 12px; overflow-x: auto; }
.seat-list li.can-bot { flex-wrap: wrap; }
.bot-tag { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 4px; }


/* ================= Tiny Epic Galaxies ================= */
.felt { background: radial-gradient(1.5px 1.5px at 12% 22%, #fff8, transparent), radial-gradient(1px 1px at 72% 34%, #fff9, transparent), radial-gradient(1.2px 1.2px at 40% 78%, #fff7, transparent), radial-gradient(1px 1px at 88% 82%, #fff8, transparent), radial-gradient(1px 1px at 25% 60%, #fff6, transparent), radial-gradient(ellipse at 55% 40%, #3a2a78 0%, var(--felt) 45%, var(--felt-dark) 100%); }
.teg-title { font-family: Georgia, serif; letter-spacing: 2px; text-transform: uppercase; }
.brand-art { font-size: 46px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.4)); }
.brand-art span { display: inline-block; transform: translateY(-10px) rotate(20deg); font-size: 36px; }
.opt-row .count-picker button { font-size: 15px; }
.pill { background: rgba(0,0,0,.45); padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }

#table { --left: calc(132px + var(--safe-l)); --right: calc(min(210px, 26vw) + var(--safe-r)); --card-h: 170px; --die: 38px; }
.teg-players { position: absolute; left: 0; top: 40px; bottom: calc(4px + var(--safe-b)); width: var(--left); padding: 0 4px 0 calc(4px + var(--safe-l)); display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; overflow-y: auto; touch-action: pan-y; z-index: 3; }
.pcard { display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; border-radius: 10px; border: 2px solid transparent; background: rgba(0,0,0,.4); text-align: left; flex: none; }
.pcard.me { background: rgba(0,0,0,.55); border-color: rgba(255,255,255,.18); }
.pcard.turn { border-color: var(--gold); box-shadow: 0 0 10px rgba(245,183,0,.5); }
.pcard.rogue { background: rgba(120,10,20,.55); }
.pcard .pc-top { display: flex; align-items: center; gap: 4px; min-width: 0; }
.pcard .avatar { width: 22px; height: 22px; font-size: 11px; }
.pcard .avatar.rogue { background: #3a0008; display: grid; place-items: center; border-radius: 50%; }
.pcard b { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .vp { font-weight: 900; font-size: 17px; color: var(--gold); }
.pcard .pc-row { display: flex; gap: 6px; font-size: 12.5px; font-weight: 700; }
.pcard .pc-row.small { font-size: 11.5px; color: var(--muted); }
.pcard .deciding { color: var(--gold); animation: pulse 1s infinite; }

.teg-main { position: absolute; left: var(--left); right: var(--right); top: 40px; bottom: calc(2px + var(--safe-b)); display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.planets { flex: 1; min-height: 0; display: flex; gap: 6px; align-items: stretch; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; padding: 2px 2px 4px; }
.pl { position: relative; flex: none; width: calc(var(--card-h) * .66); max-height: var(--card-h); display: flex; flex-direction: column; gap: 3px; padding: 5px; border-radius: 10px; background: linear-gradient(#1c1840, #0f0d26); border: 2px solid #5a4ea8; box-shadow: 0 4px 12px rgba(0,0,0,.5); cursor: pointer; }
.pl.energy { border-color: #c9a227; }
.pl.culture { border-color: #b46be0; }
.pl.weapon { border-color: #e0404e; background: linear-gradient(#3a0a14, #160408); }
.pl-head { display: flex; align-items: center; gap: 3px; font-size: 11.5px; }
.pl-head b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-head .pts { min-width: 20px; height: 20px; border-radius: 50%; background: #2f7fd0; display: grid; place-items: center; font-weight: 900; font-size: 12px; border: 2px solid #9ad0ff; }
.pl-body { position: relative; flex: 1; min-height: 34px; display: flex; align-items: center; justify-content: center; }
.orb { width: calc(var(--card-h) * .22); height: calc(var(--card-h) * .22); border-radius: 50%; background: radial-gradient(circle at 32% 30%, hsl(var(--h) 80% 75%), hsl(var(--h) 60% 40%) 55%, hsl(var(--h) 60% 15%)); box-shadow: 0 0 14px hsl(var(--h) 70% 50% / .6); }
.orb.weapon-orb { background: radial-gradient(circle at 32% 30%, #ffb3b8, #b31e2c 55%, #3a0008); }
.surf { position: absolute; top: 2px; right: 2px; display: flex; flex-wrap: wrap; gap: 1px; max-width: 60%; justify-content: flex-end; }
.ship { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--sc); font-size: 10px; border: 1.5px solid #fff; }
.ship.mine { box-shadow: 0 0 0 1.5px var(--gold); }
.ship.pick { animation: pickGlow 1s ease-in-out infinite; cursor: pointer; transform: scale(1.25); }
@keyframes pickGlow { 50% { box-shadow: 0 0 0 3px #fff, 0 0 12px #fff; } }
.sat { font-size: 12px; filter: drop-shadow(0 0 2px var(--sc)); }
.track { position: relative; display: flex; gap: 2px; align-items: stretch; min-height: 24px; }
.track .cell { position: relative; flex: 1; min-width: 0; border-radius: 4px; background: rgba(255,255,255,.1); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1px; font-size: 10px; padding: 1px; }
.track .cell i { position: absolute; left: 2px; top: 0; font-style: normal; font-size: 9px; color: rgba(255,255,255,.5); }
.track .cell.start { background: rgba(245,215,80,.25); }
.track .cell.end { background: rgba(255,255,255,.25); font-size: 13px; }
.track .cell.end.dip { background: rgba(90,170,240,.45); }
.track .cell.end.eco { background: rgba(220,170,60,.45); }
.track .ship { width: 15px; height: 15px; font-size: 8px; }
.track.can { outline: 2px solid var(--gold); outline-offset: 1px; border-radius: 5px; }
.pl-act { font-size: 10.5px; line-height: 1.2; color: #d8d4f0; max-height: 3.6em; overflow: hidden; }
.go { position: absolute; z-index: 2; border: 0; border-radius: 999px; padding: 3px 10px; font-weight: 900; font-size: 12px; background: var(--gold); color: #3a2800; box-shadow: 0 0 10px rgba(245,183,0,.8); animation: pulse 1.2s infinite; }
.go.land { bottom: 2px; left: 50%; transform: translateX(-50%); }
.go.orbitbtn { right: 2px; top: 50%; transform: translateY(-50%); }
.pl.big { width: auto; max-height: none; cursor: default; }

.galaxy { flex: none; display: flex; flex-direction: column; gap: 3px; padding: 4px 6px; border-radius: 10px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.12); }
.g-res { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; font-weight: 800; }
.g-res .bar { position: relative; min-width: 62px; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: hidden; z-index: 0; }
.g-res .bar i { position: absolute; left: 0; top: 0; bottom: 0; z-index: -1; }
.g-res .bar.e i { background: rgba(240,200,60,.45); } .g-res .bar.c i { background: rgba(180,107,224,.45); }
.g-res .lvl small { color: var(--muted); font-weight: 600; }
.g-row { position: relative; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.g-ships { display: flex; gap: 3px; }
.gship { display: flex; flex-direction: column; align-items: center; min-width: 40px; padding: 1px 3px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); font-size: 14px; line-height: 1; }
.gship small { font-size: 9px; color: var(--muted); max-width: 54px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gship.locked { opacity: .35; } .gship.captured { opacity: .5; text-decoration: line-through; }
.gship.pick { border-color: var(--gold); box-shadow: 0 0 10px rgba(245,183,0,.8); animation: pulse 1.1s infinite; }
.go.home-go { position: static; }
.g-planets { display: flex; gap: 3px; flex-wrap: wrap; }
.gp { border: 0; border-radius: 999px; padding: 2px 8px; font-size: 11.5px; font-weight: 800; background: hsl(var(--h) 45% 35%); }
.gp i { font-style: normal; margin-left: 4px; color: #9ad0ff; }
.gm, .gsat { border: 0; border-radius: 999px; padding: 2px 8px; font-size: 11.5px; font-weight: 800; background: rgba(245,183,0,.25); }

.teg-side { position: absolute; right: 0; top: 40px; bottom: calc(4px + var(--safe-b)); width: var(--right); padding: 0 calc(5px + var(--safe-r)) 0 4px; display: flex; flex-direction: column; gap: 5px; z-index: 3; overflow-y: auto; touch-action: pan-y; }
.dice { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px; border-radius: 12px; background: rgba(0,0,0,.35); min-height: calc(var(--die) + 10px); }
.dice .die { width: var(--die); height: var(--die); border-radius: 9px; border: 0; background: #f4f1ff; color: #222; font-size: calc(var(--die) * .55); display: grid; place-items: center; box-shadow: 0 3px 0 #9b93c9, 0 4px 8px rgba(0,0,0,.4); padding: 0; }
.dice .die.used { opacity: .3; transform: scale(.9); }
.dice .die.spent { opacity: .2; filter: grayscale(1); transform: scale(.85); }
.dice .die.picked { box-shadow: 0 0 0 3px var(--gold), 0 0 12px rgba(245,183,0,.9); }
.dice .die.active { box-shadow: 0 0 0 3px #fff; }
.dice .die:disabled { cursor: default; }
.dice .die.rolling { animation: tumble .16s linear infinite; }
@keyframes tumble { 50% { transform: rotate(16deg) translateY(-4px); } }
.rogue-die { display: flex; align-items: center; gap: 8px; font-size: 22px; }
.rogue-die .die.big { width: calc(var(--die) * 1.2); height: calc(var(--die) * 1.2); border-radius: 10px; background: #ffd6da; display: grid; place-items: center; }
.rogue-die small { font-size: 12px; color: var(--muted); }
.teg-prompt { font-size: 14px; line-height: 1.3; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.teg-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.teg-actions .btn { padding: 7px 10px; font-size: 14px; flex: 1 1 auto; }
.teg-actions .btn.small { padding: 5px 8px; font-size: 13px; flex: 0 1 auto; }
.teg-actions .btn.face { font-size: 18px; }
.teg-banner { position: absolute; left: 50%; top: 46px; transform: translateX(-50%); z-index: 20; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 86vw; padding: 8px 12px; border-radius: 14px; background: rgba(15,12,40,.92); border: 2px solid var(--gold); box-shadow: 0 8px 22px rgba(0,0,0,.6); font-size: 14px; animation: popIn .3s ease-out; }
.teg-banner .cd { font-weight: 900; color: var(--gold); min-width: 26px; text-align: center; }
.chooser-body { display: flex; flex-direction: column; gap: 6px; max-height: 64vh; overflow-y: auto; touch-action: pan-y; }
.chooser-body .opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 9px 11px; border-radius: 10px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.07); font-size: 15px; }
.chooser-body .opt small { color: var(--muted); font-size: 12px; }
.chooser-body .opt.ghost { background: none; border-style: dashed; }
.plist { padding-left: 18px; font-size: 14px; }
@keyframes popIn { 0% { transform: translateX(-50%) scale(.8); } 100% { transform: translateX(-50%) scale(1); } }
@media (max-height: 380px) {
  .topbar { padding-top: 3px; }
  .icon-btn { height: 30px; min-width: 30px; }
  .round-info { font-size: 13px; }
  .teg-players, .teg-side, .teg-main { top: 35px; }
  .teg-prompt { font-size: 13px; }
  .pl-act { font-size: 10px; }
}
@media (max-width: 760px) { #table { --left: calc(112px + var(--safe-l)); } }

/* ---------- 2026-10-14: cards fill their area (rows chosen in fitPlanets), text and track sized from the card ---------- */
.planets { display: grid; grid-template-columns: repeat(var(--cols, 5), var(--cw, 120px)); grid-auto-rows: var(--chh, 170px); gap: 6px; overflow: hidden; touch-action: manipulation; padding: 0; align-content: center; justify-content: center; --fs: 12px; }
.pl { width: auto; max-height: none; height: 100%; min-height: 0; font-size: var(--fs); gap: calc(var(--fs) * .3); padding: calc(var(--fs) * .45); overflow: hidden; }
.pl-head { font-size: calc(var(--fs) * 1.1); }
.pl-head .pts { min-width: calc(var(--fs) * 1.7); height: calc(var(--fs) * 1.7); font-size: calc(var(--fs) * 1.05); }
.pl-act { font-size: var(--fs); line-height: 1.25; max-height: none; color: #e6e2ff; }
.orb { width: calc(min(var(--cw), var(--chh)) * .34); height: calc(min(var(--cw), var(--chh)) * .34); }
.track { min-height: calc(var(--fs) * 1.9); }
.track .cell { font-size: calc(var(--fs) * .8); border-radius: calc(var(--fs) * .3); }
.track .cell i { font-size: calc(var(--fs) * .7); }
.track .cell.end { font-size: calc(var(--fs) * 1.1); }
.ship { width: calc(var(--fs) * 1.45); height: calc(var(--fs) * 1.45); font-size: calc(var(--fs) * .8); }
.track .ship { width: calc(var(--fs) * 1.25); height: calc(var(--fs) * 1.25); font-size: calc(var(--fs) * .7); }
.go { font-size: calc(var(--fs) * .95); padding: calc(var(--fs) * .25) calc(var(--fs) * .8); }
/* Wide cards: the planet on the left, name / track / action on the right. */
.planets.wide .pl { display: grid; grid-template-columns: calc(var(--chh) * .4) 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "body head" "body track" "body act"; column-gap: calc(var(--fs) * .5); }
.planets.wide .pl-head { grid-area: head; }
.planets.wide .pl-body { grid-area: body; flex-direction: column; justify-content: center; min-height: 0; }
.planets.wide .track { grid-area: track; }
.planets.wide .pl-act { grid-area: act; overflow: hidden; }
.planets.wide .orb { width: calc(var(--chh) * .34); height: calc(var(--chh) * .34); }
.planets.wide .surf { position: static; max-width: none; justify-content: center; margin-top: 2px; }
.planets.wide .go.land { position: static; transform: none; margin-top: 3px; }
/* Bigger dice, prompt and galaxy text. */
.dice .die { border-radius: calc(var(--die) * .22); }
.teg-prompt { font-size: clamp(14px, 2.1vh, 19px); }
.teg-actions .btn { font-size: clamp(14px, 2vh, 18px); }
.galaxy { font-size: clamp(13px, 1.9vh, 17px); }
.g-res { font-size: 1em; }
.gship { font-size: 1.15em; min-width: 46px; }
.gship small { font-size: .7em; }
.gp, .gm, .gsat { font-size: .9em; }
.pcard b { font-size: clamp(13px, 1.9vh, 17px); }
.pcard .vp { font-size: clamp(17px, 2.6vh, 24px); }
.pcard .pc-row { font-size: clamp(12.5px, 1.8vh, 16px); }
@media (min-height: 700px) { #table { --left: calc(170px + var(--safe-l)); } .pcard .avatar { width: 30px; height: 30px; font-size: 14px; } }

/* Header row: small planet dot + name + kind + points; surface ships (and Land) on the next row. Compact cards
   (class wide on #planets) hide the big planet. */
.planets.wide .pl { display: flex; flex-direction: column; }
.orb-mini { flex: none; width: calc(var(--fs) * 1.1); height: calc(var(--fs) * 1.1); border-radius: 50%; background: radial-gradient(circle at 32% 30%, hsl(var(--h) 80% 75%), hsl(var(--h) 60% 40%) 60%, hsl(var(--h) 60% 15%)); }
.orb-mini.weapon-orb { background: radial-gradient(circle at 32% 30%, #ffb3b8, #b31e2c 60%, #3a0008); }
.planets:not(.wide) .orb-mini { display: none; }
.pl-surf { display: flex; align-items: center; gap: 2px; min-height: calc(var(--fs) * 1.5); flex-wrap: wrap; }
.pl-surf .go.land { position: static; transform: none; margin-left: auto; }
.planets.wide .pl-body { display: none; }
.pl-body { flex: 1; min-height: 0; }

/* The print-and-play art (owner's copy, family site): the card's planet in the picture area, its corner planet as the dot. */
.pl-body.art { background: var(--art) center 26% / 112% auto no-repeat; border-radius: calc(var(--fs) * .4); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.orb-mini.art { background: var(--orbimg) center / 135% no-repeat; box-shadow: 0 0 0 1px rgba(255,255,255,.35); width: calc(var(--fs) * 1.5); height: calc(var(--fs) * 1.5); }
.planets.wide .orb-mini.art { display: block; }
.planets:not(.wide) .orb-mini.art { display: none; }
.gp { display: inline-flex; align-items: center; gap: 4px; }
.gp-orb { width: 1.2em; height: 1.2em; border-radius: 50%; background: var(--orbimg) center / 135% no-repeat; }
.card-art { display: block; width: min(260px, 60vw); margin: 0 auto 8px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.5); }

/* The player window: their galaxy mat (PnP art) with markers, details beside it. */
.sheet.wide:has(.pmat) { width: auto; padding: 12px 14px; }
.pmat { display: flex; gap: 14px; align-items: flex-start; }
.mat { position: relative; flex: none; width: min(600px, 56vw, calc((92vh - 34px) * 1.428)); aspect-ratio: 961 / 673; background: center / cover no-repeat; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.5); container-type: inline-size; }
.tok { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center; width: 9cqw; height: 9cqw; border-radius: 50%; font-size: 3.6cqw; line-height: 1; box-shadow: 0 0 0 .5cqw #fff, 0 .6cqw 1.6cqw rgba(0,0,0,.7); }
.tok i { position: absolute; right: -1.2cqw; bottom: -1.2cqw; min-width: 4.4cqw; height: 4.4cqw; border-radius: 2.2cqw; background: #111; color: #fff; font: 700 3.2cqw/4.4cqw system-ui, sans-serif; text-align: center; box-shadow: 0 0 0 .3cqw #fff; }
.tok.e { background: radial-gradient(circle at 35% 30%, #fff6a8, #f2b705 60%, #9a6a00); }
.tok.c { background: radial-gradient(circle at 35% 30%, #d9f1ff, #4aa3df 60%, #1b4f7a); }
.tok.emp { width: 11cqw; height: 11cqw; background: transparent; box-shadow: 0 0 0 .8cqw #fff, 0 0 2.4cqw 1cqw #ffe36e, inset 0 0 2cqw #ffe36e; animation: tokGlow 1.6s ease-in-out infinite alternate; }
@keyframes tokGlow { from { box-shadow: 0 0 0 .8cqw #fff, 0 0 1.2cqw .4cqw #ffe36e, inset 0 0 1cqw #ffe36e; } to { box-shadow: 0 0 0 .8cqw #fff, 0 0 3cqw 1.4cqw #ffe36e, inset 0 0 2.4cqw #ffe36e; } }
.pm-side { flex: 1; min-width: 220px; max-width: 360px; padding-right: 30px; font-size: 16px; }
.pm-side h2 { margin: 0 0 6px; font-size: 22px; }
.pm-vp { font: 700 16px system-ui, sans-serif; color: #ffe36e; margin-left: 6px; }
.pm-line { margin: 4px 0; }
.pm-planets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.pm-planets .gp { font-size: 15px; padding: 4px 8px; }
.pm-ships { list-style: none; margin: 6px 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 15px; }
.pm-ships .locked { opacity: .5; }
@media (max-aspect-ratio: 1/1) { .pmat { flex-direction: column; align-items: center; } .mat { width: min(600px, 86vw); } .pm-side { max-width: none; padding-right: 0; } }

/* Card parts keep their natural height (so a card whose text doesn't fit is measured as too full, and the text shrinks). */
.pl > * { flex-shrink: 0; }
.planets.wide .pl-act { flex: 1 0 auto; }

/* Your galaxy along the whole bottom (under the planets and the dice column). */
.galaxy { position: absolute; left: var(--left); right: calc(5px + var(--safe-r)); bottom: calc(2px + var(--safe-b)); z-index: 3; }
.galaxy:empty { display: none; }
.teg-main { bottom: calc(var(--galh, 0px) + 6px + var(--safe-b)); }
.teg-side { bottom: calc(var(--galh, 0px) + 6px + var(--safe-b)); }

/* The planet carousel: the real cards, full height, swipe sideways (‹ › when they don't all fit). */
.teg-main { position: absolute; }
.planets { display: flex; flex-direction: row; gap: 8px; align-items: center; justify-content: center; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; touch-action: pan-x; padding: 0 2px; scrollbar-width: none; grid-template-columns: none; }
.planets::-webkit-scrollbar { display: none; }
.planets.scrolls { justify-content: flex-start; }
.pk { position: relative; flex: none; height: var(--pkh, 200px); width: calc(var(--pkh, 200px) * .715); border-radius: calc(var(--pkh, 200px) * .035); background: #111 center / cover no-repeat; box-shadow: 0 4px 14px rgba(0,0,0,.6); scroll-snap-align: center; container-type: inline-size; cursor: pointer; }
.pk.hot { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(245,183,0,.7); }
.pk .ship { position: absolute; width: 15cqw; height: 15cqw; margin: -7.5cqw 0 0 -7.5cqw; font-size: 8cqw; border: .9cqw solid #fff; z-index: 2; box-shadow: 0 1cqw 2.4cqw rgba(0,0,0,.7); }
.pk .ship.mine { box-shadow: 0 0 0 .9cqw var(--gold), 0 1cqw 2.4cqw rgba(0,0,0,.7); }
.pk .sat { position: absolute; font-size: 9cqw; z-index: 2; }
.pk .go { position: absolute; left: 0; right: 0; margin: 0 auto; width: max-content; transform: none; font-size: max(13px, 8.5cqw); padding: 1.6cqw 5cqw; z-index: 3; }
.pk .go.land { top: 22%; }
.pk .go.orbitbtn { top: 36%; }
.pl-nav { position: absolute; top: 50%; z-index: 4; width: 30px; height: 52px; margin-top: -26px; border: 0; border-radius: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 28px; line-height: 1; }
.pl-nav.prev { left: -4px; }
.pl-nav.next { right: -4px; }
/* Super Weapon card (our own, the same shape). */
.pk.weapon { background: radial-gradient(circle at 50% 30%, #5a1020, #1c0408 70%); border: .8cqw solid #b31e2c; }
.wk-name { position: absolute; left: 5%; right: 18%; top: 4%; font-size: 8cqw; line-height: 1.1; }
.wk-pts { position: absolute; right: 5%; top: 4%; width: 13cqw; height: 13cqw; border-radius: 50%; background: #2e6bd6; display: grid; place-items: center; font: 900 8cqw system-ui, sans-serif; }
.wk-orb { position: absolute; left: 30%; top: 17%; width: 40%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 32% 30%, #ffb3b8, #b31e2c 55%, #3a0008); box-shadow: 0 0 6cqw rgba(255,60,80,.5); }
.wk-sats { position: absolute; left: 0; right: 0; top: 40%; text-align: center; font-size: 8cqw; }
.wk-cell { position: absolute; width: 16cqw; height: 16cqw; margin: -8cqw 0 0 -8cqw; border-radius: 3cqw; background: rgba(255,255,255,.12); border: .5cqw solid rgba(255,255,255,.35); display: grid; place-items: center; font: 800 7cqw system-ui, sans-serif; }
.wk-text { position: absolute; left: 6%; right: 6%; top: 64%; bottom: 4%; padding: 3cqw; border-radius: 3cqw; background: rgba(240,240,240,.92); color: #222; font-size: 6.5cqw; line-height: 1.2; overflow: hidden; }

/* The carousel is dragged by the page (mouse and finger alike). */
.planets { position: relative; touch-action: none; }
.planets.scrolls { cursor: grab; }
.planets.dragging, .planets.dragging .pk { cursor: grabbing; }
.planets.dragging .pk { user-select: none; }
.pk { -webkit-user-drag: none; user-select: none; }

/* Dice like the real ones: black cubes with the printed white symbols (PnP faces), rounded edges and a lit top. */
.dice { gap: calc(var(--die) * .16); padding: calc(var(--die) * .14); }
.dice .die, .rogue-die .die.big { position: relative; border-radius: calc(var(--die) * .2); background: radial-gradient(circle at 30% 22%, #4a4a52 0%, #1d1d22 45%, #08080a 100%); border: 0; box-shadow: inset 0 calc(var(--die) * .05) calc(var(--die) * .04) rgba(255,255,255,.22), inset 0 calc(var(--die) * -.07) calc(var(--die) * .06) rgba(0,0,0,.8), 0 calc(var(--die) * .07) 0 #000, 0 calc(var(--die) * .12) calc(var(--die) * .2) rgba(0,0,0,.55); overflow: hidden; }
.die .face { position: absolute; inset: 9%; background: center / contain no-repeat; border-radius: 12%; mix-blend-mode: screen; }
.dice .die.picked { box-shadow: 0 0 0 3px var(--gold), 0 0 14px rgba(245,183,0,.9), 0 calc(var(--die) * .07) 0 #000; }
.dice .die.active { box-shadow: 0 0 0 3px #fff, 0 0 12px rgba(255,255,255,.7), 0 calc(var(--die) * .07) 0 #000; }
.dice .die.used { opacity: .35; transform: scale(.9); }
.dice .die.spent { opacity: .2; filter: grayscale(1); transform: scale(.85); }
.rogue-die .die.big { width: calc(var(--die) * 1.2); height: calc(var(--die) * 1.2); box-shadow: 0 0 0 2px #e8505b, 0 0 14px rgba(232,80,91,.6), 0 calc(var(--die) * .07) 0 #000; }
.tok.ship-home { width: 7.5cqw; height: 7.5cqw; font-size: 4.2cqw; background: var(--sc); }

/* The dice box never shrinks below its dice (fitDice() sizes them to the room left). */
.dice { flex: none; gap: 6px; padding: 6px; min-height: 0; }

/* Two-row carousel (tall screens): cards fill top then bottom, column by column, and scroll sideways together. */
.planets.two { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, var(--pkh)); grid-auto-columns: calc(var(--pkh) * .715); grid-template-columns: none; gap: 8px; align-content: center; justify-content: center; }
.planets.two.scrolls { justify-content: start; }
