/* Cartographers — page furniture from the Ra & Write styles (old map browns); the map, cards and controls at the end. */
:root {
  --felt-glow: #8a6236; /* the glow at the top of the home page */
  --sheet: #2a1d10; /* pop-up window background */
  --felt: #4a3420;
  --felt-dark: #1c130a;
  --gold: #f5b700;
  --gold-deep: #c98a00;
  --ink: #1d1d1f;
  --paper: #fffdf6;
  --panel: rgba(28, 18, 8, 0.84);
  --text: #f4f1e8;
  --muted: #d2c2a4;
  --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);
}

button { font: inherit; color: inherit; }

/* ---------- shared bits ---------- */
#home, #lobby { -webkit-overflow-scrolling: touch; }
.home-wrap { padding: 24px 16px 48px; }
.brand { margin: 8px 0 20px; }
.brand h1 { font-size: 44px; margin: 8px 0 0; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,.3); }

.panel { box-shadow: 0 8px 24px rgba(0,0,0,.25); }

.btn { padding: 12px 18px; font-size: 17px; background: rgba(255,255,255,.12); }

.btn.ghost { background: transparent; }
.btn.danger { background: #a3242f; }
.btn.small { padding: 8px 12px; font-size: 15px; }

.count-picker button.on { color: var(--gold); }

.live-dot { background: #4be08c; box-shadow: 0 0 8px #4be08c; }

.avatar { width: 40px; height: 40px; font-size: 18px; }

/* ---------- 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 ---------- */

.sheet.narrow { width: 420px; }

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

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

@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 { animation: rise .2s ease-out; }

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

.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 | map | card ---------- */
#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); } }

/* ---------- 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; }
  .pchip .pc-score { font-size: 15px; }
  .lc-prompt { font-size: 13px; }
  .lc-actions .btn { padding: 6px 8px; font-size: 14px; }
}

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

/* 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); }

/* ================= Cartographers: the map, the cards, the controls ================= */
:root {
  --forest: #2f8a3c; --village: #b8352b; --farm: #d39327; --water: #2f78bd; --monster: #7a3fa0; --mountain: #5b3a22; --waste: #8e8a82;
  --paper-map: #f1e2bd; --grid: rgba(120, 85, 40, .35);
}
.felt {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.07), 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%, #6a4a2a 0%, var(--felt) 45%, var(--felt-dark) 100%);
}
.brand-icons { display: flex; justify-content: center; gap: 6px; }
.brand-icons span { width: 30px; height: 30px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.brand-icons .t-forest { background: var(--forest); } .brand-icons .t-village { background: var(--village); }
.brand-icons .t-farm { background: var(--farm); } .brand-icons .t-water { background: var(--water); } .brand-icons .t-monster { background: var(--monster); }
.count-picker.wrap { flex-wrap: wrap; }
.count-picker.wrap button { flex: 0 0 calc((100% - 40px) / 6); }
.count-picker button small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }

#table { --cell: 26px; --left: calc(104px + var(--safe-l)); --right: calc(min(300px, 36vw) + var(--safe-r)); }
.map-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; }

