/* Ra & Write — page furniture from the Lost Cities styles (Nile night blue and sandstone); the scoresheet and cards at the end. */
:root {
  --felt-glow: #2f5f8f; /* the glow at the top of the home page */
  --sheet: #14213a; /* pop-up window background */
  --felt: #1b3557;
  --felt-dark: #0a1426;
  --gold: #f5b700;
  --gold-deep: #c98a00;
  --ink: #1d1d1f;
  --paper: #fffdf6;
  --panel: rgba(8, 16, 34, 0.84);
  --text: #f4f1e8;
  --muted: #b8c4d8;
  --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; }

/* go-out show */
.goout { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: radial-gradient(circle, rgba(245,183,0,.35), rgba(0,0,0,.85) 70%); animation: fade .25s ease-out; }
.goout canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.goout-inner { position: relative; text-align: center; }
.goout-crown { font-size: 22vh; line-height: 1; animation: crownDrop .9s cubic-bezier(.2,1.6,.4,1) both, float 1.6s ease-in-out .9s infinite; filter: drop-shadow(0 0 30px rgba(245,183,0,.9)); }
.goout-name { font-family: Georgia, serif; font-size: 11vh; font-weight: 900; color: #fff; text-shadow: 0 0 20px var(--gold), 0 4px 0 #8a5d00; animation: zoomIn .6s .3s cubic-bezier(.2,1.6,.4,1) both; }
.goout-sub { font-size: 7vh; font-weight: 900; letter-spacing: 6px; color: var(--gold); text-shadow: 0 3px 0 #5a3d00; animation: zoomIn .6s .55s cubic-bezier(.2,1.6,.4,1) both; }
.goout-note { margin-top: 10px; font-size: 3.2vh; color: #fff; opacity: .9; animation: fade .6s 1s both; }
.goout.shake { animation: shake .5s ease-in-out; }

.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); } }

/* ================= Ra & Write ================= */
.felt {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.08), transparent 60%),
    repeating-radial-gradient(circle at 30% 30%, rgba(0,0,0,.03) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 40%, #2c5487 0%, var(--felt) 45%, var(--felt-dark) 100%);
}
.lc-title { font-family: Georgia, "Times New Roman", serif; }
.lc-title em { display: block; font-family: Kalam, "Comic Sans MS", cursive; font-style: normal; font-size: .5em; color: var(--gold); letter-spacing: 1px; }
.trump-pill { background: rgba(0,0,0,.35); padding: 3px 12px; border-radius: 999px; font-size: 15px; font-weight: 900; }

