/* ScoreChalk Builder. Setup and overlay rules mirror darts/style.css so the
   two games feel like one site; they are repeated rather than shared because
   games share shared.css and nothing else. */

.screen{
  max-width:520px;
  margin:0 auto;
  padding:10px 10px calc(10px + var(--pad));
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:100%;
}


.rules-text{font-size:14px;line-height:1.45}
.rules-actions{display:flex;gap:6px}
.rules-actions .ghost{flex:1}
.reset{color:var(--neg,#e2857a);border-color:var(--neg-line,#5a302a)}
.reset:disabled{opacity:.4;cursor:default}
.save{color:var(--green);border-color:var(--green-d)}

/* ---------- Setup ---------- */
.brand{text-align:center;padding:8px 0 2px}
.brand h1{font-size:26px;letter-spacing:-.5px}
.brand p{color:var(--dim);font-size:13px;margin-top:2px}

.brand.compact{padding:0}
.brand.compact h1{
  font-size:13px;font-weight:700;letter-spacing:1.6px;
  text-transform:uppercase;color:var(--dim);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.brand.compact.gamebar{
  display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:8px;
}
.brand.compact.gamebar .backlink{justify-self:start;padding:2px}
.brand.compact.gamebar h1{grid-column:2}
.brand.compact.gamebar .viewrow{grid-column:3}
body.playing .acct{display:none}
html{scrollbar-gutter:stable}

.backlink{
  align-self:flex-start;
  color:var(--dim);font-size:13px;text-decoration:none;
  padding:6px 2px;
}
.backlink:active{color:var(--txt)}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:12px;
  padding:11px;
  display:flex;
  flex-direction:column;
  gap:9px;
}

.field{display:flex;align-items:center;gap:12px}
.field>span{width:80px;flex:none;color:var(--dim);font-size:14px}
.field-label{color:var(--dim);font-size:14px}
.hint{color:var(--dim);font-size:12px;line-height:1.35}
.hint:empty{display:none}

input{
  flex:1;
  min-width:0;
  background:var(--bg2);
  border:1px solid var(--line);
  border-radius:10px;
  color:var(--txt);
  padding:12px;
  font-size:17px;
  -webkit-user-select:text;
  user-select:text;
}
input:focus{outline:none;border-color:var(--green)}

select{
  flex:1;min-width:0;
  background:var(--bg2);border:1px solid var(--line);border-radius:10px;
  color:var(--txt);padding:11px 12px;font:inherit;font-size:16px;
}
select:focus{outline:none;border-color:var(--green)}
input[type=number]{-moz-appearance:textfield}
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}

/* a group inside a card, set apart by a rule rather than its own card */
.subsection{
  display:flex;flex-direction:column;gap:9px;
  border-top:1px solid var(--line);padding-top:10px;margin-top:2px;
}
/* a direction the chosen ending can't use */
.seg:disabled{opacity:.35}

/* four endings do not fit one row on a phone with their labels */
.preset-row.wrap{flex-wrap:wrap}
.preset-row.wrap .seg{flex:1 1 40%}

.stepper{display:flex;align-items:center;gap:10px;margin-left:auto}
.stepper b{min-width:28px;text-align:center;font-size:20px;font-variant-numeric:tabular-nums}
.step{
  width:44px;height:40px;border-radius:10px;font-size:22px;font-weight:700;
  background:var(--bg2);border:1px solid var(--line);
}
.step:active{border-color:var(--green)}
.step:disabled{opacity:.35}


.chips{display:flex;flex-wrap:wrap;gap:6px}
.chips:empty{display:none}
.chips b{
  font-size:13px;font-weight:700;color:var(--txt);
  background:var(--bg2);border:1px solid var(--line);
  padding:3px 10px;border-radius:999px;font-variant-numeric:tabular-nums;
}
.chips .bad{color:var(--neg,#e2857a);border-color:var(--neg-line,#5a302a)}

/* switch row */
.toggle{display:flex;align-items:center;gap:12px;width:100%;text-align:left;padding:2px}
.tg-label{flex:1;display:flex;flex-direction:column;gap:2px}
.tg-label b{font-size:16px;font-weight:600}
.tg-label small{color:var(--dim);font-size:12px;line-height:1.3}
.tg-switch{
  flex:none;width:50px;height:30px;border-radius:15px;
  background:var(--bg2);border:1px solid var(--line);
  position:relative;transition:background .15s,border-color .15s;
}
.tg-switch::after{
  content:'';position:absolute;top:3px;left:3px;
  width:22px;height:22px;border-radius:50%;background:var(--dim);
  transition:transform .15s,background .15s;
}
.toggle.is-on .tg-switch{background:var(--green-d);border-color:var(--green)}
.toggle.is-on .tg-switch::after{transform:translateX(20px);background:#fff}

/* ---------- Game ---------- */
.badges{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
.badges:empty{display:none}
.badge{
  font-size:10px;font-weight:700;letter-spacing:.6px;
  text-transform:uppercase;color:var(--badge-fg,var(--gold));
  border:1px solid var(--badge-line,#4a3c18);background:var(--badge-bg,#241f11);
  padding:2px 9px;border-radius:999px;
}

/* The scoreboard: as the top of the scoresheet — a column a player, the
   name on top and the total under it. Tapping a column, name or total,
   picks who the next score is for. Its rows, and its width when it is
   wider than the page, are set by layoutBoard(). */
.scoreboard{
  display:grid;align-self:center;width:100%;max-width:none;
  border:1px solid var(--line);border-radius:12px;background:var(--card);overflow:hidden;
}
.player{
  display:flex;flex-direction:column;align-items:stretch;min-width:0;
  border-left:1px solid var(--line);background:none;
  transition:background .15s,opacity .15s;
}
.player.rowstart{border-left:none}
.player.newrow{border-top:1px solid var(--line)}
.scoreboard .pname{
  display:block;background:var(--bg2);padding:8px 4px 6px;border-bottom:3px solid transparent;
  font-size:12.5px;font-weight:700;color:var(--dim);text-align:center;line-height:1.25;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
/* who the next score is for: their name underlined, their column lit */
.player.active{background:var(--select,#1c2b23)}
.player.active .pname{border-bottom-color:var(--green);color:var(--txt)}
.player.leader .pname::before{content:'★ ';color:var(--gold)}
.player.out{opacity:.4}
.player.out .pscore b{text-decoration:line-through}
.scoreboard .pscore{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:6px 2px 0;font-size:34px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums;
}
.scoreboard.solo .pscore{font-size:46px}
.scoreboard.many .pscore{font-size:24px}
/* what the score will be once the one being entered goes in */
.ppend{display:none;font-style:normal;font-size:14px;font-weight:700;color:var(--gold);white-space:nowrap}
.player.pending .ppend{display:block}
.scoreboard.many .ppend{font-size:12px}
.pmeta{font-size:10px;color:var(--dim);min-height:12px;line-height:1.2;text-align:center;padding:1px 2px 6px}

/* entry bar: sign, the amount being built, clear */
.entrybar{
  display:flex;align-items:center;gap:8px;
  background:var(--card);border:1px solid var(--line);
  border-radius:12px;padding:6px;
}
.sign{display:flex;gap:4px}
.sgn{
  width:42px;height:40px;border-radius:9px;font-size:22px;font-weight:800;
  background:var(--bg2);border:1px solid var(--line);color:var(--dim);
}
.sgn.is-on[data-sign="1"]{background:var(--green-d);border-color:var(--green);color:var(--on-primary,#fff)}
.sgn.is-on[data-sign="-1"]{background:var(--red);border-color:var(--red);color:#fff}
.entrytotal{flex:1;text-align:center;display:flex;flex-direction:column;min-width:0}
.entrytotal span{font-size:24px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
/* who it is for, or what was tapped: up to two lines, then cut */
.entrytotal small{
  color:var(--dim);font-size:11px;line-height:1.3;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.clear{
  padding:0 12px;height:40px;border-radius:9px;font-size:13px;font-weight:600;
  color:var(--dim);border:1px solid var(--line);
}
.clear:active{background:var(--bg2)}

.quickpad{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.quickpad.four{grid-template-columns:repeat(4,1fr)}
.key{
  background:var(--card);border:1px solid var(--line);border-radius:11px;
  padding:16px 0;font-size:19px;font-weight:700;text-align:center;
  font-variant-numeric:tabular-nums;
}
.key:active{background:var(--green-d);border-color:var(--green)}
.quickpad.neg .key:active{background:var(--neg-line,#5a302a);border-color:var(--red)}

.typedrow{display:flex;gap:6px}
.typedrow .key{padding:0 20px;font-size:16px}

/* sits straight under the pad; the history below grows downward, so it can
   never push the button up the screen */
.entry{display:flex;flex-direction:column;gap:8px}
.entry #commitBtn{margin-top:4px}
.actions{display:flex;flex-direction:column;gap:22px;padding-top:18px}
.mini-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px}
.mini-row.two{grid-template-columns:1fr 1fr}
.mini-row.four{grid-template-columns:repeat(4,1fr)}
.mini-row.four .ghost{font-size:13px;padding:9px 2px}

.msg{
  text-align:center;font-size:13px;font-weight:600;color:var(--gold);
  min-height:16px;line-height:1.2;
}

/* the last few entries, newest first — settles "did I add that?" */
.history{display:flex;flex-direction:column;gap:2px;font-size:12px;color:var(--dim)}
.history:empty{display:none}
.history div{display:grid;grid-template-columns:1fr auto 64px;gap:10px;align-items:baseline;padding:3px 4px;border-top:1px solid var(--line)}
.history span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history small{font-size:11px}
.history b{text-align:right}
.history b{font-variant-numeric:tabular-nums;color:var(--txt)}
.history .neg{color:var(--neg,#e2857a)}
/* a score can be tapped to change it; a change shows as its own line */
.history .hturn{cursor:pointer}
.history .hturn:active{background:var(--select,#1c2b23)}
.history .hedit span em{font-style:italic}

/* ---------- Overlays ---------- */
.overlay{
  position:fixed;inset:0;background:var(--veil,#0b0e12ee);
  display:flex;align-items:center;justify-content:center;padding:24px;z-index:10;
}
.win-card{
  background:var(--card);border:1px solid var(--line);border-radius:18px;
  padding:26px 22px;text-align:center;width:100%;max-width:360px;
  display:flex;flex-direction:column;gap:12px;
}
.trophy{font-size:52px}
.win-card h2{font-size:26px;color:var(--gold)}
.win-card p{color:var(--dim);font-size:14px}
.overlay.confirm{z-index:20}
.overlay.confirm h2{color:var(--txt);font-size:22px}
.overlay.confirm p{font-size:15px;line-height:1.45}

.standings{list-style:none;display:flex;flex-direction:column;gap:4px;text-align:left}
.standings li{
  display:flex;justify-content:space-between;gap:10px;
  padding:6px 10px;border-radius:8px;background:var(--bg2);font-size:15px;
}
.standings li b{font-variant-numeric:tabular-nums}
.standings li:first-child{color:var(--gold)}
/* whether the game reached the profile; tappable to retry when it didn't */
.win-save{font-size:12.5px;color:var(--dim);min-height:0}
.win-save:empty{display:none}

@media (max-height:600px){
  .pscore{font-size:28px}
  .key{padding:11px 0;font-size:17px}
  .big{padding:11px;font-size:16px}
  .brand{padding:2px 0 0}
}

/* the fixed-rounds switch and its count */
#roundsBox{display:flex;flex-direction:column;gap:9px}
/* locked on by a fixed round count */
.toggle:disabled{opacity:.6;cursor:default}

/* ---------- Teams ---------- */
.teams-box{display:flex;flex-direction:column;gap:9px;border-top:1px solid var(--line);padding-top:10px}
.team-chip{
  flex:none;width:30px;height:30px;border-radius:50%;
  background:color-mix(in srgb, var(--tc) 30%, var(--bg2));border:2px solid var(--tc);
  color:#fff;font-weight:800;font-size:13px;
}

/* ---------- Named keys ---------- */
/* two across, the name over the points */
.quickpad.named{grid-template-columns:1fr 1fr}
.key.nkey{display:flex;flex-direction:column;align-items:center;gap:1px;padding:10px 4px}
.key.nkey b{font-size:15px;font-weight:700;line-height:1.2}
.key.nkey small{font-size:13px;color:var(--dim);font-weight:700}
/* a history row's breakdown, after the name */
.history em{font-style:normal;margin-left:6px;opacity:.8}

/* the round being played out after someone reached the target */
.badge.round.final{color:#fff;background:var(--red);border-color:var(--red)}

/* ---------- rooms (see /themes.css) ---------- */
/* the game's name, in the room's lettering, a size up from the plain bar */
.brand.compact h1.room-title{font-size:19px;color:var(--txt)}
.brand h1.room-title{font-size:30px}

/* the theme choice: a swatch of each room */
.swatches{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.swatch{
  display:grid;gap:2px;justify-items:center;text-align:center;padding:0 0 9px;overflow:hidden;
  border:2px solid var(--line);border-radius:12px;background:var(--bg2);color:var(--txt);
}
.swatch.is-on{border-color:var(--green);box-shadow:0 0 0 2px var(--green)}
.swatch b{font-size:13px;font-weight:700;margin-top:6px}
.swatch small{font-size:11px;color:var(--dim);line-height:1.2;padding:0 4px}
.sw-face{width:100%;height:48px;display:grid;place-items:center;font-size:24px}
.sw-parlor .sw-face{background:radial-gradient(90% 90% at 50% 0%, #2b3a34, #1c2723);color:#ecebe3;font-family:"Fredericka the Great",Georgia,serif;border-bottom:4px solid #6b4a2b}
.sw-living .sw-face{color:#22324d;font-family:"Kalam",cursive;font-weight:700;
  background:linear-gradient(90deg, transparent 14px, #d4544c 14px 15px, transparent 15px), repeating-linear-gradient(180deg, transparent 0 11px, #a9c4e0 11px 12px), #fbf1bd;
  border-bottom:4px solid #5f9a6c}
.sw-workshop .sw-face{color:#1e2b2a;font-family:"Josefin Sans",sans-serif;font-weight:700;
  background:linear-gradient(#c9d6cf 1px, transparent 1px) 0 0/10px 10px, linear-gradient(90deg, #c9d6cf 1px, transparent 1px) 0 0/10px 10px, #eef1ec;
  border-bottom:4px solid #1e2b2a}

/* the entries so far, on paper: ruled lines instead of borders, the scores
   in the room's handwriting */
/* no padding above or below, so the 24px rows sit exactly on the 24px rules */
.history.paper{border:1px solid var(--paper-edge);border-radius:4px;padding:0 8px 0 30px;font-size:12.5px;color:var(--paper-dim)}
.history.paper div{border-top:none;height:24px;line-height:24px;padding:0 2px;overflow:hidden}
.history.paper div > *{line-height:24px}
.history.paper b{color:var(--paper-ink);font-family:var(--f-hand);font-size:15px}
.history.paper span{color:var(--paper-ink)}
.history.paper small,.history.paper em{color:var(--paper-dim)}
.history.paper .neg{color:var(--paper-neg)}

/* ---------- the sheet view ----------
   For games taken in turns: a row a round, a column a player, as on paper —
   and as the Yahtzee sheet, whose scrolling it shares: the round names stay
   put down the left and the player names along the top, and past four
   players the columns scroll sideways under the round names. A cell is
   scored in a bubble beside it, which holds the same pad as the board. */
.viewrow{justify-self:end;display:flex;border:1px solid var(--line);border-radius:9px;overflow:hidden}
.vseg{font-size:11.5px;font-weight:600;color:var(--dim);padding:5px 8px}
.vseg.is-on{background:var(--green-d);color:var(--on-primary,#fff)}
.brand.compact.gamebar h1{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* The sheet view is one screen tall and the sheet takes what is left; a
   long game scrolls inside it, the names and the totals staying put. */
#game.sheet-view{height:100dvh;min-height:0}
#game.sheet-view .scoreboard,
#game.sheet-view .entry,
#game.sheet-view .history{display:none}
#game.sheet-view .actions{padding-top:2px}
/* As wide as the players need, as the Yahtzee sheet is — the sheet alone,
   centred over the page, so the top bar stays where it is when the view
   is switched. */
.sheet-wrap{
  flex:1 1 auto;min-height:0;overflow:auto;
  align-self:center;width:min(calc(100vw - 20px), max(100%, var(--sheet-w, 300px)));
  border:1px solid var(--line);border-radius:12px;background:var(--card);
  overscroll-behavior:contain;
}
.sheet{
  display:grid;grid-template-columns:minmax(82px,1fr) repeat(var(--cols),minmax(52px,1.2fr));
  grid-auto-rows:minmax(42px,auto);min-width:min-content;
}
.sheet.wide{grid-template-columns:86px repeat(var(--cols),minmax(66px,1fr))}
.sheet>*{border-top:1px solid var(--line);border-left:1px solid var(--line);min-width:0}
.sheet .corner,.sheet .ptile{position:sticky;top:0;z-index:2;border-top:none}
.sheet .corner{background:var(--card);border-left:none;z-index:3}
.sheet .lab,.sheet .corner{position:sticky;left:0;box-shadow:1px 0 0 var(--line)}
.sheet .lab{z-index:1}
.sheet .ptile{
  background:var(--bg2);padding:8px 3px 6px;display:flex;align-items:center;justify-content:center;
  border-bottom:3px solid transparent;
}
.sheet .ptile .pname{font-size:12.5px;font-weight:700;color:var(--dim)}
.sheet .ptile.turn{border-bottom-color:var(--green)}
.sheet .ptile.turn .pname{color:var(--txt)}
.sheet .ptile.turn .pname::before{content:'\25CF  ';color:var(--gold)}
.sheet .ptile.out{opacity:.45}
.sheet .lab{
  padding:0 8px;display:flex;align-items:center;font-size:13px;border-left:none;background:var(--card);
  white-space:nowrap;
}
.sheet .cell{
  display:flex;align-items:center;justify-content:center;
  font-size:16px;font-weight:700;font-variant-numeric:tabular-nums;background:none;color:var(--txt);
}
.sheet .cell.neg{color:var(--neg,#e2857a)}
.sheet .cell.zero,.sheet .cell.gone{color:var(--dim);font-weight:400}
button.cell:active{background:var(--line)}
/* the round being played: its row picked out, and the cells still to score
   in it marked as open, the way the Yahtzee sheet marks a player's boxes */
.sheet .lab.cur{background:var(--mark-open,#2d2712);color:var(--mark-open-ink,#f0d77a);font-weight:700}
.sheet .cell.cur{background:color-mix(in srgb, var(--mark-open,#2d2712) 45%, transparent)}
.sheet .cell.open{background:var(--mark-open,#2d2712);box-shadow:inset 0 0 0 2px var(--mark-open-ink,#f0d77a)}
.sheet .cell.open::after{content:'+';font-size:20px;color:var(--mark-open-ink,#f0d77a)}
.sheet .cell.done{background:var(--mark-done,#17301f)}
/* where play starts, and the totals, which stay at the bottom */
.sheet .lab.start,.sheet .cell.start{background:var(--bg2);color:var(--dim);font-size:12.5px;font-weight:600}
.sheet .lab.tot,.sheet .cell.tot{
  position:sticky;bottom:0;background:var(--bg2);border-top:2px solid var(--line);
  font-weight:800;
}
.sheet .lab.tot{z-index:2;font-size:13px}
.sheet .cell.tot{z-index:1;font-size:17px}
.sheet .cell.tot.leader{color:var(--gold)}

/* the scoring bubble: beside its cell, pointing at it (see placeEntry) */
.overlay.sheet-entry{display:block;padding:0;background:var(--veil-soft,#0b0e1255)}
.entry-card{
  position:fixed;width:min(340px, calc(100vw - 16px));
  background:var(--bg);border:1px solid var(--paper-edge,#3a4756);border-radius:14px;
  padding:10px;display:flex;flex-direction:column;gap:8px;
  box-shadow:0 12px 30px var(--shadow,#000c);
}
.entry-card::before{
  content:'';position:absolute;left:calc(var(--ax, 50%) - 8px);width:16px;height:16px;
  background:var(--bg);border:1px solid var(--paper-edge,#3a4756);transform:rotate(45deg);
}
.entry-card.below::before{top:-9px;border-right:none;border-bottom:none}
.entry-card.above::before{bottom:-9px;border-left:none;border-top:none}
.entry-top{display:flex;justify-content:space-between;align-items:flex-start}
.entry-top b{display:block;font-size:16px}
.entry-top small{color:var(--dim);font-size:12.5px}
.entry-x{font-size:26px;line-height:1;color:var(--dim);padding:0 6px}
.entry-card .key{padding:12px 0}
.entry-card .quickpad.named .key{padding:8px 4px}

/* a score changed since it was entered: a small mark in its corner */
.sheet .cell.edited{position:relative}
.sheet .cell.edited::after{
  content:'';position:absolute;top:5px;right:5px;width:6px;height:6px;border-radius:50%;
  background:var(--gold);
}

/* the corner's button, which turns the sheet on its side and back */
.flipbtn{width:100%;height:100%;font-size:11.5px;font-weight:700;color:var(--dim);white-space:nowrap}
.flipbtn:active{color:var(--txt);background:var(--line)}

/* ---------- the sheet on its side ----------
   A row a player and a column a round: the names stay put down the left,
   the rounds along the top, and the totals down the right. */
.sheet.flip .rh{
  position:sticky;top:0;z-index:2;border-top:none;background:var(--bg2);
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:5px 2px 4px;font-size:15px;font-weight:800;color:var(--dim);line-height:1.1;
}
.sheet.flip .rh small{font-size:9px;font-weight:700;letter-spacing:.05em;text-transform:uppercase}
.sheet.flip .rh.cur{background:var(--mark-open,#2d2712);color:var(--mark-open-ink,#f0d77a)}
.sheet.flip .rh.start{font-size:12px;font-weight:600}
.sheet.flip .rh.tot{right:0;z-index:3;font-size:13px;color:var(--txt);border-left:2px solid var(--line)}
.sheet.flip .ptile{
  top:auto;left:0;z-index:1;border-top:1px solid var(--line);border-left:none;border-bottom:none;
  justify-content:flex-start;padding:0 8px;background:var(--bg2);box-shadow:1px 0 0 var(--line);
}
/* a long name wraps, up to three lines; with room, it has room */
.sheet.flip .ptile{padding:5px 8px}
.sheet.flip .ptile .pname{
  white-space:normal;overflow-wrap:anywhere;line-height:1.2;
  display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;
}
.sheet.flip.roomy .ptile .pname{font-size:13.5px}
.sheet.flip .ptile.turn{box-shadow:inset 3px 0 0 var(--green),1px 0 0 var(--line)}
.sheet.flip .cell.tot{bottom:auto;right:0;border-top:1px solid var(--line);border-left:2px solid var(--line)}

/* The totals at the far edge from the start: the sheet fills its frame,
   and a blank track — rows down, or a column on its side — takes up what
   the rounds don't yet. On its side the frame is only as tall as the
   players, and the sheet as wide as the frame or the rounds, whichever
   is more. */
.sheet{min-height:100%}
.sheet .fill{background:none}
.sheet .lab.fill{background:var(--card)}
.sheet-wrap.flipped{flex:0 1 auto}
.sheet.flip{min-height:0;width:max-content;min-width:100%}

/* ---------- Counters ---------- */
/* setup: a row a counter — its name, then where it starts and what
   reaching a number does */
.counter-list{display:flex;flex-direction:column;gap:8px}
.counter-list:empty{display:none}
.crow{display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid var(--line);border-radius:10px;background:var(--bg2)}
.crow input,.crow select{padding:9px 10px;font-size:15px;background:var(--card)}
.crow-top{display:flex;gap:6px}
.c-del{
  flex:none;width:40px;border-radius:10px;font-size:22px;line-height:1;
  color:var(--neg,#e2857a);border:1px solid var(--neg-line,#5a302a);
}
.crow-rules{display:flex;gap:6px;align-items:center}
.c-start{display:flex;align-items:center;gap:6px;flex:none}
.c-start span{flex:none;color:var(--dim);font-size:13px}
.c-start input{width:58px;flex:none}
.crow-rules select{flex:1 1 auto;min-width:0;padding-right:4px}
.c-at{flex:none;width:62px}

/* game: a column a counter, a row a side; scrolls sideways when there are
   more counters than fit */
.counters{
  flex:none;overflow-x:auto;
  border:1px solid var(--line);border-radius:12px;background:var(--card);
}
.ctable{display:grid;align-items:stretch;min-width:100%;width:max-content}
.ctable > div{padding:4px 6px;border-top:1px solid var(--line);min-height:40px;display:flex;align-items:center}
.ctable .chd{
  border-top:none;min-height:0;padding:6px;flex-direction:column;align-items:center;justify-content:flex-end;
  background:var(--bg2);text-align:center;line-height:1.15;
}
.chd b{font-size:12px;font-weight:700;color:var(--txt)}
.chd small{font-size:10px;color:var(--dim)}
.cname{font-size:13px;font-weight:700;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-left:3px solid transparent}
.cname.turn{color:var(--txt);border-left-color:var(--green)}
.cname.out{opacity:.45;text-decoration:line-through}
.cval{justify-content:center;gap:6px}
.cval b{min-width:30px;text-align:center;font-size:20px;font-weight:800;font-variant-numeric:tabular-nums}
.cval.hit b{color:var(--neg,#e2857a)}
.cstep{
  width:34px;height:32px;border-radius:9px;font-size:20px;font-weight:700;line-height:1;
  background:var(--bg2);border:1px solid var(--line);color:var(--dim);
}
.cstep:active{border-color:var(--green);color:var(--txt)}
/* a seated phone changes its own row only */
.cval:not(.mine) .cstep{visibility:hidden}

.win-by{font-size:13px;color:var(--dim);margin-top:-4px}
.win-by:empty{display:none}

/* ---------- Tiles ---------- */
/* A tile a side: its name, its score, and each counter. The grid has 60
   columns, as the board does, so a row of one to four tiles each takes
   an even share; layoutTiles() sets the spans. */
.tiles{display:grid;grid-template-columns:repeat(60,1fr);gap:6px}
.tile{
  display:flex;flex-direction:column;min-width:0;cursor:pointer;
  border:1px solid var(--line);border-radius:12px;background:var(--card);overflow:hidden;
  transition:background .15s,opacity .15s;
}
.tname{
  background:var(--bg2);padding:7px 6px 5px;border-bottom:3px solid transparent;
  font-size:13px;font-weight:700;color:var(--dim);text-align:center;line-height:1.25;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.tile.active{background:var(--select,#1c2b23)}
.tile.active .tname{border-bottom-color:var(--green);color:var(--txt)}
.tile.leader .tname::before{content:'★ ';color:var(--gold)}
.tile.out{opacity:.45}
.tile.out .pnum{text-decoration:line-through}
.tscore{display:flex;align-items:center;justify-content:center;gap:8px;padding:8px 6px 0}
.tnum{display:flex;flex-direction:column;align-items:center;min-width:52px}
.tnum b{font-size:36px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
.tiles.solo .tnum b{font-size:48px}
.tile .ppend{display:none;font-style:normal;font-size:13px;font-weight:700;color:var(--gold);white-space:nowrap}
.tile.pending .ppend{display:block}
.tstep{
  width:44px;height:44px;border-radius:12px;font-size:26px;font-weight:700;line-height:1;
  background:var(--bg2);border:1px solid var(--line);color:var(--dim);flex:none;
}
.tstep:active{border-color:var(--green);color:var(--txt)}
.tile .pmeta{min-height:8px;padding:1px 2px 4px}
.trow{
  display:grid;grid-template-columns:1fr auto 30px auto;align-items:center;gap:4px;
  padding:4px max(6px, calc(50% - 110px));border-top:1px solid var(--line);
}
.trow span{font-size:12px;font-weight:600;color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.trow b{text-align:center;font-size:17px;font-weight:800;font-variant-numeric:tabular-nums}
.trow.hit b{color:var(--neg,#e2857a)}
.trow .cstep{width:32px;height:30px;font-size:18px}
/* a seated phone changes its own tile only */
.tile:not(.mine) .tstep,.tile:not(.mine) .cstep{visibility:hidden}
#game.sheet-view .tiles{display:none}

/* live, the buttons go straight onto the score: nothing to add up or enter */
.entry.live #pendAmt,.entry.live #clearBtn,.entry.live #commitBtn{display:none}
.pad-rules{display:flex;flex-direction:column;gap:9px}

/* ---------- the setup's steps: as the tournament's ---------- */
.stages{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.stage{
  display:flex;align-items:center;justify-content:center;gap:6px;
  padding:10px 4px;border-radius:10px;font-size:15px;font-weight:600;color:var(--dim);
  background:var(--bg2);border:1px solid var(--line);
}
.stage i{
  font-style:normal;font-size:12px;width:20px;height:20px;line-height:18px;border-radius:50%;
  border:1px solid currentColor;text-align:center;flex:none;
}
.stage b{font-size:12px;font-weight:600;opacity:.8}
.stage b:empty{display:none}
.stage.is-on{color:var(--on-primary,#fff);background:var(--green-d);border-color:var(--green)}
.pane{display:flex;flex-direction:column;gap:8px}

/* Take turns or any time: two choices side by side, each described in full */
.ways{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.way{
  display:flex;flex-direction:column;gap:4px;text-align:left;padding:10px;
  border-radius:10px;background:var(--bg2);border:2px solid var(--line);
}
.way b{font-size:15px;font-weight:700}
.way small{font-size:12px;line-height:1.35;color:var(--dim)}
.way.is-on{border-color:var(--green);background:var(--select,#1c2b23)}
/* a team chip in the players' list, where the list's own × button rule
   would otherwise size and colour it */
.roster li .team-chip{width:30px;height:30px;color:#fff;font-size:13px;margin-left:2px}

/* which player is you, in the players' list: a person, or You once picked */
.roster li .me-btn{
  width:auto;min-width:34px;padding:0 7px;border-radius:999px;
  display:flex;align-items:center;justify-content:center;gap:4px;
}
.me-btn svg{width:18px;height:18px;fill:none;stroke:var(--dim);stroke-width:2;stroke-linecap:round;opacity:.6}
.me-btn b{display:none;font-size:13px;font-weight:700}
.roster li .me-btn.is-on{background:var(--green-d);color:var(--on-primary,#fff)}
.me-btn.is-on svg{stroke:currentColor;opacity:1}
.me-btn.is-on b{display:inline}

/* two or three players: a tile each across the whole width, and more to it */
.tiles.roomy .tname{font-size:15px;padding:9px 6px 7px}
.tiles.roomy .tscore{gap:18px;padding:12px 6px 2px}
.tiles.roomy .tnum{min-width:80px}
.tiles.roomy .tnum b{font-size:60px}
.tiles.roomy .tstep{width:60px;height:60px;border-radius:16px;font-size:32px}
.tiles.roomy .trow{padding-block:6px}
.tiles.roomy .trow span{font-size:14px}
.tiles.roomy .trow b{font-size:22px}
.tiles.roomy .trow .cstep{width:40px;height:36px;font-size:22px}
.tiles.roomy .trow{padding-inline:max(8px, calc(50% - 140px))}
