/* ---- The Snakes & Ladders table ---- */
/* Everything here lives inside #snakes, which snakes.js fills. The colours of
   the page come from style.css; the board has its own bright ones. */
#snakes { max-width: 560px; margin: 0 auto; }
#snakes #sn-title { text-align: center; font-weight: 700; font-size: 0.9rem; padding: 0 48px; min-height: 1.3em; margin-bottom: 6px; }

/* One column: the players, the board, what happened, the dice. (On a wide screen: see the end.) */
#snakes #sn-main { display: flex; flex-direction: column; }
#snakes #sn-left, #snakes #sn-side { display: contents; }
#snakes #sn-players { order: 1; }
#snakes #sn-board-wrap { order: 2; }
#snakes #sn-last { order: 3; }
#snakes #sn-status { order: 4; }
#snakes #sn-dice { order: 5; }
#snakes #sn-error { order: 6; }
#snakes #sn-setup { order: 7; }
#snakes #sn-hint { order: 8; }

/* The four colours of the pieces, for the players' boxes and the pieces alike. */
/* The four players: ruby, sapphire, gold and emerald. */
#snakes .sn-c0 { --sn-col: #a3283c; --sn-ink: #fff; }
#snakes .sn-c1 { --sn-col: #2f5597; --sn-ink: #fff; }
#snakes .sn-c2 { --sn-col: #c99a2e; --sn-ink: #1b1b1b; }
#snakes .sn-c3 { --sn-col: #1f7a5a; --sn-ink: #fff; }

/* The players. */
#snakes #sn-players { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#snakes .sn-player { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 48px; padding: 3px 7px 3px 6px; border-radius: 10px; border: 1px solid var(--t0); border-left: 5px solid var(--sn-col); background: rgba(0, 0, 0, 0.18); }
#snakes .sn-player.sn-turn { border-color: var(--accent); border-left-color: var(--sn-col); background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 1px var(--accent); }
#snakes .sn-player.sn-won { border-color: var(--t15); border-left-color: var(--sn-col); }
#snakes .sn-player.sn-empty { opacity: 0.55; border-style: dashed; border-left-style: solid; }
#snakes .sn-player.sn-vacant { opacity: 1; cursor: pointer; }
#snakes .sn-player.sn-vacant .sn-name { text-decoration: underline; }
#snakes .sn-dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sn-col); color: var(--sn-ink); font-weight: 800; font-size: 0.8rem; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75), 0 1px 3px rgba(0, 0, 0, 0.5); }
#snakes .sn-empty .sn-dot { opacity: 0.5; box-shadow: none; }
#snakes .sn-who { flex: 1; min-width: 0; }
#snakes .sn-name { font-weight: 700; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#snakes .sn-empty .sn-name { font-weight: 400; font-size: 0.8rem; white-space: normal; }
#snakes .sn-info { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#snakes .sn-cam { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #000; box-shadow: 0 0 0 2px var(--sn-col); flex: none; }
#snakes .sn-cam.sn-mirror { transform: none; } /* my own picture is shown as the others see it, not mirrored */
#snakes .sn-cam.blank { display: none; }
#snakes .sn-clock { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.85rem; padding: 2px 6px; border-radius: 8px; background: #f4f4f4; color: #111; }
#snakes .sn-clock.sn-low { background: #d93025; color: #fff; }

/* Table talk: a speech bubble under a player's box. */
#snakes .sn-bubble { position: absolute; left: 8px; top: calc(100% + 4px); z-index: 6; width: max-content; max-width: min(300px, 78vw); background: #fdfdfd; color: #161616; border-radius: 12px; padding: 7px 11px; font-size: 0.88rem; font-weight: 600; line-height: 1.25; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); pointer-events: none; }
#snakes .sn-bubble::after { content: ''; position: absolute; left: 18px; top: -12px; border: 6px solid transparent; border-bottom-color: #fdfdfd; }
#snakes .sn-player:nth-child(even) .sn-bubble { left: auto; right: 8px; }
#snakes .sn-player:nth-child(even) .sn-bubble::after { left: auto; right: 18px; }
#snakes .sn-bubble.sn-pop { animation: sn-pop 0.22s ease-out; }
@keyframes sn-pop { from { transform: scale(0.7); opacity: 0; } }

