:root {
  /* the night look (this product's own): sea at dusk; the light look is chosen with the switch beside Home */
  --bg: #13283d;
  --bg2: #1d3852;
  --ink: #eef4f8;
  --inkDim: #a4b9c9;
  --line: #36536d;
  --accent: #ffb338;
  --accentInk: #3a2204;
  --sel: #2b4a66;
  --stageBg: #0c1c2c;
  --hudBg: rgba(10, 22, 34, 0.72);
  --hudInk: #f4f8fb;
  --mark: rgba(255, 210, 120, 0.92);
  --markInk: #2a1a02;
  --shade: rgba(14, 28, 42, 0.95);
  --toastBg: #f6fafc;
  --toastInk: #10202e;
  --danger: #f87171;
}
:root[data-theme="light"] {
  --bg: #eef3f7;
  --bg2: #dbe5ee;
  --ink: #10202e;
  --inkDim: #43586b;
  --line: #a8bccd;
  --accent: #8a5200;
  --accentInk: #ffffff;
  --sel: #c8d8e6;
  --stageBg: #1b3550;
  --hudBg: rgba(255, 255, 255, 0.85);
  --hudInk: #10202e;
  --mark: rgba(255, 196, 70, 0.95);
  --markInk: #2a1a02;
  --shade: rgba(238, 243, 247, 0.97);
  --toastBg: #10202e;
  --toastInk: #ffffff;
  --danger: #b91c1c;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%); color: var(--ink); user-select: none; -webkit-user-select: none; }
#app { height: 100%; display: flex; flex-direction: column; max-width: min(100%, 900px); margin: 0 auto; }
#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 15px; min-width: 44px; min-height: 44px; display: flex; align-items: center; cursor: pointer; justify-content: center; color: inherit; font-family: inherit; }
#hdrHome { border: none; background: var(--accent); color: var(--accentInk); font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--inkDim); }
.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 18px; gap: 10px; min-height: 0; overscroll-behavior: contain; }
.scr.on { display: flex; }
#scr-menu { align-items: center; text-align: center; justify-content: center; }
#scr-menu h1 { font-size: clamp(30px, 9vw, 46px); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; max-width: 34ch; }
.pick { width: 100%; display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 14px; }
.menuRow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
button.big { width: 100%; border-radius: 16px; min-height: 52px; font-size: 18px; font-weight: 800; background: var(--bg2); color: var(--ink); border: 3px solid var(--line); cursor: pointer; font-family: inherit; padding: 6px 10px; }
button.big:active { transform: translateY(2px); }
button.big.primary { background: var(--accent); border-color: var(--accent); color: var(--accentInk); }
button.big.danger { border-color: var(--danger); color: var(--danger); }
button.big:disabled { opacity: 0.45; cursor: default; }
#statsLine { color: var(--inkDim); font-weight: 700; font-size: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.seg button { flex: 1; min-height: 44px; min-width: 64px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; }
.seg button.sel { border-color: var(--accent); background: var(--sel); }

/* play: the seats, the island, your goods, the bar */
#scr-play { padding: 0 8px max(6px, env(safe-area-inset-bottom)); gap: 6px; }
#seats { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.seat { border: 3px solid var(--line); border-radius: 10px; padding: 3px 8px; font-weight: 800; font-size: 13px; background: var(--bg2); white-space: nowrap; }
.seat.now { background: var(--sel); }
#stageWrap { position: relative; flex: 1; min-height: 0; background: var(--stageBg); border-radius: 14px; overflow: hidden; touch-action: none; }
#stage { display: block; width: 100%; height: 100%; }
#marks { position: absolute; inset: 0; pointer-events: none; }
.mark { position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 0; background: none; color: var(--markInk); font-size: 18px; cursor: pointer; pointer-events: auto; display: flex; align-items: center; justify-content: center; padding: 0; }
/* R8.2 the tap area is 44 px; what is drawn is a small dot, so the numbers under it stay readable */
.mark::before { content: ""; width: 20px; height: 20px; border-radius: 50%; background: var(--mark); border: 3px solid var(--markInk); box-sizing: border-box; }
.mark.robber::before { width: 30px; height: 30px; }
#say { position: absolute; left: 8px; right: 8px; bottom: 8px; text-align: center; background: var(--hudBg); color: var(--hudInk); border-radius: 10px; padding: 5px 8px; font-weight: 800; font-size: 14px; pointer-events: none; }
#say:empty { visibility: hidden; }
#dice { position: absolute; right: 8px; top: 8px; background: var(--hudBg); color: var(--hudInk); border-radius: 10px; padding: 4px 8px; font-weight: 900; font-size: 15px; pointer-events: none; }
#dice:empty { visibility: hidden; }
#hand { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.good { min-width: 52px; text-align: center; background: var(--bg2); border: 2px solid var(--line); border-radius: 10px; padding: 3px 6px; font-weight: 800; font-size: 15px; }
.good.none { opacity: 0.5; }
#bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
button.act { min-height: 48px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg2); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 18px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
button.act span { font-size: 11.5px; }
button.act.primary { grid-column: 1 / -1; border-color: var(--accent); font-size: 17px; }   /* outlined: Home and the menu's big button are the two filled (game-ui-colour) */
button.act:disabled { opacity: 0.4; cursor: default; }
button.act[hidden] { display: none; }
#glFail { position: absolute; left: 12px; right: 12px; top: 30%; background: var(--shade); border: 3px solid var(--line); border-radius: 16px; padding: 14px; font-weight: 700; line-height: 1.5; text-align: center; }
#glFail[hidden], #fpsNow[hidden] { display: none; }
#fpsNow { position: absolute; left: 8px; top: 8px; background: var(--hudBg); color: var(--hudInk); border-radius: 8px; padding: 2px 6px; font: 700 12px ui-monospace, Menlo, monospace; }

/* a card over the board: trades, cards, giving back, the end */
.ovl { position: fixed; inset: 0; display: none; align-items: flex-start; justify-content: center; background: rgba(0, 0, 0, 0.45); z-index: 30; padding: 16px; overflow-y: auto; }
.ovl.on { display: flex; }
.ovlCard { width: min(100%, 420px); margin: auto; background: var(--shade); border: 3px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
#ovlTitle { font-weight: 900; font-size: 22px; text-align: center; }
#ovlSub { color: var(--inkDim); font-weight: 600; text-align: center; }
#ovlBtns { display: flex; flex-direction: column; gap: 8px; }
.goods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
button.gbtn { min-height: 48px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg2); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 16px; cursor: pointer; }
button.gbtn.sel { border-color: var(--accent); background: var(--sel); }
.lbl { font-weight: 700; font-size: 14px; color: var(--inkDim); }
.cards { display: flex; flex-direction: column; gap: 6px; }

.card { background: var(--bg2); border: 3px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.55; font-weight: 600; }
.setRow { display: flex; flex-direction: column; gap: 6px; }
.setNote { font-size: 13.5px; color: var(--inkDim); }
#toast { position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%); background: var(--toastBg); color: var(--toastInk); font-weight: 800; padding: 9px 16px; border-radius: 999px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 40; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* the game is not being saved (a write the storage did not take): shown until a write goes in */
#saveNote { padding: 6px 12px; font-size: 14px; font-weight: 700; line-height: 1.4; text-align: center; color: var(--ink); background: var(--bg2); border-bottom: 2px solid var(--danger); }
#saveNote[hidden] { display: none; }
