/* Central. Big text, big buttons, one column on a phone. */
:root {
  --paper: #f4f1ea; --card: #ffffff; --ink: #1f2933; --soft: #5b6672; --line: #d9d3c7;
  --primary: #2563eb; --primary-dark: #1d4ed8; --good: #15803d; --good-bg: #dcfce7;
  --wait-bg: #e8edf4; --bad: #b91c1c; --bad-bg: #fee2e2; --gold: #b7791f; --gold-bg: #fef3c7;
  --head: #1e293b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; margin: 1.6rem 0 .7rem; } h3 { font-size: 1.05rem; margin-bottom: .4rem; }
p { margin: .5rem 0; }
[hidden] { display: none !important; }
.loading { text-align: center; padding: 4rem 1rem; color: var(--soft); }

/* ---- buttons and fields ---- */
button { font: inherit; color: inherit; cursor: pointer; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: .55rem 1rem; min-height: 48px; touch-action: manipulation; }
button:hover:not(:disabled) { border-color: var(--primary); }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [role='button']:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
button.primary { background: var(--primary); border-color: var(--primary-dark); color: #fff; font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--primary-dark); }
button.big { font-size: 1.15rem; padding: .8rem 1.4rem; min-height: 56px; }
button.danger { color: var(--bad); border-color: #f0b4b4; }
.chip-btn { min-height: 40px; padding: .3rem .8rem; border-radius: 999px; font-size: .95rem; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.tv .chip-btn { background: var(--card); color: var(--ink); border-color: var(--line); }
input[type='text'], input[type='password'], select { font: inherit; width: 100%; min-height: 52px; padding: .5rem .8rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
label { display: block; font-weight: 600; margin: 1rem 0 .3rem; }
.error { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: .5rem 0; }
.hint { color: var(--soft); font-size: .95rem; }
.lead { color: var(--soft); margin-top: .3rem; }

/* ---- top bar ---- */
.top { background: var(--head); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem max(.8rem, env(safe-area-inset-left)); flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: .5rem; background: none; border: 0; color: #fff; font-weight: 800; font-size: 1.25rem; padding: .2rem .4rem; min-height: 44px; }
.logo-mark { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: .4em; background: var(--primary); color: #fff; font-weight: 800; }
.top-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.hello { font-weight: 600; }
main { max-width: 980px; margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-left)) 3rem; }
#offline { display: none; position: fixed; top: 0; left: 0; right: 0; background: var(--gold-bg); color: #7a4b00; text-align: center; padding: .3rem; font-weight: 600; z-index: 30; }
body.offline #offline { display: block; }

/* ---- signing in ---- */
.auth { display: grid; place-items: start center; padding-top: 6vh; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1.6rem; width: min(100%, 440px); box-shadow: 0 8px 30px rgba(30,41,59,.08); }
.auth-card h1 { display: flex; align-items: center; gap: .6rem; font-size: 2rem; }
.auth-card form button { width: 100%; margin-top: .4rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin: 1.2rem 0 .2rem; background: var(--wait-bg); padding: .3rem; border-radius: 14px; }
.tabs button { border: 0; background: transparent; font-weight: 600; }
.tabs button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.15); color: var(--primary-dark); }

/* ---- the menu ---- */
.join { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .4rem 1rem 1rem; }
.join-row { display: flex; gap: .6rem; }
.join-row input { text-transform: uppercase; letter-spacing: .4em; font-weight: 800; font-size: 1.3rem; text-align: center; max-width: 12rem; }
.join .error:empty { display: none; }
.rows { display: grid; gap: .5rem; }
.row { display: flex; align-items: center; gap: .8rem; text-align: left; width: 100%; padding: .7rem 1rem; }
.row.turn { border-color: var(--good); background: var(--good-bg); }
.row-icon { font-size: 1.8rem; }
.row-text { flex: 1; display: grid; }
.row-text span { color: var(--soft); font-size: .95rem; }
.tag { font-weight: 700; font-size: .9rem; padding: .2rem .7rem; border-radius: 999px; background: var(--wait-bg); white-space: nowrap; }
.row.turn .tag { background: var(--good); color: #fff; }
.row.done .tag { background: var(--gold-bg); color: #7a4b00; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .8rem; }
.tile { display: grid; gap: .25rem; justify-items: start; text-align: left; padding: 1rem; border-radius: 18px; height: 100%; align-content: start; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(30,41,59,.12); }
.tile-icon { font-size: 2.2rem; line-height: 1; }
.tile strong { font-size: 1.15rem; }
.tile-blurb { color: var(--soft); font-size: .95rem; }
.tile-players { font-size: .85rem; font-weight: 700; color: var(--primary-dark); margin-top: .2rem; }

/* ---- setting a game up ---- */
.setup h1, .match-title { display: flex; align-items: center; gap: .6rem; }
.setup-body { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .4rem 1.1rem 1rem; margin: 1rem 0; }
.field { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.field-label { display: block; font-weight: 700; margin-bottom: .5rem; }
.stepper { display: inline-flex; align-items: center; gap: .9rem; }
.stepper button { width: 56px; height: 56px; font-size: 1.6rem; font-weight: 800; padding: 0; border-radius: 50%; }
.stepper output { font-size: 1.8rem; font-weight: 800; min-width: 1.5em; text-align: center; }
.meter { width: 100%; height: 44px; accent-color: var(--primary); }
.meter-now { color: var(--primary-dark); }
.meter-ends { display: flex; justify-content: space-between; color: var(--soft); font-size: .9rem; }
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choices button.on { background: var(--primary); border-color: var(--primary-dark); color: #fff; font-weight: 700; }
.summary { font-weight: 600; margin: 1rem 0 0; }
.how { margin-top: 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .3rem 1rem; }
.how summary { cursor: pointer; font-weight: 700; padding: .6rem 0; }
.rules { padding-left: 1.3rem; margin: .2rem 0 .8rem; }
.rules li { margin: .45rem 0; }

/* ---- a game ---- */
.seats { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 .6rem; }
.seat { display: flex; align-items: center; gap: .45rem; background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: .3rem .8rem; }
.seat.turn { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.seat.won { border-color: var(--gold); background: var(--gold-bg); }
.seat-dot { width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.35); flex: none; }
.seat-name { font-weight: 700; }
.seat-name em { font-weight: 400; font-style: normal; color: var(--soft); }
.seat-bot { font-size: .8rem; color: var(--soft); background: var(--wait-bg); border-radius: 999px; padding: 0 .5rem; }
.seat-score { font-weight: 800; font-size: 1.1rem; min-width: 1.2em; text-align: center; letter-spacing: -.05em; }
.status { border-radius: 14px; padding: .7rem 1rem; font-weight: 700; font-size: 1.15rem; display: flex; flex-wrap: wrap; gap: .2rem .8rem; align-items: baseline; }
.status span { font-weight: 500; font-size: 1rem; }
.status.turn { background: var(--good); color: #fff; }
.status.wait { background: var(--wait-bg); color: var(--soft); }
.status.won { background: var(--gold-bg); color: #7a4b00; font-size: 1.4rem; }
.status.lost { background: var(--bad-bg); color: var(--bad); }
.status.draw { background: var(--wait-bg); }
.note { min-height: 1.5em; margin: .5rem .2rem; font-weight: 600; color: var(--primary-dark); }
.stage { margin: .4rem 0 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.bot-add { display: flex; gap: .5rem; align-items: center; }
.bot-add select { width: auto; min-height: 48px; }
.lobby { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1.2rem; text-align: center; }
.code { display: flex; justify-content: center; gap: .5rem; margin: .6rem 0; }
.code span { display: grid; place-items: center; width: 3.4rem; height: 4rem; font-size: 2.4rem; font-weight: 800; background: var(--head); color: #fff; border-radius: 12px; }
.lobby-seats { list-style: none; padding: 0; margin: 1rem auto 0; max-width: 22rem; text-align: left; display: grid; gap: .35rem; }
.lobby-seats li { padding: .45rem .8rem; border-radius: 10px; background: var(--wait-bg); font-weight: 600; }
.lobby-seats li.open { background: transparent; border: 2px dashed var(--line); color: var(--soft); font-weight: 400; }

/* ---- cat TV ---- */
.tv { margin-top: 1.5rem; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: .8rem; max-width: 560px; }
.tv-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.tv-head strong { flex: 1; }
.tv-screen { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 12px; background: #14101a; }
.tv-caption { text-align: center; font-weight: 700; margin: .5rem 0 0; }

/* ---- boards ---- */
.board { display: block; width: min(100%, 74vh, 640px); height: auto; margin: 0 auto; user-select: none; -webkit-user-select: none; touch-action: manipulation; border-radius: 10px; box-shadow: 0 6px 20px rgba(30,41,59,.18); }
.board.wide { width: min(100%, 900px); box-shadow: none; }
.board.c4 { box-shadow: none; }
.hit, .col, .spot, .db-line, .sea-cell { cursor: pointer; }
.hit:hover, .sea-cell:hover { fill: rgba(255,255,255,.18); }
.col-arrow { opacity: 0; }
.col:hover .col-arrow, .col:focus .col-arrow { opacity: 1; }
.col:hover rect { fill: rgba(255,255,255,.12); }
.spot:hover circle { r: 20px; }
.db-ghost { opacity: 0; }
.db-line:hover .db-ghost, .db-line:focus .db-ghost { opacity: .55; }
@media (hover: none) { .col-arrow { opacity: .7; } }
.drop { animation: drop .42s cubic-bezier(.45, 0, 1, .6); }
@keyframes drop { from { transform: translateY(var(--dy)); } }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.flip { transform-box: fill-box; transform-origin: center; animation: flip .45s; }
@keyframes flip { 50% { transform: scaleX(0); } }
.pop { transform-box: fill-box; transform-origin: center; animation: pop .25s; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.mc-count { font: 800 30px system-ui, sans-serif; text-anchor: middle; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.45); stroke-width: 5px; }
.mc-label { font: 600 20px system-ui, sans-serif; text-anchor: middle; fill: #fdebd2; }
.db-initial { font: 800 52px system-ui, sans-serif; text-anchor: middle; }
.ch-coord { font: 700 17px system-ui, sans-serif; }
.ch-promo { font: 700 24px system-ui, sans-serif; fill: #3a2912; }
.dt-num { font: 700 27px system-ui, sans-serif; text-anchor: middle; fill: #f3f3f3; }
.dartboard { width: min(100%, 70vh, 620px); cursor: crosshair; touch-action: none; }
.dt-reticle, .dart { pointer-events: none; }
.dt-controls { display: grid; justify-items: center; gap: .3rem; margin-top: .8rem; text-align: center; }
.dt-controls button { min-width: 16rem; }
.dt-tally { text-align: center; min-height: 1.6em; }

.ttt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(100%, 62vh, 460px); margin: 0 auto; background: var(--head); padding: 10px; border-radius: 16px; }
.ttt-cell { aspect-ratio: 1; border: 0; border-radius: 10px; background: #fff; font-size: clamp(3rem, 16vw, 6rem); font-weight: 800; line-height: 1; padding: 0; opacity: 1 !important; }
.ttt-cell.x { color: #e4572e; } .ttt-cell.o { color: #2f7fd8; }
.ttt-cell.last { background: #fff7d6; }
.ttt-cell.win { background: #bbf7d0; }
.ttt-cell:not(:disabled):hover { background: #eef4ff; }

.mem { display: grid; grid-template-columns: repeat(var(--cols, 6), 1fr); gap: 8px; width: min(100%, 640px); margin: 0 auto; }
.mem-card { aspect-ratio: 3 / 4; padding: 0; min-height: 0; border-radius: 10px; border: 3px solid #1d4ed8; background: repeating-linear-gradient(45deg, #2563eb 0 8px, #3b82f6 8px 16px); opacity: 1 !important; display: grid; place-items: center; }
.mem-card.up { background: #fff; border-color: var(--line); }
.mem-card.found { background: #f1f5f9; border-width: 4px; }
.mem-card.found .mem-face { opacity: .55; }
.mem-face { font-size: clamp(1.5rem, 8vw, 3rem); line-height: 1; }

.seas { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; align-items: start; }
.sea-panel .board { width: min(100%, 60vh, 480px); }
.sea-panel h3 { text-align: center; }
.sea-tools { margin-top: .8rem; text-align: center; }
.sea-buttons { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.sea-left { margin: .2rem 0; font-size: .95rem; }

/* ---- messages ---- */
#toasts { position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: .5rem; z-index: 40; width: min(92vw, 30rem); pointer-events: none; }
.toast { background: var(--head); color: #fff; padding: .7rem 1rem; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .4s, transform .4s; }
.toast.bad { background: var(--bad); } .toast.good { background: var(--good); }
.toast.gone { opacity: 0; transform: translateY(10px); }

@media (max-width: 520px) {
  body { font-size: 17px; }
  main { padding-top: .7rem; }
  .hello { display: none; }
  .mem { gap: 5px; }
  .dt-controls button { min-width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .drop, .pulse, .flip, .pop { animation: none; } }