/* The board: square, a little smaller than the column it sits in, and never taller than the screen. */
#snakes #sn-board-wrap { position: relative; width: min(92%, calc(100dvh - 300px)); min-width: 260px; margin: 8px auto 0; }
#snakes #sn-board { border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 2px #c9a24b, 0 0 0 9px #173d2c, 0 0 0 10px rgba(201, 162, 75, 0.6), 0 12px 26px rgba(0, 0, 0, 0.55); line-height: 0; margin: 10px; }
#snakes #sn-svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
#snakes .sn-frame { fill: #173d2c; }
#snakes .sn-square { stroke: rgba(92, 70, 38, 0.35); stroke-width: 1.5; }
#snakes .sn-no { font: 600 22px Georgia, 'Times New Roman', serif; fill: rgba(70, 50, 24, 0.78); }
#snakes .sn-goal { font: 700 15px Georgia, 'Times New Roman', serif; letter-spacing: 1.5px; text-anchor: middle; fill: #4a3410; }
#snakes .sn-goal-ring { fill: none; stroke: rgba(74, 52, 16, 0.55); stroke-width: 2; stroke-dasharray: 3 4; }
#snakes .sn-start { font: 700 14px Georgia, 'Times New Roman', serif; letter-spacing: 2px; text-anchor: middle; fill: rgba(70, 50, 24, 0.7); }
/* Special squares: a dark green medallion with a gold mark. */
#snakes .sn-special > circle { fill: #173d2c; stroke: #c9a24b; stroke-width: 2.5; }
#snakes .sn-mark path, #snakes .sn-mark circle { fill: #e2c170; }
#snakes .sn-mark .sn-line { fill: none; stroke: #e2c170; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
/* Ladders: dark underneath, wood on top. */
#snakes .sn-ladder { opacity: 0.95; }
#snakes .sn-wood-edge { stroke: #3a2511; stroke-width: 11; stroke-linecap: round; }
#snakes .sn-wood { stroke: #7a5328; stroke-width: 6.5; stroke-linecap: round; }
#snakes .sn-wood.sn-rung { stroke: #c9a24b; stroke-width: 5; } /* walnut rails, brass rungs */
/* Snakes. */
#snakes .sn-snake { opacity: 0.95; }
#snakes .sn-skin { stroke: rgba(20, 14, 6, 0.75); stroke-width: 2.5; stroke-linejoin: round; }
#snakes .sn-spot { fill: rgba(255, 236, 190, 0.38); }
#snakes .sn-eye { fill: #f0d58a; stroke: rgba(0, 0, 0, 0.6); stroke-width: 1; }
#snakes .sn-tongue { stroke: #7a1420; stroke-width: 2.5; stroke-linecap: round; fill: none; }
/* Where the dice lead: dashed where a die lands, full where the move ends. */
#snakes .sn-target { stroke-width: 10; fill-opacity: 0.3; pointer-events: none; animation: sn-blink 0.7s ease-in-out infinite alternate; }
#snakes .sn-target.sn-via { fill-opacity: 0; stroke-dasharray: 18 11; }
@keyframes sn-blink { from { opacity: 0.55; } to { opacity: 1; } }
/* The pieces. */
#snakes .sn-piece { pointer-events: none; }
#snakes .sn-body { fill: var(--sn-col); stroke: #1c140a; stroke-width: 3; }
#snakes .sn-piece.sn-turn .sn-body { stroke: #f3e2ae; stroke-width: 5; }
#snakes .sn-piece.sn-mine .sn-body { stroke: #f3e2ae; stroke-width: 6; }
#snakes .sn-shine { fill: rgba(255, 255, 255, 0.2); }
#snakes .sn-initial { font: 700 34px Georgia, 'Times New Roman', serif; text-anchor: middle; fill: var(--sn-ink); }
#snakes .sn-ring { display: none; fill: rgba(77, 217, 255, 0.22); stroke: #4dd9ff; stroke-width: 6; stroke-dasharray: 11 7; }
#snakes .sn-piece.sn-shielded .sn-ring { display: inline; }
#snakes .sn-pulse { fill: none; stroke-width: 9; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: sn-pulse 0.8s ease-out forwards; }
#snakes .sn-pulse-shield { stroke: #4dd9ff; }
#snakes .sn-pulse-bump { stroke: #ff3b30; }
#snakes .sn-pulse-rocket { stroke: #ff9f1c; }
@keyframes sn-pulse { from { transform: scale(0.6); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }

/* What just happened, and whose go it is. */
#snakes #sn-last { text-align: center; font-size: 0.86rem; line-height: 1.3; min-height: 2.6em; margin-top: 6px; color: var(--t3); }
#snakes #sn-status { text-align: center; font-weight: 700; min-height: 1.5em; margin: 2px 0; }
#snakes #sn-status.sn-go { color: var(--accent); }
#snakes #sn-error { text-align: center; min-height: 1.2em; margin: 2px 0 0; }
#snakes #sn-hint { margin-top: 10px; line-height: 1.45; }

/* The two dice. On my turn each is a big button. */
#snakes .sn-dice-row { display: flex; gap: 10px; margin-top: 4px; }
#snakes .sn-die { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; min-height: 112px; padding: 9px 4px 6px; border-radius: 16px; border: 2px solid var(--sn-die); background: rgba(0, 0, 0, 0.22); color: var(--text); -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease-out, opacity 0.2s; }
#snakes .sn-die0 { --sn-die: #c0701c; --sn-glow: rgba(192, 112, 28, 0.5); }
#snakes .sn-die1 { --sn-die: #1f7f8c; --sn-glow: rgba(31, 127, 140, 0.5); }
#snakes .sn-die:disabled { opacity: 1; }
#snakes .sn-die.sn-can { background: rgba(255, 255, 255, 0.1); box-shadow: 0 0 0 2px var(--sn-die), 0 0 16px 2px var(--sn-glow); animation: sn-nudge 1.1s ease-in-out infinite alternate; }
#snakes .sn-die.sn-can:active { transform: scale(0.96); }
#snakes .sn-die.sn-no-go, #snakes .sn-die.sn-dim { opacity: 0.4; }
#snakes .sn-die.sn-picked { background: rgba(255, 255, 255, 0.08); }
@keyframes sn-nudge { from { transform: translateY(0); } to { transform: translateY(-3px); } }
#snakes .sn-face { flex: none; width: 60px; height: 60px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3px; padding: 9px; border-radius: 13px; background: #fdfdfb; border: 3px solid var(--sn-die); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.08); }
#snakes .sn-face i { border-radius: 50%; }
#snakes .sn-face i.sn-on { background: #1b1b1b; }
#snakes .sn-face.sn-blank { background: #c9cdc9; }
#snakes .sn-face.sn-tumble { animation: sn-tumble 0.65s ease-out; }
#snakes .sn-die1 .sn-face.sn-tumble { animation-direction: reverse; }
@keyframes sn-tumble {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-16px) rotate(140deg); }
  50% { transform: translateY(0) rotate(250deg); }
  75% { transform: translateY(-7px) rotate(330deg); }
  100% { transform: translateY(0) rotate(360deg); }
}
#snakes .sn-cap { font-weight: 800; font-size: 0.98rem; line-height: 1.25; min-height: 2.5em; text-align: center; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#snakes #sn-dice.sn-mine .sn-cap { font-size: 1.05rem; }
/* The time left to pick. */
#snakes #sn-timer { height: 6px; margin-top: 8px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
#snakes #sn-timer.sn-off { visibility: hidden; }
#snakes #sn-timer-fill { height: 100%; width: 100%; background: var(--accent); border-radius: 3px; transition: width 0.25s linear; }
#snakes #sn-timer.sn-low #sn-timer-fill { background: #d93025; }
#snakes #sn-setup > button { min-height: 48px; }

