/* Cribbage. Setup, overlay and action rules follow darts/style.css so the
   games feel like one site; repeated rather than shared, as games share
   shared.css and nothing else. */

.screen{
  max-width:560px;
  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}

.brand.compact{padding:0}
.brand.compact h1{
  font-size:13px;font-weight:700;letter-spacing:1.6px;
  text-transform:uppercase;color:var(--dim);
}
.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}

.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-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}

.names{display:flex;flex-direction:column;gap:6px}
.name-row{display:flex;align-items:center;gap:10px}
.dot{width:14px;height:14px;border-radius:50%;flex:none}
#dealRow .seg{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:12px 6px}

/* ---------- Board ---------- */
/* Wood behind the coloured lanes, like the real thing. Small on a phone is
   fine: the exact scores sit in the player headers right under it. */
.board-wrap{
  background:linear-gradient(180deg,#c9a46e,#b48a52);
  border-radius:12px;padding:4px 6px;
  box-shadow:inset 0 0 0 1px #00000030;
}
.board{display:block;width:100%;height:auto}
.board .hole{fill:#3a2a18;opacity:.7}
.board .tick{stroke:#3a2a18;stroke-width:.5;opacity:.45}
.board .num{font:600 6.5px -apple-system,system-ui,sans-serif;fill:#3a2a18;text-anchor:middle;opacity:.75}
.board .finish{fill:#3a2a18;stroke:#f5e6c8;stroke-width:.8}
.board .peg{stroke:#fff;stroke-width:1.2;transition:cx .35s ease,cy .35s ease}
.board .peg-back{fill:none;stroke-width:1.6;opacity:.75}

/* ---------- Phase ---------- */
.phasebar{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  font-size:13px;color:var(--dim);padding:0 2px;
}
.phasebar b{color:var(--txt)}
.phase-steps{display:flex;align-items:center;gap:6px}
.step{
  font-size:11px;font-weight:700;letter-spacing:.6px;text-transform:uppercase;
  padding:3px 10px;border-radius:999px;border:1px solid var(--line);
}
.step.is-on{color:var(--on-primary,#fff);background:var(--green-d);border-color:var(--green)}
.step-sep{opacity:.5}

/* ---------- Players ---------- */
.players{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.players.three{grid-template-columns:1fr 1fr 1fr;gap:6px}

.pcol{display:flex;flex-direction:column;gap:6px;min-width:0}
.phead{
  background:var(--card);border:2px solid var(--line);border-top:4px solid var(--pc);
  border-radius:12px;padding:5px 6px;
  display:flex;flex-direction:column;align-items:center;
}
.pcol.counting .phead{border-color:var(--pc);background:color-mix(in srgb, var(--pc) 14%, var(--card))}
.pname{font-size:12.5px;font-weight:700;color:var(--dim);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pscore{font-size:30px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
/* badge row: one line, fixed height, so nothing below it moves */
.prow{display:flex;gap:5px;align-items:center;justify-content:center;min-height:22px;max-width:100%}
.pmeta{display:flex;gap:5px;align-items:center}
.heels{
  font-size:11px;color:var(--gold);white-space:nowrap;
  border:1px solid var(--badge-line,#6b5620);background:var(--badge-bg,#241f11);border-radius:999px;padding:2px 9px;
}
.heels b{font-weight:800}
.heels:active{filter:brightness(1.15)}
.badge-d{
  font-size:9.5px;font-weight:800;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:1px 7px;border-radius:999px;
}
.lead{font-size:11px;font-weight:700;color:var(--green)}

/* Pegging keys under each player: Heels when it's live, the four common
   ones two by two, then "Of a kind" and "Run of" sections whose keys are
   just numbers — smaller for the rarer ones. */
.ppad{display:flex;flex-direction:column;gap:7px}
.pgrid{display:grid;gap:5px}
.pgrid.g2{grid-template-columns:1fr 1fr}
.pgrid.g3{grid-template-columns:1fr 1fr 1fr}
.psec{display:flex;flex-direction:column;gap:5px}
.psec-label{
  font-size:10px;font-weight:700;letter-spacing:.8px;text-transform:uppercase;
  color:var(--dim);padding-left:2px;
}
.pkey{
  background:var(--card);border:1px solid var(--line);border-radius:10px;
  padding:8px 2px 6px;display:flex;flex-direction:column;align-items:center;gap:1px;
  min-width:0;
}
.pkey b{font-size:14px;font-weight:700;white-space:nowrap}
.sm .pkey{padding:5px 1px 4px}
.sm .pkey b{font-size:13px}
.sm .pkey small{font-size:9.5px}
.pkey small{font-size:10.5px;color:var(--dim);font-variant-numeric:tabular-nums}
.pkey:active{background:color-mix(in srgb, var(--pc, var(--green)) 35%, var(--card));border-color:var(--pc, var(--green))}
.players.three .pkey b{font-size:12.5px}
.players.three .pgrid.g2 .pkey b{font-size:12px}
.players.three .sm .pkey b{font-size:12px}
.players.three .ppad{gap:4px}

/* ---------- Count ---------- */
.countbox{display:flex;flex-direction:column;gap:8px}
.count-seq{display:flex;flex-wrap:wrap;align-items:center;gap:5px;justify-content:center}
.cs{
  font-size:11.5px;font-weight:600;padding:3px 9px;border-radius:999px;
  border:1px solid var(--line);color:var(--dim);
}
.cs.now{color:#fff;border-color:var(--pc);background:color-mix(in srgb, var(--pc) 45%, var(--card))}
.cs.done{text-decoration:line-through;opacity:.5}
.cs-sep{color:var(--dim);opacity:.5;font-size:12px}

.handcard{
  background:var(--card);border:2px solid var(--pc);border-radius:12px;
  padding:10px;display:flex;flex-direction:column;gap:8px;
}
.hand-head{display:flex;align-items:center;justify-content:space-between}
.hand-head b{font-size:16px}
.hand-name{display:flex;flex-direction:column;align-items:flex-start;gap:5px}

.hand-total{font-size:28px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1}
.hand-total.bad{color:var(--neg,#e2857a)}
.hand-taps{display:flex;flex-wrap:wrap;gap:5px;min-height:22px}
.tap{font-size:12px;font-weight:600;background:var(--bg2);border:1px solid var(--line);border-radius:999px;padding:2px 9px}
.tap-none{font-size:12px;color:var(--dim)}
.hand-pad{display:grid;grid-template-columns:repeat(5,1fr);gap:5px}
.hand-pad .pkey{--pc:var(--green)}
.combo-pad{display:grid;grid-template-columns:repeat(4,1fr);gap:5px}
.pkey.combo{--pc:var(--green);padding:7px 2px 5px;gap:2px}
.pkey.combo b{font-size:11.5px;white-space:normal;line-height:1.15;text-align:center}
/* a reminder that 15s, flushes and knobs are still tapped separately */
.psec-note{font-style:normal;font-weight:600;letter-spacing:.2px;text-transform:none;opacity:.75;margin-left:4px}
.pkey.combo .cards{font-size:10px;color:var(--dim);letter-spacing:.3px;white-space:nowrap}
.typed-row{display:flex;gap:6px}
.typed-row input{padding:10px;font-size:15px}
.key.small{
  background:var(--bg2);border:1px solid var(--line);border-radius:10px;
  padding:0 16px;font-size:18px;
}

/* ---------- Actions ---------- */
.actions{display:flex;flex-direction:column;gap:20px;padding-top:4px}
.mini-row{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.mini-row.three{grid-template-columns:1fr 1fr 1fr}
.primary:disabled{cursor:default}

.msg{text-align:center;font-size:13px;font-weight:600;color:var(--gold);min-height:16px;line-height:1.2}

.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 minmax(44px,auto);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 b{text-align:right;color:var(--txt);font-variant-numeric:tabular-nums}
.hdot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px;vertical-align:0}

/* ---------- 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}
.win-skunk{font-weight:800;color:var(--neg,#e2857a) !important;font-size:16px !important}
.win-skunk:empty,.win-save:empty{display:none}
.win-save{font-size:12.5px !important}
.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}

@media (max-height:640px){
  .pkey{padding:6px 2px 4px}
  .pscore{font-size:26px}
}

/* three across: the Dealer badge and Heels share one narrow header row */
.players.three .badge-d{font-size:8.5px;padding:1px 5px;letter-spacing:.3px}
.players.three .heels{font-size:10px;padding:2px 6px}
.players.three .prow{gap:3px}

/* ---------- Cards mode ----------
   Entering the hand's cards, inside the hand card. */
.mode-row{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;gap:2px}
.mode{font-size:11.5px;font-weight:700;padding:3px 11px;border-radius:999px;color:var(--dim)}
.mode.is-on{background:var(--green-d);color:var(--on-primary,#fff)}
.ct-box{display:flex;flex-direction:column;gap:9px}

/* five playing cards: the hand, a gap, the starter */
.ct-slots{display:flex;gap:6px;justify-content:center;align-items:center}
.ct-gap{width:10px}
.ct-card{
  width:50px;height:68px;border-radius:8px;background:#fffdf7;color:#1a1a1a;
  border:2px solid var(--line);display:flex;align-items:center;justify-content:center;
  box-shadow:0 2px 6px var(--shadow,#0006);
}
.ct-card b{font-size:23px;font-weight:800}
.ct-card.empty{background:var(--bg2);border:2px dashed var(--line);box-shadow:none}
.ct-card.is-at{border-color:var(--green);box-shadow:0 0 0 3px color-mix(in srgb, var(--green) 35%, transparent)}
.ct-card.empty.is-at{border-style:solid}
/* while a question is open: the cards it asks about, and the rest */
.ct-card.asked{border-color:var(--gold);box-shadow:0 0 0 3px #e0b34166,0 2px 10px #e0b34155}
.ct-card.muted{opacity:.4}
.ct-card{transition:opacity .15s,box-shadow .15s,border-color .15s}
/* under the four hand cards and the starter, matching the gap above */
.ct-labels{display:grid;grid-template-columns:218px 50px;gap:16px;justify-content:center;
  font-size:10.5px;font-weight:700;letter-spacing:.7px;text-transform:uppercase;color:var(--dim);text-align:center;margin-top:-4px}
.ct-hint{text-align:center;font-size:12.5px;color:var(--dim);min-height:16px}
/* under the ranks: the submit button or a question, and Clear beside it */
.ct-action{display:flex;gap:6px;align-items:flex-start}
.ct-main{flex:1;min-width:0;display:flex;flex-direction:column}
.ct-main .ct-q{flex:1}
.hand-submit{width:100%}
.hand-submit:disabled{opacity:.45;cursor:default}
/* the same boxed Clear as the Buttons screen */
.ct-clear{
  flex:none;background:var(--bg2);border:1px solid var(--line);border-radius:10px;
  padding:0 14px;min-height:50px;font-size:13.5px;font-weight:600;color:var(--dim);
}
.ct-clear:active{color:var(--txt)}

.ct-ranks{display:grid;grid-template-columns:repeat(7,1fr);gap:5px}
.ct-rank{
  background:var(--bg2);border:1px solid var(--line);border-radius:9px;
  padding:11px 0;font-size:17px;font-weight:700;
}
.ct-rank:active{background:var(--green-d);border-color:var(--green)}
.ct-rank:disabled{opacity:.3}

.ct-q{background:var(--bg2);border:1px solid var(--gold);border-radius:12px;padding:10px;display:flex;flex-direction:column;gap:8px}
.ct-q p{font-size:15px;font-weight:600;text-align:center}
.ct-yn{display:flex;gap:8px}

/* the hand counted aloud: what, its points, the running total */
.ct-items{list-style:none;display:flex;flex-direction:column}
.ct-items li{display:grid;grid-template-columns:1fr 40px 32px;gap:8px;align-items:baseline;padding:6px 2px;border-top:1px solid var(--line);font-size:14px}
/* which cards score it, under the name */
.ct-items span small{display:block;font-size:12px;color:var(--dim);margin-top:1px;letter-spacing:.2px}
.ct-items li:first-child{border-top:none}
.ct-items i{font-style:normal;color:var(--dim);text-align:right}
.ct-items b{text-align:right;font-variant-numeric:tabular-nums}
.ct-none span{color:var(--dim)}

/* ---------- Simple play ---------- */
.play-mode{align-self:center}
.psimple{display:flex;flex-direction:column;gap:6px}
.skey{
  background:var(--card);border:1px solid var(--line);border-radius:12px;
  padding:16px 0;font-size:24px;font-weight:800;font-variant-numeric:tabular-nums;
}
.skey:active{background:color-mix(in srgb, var(--pc) 35%, var(--card));border-color:var(--pc)}

/* what +1, +2 and +3 each cover */
.play-legend{
  background:var(--card);border:1px solid var(--line);border-radius:12px;
  padding:10px 12px;display:flex;flex-direction:column;gap:5px;
}
.play-legend div{display:flex;gap:10px;align-items:baseline}
.play-legend dt{font-weight:800;min-width:24px;font-variant-numeric:tabular-nums}
.play-legend dd{color:var(--txt);font-size:14px}
.play-legend p{color:var(--dim);font-size:12px;line-height:1.4;margin-top:3px}

/* Buttons' Clear, beside the typed total */
.key.small.clear-btn{font-size:13.5px;font-weight:600;padding:0 14px;color:var(--dim)}

/* Buttons' submit, under the typed total */
.buttons-box{display:flex;flex-direction:column;gap:8px}

/* ---------- the room ---------- */
.brand.compact h1.room-title{font-size:19px;color:var(--txt)}
.brand h1.room-title{font-size:30px}
/* the hand on its slip: the player's colour edges it, the paper's ink writes on it */
.handcard.paper{border-color:var(--pc)}
.handcard.paper .hand-head b,.handcard.paper .hand-total{color:var(--paper-ink)}
.handcard.paper .ct-hint,.handcard.paper .tap-none,.handcard.paper .ct-labels,.handcard.paper .psec-label{color:var(--paper-dim)}
.handcard.paper .ct-items li{border-top-color:var(--paper-edge)}
.handcard.paper .ct-items,.handcard.paper .ct-items b{color:var(--paper-ink)}
.handcard.paper .ct-items i,.handcard.paper .ct-items span small{color:var(--paper-dim)}

/* a phone that joined by seat, while another player's hand is counted:
   the hand card greyed and out of reach, its button saying whose it is */
#game.waiting #handCard{opacity:.4;pointer-events:none}

/* in the play, on a phone scoring one player: everyone else's pegging
   buttons and heels greyed and out of reach */
.pcol.locked .ppad,
.pcol.locked .psimple,
.pcol.locked .heels{opacity:.35;pointer-events:none}
