:root {
  --ink: #2b1d18; --panel: rgba(43, 29, 24, 0.93); --panel2: rgba(66, 46, 36, 0.95); --line: rgba(243, 234, 212, 0.18);
  --paper: #f3ead4; --muted: #cdbfa4; --H: #1fb3a6; --P: #f0a03a; --me: #1fb3a6; --them: #f0a03a; --red: #e0533d; --gold: #f6c453;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom); --sal: env(safe-area-inset-left); --sar: env(safe-area-inset-right);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #d9cdb2; color: var(--paper); font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.touch { -webkit-user-select: none; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.45; cursor: default; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; }
body.touch .key-only, body:not(.touch) .touch-only { display: none; }
#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--ink); z-index: 50; }
#loading b { font-family: "Playfair Display", Georgia, serif; font-size: 34px; letter-spacing: 6px; color: var(--paper); }
#loading span { color: var(--muted); }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud > .feed { pointer-events: none; }   /* the news feed is display only: taps go through to the map */
.bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: max(6px, var(--sat)) max(10px, var(--sar)) 6px max(10px, var(--sal));
  background: linear-gradient(180deg, rgba(43, 29, 24, 0.95), rgba(43, 29, 24, 0.82)); border-bottom: 2px solid rgba(243, 234, 212, 0.12); }