/* The winner, over the board, and paper falling. */
#snakes #sn-result { position: absolute; left: 50%; top: 40%; z-index: 4; width: min(90%, 380px); transform: translate(-50%, -50%); padding: 14px 14px 12px; border-radius: 16px; background: var(--panel); border: 2px solid var(--accent); text-align: center; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.65); animation: sn-win 0.4s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes sn-win { from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } }
#snakes .sn-result-head { font-weight: 800; font-size: 1.35rem; }
#snakes .sn-result-how { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
#snakes .sn-scores { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 9px; }
#snakes .sn-score { font-weight: 700; font-variant-numeric: tabular-nums; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); }
#snakes .sn-score.sn-score-won { background: var(--t15); color: #1b1b1b; }
#snakes #sn-confetti { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; border-radius: 12px; }
#snakes .sn-bit { position: absolute; top: -6%; width: 9px; height: 15px; border-radius: 2px; opacity: 0.95; animation: sn-fall 3s linear forwards; }
#snakes .sn-bit:nth-child(3n) { width: 12px; height: 8px; }
#snakes .sn-bit:nth-child(4n) { border-radius: 50%; width: 9px; height: 9px; }
@keyframes sn-fall {
  from { top: -6%; transform: translateX(0) rotate(0); }
  to { top: 106%; transform: translateX(var(--sn-drift, 0)) rotate(720deg); }
}

