.screen{
  max-width:520px;
  margin:0 auto;
  padding:10px 10px calc(10px + var(--pad));
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:100%;
}

/* ---------- 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}

/* The game screen is vertically tight — scoreboard, pad and submit button all
   have to share one screen — so its wordmark is a small quiet line, not a
   second full-size heading. */
.brand.compact{padding:0}
.brand.compact h1{
  font-size:13px;font-weight:700;letter-spacing:1.6px;
  text-transform:uppercase;color:var(--dim);
}

.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}

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)}
input[type=number]{-moz-appearance:textfield}
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}

/* 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}

/* rule reminders on the game screen */
.badges{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
.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;
}
.badge.alert{
  color:#fff;background:var(--red);border-color:var(--red);
}

/* ---------- Scoreboard ---------- */
.scoreboard{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.scoreboard.solo{grid-template-columns:1fr}
.scoreboard.solo .pscore{font-size:42px}

.player{
  background:var(--card);
  border:2px solid var(--line);
  border-radius:12px;
  padding:5px 6px 4px;
  display:flex;flex-direction:column;align-items:center;gap:0;
  transition:border-color .15s,background .15s;
}
.player.active{border-color:var(--green);background:var(--select,#1c2b23)}
.pname{
  font-size:12px;color:var(--dim);font-weight:600;line-height:1.25;
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.player.active .pname{color:var(--green)}
.pscore{
  display:flex;align-items:baseline;justify-content:center;gap:5px;
  font-size:34px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums;
}
/* projected score for the turn in progress */
.ppend{
  display:none;font-style:normal;font-size:17px;font-weight:700;
  color:var(--gold);white-space:nowrap;
}
.player.pending .ppend{display:inline}
.ppend.bust{color:var(--red);font-size:13px}
.ppend.checkout{color:var(--green)}

.pmeta{font-size:10px;color:var(--dim);min-height:12px;line-height:1.2}
.pmeta span+span::before{content:' · '}

/* Three or four players, side by side. The player on turn takes the wide card
   — it has to fit the projected score beside their total — and hands it on
   with the turn. Everyone else's stats stack under their score to fit the
   narrow column. */
.scoreboard.crowded{display:flex;gap:6px}
.scoreboard.crowded .player{
  flex:1 1 0;min-width:0;padding:5px 3px 4px;
  transition:flex-grow .2s,border-color .15s,background .15s;
}
.scoreboard.crowded .player.active{flex-grow:2}
.scoreboard.crowded .pscore{font-size:22px;gap:4px}
.scoreboard.crowded .player.active .pscore{font-size:30px}
.scoreboard.crowded .ppend{font-size:15px}
.scoreboard.crowded .pmeta{display:flex;flex-direction:column;align-items:center;min-height:24px}
.scoreboard.crowded .pmeta span+span::before{content:none}

/* ---------- Turn bar ---------- */
.turnbar{
  display:flex;align-items:center;gap:8px;
  background:var(--card);border:1px solid var(--line);
  border-radius:12px;padding:6px;
}
.darts{display:flex;gap:5px;flex:1}
.slot{
  flex:1;text-align:center;padding:6px 2px;
  background:var(--bg2);border:1px dashed var(--line);border-radius:9px;
  font-size:15px;font-weight:700;color:var(--dim);
}
.slot.filled{border-style:solid;border-color:var(--green);color:var(--txt)}
/* a dart thrown before the double-in landed — shown, but scores nothing */
.slot.void{border-color:var(--line);color:var(--dim);text-decoration:line-through}
.turntotal{
  text-align:center;min-width:56px;
  border-left:1px solid var(--line);padding-left:8px;
}
.turntotal span{display:block;font-size:20px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
.turntotal small{color:var(--dim);font-size:9px}

/* ---------- Checkout suggestion ---------- */
.checkout{
  position:relative;
  display:flex;align-items:center;justify-content:center;gap:8px;
  min-height:34px;padding:4px 38px;
  border:1px solid var(--line);border-radius:11px;background:var(--card);
}
/* Absolutely positioned, so the darts stay centred and do not jump sideways
   when the back arrow appears after the first page over. The generous top/
   bottom stretch is tap area — the box itself is too short to give it. */
.co-arrow{
  position:absolute;top:3px;bottom:3px;width:34px;
  display:flex;align-items:center;justify-content:center;
  color:var(--dim);
  border:1px solid var(--line);border-radius:8px;background:var(--bg2);
}
/* block kills the inline baseline gap; pointer-events keeps the click target
   the button itself, so the delegated handler never sees a <path> */
.co-arrow svg{display:block;pointer-events:none}
.co-arrow.prev{left:3px}
.co-arrow.next{right:3px}
.co-arrow:active{background:var(--line);color:var(--txt)}
.co-label{font-size:10px;font-weight:700;letter-spacing:.7px;text-transform:uppercase;color:var(--dim)}
.co-darts{display:flex;gap:6px;flex-wrap:wrap;justify-content:center}
.co-darts b{
  font-size:16px;font-weight:800;letter-spacing:.3px;
  color:#0f1a13;background:var(--green);
  padding:3px 9px;border-radius:7px;
}
.co-none{font-size:12px;color:var(--dim)}
.co-hint{font-size:11px;color:var(--dim)}
.checkout.empty{opacity:.35}
/* the hint has to stay readable, so it opts out of the dimming above */
.checkout.empty.hint{opacity:.7}

/* ---------- Pads ---------- */
.pad{display:flex;flex-direction:column;gap:6px}

/* multiplier column + number grid, side by side */
.entry{display:flex;gap:6px;align-items:stretch}
.mult-col{display:flex;flex-direction:column;gap:6px;flex:0 0 76px}
.mult{
  flex:1;padding:0;border-radius:11px;font-weight:700;font-size:13px;
  background:var(--bg2);border:1px solid var(--line);color:var(--dim);
}
.mult.is-on{background:var(--red);border-color:var(--red);color:#fff}
.mult[data-m="1"].is-on{background:var(--green-d);border-color:var(--green);color:#fff}

.numgrid{flex:1;display:grid;grid-template-columns:repeat(5,1fr);gap:6px}

.key{
  background:var(--card);border:1px solid var(--line);border-radius:11px;
  padding:14px 0;font-size:17px;font-weight:700;text-align:center;
  font-variant-numeric:tabular-nums;
}
.key:active{background:var(--green-d);border-color:var(--green)}

.special-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px}
/* Bull is a real scoring key, so keep this row close to a 44px target */
.special{font-size:13px;font-weight:600;padding:14px 0;color:var(--dim)}

/* ---------- Actions ---------- */
/* the wide gap is deliberate: Submit is tapped constantly and Bust / New game
   are destructive, so they get real separation rather than a 6px neighbour */
.actions{margin-top:auto;display:flex;flex-direction:column;gap:26px;padding-top:2px}
.mini-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px}

/* voids the turn — a play action, so it reads apart from the two neutral ones */
.bust-btn{color:var(--neg,#e2857a);border-color:var(--neg-line,#5a302a);font-weight:600}
.bust-btn:active{background:var(--neg-line,#2a1a17);border-color:var(--red)}

.msg{
  text-align:center;font-size:13px;font-weight:600;color:var(--gold);
  min-height:16px;line-height:1.2;
}

/* ---------- Win overlay ---------- */
.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:28px 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}

/* confirmation sits above the win overlay, and reads as a warning */
.overlay.confirm{z-index:20}
.overlay.confirm h2{color:var(--txt);font-size:22px}
.overlay.confirm p{font-size:15px;line-height:1.45}

/* very short viewports: give up a little more */
@media (max-height:600px){
  .pscore{font-size:28px}
  .scoreboard.solo .pscore{font-size:34px}
  .key{padding:8px 0;font-size:16px}
  .checkout{min-height:30px}
  .big{padding:11px;font-size:16px}
  .brand{padding:2px 0 0}
  .brand.compact h1{font-size:11px}
}

/* back to the game chooser — setup screen only */
.backlink{
  align-self:flex-start;
  color:var(--dim);font-size:13px;text-decoration:none;
  padding:6px 2px;
}
.backlink:active{color:var(--txt)}

/* the row grows to four only when Save is present, so a signed-out player
   keeps three comfortable buttons */
.mini-row.has-save{grid-template-columns:repeat(4,1fr)}
.mini-row.has-save .ghost{font-size:13px;padding:9px 2px}

/* unfinished games offered from the profile, under the local resume */
.cloud-resume{display:flex;flex-direction:column;gap:6px}
.cloud-resume:empty{display:none}

/* Game screen header: the way out on the left, the title centred, and room
   kept on the right for the fixed account bubble. Grid rather than flex so
   the title stays centred on the screen regardless of the link's width. */
/* The empty third column balances the link, so the title stays centred on the
   scoreboard below rather than on the space left over beside the link. The
   fixed account bubble sits over that empty column, which is why it is
   empty. */
.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}
.cloud-error{font-size:12.5px;color:var(--neg,#e2857a);text-align:center;padding:4px 0}

/* The "you are" selector sits in a .field row, whose children are not
   flexible by default — without this the two buttons collapse to the width
   of the names in them. */
#meRow .preset-row{flex:1;min-width:0}
#meRow .seg{
  flex:1;min-width:0;font-size:14px;padding:10px 4px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}

/* ---------- the room: the Parlor (see /themes.css) ----------
   Chalk for the name and the checkout, the board's wooden frame under the
   title bar, brass for what is in play — the player on the oche, the darts
   thrown, a double or treble — and felt for Single and Submit. */
.brand h1.room-title{font-size:34px}
.brand.compact.gamebar{border-bottom:5px solid var(--frame);padding-bottom:7px}
.brand.compact.gamebar h1.room-title{font-size:22px;color:var(--txt)}

[data-room="parlor"] .player.active{border-color:var(--gold)}
[data-room="parlor"] .player.active .pname{color:var(--gold)}
[data-room="parlor"] .slot.filled{border-color:var(--gold)}
[data-room="parlor"] .mult.is-on{background:var(--gold);border-color:var(--gold);color:var(--on-gold)}
[data-room="parlor"] .mult[data-m="1"].is-on{background:var(--green-d);border-color:var(--green);color:var(--on-primary)}

/* the way out, written up in chalk */
[data-room="parlor"] .co-darts b{
  font-family:var(--f-title);font-weight:400;font-size:19px;letter-spacing:.5px;
  color:var(--txt);background:none;padding:0 4px;
}
[data-room="parlor"] .co-label{color:var(--gold)}
[data-room="parlor"] .checkout{border-style:dashed}

/* a phone that joined by seat, waiting for its player's turn to come round:
   the pad and the turn's buttons greyed, and out of reach */
#game.waiting #dartsPad,
#game.waiting #submitBtn,
#game.waiting #bustBtn{opacity:.35;pointer-events:none}

/* the way to a darts tournament, at the top of the setup */
.tourney-link{
  display:flex;align-items:center;gap:10px;padding:11px 13px;
  background:var(--card);border:1px solid var(--gold);border-radius:12px;
  color:var(--txt);text-decoration:none;font-size:15px;
}
.tourney-link b{flex:1;font-weight:600}
.tourney-link i{font-style:normal;color:var(--gold);font-size:20px;line-height:1}
.tourney-link:active{background:var(--bg2)}