.b-day { display: flex; align-items: center; gap: 8px; }
.b-day b { font-family: "Playfair Display", Georgia, serif; font-size: 18px; white-space: nowrap; }
.b-day > span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.speed { display: flex; gap: 2px; background: rgba(0, 0, 0, 0.25); border-radius: 8px; padding: 2px; }
.speed button { background: transparent; border: 0; border-radius: 6px; padding: 3px 7px; font-weight: 800; font-size: 12.5px; color: var(--muted); }
.speed button.on { background: var(--paper); color: var(--ink); }
.b-res { display: flex; gap: 14px; align-items: center; margin-left: auto; }
.res { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.res i { font-style: normal; } .res b { font-variant-numeric: tabular-nums; font-size: 15px; }
.res small { font-size: 11px; color: var(--muted); } .res small.neg { color: var(--red); }
.bar2 { width: 70px; height: 8px; border-radius: 5px; background: rgba(0, 0, 0, 0.35); overflow: hidden; display: block; }
.bar2 u { display: block; height: 100%; width: 30%; background: var(--gold); transition: width 0.3s; }
.b-poll { min-width: 210px; font-size: 12.5px; }
.b-poll .pl { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.b-poll .pb { position: relative; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.35); overflow: hidden; margin-top: 3px; }
.b-poll .pb u { position: absolute; top: 0; bottom: 0; } .b-poll .pb i { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--paper); }
.b-poll small { color: var(--muted); font-size: 11px; }
.b-menu { width: 36px; height: 36px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); font-size: 17px; }
.feed { position: absolute; top: calc(max(6px, var(--sat)) + 52px); left: max(10px, var(--sal)); width: min(330px, 34vw); display: flex; flex-direction: column; gap: 4px; pointer-events: none !important; }
.feed p { margin: 0; font-size: 12.5px; line-height: 1.35; background: rgba(43, 29, 24, 0.8); padding: 5px 9px; border-radius: 8px; border-left: 3px solid var(--muted); animation: in 0.3s; }
.feed p.me { border-left-color: var(--me); } .feed p.them { border-left-color: var(--them); } .feed p.beat { border-left-color: var(--gold); background: rgba(80, 58, 20, 0.88); }
.feed p.old { opacity: 0.55; }
@keyframes in { from { transform: translateX(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.cards { position: absolute; top: calc(max(6px, var(--sat)) + 52px); right: max(10px, var(--sar)); width: min(320px, 36vw); display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--paper); color: var(--ink); border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(30, 20, 15, 0.45); border: 2px solid var(--ink); animation: in 0.3s; }
.card header { display: flex; gap: 8px; align-items: center; font-weight: 900; font-size: 15px; }
.card header i { font-style: normal; font-size: 20px; }
.card p { margin: 4px 0 8px; font-size: 13px; line-height: 1.4; }
.card .opts { display: flex; flex-direction: column; gap: 5px; }
.card .opts button { text-align: left; background: #fffaf0; border: 1.5px solid var(--ink); border-radius: 8px; padding: 6px 9px; font-weight: 800; font-size: 13px; }
.card .opts button:hover { background: var(--ink); color: var(--paper); }
.card .timer { height: 4px; background: rgba(43, 29, 24, 0.15); border-radius: 3px; margin-top: 8px; overflow: hidden; } .card .timer u { display: block; height: 100%; background: var(--red); }
.coach { position: absolute; z-index: 3; left: 50%; transform: translateX(-50%); top: calc(max(6px, var(--sat)) + 58px); max-width: min(460px, 80vw); background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; padding: 9px 34px 9px 13px; font-weight: 800; font-size: 14px; box-shadow: 0 8px 24px rgba(30, 20, 15, 0.4); }
.coach button { position: absolute; top: 4px; right: 5px; background: transparent; border: 0; font-size: 14px; color: var(--ink); }
.panel { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, var(--sab)); width: min(620px, calc(100vw - 240px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(30, 20, 15, 0.45); }
.panel:empty { display: none; }
.panel h3 { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 18px; display: flex; align-items: baseline; gap: 8px; }
.panel h3 small { font-family: "Nunito", sans-serif; font-size: 12px; color: var(--muted); font-weight: 700; }
.panel .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.panel .act { background: var(--paper); color: var(--ink); border: 0; border-radius: 9px; padding: 7px 11px; font-weight: 900; font-size: 13px; }
.panel .act small { font-weight: 700; opacity: 0.75; margin-left: 4px; }
.panel .act.ghost { background: transparent; color: var(--paper); border: 1px solid var(--line); }
.panel .why { font-size: 12px; color: var(--muted); }
.panel .units { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.panel .units span { background: rgba(0, 0, 0, 0.25); border-radius: 7px; padding: 2px 7px; font-size: 12.5px; }
.panel .est { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; margin-top: 6px; align-items: center; }
.panel .sbar { height: 10px; border-radius: 5px; overflow: hidden; display: flex; background: rgba(0, 0, 0, 0.3); }
.panel .sbar u { display: block; height: 100%; }
.panel .train { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.panel .train button { background: rgba(243, 234, 212, 0.08); border: 1px solid var(--line); border-radius: 10px; padding: 6px; text-align: center; font-size: 12px; font-weight: 800; line-height: 1.25; }
.panel .train button i { display: block; font-style: normal; font-size: 18px; }
.panel .train button small { display: block; color: var(--muted); font-weight: 700; }
.panel .x { position: absolute; top: 6px; right: 8px; background: transparent; border: 0; color: var(--muted); font-size: 15px; }
.dock { position: absolute; left: max(10px, var(--sal)); bottom: max(10px, var(--sab)); display: flex; flex-direction: column; gap: 6px; }
.dock button { width: 58px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 5px 0 4px; font-size: 18px; line-height: 1.1; }
.dock button span { display: block; font-size: 10.5px; font-weight: 800; color: var(--muted); }
.night { position: absolute; top: calc(max(6px, var(--sat)) + 56px); left: 50%; transform: translateX(-50%); width: min(640px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; text-align: center; }
.night .kicker { margin: 0 0 4px; }
.tally { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 10px; align-items: center; }
.t-side b { display: block; font-family: "Playfair Display", Georgia, serif; font-size: 16px; } .t-side span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.t-side.l { text-align: left; } .t-side.r { text-align: right; }
.t-bar { position: relative; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.t-bar u { position: absolute; top: 0; bottom: 0; transition: width 0.5s; } .t-bar u:first-child { left: 0; } .t-bar u:nth-child(2) { right: 0; }
.t-bar i { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--paper); }
.n-rep { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.n-call { margin: 6px 0 0; font-size: 18px; font-weight: 900; font-family: "Playfair Display", Georgia, serif; }
#rotate { display: none; position: fixed; inset: 0; z-index: 40; background: var(--ink); flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 24px; }
#rotate b { font-size: 54px; } #rotate p { font-size: 17px; max-width: 280px; }
@media (orientation: portrait) and (pointer: coarse) { body.playing #rotate { display: flex; } }

/* ------------------------------------------------------------ screens */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.screen { position: absolute; inset: 0; display: none; pointer-events: auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: max(16px, var(--sat)) max(16px, var(--sar)) max(16px, var(--sab)) max(16px, var(--sal)); background: rgba(43, 29, 24, 0.55); }
.screen.active { display: flex; }
.screen > * { margin: auto; }
#title.screen { background: linear-gradient(90deg, rgba(43, 29, 24, 0.94) 0%, rgba(43, 29, 24, 0.72) 46%, rgba(43, 29, 24, 0.1) 100%); gap: 24px; align-items: center; }
.t-main { max-width: 500px; width: 100%; margin: auto auto auto clamp(0px, 5vw, 80px); }
.kicker { color: var(--gold); letter-spacing: 1.5px; text-transform: uppercase; font-size: 12.5px; font-weight: 800; margin: 0; }
.logo { margin: 6px 0 10px; font-family: "Playfair Display", Georgia, serif; font-size: clamp(50px, 8.5vw, 92px); line-height: 0.88; font-weight: 900; letter-spacing: 1px; color: var(--paper); text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.logo span { background: linear-gradient(90deg, var(--H) 0 50%, var(--P) 50% 100%); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)); }
.lead { color: #efe4cc; font-size: 15.5px; line-height: 1.5; margin: 0 0 16px; }
.challenge:empty { display: none; }
.challenge { background: rgba(246, 196, 83, 0.14); border: 1px solid rgba(246, 196, 83, 0.5); padding: 8px 12px; border-radius: 10px; margin-bottom: 12px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu .row { display: flex; gap: 8px; } .menu .row button { flex: 1; }
.menu button, .buttons button { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 17px; font-weight: 800; text-align: left; }
.menu button:hover, .buttons button:hover { border-color: var(--gold); }
button.primary { background: var(--paper) !important; color: var(--ink) !important; border-color: transparent !important; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--muted); }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.45; } .disclaimer a { color: var(--muted); }
.t-side { width: 320px; max-width: 100%; margin: auto clamp(0px, 4vw, 60px) auto auto; display: flex; flex-direction: column; gap: 10px; }
.t-side > div:empty { display: none; }
.ss-board { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px 20px; width: 100%; max-width: 760px; }
.sheet.wide { max-width: 980px; } .sheet.narrow { max-width: 400px; }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet h2 { margin: 0; font-family: "Playfair Display", Georgia, serif; font-size: 28px; }
.sheet h4 { margin: 14px 0 8px; font-size: 12.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold); }
.big { width: 100%; margin-top: 16px; padding: 14px !important; text-align: center !important; font-size: 19px !important; border-radius: 12px; font-weight: 900; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 8px 0 0; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.party { text-align: left; border-radius: 14px; padding: 12px 14px; border: 2px solid var(--line); background: linear-gradient(150deg, color-mix(in srgb, var(--c) 35%, transparent), rgba(0, 0, 0, 0.15)); display: grid; gap: 3px; }
.party.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.party b { font-family: "Playfair Display", Georgia, serif; font-size: 20px; } .party em { font-style: italic; color: var(--paper); font-size: 13.5px; } .party small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(243, 234, 212, 0.08); border: 1px solid var(--line); border-radius: 99px; padding: 6px 13px; font-weight: 800; font-size: 14px; }
.chip.on { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.srow b { font-size: 15px; } .srow input[type=range] { flex: 1; max-width: 170px; accent-color: var(--gold); }
.help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.help p { font-size: 14px; line-height: 1.5; color: #efe4cc; margin: 0 0 10px; } .help .small { font-size: 12.5px; }
.rh { margin: 2px 0 4px; font-family: "Playfair Display", Georgia, serif; font-size: 34px; }
.rgrid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; margin-top: 10px; }
.score { margin-top: 6px; } .score small { display: block; color: var(--muted); letter-spacing: 2px; font-size: 12px; } .score b { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; }
.kv { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.kv li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 4px 0; color: var(--muted); }
.kv li b { color: var(--paper); font-variant-numeric: tabular-nums; }
.clist { list-style: none; padding: 0; margin: 0; font-size: 13px; columns: 2; column-gap: 14px; }
.clist li { display: flex; justify-content: space-between; padding: 2px 0; break-inside: avoid; } .clist li i { font-style: normal; width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; position: sticky; bottom: -20px; background: var(--panel); padding: 8px 0; z-index: 2; } .buttons button { flex: 1 1 140px; text-align: center; }
#setup .big { position: sticky; bottom: 0; box-shadow: 0 -10px 20px rgba(43, 29, 24, 0.9); }
.e-board:empty { display: none; } .e-board { margin: 12px 0 0; }

/* ------------------------------------------------------------ phones and small screens */
@media (max-width: 1000px) { .b-day > span { display: none; } .b-poll { min-width: 170px; } }
body.touch .bar { gap: 8px; padding-top: max(4px, var(--sat)); padding-bottom: 4px; }
body.touch .b-day b { font-size: 15px; }
body.touch .res b { font-size: 13.5px; } body.touch .res small { display: none; } body.touch .bar2 { width: 50px; }
body.touch .b-poll { min-width: 150px; font-size: 11.5px; } body.touch .b-res { gap: 9px; }
body.touch .feed { top: calc(max(4px, var(--sat)) + 44px); width: min(260px, 32vw); } body.touch .feed p { font-size: 11px; padding: 3px 7px; } body.touch .feed p.old { display: none; }
body.touch .cards { top: calc(max(4px, var(--sat)) + 44px); width: min(280px, 38vw); } body.touch .card { padding: 7px 9px; } body.touch .card p { font-size: 12px; margin: 3px 0 6px; } body.touch .card .opts button { padding: 5px 8px; font-size: 12px; }
body.touch .panel { width: auto; left: calc(max(8px, var(--sal)) + 64px); right: max(8px, var(--sar)); transform: none; padding: 8px 10px; }
body.touch .dock button { width: 52px; font-size: 16px; }
@media (max-height: 460px) {
  .bar { gap: 6px; } .b-day .speed button { padding: 2px 6px; } .b-poll .pb { height: 6px; } .b-poll small { display: none; }
  .b-day > span { display: none; }
  .feed { width: min(230px, 30vw); } .feed p:nth-child(n+3) { display: none; }
  .cards, body.touch .cards { width: min(250px, 30vw); } .feed, body.touch .feed { width: min(230px, 30vw); } .card header { font-size: 13px; } .card p { display: none; }
  .coach { max-width: 30vw !important; }
  .panel .why { display: none; } .panel h3 small { font-size: 11px; }
  .panel .train button { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 5px; text-align: left; } .panel .train button i { grid-row: span 2; }
  .panel .train button small { font-size: 10px; }
  .kv li:nth-child(n+5) { display: none; }
  .panel { max-height: 46vh; overflow-y: auto; } .panel h3 { font-size: 15px; } .panel .train { grid-template-columns: repeat(4, 1fr); gap: 4px; } .panel .train button { padding: 4px; font-size: 11px; } .panel .train button i { font-size: 15px; }
  .panel .est { font-size: 12px; margin-top: 3px; } .panel .row { margin-top: 4px; } .panel .act { padding: 5px 9px; font-size: 12px; }
  .dock { gap: 4px; } .dock button { width: 48px; padding: 3px 0 2px; font-size: 14px; } .dock button span { font-size: 9.5px; }
  .coach { top: calc(max(4px, var(--sat)) + 44px); font-size: 12.5px; max-width: 34vw; padding: 6px 28px 6px 10px; }
  .night { padding: 6px 10px; } .night .kicker { display: none; } .t-side b { font-size: 13px; } .n-call { font-size: 15px; }
  #title.screen { gap: 14px; } .logo { font-size: 48px; } .lead { font-size: 13.5px; margin-bottom: 10px; } .menu button { padding: 8px 14px; font-size: 15px; } .disclaimer { margin-top: 8px; font-size: 11px; }
  .t-side { width: 270px; } .t-side .ss-board { max-height: 62vh; overflow: auto; }
  .sheet { padding: 12px 14px; } .sheet h2 { font-size: 22px; } .sheet h4 { margin: 8px 0 6px; }
  .party { padding: 8px 10px; } .party b { font-size: 16px; } .party small { font-size: 11.5px; } .big { margin-top: 10px; padding: 10px !important; font-size: 16px !important; }
  .help p { font-size: 12.5px; } .rh { font-size: 24px; } .score b { font-size: 28px; } .rgrid { gap: 10px; margin-top: 4px; } .clist { font-size: 11.5px; } .kv { font-size: 12.5px; }
}
@media (max-width: 760px) { .help { grid-template-columns: 1fr; } .rgrid { grid-template-columns: 1fr; } .parties { grid-template-columns: 1fr; } .two { grid-template-columns: 1fr; } }
@media (max-width: 640px) and (orientation: portrait) {
  #title.screen { flex-direction: column; align-items: stretch; background: linear-gradient(180deg, rgba(43, 29, 24, 0.3), rgba(43, 29, 24, 0.94) 38%); }
  .t-main { margin: 30vh 0 0; } .t-side { width: 100%; margin: 0; }
}
@media (orientation: landscape) and (max-height: 460px) { .help { grid-template-columns: repeat(3, 1fr); } .parties { grid-template-columns: 1fr 1fr; } .two { grid-template-columns: 1fr 1fr; } .rgrid { grid-template-columns: 1.1fr 1fr; } }
body.nightmode .feed, body.nightmode .cards, body.nightmode .panel, body.nightmode .dock, body.nightmode .coach, body.nightmode .b-res, body.nightmode .speed, body.nightmode .b-poll, body.nightmode .b-day > span { display: none !important; }
@media (max-height: 460px) { .night { top: calc(max(4px, var(--sat)) + 44px); } }
/* very short landscape phones (667x320): drop the party blurbs (How to play has them) so the length and opponent chips sit above the sticky Launch button */
@media (orientation: landscape) and (max-height: 360px) { .party small { display: none; } .party { gap: 1px; padding: 6px 10px; } }