@media (prefers-reduced-motion: reduce) {
  #snakes .sn-target, #snakes .sn-die.sn-can, #snakes .sn-face.sn-tumble, #snakes .sn-pulse, #snakes .sn-bubble.sn-pop, #snakes #sn-result, #snakes .sn-bit { animation: none; }
  #snakes .sn-pulse, #snakes .sn-bit { display: none; }
  #snakes #sn-timer-fill, #snakes .sn-die { transition: none; }
}

@media (max-width: 699px) {
  #snakes { padding-top: 46px; } /* room for the row of round buttons along the top */
  #snakes #sn-title { padding: 0; }
  #snakes #sn-board-wrap { width: min(94%, calc(100dvh - 330px)); min-width: 0; margin: 8px auto 0; }
  #snakes #sn-last { font-size: 0.82rem; }
}
@media (max-width: 380px) {
  #snakes .sn-player { padding: 3px 5px 3px 4px; gap: 5px; }
  #snakes .sn-name { font-size: 0.86rem; }
  #snakes .sn-cap { font-size: 0.9rem; }
  #snakes #sn-dice.sn-mine .sn-cap { font-size: 0.95rem; }
}

/* A wide screen: the board on the left, the players and the dice beside it.
   The section is made wider than the page's narrow column and centred on it. */
@media (min-width: 900px) {
  #snakes { --sn-w: min(980px, calc(100vw - 32px)); max-width: none; width: var(--sn-w); margin-left: calc(50% - var(--sn-w) / 2); margin-right: 0; }
  #snakes #sn-main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
  #snakes #sn-left, #snakes #sn-side { display: block; min-width: 0; }
  #snakes #sn-players { grid-template-columns: 1fr; }
  #snakes .sn-player { min-height: 54px; }
  #snakes .sn-player:nth-child(even) .sn-bubble { left: 8px; right: auto; }
  #snakes .sn-player:nth-child(even) .sn-bubble::after { left: 18px; right: auto; }
  #snakes #sn-board-wrap { width: min(92%, calc(100dvh - 190px)); margin-top: 0; }
  #snakes #sn-status { margin-top: 14px; font-size: 1.05rem; }
  #snakes .sn-die { min-height: 128px; }
  #snakes .sn-face { width: 68px; height: 68px; padding: 10px; }
  #snakes #sn-result { top: 45%; }
}

