/* Skip-Bo table. Seats sit around the building piles: you along the bottom,
   the next player on the left, the third on the right, anyone else across the top.
   Five pile columns line up: four piles, then stock or the draw pile. */

#view-skipbo:not([hidden]) { display: block; }

html:has(body.skipbo-play),
body.skipbo-play { overflow: hidden; }
body.skipbo-play .shell {
  max-width: none; height: 100vh; height: 100dvh; padding: 8px 12px; overflow: hidden;
}
body.skipbo-play .top { padding: 0 2px 6px; margin-bottom: 8px; }
body.skipbo-play #view-skipbo:not([hidden]) {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
}
body.skipbo-play #skipbo-root { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
body.skipbo-play .sb-play { flex: 1; min-height: 0; min-width: 0; }
body.skipbo-play .sb-play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 270px);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}
body.skipbo-play .sb-felt {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 8px 10px;
}
body.skipbo-play .sb-felt > .panel-head { flex: 0 0 auto; margin-bottom: 6px; }
body.skipbo-play .sb-side {
  width: auto; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; padding: 14px;
}
body.skipbo-play .sb-side > .fold { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.skipbo-play .sb-side > .fold.open > .fold-body { flex: 1; min-height: 0; overflow: auto; }
body.skipbo-play .sb-prompt { flex: 0 0 auto; min-height: 0; margin: 0 0 6px; }
body.skipbo-play .sb-log { flex: 1; min-height: 0; max-height: none; margin: 4px 0 0; overflow: auto; }

.sb-around {
  flex: 1; min-height: 0; min-width: 0; width: 100%; height: 100%;
  container-type: size;
  --sb-gap: 6px;
  --sb-across: 7;
  --sb-down: 5;
  /* Side lanes are the spare width. The bottom row is your hand and piles, so the
     card size leaves that row out of the height shared with the other players. */
  --sb-card: max(32px, min(
    calc((100cqi - 8rem) / var(--sb-across)),
    calc((100cqb - 9rem) / 10)
  ));
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "left main right" "you you you";
  column-gap: clamp(40px, 6vw, 96px);
  row-gap: 14px;
  justify-items: center; align-items: center;
}
.sb-around.n2 {
  --sb-across: 6; --sb-down: 5;
  grid-template-areas: "left main ." "you you you";
}
.sb-around.n3 { --sb-across: 7; --sb-down: 5; }
.sb-around.n4, .sb-around.n5, .sb-around.n6 {
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top top" "left main right" "you you you";
}
.sb-around.n4 { --sb-across: 7; --sb-down: 6; }
.sb-around.n5 { --sb-across: 10; --sb-down: 6; }
.sb-around.n6 { --sb-across: 15; --sb-down: 6; }
.sb-at { min-width: 0; min-height: 0; height: max-content; }
.sb-at-top { grid-area: top; display: flex; gap: 10px; justify-content: center; align-self: end; }
.sb-at-left, .sb-at-right, .sb-at-main { align-self: center; height: max-content; }
.sb-you {
  grid-area: you; justify-self: center; align-self: end;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: 100%;
}
.sb-at-left { grid-area: left; justify-self: center; }
.sb-at-left .sb-who, .sb-at-right .sb-who {
  flex-wrap: wrap; justify-content: center; max-width: calc(var(--sb-card) + 10px); row-gap: 2px;
}
.sb-at-main {
  grid-area: main; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0;
}
.sb-at-right { grid-area: right; }

.sb-felt, .sb-side, .sb-room { min-width: 0; }
.sb-line {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 0; min-height: 0; height: auto; margin: 0;
}
.sb-line.turn .sb-who { box-shadow: inset 3px 0 0 var(--you, var(--orange)); border-radius: 4px; }
.sb-mid {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255,255,255,0.16), transparent 55%),
    #1a7344;
  border-radius: 18px;
  padding: 16px 20px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.22),
    inset 0 12px 24px rgba(0,0,0,0.22);
}
.sb-mid .sb-cap { color: rgba(255,255,255,0.82); }
.sb-piles.sb-split {
  display: flex; align-items: flex-end; gap: 28px;
  grid-template-columns: none;
}
.sb-group {
  display: grid; grid-template-columns: repeat(4, var(--sb-card)); gap: var(--sb-gap);
}
.sb-who {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  min-width: 0; line-height: 1.2;
}
.sb-who .sb-name { flex: 0 1 auto; }
.sb-seat { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sb-name, .sb-seat b {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.sb-meta { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.sb-piles {
  flex: 0 0 auto; min-height: 0; min-width: 0;
  display: grid; grid-template-columns: repeat(5, var(--sb-card)); gap: var(--sb-gap);
  width: max-content;
}
.sb-at-left .sb-piles, .sb-at-right .sb-piles {
  display: flex; flex-direction: column; align-items: center;
  width: var(--sb-card); height: auto; gap: var(--sb-gap);
}
.sb-slot {
  min-width: 0; min-height: 0; height: auto;
  display: grid; grid-template-rows: 1.05em auto; justify-items: center;
}
.sb-at-left .sb-cap:empty, .sb-at-right .sb-cap:empty { display: none; }
.sb-at-left .sb-slot, .sb-at-right .sb-slot { grid-template-rows: auto auto; }
.sb-cap {
  height: 1.1em; line-height: 1.1; font-size: 0.62rem; text-transform: uppercase;
  color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
}
.sb-face {
  width: var(--sb-card); height: calc(var(--sb-card) * 7 / 5); min-width: 0; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.sb-face:has(.sb-stack) { height: calc(var(--sb-card) * 7 / 5 + 22px); align-items: flex-end; }
.sb-stack { position: relative; width: var(--sb-card); height: 100%; }
.sb-under {
  position: absolute; top: 0; left: 0; width: var(--sb-card); height: calc(var(--sb-card) * 7 / 5);
  border-radius: 8px; border: 1px solid #fff; overflow: hidden;
}
.sb-under.low { background: #1f78d1; color: #fff; }
.sb-under.mid { background: #2f9e36; color: #fff; }
.sb-under.high { background: #e23b32; color: #fff; }
.sb-under.wild { background: #f5b31a; color: #1a4f9c; }
#view-skipbo .sb-stack > .sb-card {
  position: absolute; left: 0; bottom: 0;
  width: var(--sb-card); height: calc(var(--sb-card) * 7 / 5);
}
#view-skipbo .sb-face > .sb-card,
#view-skipbo .sb-face > .sb-back,
#view-skipbo .sb-ghost,
.fold.floated[data-fold^="skipbo-"] .sb-face > .sb-card,
.fold.floated[data-fold^="skipbo-"] .sb-face > .sb-back {
  width: var(--sb-card); height: calc(var(--sb-card) * 7 / 5);
  max-width: none; max-height: none; aspect-ratio: auto;
}
#view-skipbo .sb-card,
.fold.floated[data-fold^="skipbo-"] .sb-card {
  position: relative; box-sizing: border-box; container-type: inline-size;
  border-radius: 8px; border: 1px solid #d9cbb8; background: #f7f1e6; color: #1c1614;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 750; font-variant-numeric: tabular-nums;
}
#view-skipbo button.sb-card,
.fold.floated[data-fold^="skipbo-"] button.sb-card { margin: 0; padding: 0; font: inherit; font-weight: 750; cursor: pointer; box-shadow: none; }
#view-skipbo .sb-card.low,
.fold.floated[data-fold^="skipbo-"] .sb-card.low { background: #1f78d1; color: #fff; border-color: #fff; }
#view-skipbo .sb-card.mid,
.fold.floated[data-fold^="skipbo-"] .sb-card.mid { background: #2f9e36; color: #fff; border-color: #fff; }
#view-skipbo .sb-card.high,
.fold.floated[data-fold^="skipbo-"] .sb-card.high { background: #e23b32; color: #fff; border-color: #fff; }
#view-skipbo .sb-card.wild,
.fold.floated[data-fold^="skipbo-"] .sb-card.wild { background: #f5b31a; color: #1a4f9c; border-color: #fff; }
#view-skipbo .sb-card.wild .sb-logo,
.fold.floated[data-fold^="skipbo-"] .sb-card.wild .sb-logo {
  font-size: clamp(0.95rem, 32cqi, 1.6rem); font-weight: 800; letter-spacing: 0.01em;
}
#view-skipbo button.sb-card.low:hover { background: #3890e4; color: #fff; }
#view-skipbo button.sb-card.mid:hover { background: #3cb844; color: #fff; }
#view-skipbo button.sb-card.high:hover { background: #ef554c; color: #fff; }
#view-skipbo button.sb-card.wild:hover { background: #ffc43a; color: #1a4f9c; }
#view-skipbo .sb-card.sb-empty,
.fold.floated[data-fold^="skipbo-"] .sb-card.sb-empty {
  background: transparent; color: var(--muted); border-style: dashed; border-color: var(--border);
}
#view-skipbo button.sb-card.sb-empty:hover { background: var(--accent-faint); color: var(--text); }
#view-skipbo .sb-card.on { outline: 2px solid var(--orange); outline-offset: 2px; }
#view-skipbo .sb-card.hot { outline: 2px solid var(--pending); outline-offset: 2px; }
#view-skipbo button.sb-card[data-sb="card"] { cursor: grab; }
#view-skipbo .sb-card.sb-lifting { opacity: 0.35; }
#view-skipbo .sb-slot.sb-drop > .sb-face > .sb-card { outline: 2px solid var(--pending); outline-offset: 2px; }
#view-skipbo .sb-slot.sb-over > .sb-face > .sb-card { outline: 2px solid var(--found, #3ddc6e); outline-offset: 2px; }
#view-skipbo .sb-card.sb-ghost {
  position: fixed; z-index: 80; margin: 0; pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
body.sb-dragging, body.sb-dragging * { cursor: grabbing; }
.sb-opp { height: auto; display: flex; flex-direction: column; align-items: center; }
.sb-opp > .fold-head { align-items: center; width: max-content; max-width: none; flex: none; }
.sb-opp .fold-toggle {
  justify-content: flex-start; flex-wrap: nowrap; text-transform: none; letter-spacing: 0;
  font-size: 0.78rem; width: auto; max-width: 100%;
}
.sb-opp .fold-arrow, .sb-opp > .fold-head > .fold-float { flex: 0 0 auto; }
.sb-opp-meta { margin: 0; text-align: center; line-height: 1.2; white-space: nowrap; }
.sb-at-left .sb-opp, .sb-at-right .sb-opp { width: max-content; max-width: none; }
.sb-at-left .sb-opp .fold-body, .sb-at-right .sb-opp .fold-body {
  display: block; height: auto; flex: none; overflow: visible;
}
.sb-opp .fold-title { flex: 0 1 auto; min-width: 0; }
.sb-opp .swatch { flex: 0 0 auto; }
.sb-opp.turn > .fold-head { box-shadow: inset 3px 0 0 var(--you, var(--orange)); }
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) {
  --sb-fit: min(76px, calc((min(520px, 100vw - 56px) - 24px) / 5));
  width: max-content; max-width: calc(100vw - 16px); max-height: none; overflow: visible;
}
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) > .fold-body { overflow: visible; }
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) .sb-piles {
  display: grid; grid-template-columns: repeat(5, var(--sb-fit)); width: max-content; height: auto;
}
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) .sb-face,
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) .sb-face > .sb-card,
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) .sb-face > .sb-back {
  width: var(--sb-fit); height: calc(var(--sb-fit) * 7 / 5);
}
.fold.floated[data-fold^="skipbo-"]:not([data-fold="skipbo-log"]) .sb-face:has(.sb-stack) {
  height: calc(var(--sb-fit) * 7 / 5 + 22px);
}
body.skipbo-play .sb-play:not(:has(.sb-side .fold:not(.floated))) { grid-template-columns: minmax(0, 1fr); }
body.skipbo-play .sb-side:not(:has(.fold:not(.floated))) { display: none; }
.sb-rank { font-size: clamp(1.55rem, 58cqi, 3.5rem); font-weight: 800; line-height: 0.85; }
.sb-corner {
  position: absolute; top: 3px; left: 4px; font-size: clamp(0.5rem, 16cqi, 0.72rem);
  font-variant-numeric: tabular-nums;
}
.sb-as { margin-top: 2px; font-size: clamp(0.45rem, 12cqi, 0.62rem); font-weight: 650; letter-spacing: 0.03em; }
.sb-count {
  position: absolute; right: 3px; bottom: 2px; font-size: clamp(0.5rem, 14cqi, 0.68rem);
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.62); color: #fff; border-radius: 999px; padding: 0 4px;
}
.sb-back {
  border-radius: 8px; border: 1px solid #4a181c;
  background: repeating-linear-gradient(45deg, #8a3039 0 6px, #6e242c 6px 12px);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 750; font-variant-numeric: tabular-nums; font-size: 1rem;
}
.sb-peek {
  position: fixed; z-index: 80; min-width: 148px; max-width: 220px;
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
}
.sb-peek b { font-size: 0.78rem; padding: 0 2px; }
.sb-peek ol {
  list-style: none; margin: 0; padding: 0; overflow: auto; max-height: min(60vh, 360px);
  display: flex; flex-direction: column; gap: 4px;
}
.sb-peek-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  height: 26px; margin: 0; padding: 0 8px; border-radius: 6px;
  font-weight: 750; font-variant-numeric: tabular-nums; color: #fff;
}
.sb-peek-card.low { background: #1f78d1; }
.sb-peek-card.mid { background: #2f9e36; }
.sb-peek-card.high { background: #e23b32; }
.sb-peek-card.wild { background: #f5b31a; color: #1a4f9c; }
.sb-peek-top { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.sb-prompt { margin: 0; }
.sb-log {
  list-style: none; margin: 0; padding: 0; font-size: 0.82rem; color: var(--muted);
  max-height: none; overflow: auto;
}
.sb-log li {
  border-left: 3px solid var(--border); padding: 1px 0 1px 8px; margin-bottom: 3px;
  overflow-wrap: anywhere; min-width: 0;
}
.sb-form { max-width: 280px; margin-top: 12px; }
.sb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sb-rules { margin: 0 0 8px; max-width: 62rem; }

@media (max-width: 720px) {
  body.skipbo-play .sb-play {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 4.6rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  #view-skipbo button.sb-card.on { outline-offset: 1px; }
}
