/* PEAR: a colony terminal in Vroom's family (same fonts, same chunky controls), on Bartlett soil instead of
   screen blue. Single deliberate look, so no light/dark switch. Owners are a coloured ring plus a seat number;
   plot types are a coloured plate plus a letter, so nothing relies on colour alone. */
:root {
  color-scheme: dark;
  --frame: #5a3d1c;      /* soil */
  --screen: #2a2016;     /* panel ink */
  --card: #362a1d;
  --line: #5e4a33;
  --ink: #F3EBDD;
  --muted: #C9B79A;
  --accent: #BFCE72;     /* pear */
  --warn: #F08A5D;
  --flats: #4d6f37; --ridge: #75695c; --creek: #3c5aa0;
  --power: #F2C14E; --compute: #7FD1C7; --tokens: #D98CE0;
  /* seat colours: validated as a set (lightness, chroma, colour-blind and normal-vision separation, contrast)
     against the panel; the worst pair is in the 6-8 band, so a seat always shows its number beside its colour */
  --p1: #d55181; --p2: #3987e5; --p3: #c98500; --p4: #008300;
  --font-display: "Silkscreen", "Courier New", monospace;
  --font-body: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --tile: min(64px, calc((100vw - 32px - 8 * 4px) / 9));
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }
body { background: var(--frame); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.4; }
.app {
  min-height: 100vh; display: flex; flex-direction: column; gap: 12px; padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.bar { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.logo { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1; letter-spacing: .06em; color: var(--accent); }
.status { flex: 1 1 220px; min-width: 0; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.btn {
  font: 600 14px/1 var(--font-body); color: var(--ink); background: var(--screen);
  border: 2px solid var(--line); border-radius: 4px; padding: 9px 12px; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #1f1a0e; border-color: var(--accent); }
.btn:focus-visible, .tile:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.board { display: grid; grid-template-columns: minmax(0, auto) minmax(300px, 380px); gap: 16px; align-items: start; justify-content: center; }
.mapcol { display: grid; gap: 10px; min-width: 0; width: calc(9 * var(--tile) + 8 * 4px + 16px); max-width: 100%; }  /* fixed: hovering must not shift the layout */
.side { display: grid; gap: 10px; min-width: 0; }
/* one column on narrow screens: map, then whose turn it is, then the details */
@media (max-width: 920px) {
  .board { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .mapcol, .side { display: contents; }
  .banner { order: 0; } .auction { order: 1; } .map { order: 1; } .legend { order: 2; } .prompt { order: 3; } .inspect { order: 4; }
  .economy { order: 5; } .players { order: 6; } .logcard { order: 7; }
}

.card { background: var(--screen); border: 2px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.card h3, .field h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.banner { margin: 0; background: var(--accent); color: #1f1a0e; font-weight: 700; border-radius: 4px; padding: 8px 12px; }

/* map */
.map { display: grid; grid-template-columns: repeat(9, var(--tile)); gap: 4px; padding: 8px; background: #1d160e; border-radius: 6px; width: max-content; max-width: 100%; }
.tile {
  position: relative; width: var(--tile); height: var(--tile); padding: 0; border: 0; border-radius: 4px; cursor: pointer;
  color: var(--ink); font-family: var(--font-body); background: var(--flats);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.18);
}
.tile.t-ridge { background: var(--ridge); }
.tile.t-creek { background: var(--creek); }
.tile.store { background: #1f1a0e; box-shadow: inset 0 0 0 2px var(--accent); cursor: default; }
.tile.store .glyph { color: var(--accent); background: none; font-size: calc(var(--tile) * .12); width: auto; }
.tile.owned { box-shadow: inset 0 0 0 4px var(--owner), inset 0 0 0 5px rgba(0,0,0,.55); }  /* a dark edge keeps the ring readable on any ground */
.tile.pick { outline: 2px dashed var(--accent); outline-offset: -4px; }
.tile.sel { outline: 3px solid var(--ink); outline-offset: 1px; z-index: 1; }
.tile.fresh::after { content: ""; position: absolute; inset: 0; border-radius: 4px; background: rgba(255,255,255,.18); pointer-events: none; }
.tile .seat { position: absolute; left: 4px; top: 3px; font: 700 calc(var(--tile) * .17)/1 var(--font-display); color: var(--owner); text-shadow: 0 1px 0 #000; }
.tile .name { position: absolute; right: 4px; top: 3px; font-size: calc(var(--tile) * .15); color: rgba(255,255,255,.55); }
.tile .glyph {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 3px;
  font: 700 calc(var(--tile) * .26)/1 var(--font-display); color: #1f1a0e;
}
.ty-power { background: var(--power); } .ty-compute { background: var(--compute); } .ty-tokens { background: var(--tokens); }
.tile .badges { position: absolute; left: 4px; bottom: 2px; font-size: calc(var(--tile) * .17); font-weight: 700; letter-spacing: .05em; }
.tile .out { position: absolute; right: 4px; bottom: 2px; font-size: calc(var(--tile) * .16); font-weight: 700; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 #000; }
.tile .out.bad { color: var(--warn); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.sw.t-flats { background: var(--flats); } .sw.t-ridge { background: var(--ridge); } .sw.t-creek { background: var(--creek); }
.ty { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 3px; color: #1f1a0e; font: 700 11px/1 var(--font-display); }

/* inspect */
.inspect h4 { margin: 0 0 6px; font-size: 16px; }
.inspect p { margin: 4px 0; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 2px 16px; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.neg { color: var(--warn); } .pos { color: var(--accent); }

/* prompt */
.prompt .who { margin: 0 0 4px; font-family: var(--font-display); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--owner, var(--accent)); }
.prompt h2 { margin: 0 0 6px; font-size: 19px; }
.prompt p { margin: 0 0 10px; color: var(--muted); }
.actions { display: grid; gap: 6px; margin-bottom: 10px; }
.action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; text-align: left; padding: 8px 10px; }
.action small { grid-column: 1 / -1; font-weight: 400; font-size: 12px; color: var(--muted); line-height: 1.3; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.spin { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 8px; animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.results { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; margin-bottom: 10px; }
.results th, .results td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.results th:first-child, .results td:first-child { text-align: left; }
.results th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* players */
.players { display: grid; gap: 8px; }
.player { background: var(--screen); border: 2px solid var(--line); border-left: 6px solid var(--owner); border-radius: 6px; padding: 8px 12px; }
.player.turn { border-color: var(--owner); }
.player header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.player b { font-size: 15px; }
.player .sub { font-size: 12px; color: var(--muted); }
.player .score { font: 700 15px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.stock { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.stock span { color: var(--muted); } .stock span b { color: var(--ink); font-weight: 600; }
.toggles { display: grid; gap: 4px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.toggles label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.toggles input { accent-color: var(--accent); width: 16px; height: 16px; }

/* auction */
.auction { display: grid; gap: 10px; }
.auction header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.auction h2 { margin: 0; font-family: var(--font-display); font-size: 20px; }
.auction .clock { height: 10px; background: #1d160e; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.auction .clock i { display: block; height: 100%; background: var(--accent); }
.auction .clock.late i { background: var(--warn); }
.ladder { position: relative; height: min(360px, 52vh); display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; margin: 26px 0 18px; }
.axis { position: relative; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.axis span { position: absolute; right: 0; transform: translateY(50%); }
.axis span.store { color: var(--accent); font-weight: 700; white-space: nowrap; }
.lanes { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px;
  background: repeating-linear-gradient(to top, transparent 0, transparent calc(100% / 6 - 1px), rgba(255,255,255,.06) calc(100% / 6 - 1px), rgba(255,255,255,.06) calc(100% / 6)); }
.lanes::before, .lanes::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); opacity: .6; }
.lanes::before { top: 0; } .lanes::after { bottom: 0; }
.lane { position: relative; border-left: 1px dashed rgba(255,255,255,.12); }
.lane .chip { --chip-ink: #fff; position: absolute; left: 50%; transform: translate(-50%, 50%); min-width: 64px; text-align: center; padding: 4px 6px; border-radius: 4px;
  background: var(--owner); color: var(--chip-ink); font: 700 13px/1.1 var(--font-body); font-variant-numeric: tabular-nums; transition: bottom .1s linear; box-shadow: 0 2px 0 rgba(0,0,0,.4); }
.lane .chip small { display: block; font-weight: 600; font-size: 11px; }
.lane.done .chip { opacity: .45; }
.lane .tag { position: absolute; top: -2px; left: 50%; transform: translate(-50%, -100%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.dealline { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--ink); pointer-events: none; transform: translateY(1px); }
.dealline span { position: absolute; right: 0; transform: translateY(-100%); font-size: 12px; font-weight: 700; background: var(--screen); padding: 0 4px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font: 700 64px/1 var(--font-display); color: var(--accent); text-shadow: 0 3px 0 #000; pointer-events: none; }
.bidders { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px; }
.bidder { background: var(--card); border-left: 5px solid var(--owner); border-radius: 4px; padding: 6px 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.bidder b { font-size: 14px; } .bidder .sub { color: var(--muted); }
.pads { display: flex; gap: 6px; margin-top: 6px; }
.pads button { flex: 1 1 0; font: 700 18px/1 var(--font-body); padding: 10px 0; touch-action: none; user-select: none; -webkit-user-select: none; }

.aucintro { margin: 0; padding-left: 20px; display: grid; gap: 6px; max-width: 64ch; }
.roster { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.roster li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; background: var(--card); border-left: 5px solid var(--owner); border-radius: 4px; padding: 8px 10px; }
.roster .st { margin-left: auto; color: var(--muted); }
.lane.me .chip { outline: 2px solid var(--ink); outline-offset: 2px; }

/* charts */
.panel.wide { width: min(1100px, 100%); }
#charts { z-index: 11; }   /* over the results, so a finished game can be looked back on */
.row.spread { justify-content: space-between; align-items: flex-start; }
.filters { gap: 16px; color: var(--muted); }
.cgroup { display: grid; gap: 10px; margin-top: 6px; }
.cgroup > h3 { margin: 8px 0 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.chart { margin: 0; background: var(--card); border-radius: 6px; padding: 10px 12px; }
.chart figcaption { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.chart figcaption small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .cx { fill: var(--muted); font: 11px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .cl { fill: var(--ink); font: 600 11px var(--font-body); }
.chart .hit:focus { outline: none; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 1; }
.cplot { position: relative; }
.ctip { position: absolute; top: 4px; background: var(--screen); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; font-size: 12px; display: grid; gap: 2px; pointer-events: none; min-width: 120px; }
.ctip span, .clegend span { display: flex; align-items: center; gap: 6px; }
.clegend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.clegend i, .ctip i { display: inline-block; width: 12px; flex: none; }
.clegend i.bar, .ctip i.bar { height: 10px; border-radius: 2px 2px 0 0; }
.clegend i.line, .ctip i.line { height: 2px; border-radius: 1px; }
.ctable { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 6px; }
.ctable th, .ctable td { text-align: right; padding: 2px 6px; border-bottom: 1px solid var(--line); }
.ctable th:first-child, .ctable td:first-child { text-align: left; }
.seatsw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* online */
.updatenote { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--accent); color: #1f1a0e; border-radius: 4px; padding: 4px 6px 4px 10px; font-weight: 600; }
.updatenote .hint { color: #1f1a0e; }
.toggles select { padding: 2px 4px; font-size: 13px; }
.modeseg { justify-self: start; }
.err { margin: 0; color: var(--warn); min-height: 1.2em; }
#lobbyLinkText { flex: 1 1 260px; min-width: 0; }
.wgrid { display: grid; gap: 6px; justify-content: start; }
.wrow { display: grid; grid-template-columns: repeat(5, 46px); gap: 6px; }
.wt { height: 46px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 4px; font: 700 22px/1 var(--font-display); }
.wt.w-g { background: #5d8a3a; border-color: #5d8a3a; } .wt.w-y { background: #b8932c; border-color: #b8932c; } .wt.w-b { background: #3d3326; border-color: #3d3326; }
#guessInput, #hostWord, #joinWord { width: 8em; text-transform: uppercase; letter-spacing: .2em; font-family: var(--font-display); }
.seatpick { display: flex; gap: 8px; align-items: center; background: var(--card); border-left: 5px solid var(--owner); border-radius: 4px; padding: 8px 10px; cursor: pointer; }

/* a seat's next-round balance */
.bal { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr); gap: 1px 12px; margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.bal span { color: var(--muted); } .bal b { font-weight: 600; } .bal .h { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.bal .pos { color: var(--accent); } .bal .neg { color: var(--warn); }
.scroll { overflow-x: auto; }

/* economy */
.gauge { height: 14px; background: #1d160e; border-radius: 3px; overflow: hidden; margin: 4px 0 6px; border: 1px solid var(--line); }
.gauge i { display: block; height: 100%; background: var(--creek); }
.gauge.low i { background: var(--warn); }
.econ { display: grid; grid-template-columns: auto auto auto; gap: 2px 14px; justify-content: start; font-variant-numeric: tabular-nums; font-size: 14px; }
.econ span { color: var(--muted); }
.econ .h { color: var(--muted); font-size: 12px; }
.economy p { margin: 4px 0; font-size: 14px; }

/* log */
.log { margin: 0; padding-left: 18px; max-height: 220px; overflow: auto; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.log li.new { color: var(--ink); }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 10; overflow: auto; background: rgba(20, 15, 9, .92); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; }
.panel { width: min(760px, 100%); background: var(--screen); border: 2px solid var(--line); border-radius: 8px; padding: 22px 24px; display: grid; gap: 16px; }
.eyebrow { margin: 0; font-family: var(--font-display); font-size: 12px; letter-spacing: .12em; color: var(--accent); text-transform: uppercase; }
.panel h2 { margin: 2px 0 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; text-wrap: balance; }
.lede { margin: 8px 0 0; color: var(--muted); max-width: 62ch; }
.field { display: grid; gap: 8px; }
.seats { display: grid; gap: 8px; }
.seatrow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; align-items: center; background: var(--card); border-left: 6px solid var(--owner); border-radius: 4px; padding: 8px 10px; }
.seatrow .num { font: 700 16px/1 var(--font-display); color: var(--owner); }
.seatrow .controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seatrow .blurb { grid-column: 2; font-size: 12px; color: var(--muted); }
select, input { font: 600 14px/1.1 var(--font-body); color: var(--ink); background: var(--screen); border: 2px solid var(--line); border-radius: 4px; padding: 7px 8px; min-width: 0; }
input#seed { width: 9em; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { font: 600 13px/1 var(--font-body); color: var(--ink); background: var(--screen); border: 0; padding: 8px 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #1f1a0e; }
.hint { color: var(--muted); font-size: 13px; }
.rules p { margin: 0 0 10px; color: var(--ink); max-width: 70ch; }
.rules b { color: var(--accent); }
.ranking { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.ranking li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--card); border-left: 6px solid var(--owner); border-radius: 4px; padding: 10px 12px; font-variant-numeric: tabular-nums; }
.ranking .place { font: 700 18px/1 var(--font-display); color: var(--owner); }
.ranking small { display: block; color: var(--muted); }
.ranking .pts { font: 700 18px/1 var(--font-display); }

/* power auction: Bartlett's grid as a bidder, and the rungs above the store's price when its shelf is empty */
.lane.town .chip { outline: 2px dashed rgba(0,0,0,.45); outline-offset: -4px; }
.squeeze { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, rgba(243,235,221,.06) 0 6px, transparent 6px 12px);
  border-bottom: 1px dashed rgba(243,235,221,.35); pointer-events: none; }
.squeeze span { position: absolute; left: 6px; top: 4px; font-size: 11px; color: var(--muted); }
.townline { min-height: 1.2em; margin: 6px 0 0; }