/* A player whose camera is on is their own piece: the picture sits on the piece and moves with it. */
#snakes #sn-faces { position: absolute; inset: 0; pointer-events: none; }
#snakes .sn-vid { position: absolute; aspect-ratio: 1; height: auto; transform: translate(-50%, -50%); border-radius: 50%; object-fit: cover; background: #000; box-shadow: 0 0 0 2px var(--sn-col), 0 2px 5px rgba(0, 0, 0, 0.5); }
#snakes .sn-vid.blank, #snakes .sn-vid.sn-off { display: none; }

/* The choice of board, in the settings window. */
#snakes-look-pick button { flex: 1; }
#snakes-look-pick button.picked { background: var(--t15); color: #1b1b1b; border-color: var(--t15); }

/* ---- The colourful look (the board's first look), for those who pick it ---- */
#snakes.sn-bright .sn-c0 { --sn-col: #e63946; --sn-ink: #fff; }
#snakes.sn-bright .sn-c1 { --sn-col: #2f6fed; --sn-ink: #fff; }
#snakes.sn-bright .sn-c2 { --sn-col: #f4b400; --sn-ink: #1b1b1b; }
#snakes.sn-bright .sn-c3 { --sn-col: #17a34a; --sn-ink: #fff; }
#snakes.sn-bright #sn-board { border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 0 0 3px #3b2412; margin: 0; }
#snakes.sn-bright .sn-frame { fill: #3b2412; }
#snakes.sn-bright .sn-square { stroke: rgba(0, 0, 0, 0.22); stroke-width: 2; }
#snakes.sn-bright .sn-no { font: 800 28px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; fill: rgba(0, 0, 0, 0.72); }
#snakes.sn-bright .sn-goal { font-size: 46px; letter-spacing: 0; }
#snakes.sn-bright .sn-start { font: 800 15px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: 1.5px; fill: rgba(0, 0, 0, 0.55); }
#snakes.sn-bright .sn-special > circle { fill: rgba(255, 255, 255, 0.82); stroke: rgba(0, 0, 0, 0.35); stroke-width: 3; }
#snakes.sn-bright .sn-special text { font-size: 46px; text-anchor: middle; }
#snakes.sn-bright .sn-k-shield > circle { stroke: #1597c4; }
#snakes.sn-bright .sn-k-rocket > circle { stroke: #e2590b; }
#snakes.sn-bright .sn-k-swap > circle { stroke: #6a3fd1; }
#snakes.sn-bright .sn-k-again > circle { stroke: #1b1b1b; }
#snakes.sn-bright .sn-wood-edge { stroke: #4a2b10; stroke-width: 15; }
#snakes.sn-bright .sn-wood { stroke: #e0a458; stroke-width: 9; }
#snakes.sn-bright .sn-wood.sn-rung { stroke: #c98a3f; stroke-width: 8; }
#snakes.sn-bright .sn-skin { stroke: rgba(0, 0, 0, 0.6); stroke-width: 3.5; }
#snakes.sn-bright .sn-spot { fill: rgba(255, 255, 255, 0.42); }
#snakes.sn-bright .sn-eye { fill: #fff; stroke: #111; stroke-width: 1.5; }
#snakes.sn-bright .sn-pupil { fill: #111; }
#snakes.sn-bright .sn-tongue { stroke: #d00000; stroke-width: 4.5; }
#snakes.sn-bright .sn-body { stroke: #1b1b1b; stroke-width: 4; }
#snakes.sn-bright .sn-piece.sn-turn .sn-body { stroke: #fff; stroke-width: 5; }
#snakes.sn-bright .sn-piece.sn-mine .sn-body { stroke: #fff; stroke-width: 7; }
#snakes.sn-bright .sn-initial { font: 800 36px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#snakes.sn-bright .sn-die0 { --sn-die: #ff7b00; --sn-glow: rgba(255, 123, 0, 0.55); }
#snakes.sn-bright .sn-die1 { --sn-die: #00a6d6; --sn-glow: rgba(0, 166, 214, 0.55); }