/* ---------- the table: players | sheet | dice ---------- */
#table { --cell: 30px; --die: 50px; --left: calc(104px + var(--safe-l)); --right: calc(min(220px, 27vw) + var(--safe-r)); }
.lc-players { position: absolute; left: 0; top: 42px; 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; z-index: 3; overflow-y: auto; touch-action: pan-y; }
.pchip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 4px 6px; border-radius: 10px; border: 2px solid transparent; background: rgba(0,0,0,.32); text-align: left; width: 100%; flex: none; }
.pchip .pc-top { display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; }
.pchip .avatar { width: 22px; height: 22px; font-size: 11px; border-width: 1.5px; }
.pchip b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchip .pc-score { font-size: 17px; font-weight: 900; line-height: 1; }
.pchip .pc-score small { font-size: 10px; color: var(--muted); font-weight: 600; }
.pchip .pc-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pchip.me { background: rgba(0,0,0,.45); border-color: rgba(255,255,255,.18); }
.pchip.roller { border-color: var(--gold); }
.pchip.roller .pc-sub { color: var(--gold); font-weight: 700; }
.pchip.done .pc-sub { color: #8fe3a8; }
.pchip.flash { animation: chipFlash .7s ease-out; }
@keyframes chipFlash { 0% { background: rgba(245,183,0,.6); } 100% { background: rgba(0,0,0,.32); } }

.sheet-wrap { position: absolute; left: var(--left); right: var(--right); top: 40px; bottom: calc(2px + var(--safe-b)); display: grid; place-items: center; z-index: 2; }
.sheet-wrap > .hint { text-align: center; }

/* ---------- right: dice, prompt, buttons ---------- */
.lc-right { position: absolute; right: 0; top: 42px; bottom: calc(4px + var(--safe-b)); width: var(--right); padding: 0 calc(6px + var(--safe-r)) 0 4px; display: flex; flex-direction: column; gap: 6px; z-index: 3; overflow-y: auto; touch-action: pan-y; }
.lc-prompt { font-size: 14px; line-height: 1.3; padding: 2px 4px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.lc-prompt .sw, table.scores .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 3px; vertical-align: -1px; border: 1px solid rgba(255,255,255,.6); }
.lc-actions { display: flex; flex-direction: column; gap: 5px; }
.lc-actions .btn { padding: 8px 10px; font-size: 15px; width: 100%; }
.lc-actions .btn small { font-weight: 600; font-size: 12px; opacity: .85; }

/* ---------- everyone's sheets + the end ---------- */
.sheets-body { display: flex; flex-direction: column; gap: 12px; align-items: center; max-height: 76vh; overflow-y: auto; touch-action: pan-y; }
.sheet-card { display: flex; flex-direction: column; gap: 4px; }
.sc-name { display: flex; align-items: center; gap: 6px; }
.sc-name .avatar { width: 26px; height: 26px; font-size: 12px; }
#sheetsWin .sheet, #final .sheet { max-height: 94vh; overflow: auto; touch-action: pan-y; }
table.final-table td .avatar { width: 22px; height: 22px; font-size: 11px; display: inline-grid; vertical-align: middle; }

/* short screens */
@media (max-height: 360px) {
  .topbar { padding-top: 3px; }
  .icon-btn { height: 30px; min-width: 30px; }
  .round-info { font-size: 14px; }
  .trump-pill { font-size: 13px; padding: 2px 8px; }
  .lc-players, .lc-right { top: 36px; }
  .sheet-wrap { top: 34px; }
  .pchip .pc-score { font-size: 15px; }
  .lc-prompt { font-size: 13px; }
  .lc-actions .btn { padding: 6px 8px; font-size: 14px; }
}
@media (min-height: 500px) {
  .ra-sheet.small { --c: 26px; }
}

.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; }