/* the map */
.cmap { --c: var(--cell); position: relative; display: grid; grid-template-columns: calc(var(--c) * .55) repeat(11, var(--c)); grid-auto-rows: var(--c); padding: calc(var(--c) * .15) calc(var(--c) * .3) calc(var(--c) * .1) calc(var(--c) * .1);
  background: var(--paper-map) linear-gradient(180deg, rgba(255,255,255,.3), rgba(120,80,20,.08)); border-radius: 8px; box-shadow: 0 10px 26px rgba(0,0,0,.45), inset 0 0 0 1px #c9a86a; color: #3b2a14; }
.cmap.small { --c: 15px; }
.cmap .rl { display: grid; place-items: center; font-size: calc(var(--c) * .42); font-weight: 800; color: #8a6a3a; }
.cmap .rl.cl { grid-column: auto; }
.sq { position: relative; border-right: 1px dashed var(--grid); border-bottom: 1px dashed var(--grid); display: grid; place-items: center; }
.sq.top { border-top: 2px solid #6b4a24; } .sq.bot { border-bottom: 2px solid #6b4a24; } .sq.lft { border-left: 2px solid #6b4a24; } .sq.rgt { border-right: 2px solid #6b4a24; }
.sq svg { width: 74%; height: 74%; }
.sq.t-forest { background: var(--forest); color: #d8f3c8; }
.sq.t-village { background: var(--village); color: #ffd9cc; }
.sq.t-farm { background: var(--farm); color: #fff0c4; }
.sq.t-water { background: var(--water); color: #d6ecff; }
.sq.t-monster { background: var(--monster); color: #f0d8ff; }
.sq.t-mountain { background: #6b4a2e; color: #f1e2bd; }
.sq.t-waste { background: repeating-linear-gradient(135deg, #a49f95 0 4px, #8e8a82 4px 8px); color: #555; }
.sq .ru { position: absolute; inset: 8%; color: #8a6a3a; opacity: .9; }
.sq .ru svg { width: 100%; height: 100%; }
.sq.filled .ru { inset: auto 0 0 auto; width: 46%; height: 46%; color: #fff; opacity: .95; filter: drop-shadow(0 0 1px #000); }
.sq.hurt::after { content: ''; position: absolute; inset: 2px; border-radius: 3px; box-shadow: inset 0 0 0 2px rgba(122,63,160,.85); }
@keyframes inkPop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
.sq.fresh { animation: inkPop .45s cubic-bezier(.2,1.6,.4,1); }
.sq.tap { cursor: pointer; }
/* pencilled preview */
.sq.pv { background: color-mix(in srgb, var(--pvc) 55%, transparent); outline: 2px dashed #1f2a44; outline-offset: -3px; color: #fff; }
.sq.pv.bad { background: rgba(214,40,58,.45); outline-color: #b0101e; }
.sq.ruin-want .ru { color: var(--gold); filter: drop-shadow(0 0 3px var(--gold)); animation: pulse 1.4s infinite; }
.map-tag { position: absolute; left: 50%; top: 0; transform: translate(-50%, -70%); z-index: 3; display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 4px; border-radius: 999px; background: var(--monster); color: #fff; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.4); font-weight: 800; font-size: 13px; }
.map-tag .avatar { width: 22px; height: 22px; font-size: 11px; }
.map-host { position: relative; }
.map-host.ambush .cmap { box-shadow: 0 0 0 4px var(--monster), 0 10px 26px rgba(0,0,0,.45); }

/* the explore card */
.card-box { display: flex; flex-direction: column; gap: 4px; }
.xcard { position: relative; border-radius: 10px; padding: 6px 8px 8px; background: linear-gradient(180deg, #3a2a1a, #21170d); border: 2px solid #8a6a3a; box-shadow: 0 6px 16px rgba(0,0,0,.45); }
.xcard.flipin { animation: cardIn .45s ease-out; }
@keyframes cardIn { from { transform: rotateY(90deg) scale(.9); opacity: .3; } to { transform: none; opacity: 1; } }
.xcard.ambush { background: linear-gradient(180deg, #4a2363, #2a1238); border-color: #b07ad6; }
.xcard .xc-head { display: flex; align-items: center; gap: 6px; font-family: Georgia, serif; font-weight: 800; font-size: 16px; }
.xcard .xc-time { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px 1px 3px; border-radius: 999px; background: rgba(255,255,255,.15); font-size: 13px; }
.xcard .xc-time svg { width: 13px; height: 13px; }
.xcard .xc-ruins { margin-left: auto; font-size: 11px; font-weight: 800; color: var(--gold); }
.xcard .xc-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tbtn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px 4px 4px; border-radius: 8px; border: 2px solid transparent; background: rgba(255,255,255,.08); font-size: 13px; font-weight: 700; }
.tbtn .sw { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; }
.tbtn .sw svg { width: 80%; height: 80%; }
.tbtn.on { border-color: var(--gold); background: rgba(245,183,0,.18); }
.tbtn:disabled { opacity: .35; }
.sbtn { display: inline-flex; align-items: center; gap: 4px; padding: 5px; border-radius: 8px; border: 2px solid transparent; background: rgba(255,255,255,.08); }
.sbtn.on { border-color: var(--gold); background: rgba(245,183,0,.18); }
.sbtn:disabled { opacity: .3; }
.shape { display: inline-grid; grid-template-columns: repeat(var(--sw), 12px); grid-auto-rows: 12px; gap: 1px; }
.shape i { border-radius: 2px; }
.shape i.on { background: #d9c9a3; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); }
.shape i.t-forest { background: var(--forest); } .shape i.t-village { background: var(--village); } .shape i.t-farm { background: var(--farm); }
.shape i.t-water { background: var(--water); } .shape i.t-monster { background: var(--monster); }
.coin-ic { display: inline-block; width: 16px; height: 16px; }
.coin-ic svg { width: 100%; height: 100%; }
.xc-arrow { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: #e9d3ff; }
.xc-arrow svg { width: 20px; height: 20px; }
.past { display: flex; flex-wrap: wrap; gap: 3px; }
.past span { font-size: 10.5px; padding: 1px 5px; border-radius: 6px; background: rgba(0,0,0,.3); color: var(--muted); }
.past span b { color: var(--text); }

/* the controls */
.lc-actions .row2 { display: flex; gap: 5px; }
.lc-actions .row2 .btn { flex: 1; padding: 8px 4px; white-space: nowrap; }
.lc-actions .row2 .btn.go { flex: 1.4; }
.lc-prompt b { color: var(--gold); }
.countdown { font-weight: 800; color: var(--gold); }

/* the edicts */
.edicts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: auto; }
.edict { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 4px 6px; border-radius: 8px; border: 2px solid transparent; background: rgba(0,0,0,.32); text-align: left; min-width: 0; }
.edict .ed-l { font-family: Georgia, serif; font-weight: 900; font-size: 14px; color: var(--gold); }
.edict .ed-n { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.edict .ed-s { font-size: 11px; color: var(--muted); }
.edict.now { border-color: var(--gold); background: rgba(245,183,0,.14); }
.edict.st-forest { box-shadow: inset 4px 0 0 var(--forest); } .edict.st-village { box-shadow: inset 4px 0 0 var(--village); }
.edict.st-farmwater { box-shadow: inset 4px 0 0 var(--water); } .edict.st-space { box-shadow: inset 4px 0 0 #b9b2a3; }

/* windows */
.maps-body { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-height: 78vh; overflow-y: auto; touch-action: pan-y; }
.map-card { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.map-card .sc-name { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.map-card .sc-name .avatar { width: 24px; height: 24px; font-size: 11px; }
.map-card.focus .cmap { box-shadow: 0 0 0 3px var(--gold), 0 10px 26px rgba(0,0,0,.45); }
table.scores td.neg { color: #ff8f8f; }
.title-banner { text-align: center; margin: 6px 0 12px; font-size: 18px; }
.title-banner b { display: block; font-family: Georgia, serif; font-size: 26px; color: var(--gold); }

@media (max-height: 360px) {
  .xcard { padding: 4px 6px 6px; }
  .xcard .xc-head { font-size: 14px; }
  .tbtn { padding: 2px 6px 2px 2px; font-size: 12px; }
  .tbtn .sw { width: 18px; height: 18px; }
  .shape { grid-template-columns: repeat(var(--sw), 10px); grid-auto-rows: 10px; }
  .edict { padding: 2px 5px; }
  .edicts { grid-template-columns: repeat(4, 1fr); }
  .edict .ed-l .ed-s { display: none; }
  .edict .ed-n { font-size: 11px; }
  .map-wrap { top: 34px; }
}