/* Holding a player's name shows their sheet in place of yours */
.pchip { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: pan-y; }
.pchip.peeking { border-color: #fff; background: rgba(255,255,255,.22); }
.peek-wrap { position: relative; }
.peek-wrap .ra-sheet { box-shadow: 0 0 0 4px #fff, 0 10px 26px rgba(0,0,0,.45); }
.peek-tag { position: absolute; left: 50%; top: 0; transform: translate(-50%, -60%); z-index: 3; display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 4px; border-radius: 999px; background: #fff; color: #222; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.peek-tag .avatar { width: 24px; height: 24px; font-size: 11px; }
.peek-tag small { color: #777; font-size: 11px; }

/* ================= Ra & Write: the scoresheet, the cards ================= */
.trump-pill { display: inline-flex; align-items: center; gap: 6px; }
.trump-pill small { font-size: 11px; font-weight: 700; color: var(--muted); }
.ra-suns { display: inline-flex; gap: 2px; }
.ra-suns .sun { width: 20px; height: 20px; opacity: .3; filter: grayscale(1); }
.ra-suns .sun.on { opacity: 1; filter: none; animation: inkPop .5s cubic-bezier(.2,1.6,.4,1); }
.ra-suns svg { width: 100%; height: 100%; }
.kname { color: var(--hg); filter: brightness(1.35); }

#table { --cell: 28px; --right: calc(min(230px, 28vw) + var(--safe-r)); }

/* the paper */
.ra-sheet {
  --c: var(--cell);
  display: flex; flex-direction: column; gap: calc(var(--c) * .08); padding: calc(var(--c) * .22) calc(var(--c) * .25);
  border-radius: 10px; color: #3b2a14; font-size: calc(var(--c) * .42);
  background: #f3e3bf linear-gradient(180deg, rgba(255,255,255,.35), rgba(120,80,20,.06)), repeating-linear-gradient(90deg, rgba(150,110,50,.05) 0 3px, transparent 3px 7px);
  box-shadow: 0 10px 26px rgba(0,0,0,.45), inset 0 0 0 1px #cdb27a;
}
.ra-sheet.small { --c: 22px; }
.ra-sheet .srow { display: flex; align-items: center; gap: calc(var(--c) * .15); }
.ra-sheet .srow.first { margin-top: calc(var(--c) * .12); }
.ra-sheet .lab { width: calc(var(--c) * 1.1); height: var(--c); display: grid; place-items: center; flex: none; }
.ra-sheet .lab svg { width: 88%; height: 88%; }
.ra-sheet .lab.kl { font-family: Georgia, serif; font-weight: 900; color: var(--hg); font-size: calc(var(--c) * .5); }
.ra-sheet .cont { width: calc(var(--c) * 12); display: grid; gap: 2px; flex: none; }
.ra-sheet .c12 { grid-template-columns: repeat(12, 1fr); }
.ra-sheet .c5 { grid-template-columns: repeat(5, 1fr); }
.ra-sheet .c8 { grid-template-columns: repeat(8, 1fr); }
.ra-sheet .cell { position: relative; height: var(--c); border-radius: 4px; display: grid; place-items: center; border: 1.5px solid rgba(60,35,10,.22); }
.ra-sheet .r-civ .cell, .ra-sheet .r-mon .cell { height: calc(var(--c) * .8); }
.ra-sheet .r-civ .lab, .ra-sheet .r-mon .lab { height: calc(var(--c) * .8); }
.ra-sheet .ink { font-family: Kalam, cursive; font-weight: 700; color: #1f3fae; font-size: calc(var(--c) * .64); line-height: 1; transform: rotate(-4deg); }
.ra-sheet .scr { position: absolute; inset: 10%; width: 80%; height: 80%; }
.ra-sheet .badge { position: absolute; right: -3px; bottom: -3px; width: calc(var(--c) * .42); height: calc(var(--c) * .42); border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); display: grid; place-items: center; }
.ra-sheet .badge svg { width: 80%; height: 80%; }
/* sections in the sheet's colours */
.ra-sheet .god { background: #f6c99a; border-top: 3px solid var(--hg); }
.ra-sheet .god.cur { box-shadow: inset 0 0 0 1.5px var(--hg); }
.ra-sheet .gtot { background: #fff4e0; border-radius: 50%; border: 1.5px dashed var(--hg); color: #8a6a3a; }
.ra-sheet .gtot i { font-style: normal; font-weight: 900; opacity: .5; }
.ra-sheet .gtot .ink { font-size: calc(var(--c) * .5); }
.ra-sheet .phar { background: #b9dcb3; }
.ra-sheet .phar.b-nile { border-color: #1d6fb8; }
.ra-sheet .nile { background: #b6d6f0; }
.ra-sheet .nile.part-end { margin-right: calc(var(--c) * .14); }
.ra-sheet .badge.civ { background: #fff6dc; }
.ra-sheet .civ { background: #f1e6cf; }
.ra-sheet .civ.cur { background: #fbe9c3; border-color: rgba(200,120,20,.6); }
.ra-sheet .mon { background: #d9c9ea; }
.ra-sheet .mon.done { border-color: #f5b700; box-shadow: inset 0 0 0 1.5px #f5b700; }
.ra-sheet .wm { position: absolute; inset: 8%; display: grid; place-items: center; opacity: .5; }
.ra-sheet .wm svg { width: 100%; height: 100%; }
.ra-sheet .full .wm { opacity: .3; }
/* scores: each Kingdom, then the section total */
.ra-sheet .scs { display: flex; gap: 2px; flex: none; width: calc(var(--c) * 4.5); align-items: center; }
.ra-sheet .scs.side { justify-content: center; }
.ra-sheet .scs small { font-size: calc(var(--c) * .36); font-weight: 800; color: #8a5a1a; }
.ra-sheet .ks { width: var(--c); height: calc(var(--c) * .86); border-radius: 4px; display: grid; place-items: center; font-weight: 900; background: #fffaf0; border: 1.5px solid var(--hg); color: #3b2a14; }
.ra-sheet .ks.empty { opacity: .45; }
.ra-sheet .ks.now { opacity: .9; border-style: dashed; }
.ra-sheet .ks.blank, .ra-sheet .kt.blank { visibility: hidden; }
.ra-sheet .kt { width: calc(var(--c) * 1.35); height: var(--c); border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: #fff; border: 2px solid #8a6a3a; font-size: calc(var(--c) * .48); }
.ra-sheet .r-tot { margin-top: calc(var(--c) * .1); }
.ra-sheet .totline { display: flex; align-items: center; font-size: calc(var(--c) * .34); line-height: 1.15; color: #7a5a2a; }
.ra-sheet .totline .hint { color: #8a6a3a; font-size: 1em; }
.ra-sheet .bon { font-weight: 900; color: #2a7a3a; font-size: calc(var(--c) * .5); }
.ra-sheet .grand { width: calc(var(--c) * 2.2); height: var(--c); margin-left: auto; border-radius: 8px; display: grid; place-items: center; font-family: Georgia, serif; font-weight: 900; font-size: calc(var(--c) * .6); background: #fff8; border: 2px solid #8a6a3a; }
/* taps, pencil and fresh ink */
.ra-sheet .tgt { cursor: pointer; z-index: 1; box-shadow: 0 0 0 2.5px var(--gold), 0 0 12px rgba(245,183,0,.85); animation: ghostPulse 1.1s ease-in-out infinite; }
.ra-sheet .ghost { box-shadow: 0 0 0 2.5px var(--gold), 0 0 12px rgba(245,183,0,.8); z-index: 1; animation: ghostPulse 1.1s ease-in-out infinite; }
.ra-sheet .ghost .ink, .ra-sheet .ghost .scr { opacity: .5; }
.ra-sheet .fresh .ink, .ra-sheet .fresh .scr { animation: inkPop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes ghostPulse { 50% { box-shadow: 0 0 0 2.5px var(--gold), 0 0 4px rgba(245,183,0,.4); } }
@keyframes inkPop { from { transform: scale(2.2) rotate(-12deg); opacity: 0; } }
.peek-wrap .ra-sheet { box-shadow: 0 0 0 4px #fff, 0 10px 26px rgba(0,0,0,.45); }

/* ---------- the three cards ---------- */
.card-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 6px 9px; border-radius: 14px; background: rgba(0,0,0,.28); flex: none; }
.card-tray .slot { position: relative; padding: 0; border: 0; background: none; border-radius: 10px; transition: transform .15s; }
.card-tray .slot:disabled { cursor: default; }
.card-tray .slot.can { cursor: pointer; }
.card-tray .slot.can .racard { box-shadow: 0 0 0 2px rgba(245,183,0,.6), 0 4px 10px rgba(0,0,0,.45); }
.card-tray .slot.sel { transform: translateY(-5px); }
.card-tray .slot.sel .racard { box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(245,183,0,.9); }
.card-tray .slot.reserved .racard { filter: saturate(.6) brightness(.85); }
.card-tray .slot.nofit .racard { opacity: .6; }
.card-tray .slot.flip .racard { animation: cardFlip .4s ease-out; }
@keyframes cardFlip { from { transform: rotateY(90deg) scale(.9); } to { transform: none; } }
.res-tag { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); font-size: 10px; font-weight: 900; background: var(--gold); color: #3a2800; padding: 0 5px; border-radius: 4px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.whos { position: absolute; left: 2px; right: 2px; bottom: -6px; display: flex; justify-content: center; gap: 2px; flex-wrap: wrap; }
.whos .who { width: 16px; height: 16px; border-radius: 50%; background: var(--pc); color: #fff; font-size: 10px; font-weight: 900; display: grid; place-items: center; border: 1.5px solid #fff; }

.racard { --band: #c8a060; position: relative; width: 100%; aspect-ratio: 5 / 7; border-radius: 9px; overflow: hidden; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #fffaf0, #f0dcb0); border: 2px solid #5a3a14; box-shadow: 0 4px 10px rgba(0,0,0,.45); color: #2a1d0e; }
.racard .rc-band { position: absolute; left: 0; right: 0; top: 0; height: 16%; background: var(--band); border-bottom: 2px solid #5a3a14; }
.racard .rc-icon { width: 62%; aspect-ratio: 1; margin-top: 6%; display: grid; place-items: center; }
.racard .rc-icon svg { width: 100%; height: 100%; }
.racard .rc-num { position: absolute; left: 6%; top: 1%; font-family: Georgia, serif; font-size: clamp(14px, 2.4vh, 24px); font-weight: 900; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); line-height: 1.2; }
.racard .rc-name { position: absolute; left: 0; right: 0; bottom: 4%; text-align: center; font-size: clamp(9px, 1.6vh, 13px); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; }
.racard.k-god { --band: #e07a2e; }
.racard.k-nile { --band: #1d6fb8; }
.racard.k-phar { --band: #3d9a4a; }
.racard.k-civ { --band: #c9a35a; }
.racard.k-mon { --band: #7b4fae; }
.racard.k-ra, .racard.back { --band: #c0392b; background: radial-gradient(circle at 50% 45%, #f0a43a, #8a2a12); }
.racard.back .rc-icon { margin: 0; opacity: .8; }

/* Ra! */
.ra-banner { position: fixed; inset: 0; margin: auto; width: max-content; height: max-content; z-index: 75; text-align: center; padding: 14px 30px; border-radius: 20px; background: rgba(40,10,0,.75); box-shadow: 0 0 60px rgba(240,140,40,.7); pointer-events: none; animation: zoomIn .5s cubic-bezier(.2,1.6,.4,1) both, fadeOut .4s 1.1s forwards; }
.ra-banner .rb-sun { width: 90px; height: 90px; margin: 0 auto; animation: spin 3s linear infinite; }
.ra-banner .rb-sun svg { width: 100%; height: 100%; }
.ra-banner .rb-text { font-family: Georgia, serif; font-size: 44px; font-weight: 900; color: #ffd166; text-shadow: 0 3px 0 #7a2a00; }
.ra-banner .rb-sub { font-size: 16px; font-weight: 700; color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Kingdom scores, the number picker */
table.ktable th svg { width: 24px; height: 24px; vertical-align: middle; }
table.ktable td.pos { color: #8fe3a8; } table.ktable td.neg { color: #ff8f8f; }
table.ktable td .avatar { width: 22px; height: 22px; font-size: 11px; display: inline-grid; vertical-align: middle; }
#kingdomWin .sheet { max-height: 94vh; overflow: auto; touch-action: pan-y; }
.num-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.num-grid .num { padding: 10px 0; border-radius: 10px; border: 2px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); font-size: 18px; font-weight: 800; }
.num-grid .num:not(:disabled) { border-color: var(--gold); background: rgba(245,183,0,.18); }
.num-grid .num:disabled { opacity: .25; }

.lc-prompt small { opacity: .8; }
@media (max-height: 360px) { .card-tray { padding: 4px 4px 8px; gap: 4px; } }

/* The cards stacked down the right edge; the prompt and buttons in the top bar; the sheet gets the rest. */
.topbar { gap: 8px; align-items: center; }
.round-info { flex-direction: column; align-items: flex-start; gap: 0; width: calc(var(--left) - 14px); flex: none; font-size: 14px; line-height: 1.15; }
.trump-pill { padding: 1px 6px; font-size: 12px; }
.trump-pill:empty { display: none; }
.ra-suns .sun { width: 17px; height: 17px; }
.ra-bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; pointer-events: auto; min-height: 36px; }
.ra-bar .lc-prompt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.2; padding: 0; max-height: 2.5em; overflow: hidden; }
.ra-bar .lc-actions { flex-direction: row; flex: none; gap: 6px; }
.ra-bar .lc-actions .btn { width: auto; padding: 6px 12px; font-size: 14px; white-space: nowrap; margin: 0; }
.lc-players, .lc-right, .sheet-wrap { top: 44px; }
.lc-right { padding: 0 calc(6px + var(--safe-r)) 0 4px; overflow: visible; }
.card-tray { height: 100%; box-sizing: border-box; grid-template-columns: 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px 4px 8px; align-items: center; justify-items: center; }
.card-tray .slot { height: 100%; aspect-ratio: 5 / 7; max-width: 100%; }
.card-tray .slot .racard { width: 100%; height: 100%; aspect-ratio: auto; }
.card-tray .slot.sel { transform: translateX(-6px); }
.racard .rc-num { font-size: clamp(14px, 3.4vh, 30px); }
.racard .rc-name { font-size: clamp(9px, 2.1vh, 15px); }
@media (max-height: 360px) {
  .lc-players, .lc-right, .sheet-wrap { top: 40px; }
  .ra-bar .lc-prompt { font-size: 13px; }
  .ra-bar .lc-actions .btn { padding: 5px 10px; font-size: 13px; }
  .icon-btn span { display: none; }
}

/* (the sheet's rows are .srow: the page's general .row wraps and adds a gap) */
.ra-sheet .totline .hint { margin: 0; }
.card-tray .slot.empty { visibility: hidden; }

/* Your sheet's rows are as tall as the screen allows (--rowh, up to 1.8 × the box width); the small sheets keep square boxes. */
.ra-sheet { --h: var(--c); }
#mySheet .ra-sheet { --h: var(--rowh, var(--c)); }
.ra-sheet .lab, .ra-sheet .cell, .ra-sheet .kt, .ra-sheet .grand { height: var(--h); }
.ra-sheet .r-civ .cell, .ra-sheet .r-mon .cell, .ra-sheet .r-civ .lab, .ra-sheet .r-mon .lab { height: calc(var(--h) * .8); }
.ra-sheet .ks { height: calc(var(--h) * .86); }
.ra-sheet .ink { font-size: min(calc(var(--c) * .8), calc(var(--h) * .64)); }
.ra-sheet .gtot .ink { font-size: min(calc(var(--c) * .55), calc(var(--h) * .5)); }
.ra-sheet .wm { inset: 10% 8%; }

/* The sheet sits on the dark table (its papyrus background never applied — kept dark as the owner has been using it),
   so its loose text is light. */
.ra-sheet { background: transparent; }
.ra-sheet .totline, .ra-sheet .totline .hint { color: #fff; font-size: max(13px, calc(var(--c) * .42)); line-height: 1.25; }
.ra-sheet .scs small { color: #ffd98a; font-size: max(12px, calc(var(--c) * .38)); }
.ra-sheet .bon { color: #8fe3a8; }
/* Bigger score numbers: each Kingdom's score and the section total. */
.ra-sheet .ks { font-size: min(calc(var(--c) * .56), calc(var(--h) * .5)); }
.ra-sheet .kt { font-size: min(calc(var(--c) * .64), calc(var(--h) * .56)); }
.ra-sheet .grand { font-size: min(calc(var(--c) * .72), calc(var(--h) * .62)); }
