/* Backgammon. An open board seen from above, in a navy case with a gold edge. app.js sizes it to the room .board-wrap is
   given (--bw is the board's width; it is 0.8 of that high) and lays the points, checkers and dice on it in percent.
   Wide screens (desktop, a tablet on its side, a sideways phone): the board beside a column with the players, the actions
   and the turn line. Upright screens: the players above the board, the actions and the turn line under it; on a tablet the
   players and the actions stand side by side under the board. */

/* Board themes: the field and its grain, the two point colours, the wood of the bar and the tray, and the table's own
   checkers. A tile of the look pop-up or of New game carries the same attribute, so it previews its own theme. */
[data-board=walnut] { --field: #5d3a22; --grain: #25140a; --grain-o: .5; --point-a: #17110d; --point-b: #e3bb7c; --point-line: #0000005c; --frame-a: #8a5630; --tray: #3a2213; --light: #ecc88c; --light-2: #c9995a; --light-3: #8f6430; --dark: #4a2f1e; --dark-2: #2c1a10; --dark-3: #120a06; }
[data-board=mahogany] { --field: #b8663a; --grain: #6f3216; --grain-o: .45; --point-a: #1f5c50; --point-b: #f2dcb2; --point-line: #00000045; --frame-a: #b5633a; --tray: #7c3f22; --light: #ecd0a6; --light-2: #cda877; --light-3: #9a7647; --dark: #4d362b; --dark-2: #33221a; --dark-3: #170e0a; }
[data-board=lacquer] { --field: #f3ecdc; --grain: #000; --grain-o: 0; --point-a: #1b2a52; --point-b: #6d8fe3; --point-line: #00000030; --frame-a: #cf9b7c; --tray: #e4d6c2; --tray-ink: #2a3252; --light: #98a6ee; --light-2: #7f8fe0; --light-3: #5a69bd; --dark: #1f2a4d; --dark-2: #151d38; --dark-3: #080c1c; }
[data-board=felt] { --field: #1f5c46; --grain: #0c2c20; --grain-o: .28; --point-a: #efe2c6; --point-b: #9c332c; --point-line: #00000050; --frame-a: #7a4b2a; --tray: #153f30; --light: #f6ecd8; --light-2: #dcc9a6; --light-3: #a8936b; --dark: #8d2a25; --dark-2: #641a17; --dark-3: #2e0a09; }
[data-board=royal] { --field: #16295c; --grain: #050d28; --grain-o: .3; --point-a: #e6bf5c; --point-b: #f1ead8; --point-line: #00000050; --frame-a: #b98a2c; --tray: #0d1b40; --light: #f6ecd8; --light-2: #dcc9a6; --light-3: #a8936b; --dark: #c2372f; --dark-2: #8f1f1a; --dark-3: #470a08; }
[data-board=ebony] { --field: #2a2a30; --grain: #000; --grain-o: .35; --point-a: #b3312b; --point-b: #d9cfbd; --point-line: #00000060; --frame-a: #55555e; --tray: #17171a; --light: #f1e3c4; --light-2: #d6c097; --light-3: #9c8457; --dark: #d8ab42; --dark-2: #a67c20; --dark-3: #5e430b; }
/* Checker sets of their own: they replace the table's two colours. */
[data-pieces=classic] { --light: #f1e3c4; --light-2: #d6c097; --light-3: #9c8457; --dark: #3c3c43; --dark-2: #222226; --dark-3: #09090b; }
[data-pieces=ruby] { --light: #faf4e8; --light-2: #e0d3bd; --light-3: #a8997c; --dark: #c2302a; --dark-2: #8f1c18; --dark-3: #4a0a08; }
[data-pieces=royal] { --light: #f3cf6a; --light-2: #d2a53a; --light-3: #8f6a17; --dark: #3a5fc4; --dark-2: #223b8f; --dark-3: #0d1a4a; }
[data-pieces=emerald] { --light: #eef5e6; --light-2: #cfdcc0; --light-3: #93a37f; --dark: #2a8a59; --dark-2: #17633c; --dark-3: #07321c; }
[data-pieces=plum] { --light: #f7d7e3; --light-2: #e0aec2; --light-3: #a8718a; --dark: #6f39a6; --dark-2: #48207a; --dark-3: #210b40; }
/* Dice colours: the two sides of the plate, the rounded edge and the dots. */

/* ---------- The room ---------- */
.stage { flex: 1; min-height: 0; display: flex; gap: 18px; justify-content: center; padding: 12px max(12px, var(--gk-safe-end)) max(12px, var(--gk-safe-bottom)) max(12px, var(--gk-safe-start)); }
.board-wrap { flex: 1; min-width: 0; min-height: 0; display: grid; place-items: center; }
.case { --bw: 600px; --rim: calc(var(--bw) * .028); direction: ltr; padding: var(--rim); border-radius: calc(var(--rim) * .9);
  background: linear-gradient(145deg, var(--gk-raise), var(--gk-rim)); border: 1px solid var(--gk-gold-deep); box-shadow: 0 0 0 3px var(--gk-rim), var(--gk-shadow-2), var(--gk-inset); }
.board { position: relative; width: var(--bw); height: calc(var(--bw) * .8); isolation: isolate; touch-action: manipulation; }
.board::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2; box-shadow: inset 0 0 calc(var(--bw) * .03) var(--gk-dark), inset 0 0 0 1px var(--gk-dark); }
#board-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board.reversed #board-art { transform: scaleX(-1); }
#points { position: absolute; inset: 0; z-index: 3; }
/* A clear board behind New game and while a room waits for its people. */
html.gk-clear :is(#board .checker, #dice > *, .off-tray .slabs, .cube-badge) { visibility: hidden; }

/* ---------- Points and checkers ---------- */
.point { position: absolute; width: 7.2%; height: 41%; padding: 0; border: 0; background: none; }
.point.top { top: 0; } .point.bottom { bottom: 0; }
:is(.point, .bar, .off-tray):disabled { cursor: default; opacity: 1; }
/* Point numbers stand in the rim, when the rim is wide enough for them (app.js marks the case "numbered"). */
.point-number { display: none; position: absolute; left: 0; right: 0; text-align: center; font-size: var(--gk-text-xs); line-height: var(--rim); color: color-mix(in srgb, var(--gk-ink) 70%, transparent); pointer-events: none; }
.case.numbered .point-number { display: block; }
.point.top .point-number { bottom: 100%; } .point.bottom .point-number { top: 100%; }
.checker {
  position: absolute; left: 5%; width: 90%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  background: linear-gradient(150deg, color-mix(in srgb, var(--gk-white) 28%, transparent), transparent 46%, color-mix(in srgb, var(--gk-night) 22%, transparent)), radial-gradient(circle, var(--c2) 0 17%, var(--c1) 18% 33%, var(--c3) 34% 36%, var(--c1) 37% 57%, var(--c3) 58% 61%, var(--c1) 62% 100%);
  box-shadow: inset 0 0 0 1px var(--c3), 0 calc(var(--bw) * .003) calc(var(--bw) * .005) var(--gk-dark);
}
.checker.light { --c1: var(--light); --c2: var(--light-2); --c3: var(--light-3); }
.checker.dark { --c1: var(--dark); --c2: var(--dark-2); --c3: var(--dark-3); }
.point.can-select .checker:last-of-type { box-shadow: inset 0 0 0 1px var(--c3), 0 0 0 calc(var(--bw) * .004) var(--gk-gold), 0 0 calc(var(--bw) * .016) var(--gk-gold); }
.point.last-move:not(.can-select) .checker:last-of-type { box-shadow: inset 0 0 0 1px var(--c3), 0 0 0 calc(var(--bw) * .003) color-mix(in srgb, var(--gk-white) 63%, transparent); }
.point.destination::before { content: ""; position: absolute; inset: 0; background: linear-gradient(color-mix(in srgb, var(--gk-gold) 50%, transparent), color-mix(in srgb, var(--gk-gold) 18%, transparent)); }
.point.top.destination::before { clip-path: polygon(7% 0, 93% 0, 50% 100%); }
.point.bottom.destination::before { clip-path: polygon(7% 100%, 93% 100%, 50% 0); }
.target-dot { position: absolute; left: 5%; width: 90%; aspect-ratio: 1; border-radius: 50%; border: calc(var(--bw) * .004) dashed var(--gk-white); background: color-mix(in srgb, var(--gk-gold) 44%, transparent); box-shadow: 0 0 calc(var(--bw) * .02) var(--gk-gold); pointer-events: none; z-index: 3; }
/* A checker on its way between two points. */
.checker.gliding { box-shadow: inset 0 0 0 1px var(--c3), 0 8px 14px var(--gk-dark); }

/* ---------- The bar: hit checkers wait on the hinge strip ---------- */
.bar { position: absolute; left: 43.2%; width: 5.6%; height: 30%; padding: 0; border: 0; background: none; z-index: 3; }
.board.reversed .bar { left: 51.2%; }
.bar-top { top: 13%; } .bar-bottom { bottom: 13%; }
.bar .checker { left: 4%; width: 92%; top: 50%; translate: 0 -50%; }
.bar b { position: absolute; left: 0; right: 0; top: 50%; translate: 0 -50%; text-align: center; font-size: max(var(--gk-text-xs), calc(var(--bw) * .026)); color: var(--gk-white); text-shadow: 0 1px 3px var(--gk-night), 0 0 2px var(--gk-night); pointer-events: none; }
.bar.zero { visibility: hidden; }
.bar.can-select .checker { box-shadow: inset 0 0 0 1px var(--c3), 0 0 0 calc(var(--bw) * .004) var(--gk-gold), 0 0 calc(var(--bw) * .016) var(--gk-gold); }

/* ---------- The bear-off tray beside the home board: borne-off checkers stand on edge ---------- */
.off-tray { position: absolute; left: 93.3%; width: 6.5%; height: 48.3%; padding: 0; border: 0; background: none; z-index: 3; }
.board.reversed .off-tray { left: .2%; }
.opponent-off { top: .6%; } .your-off { bottom: .6%; }
.slabs { position: absolute; inset: 3% 9%; display: flex; flex-direction: column; gap: 1.2%; }
.your-off .slabs { flex-direction: column-reverse; }
.slab { flex: none; height: 5.2%; border-radius: calc(var(--bw) * .003); box-shadow: 0 1px 1px var(--gk-dark); }
.slab.light { background: linear-gradient(90deg, var(--light-3), var(--light) 22%, var(--light) 78%, var(--light-3)); }
.slab.dark { background: linear-gradient(90deg, var(--dark-3), var(--dark) 22%, var(--dark) 78%, var(--dark-3)); }
.off-tray b { position: absolute; left: 0; right: 0; font-size: max(var(--gk-text-xs), calc(var(--bw) * .022)); font-weight: var(--gk-number); color: var(--tray-ink, var(--gk-ink)); text-align: center; }
.opponent-off b { bottom: 2%; } .your-off b { top: 2%; }
.off-tray.destination { background: color-mix(in srgb, var(--gk-gold) 33%, transparent); box-shadow: 0 0 0 calc(var(--bw) * .004) var(--gk-gold), 0 0 calc(var(--bw) * .03) var(--gk-gold); border-radius: calc(var(--bw) * .006); }

/* The table turned round: your side is the top one. */
.board.flipped .bar-top { top: auto; bottom: 13%; } .board.flipped .bar-bottom { bottom: auto; top: 13%; }
.board.flipped .opponent-off { top: auto; bottom: .6%; } .board.flipped .your-off { bottom: auto; top: .6%; }
.board.flipped .your-off .slabs { flex-direction: column; } .board.flipped .opponent-off .slabs { flex-direction: column-reverse; }
.board.flipped .opponent-off b { bottom: auto; top: 2%; } .board.flipped .your-off b { top: auto; bottom: 2%; }
.board.flipped .cube-badge[data-side=mine] { top: 7%; } .board.flipped .cube-badge[data-side=theirs] { top: 93%; }

/* ---------- Dice: solid lit dice (shared/dice.js and dice.css; the roller's dice skin) thrown onto the roller's half ---------- */
.dice-zone { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.die {
  --die: calc(var(--bw) * .068);
  position: absolute; width: var(--die); height: var(--die); padding: 0; border: 0; border-radius: 21%; pointer-events: auto; transform: translate(-50%, -50%); perspective: calc(var(--die) * 9);
  transition: opacity .25s, scale .2s;
}
.die:disabled { pointer-events: none; opacity: 1; }
.die.used { opacity: .45; scale: .9; }
.die.chosen { outline: calc(var(--die) * .07) solid var(--gk-gold); outline-offset: calc(var(--die) * .08); }
.die:not(:disabled):hover { scale: 1.07; }
/* A throw is drawn by app.js, frame by frame (see simulateThrow). The two extra dice of a double pop in. */
.die.pop { animation: die-pop .24s ease-out backwards; }
@keyframes die-pop { from { scale: 0; opacity: 0; } }

/* ---------- The doubling cube: in the middle of the bar until someone takes a double, then on its owner's side ---------- */
.cube-badge { position: absolute; left: 46%; top: 50%; translate: -50% -50%; z-index: 4; width: calc(var(--bw) * .052); aspect-ratio: 1; display: grid; place-items: center; border-radius: 18%;
  background: linear-gradient(145deg, var(--gk-white), var(--gk-ink-soft)); color: var(--gk-on-gold); font-weight: var(--gk-number); font-size: max(var(--gk-text-xs), calc(var(--bw) * .027));
  box-shadow: 0 0 0 2px var(--gk-gold-deep), var(--gk-shadow-2); transition: top var(--gk-slow) ease; pointer-events: none; }
.board.reversed .cube-badge { left: 54%; }
.cube-badge[data-side=mine] { top: 93%; } .cube-badge[data-side=theirs] { top: 7%; }

/* ---------- The column: the players, the actions and the turn line ---------- */
.side { flex: none; width: 288px; display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 0; }
.seats { display: grid; gap: 8px; }
.seats.flipped #you { order: -1; }
.seat-light { --seat: var(--gk-gold-pale); } .seat-dark { --seat: var(--gk-info); }
.seat-mark { position: relative; flex: none; width: 30px; height: 30px; }
.seat-mark .checker { left: 0; width: 100%; box-shadow: inset 0 0 0 1px var(--c3), var(--gk-shadow-1); }
.gk-seat-score small { display: block; font-size: var(--gk-text-xs); font-weight: var(--gk-regular); line-height: 1.2; color: var(--gk-muted); white-space: nowrap; }
.gk-seat-score b { display: block; font-weight: inherit; line-height: 1.2; }
.play { display: flex; flex-direction: column; gap: 10px; }
/* Roll, Double and the switch for bearing off by itself. The row keeps its height when it is empty. */
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: var(--gk-tap); }
.actions .gk-btn { flex: 1 1 auto; padding-inline: 12px; }
#roll { animation: roll-ready 1.1s ease-in-out infinite alternate; }
@keyframes roll-ready { to { scale: 1.06; } }
/* Room for the turn and two lines under it, so nothing moves when the words change. */
.talk { min-height: 64px; padding-inline: 4px; }
.gk-event { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* ---------- Small pictures on the tiles of New game and of the look pop-up ---------- */
.mini-home { position: relative; display: block; width: 100%; aspect-ratio: 1.7; border-radius: var(--gk-r-sm); background: var(--field); border: 3px solid var(--frame-a); overflow: hidden; }
.mini-home i { position: absolute; left: calc(50% - 2px); top: 0; bottom: 0; width: 4px; background: var(--frame-a); }
.mini-home b { position: absolute; width: calc(50% - 2px); height: 50%; background: var(--gk-gold); opacity: .9; }
[data-home=br] .mini-home b, .mini-home[data-home=br] b { right: 0; bottom: 0; }
[data-home=bl] .mini-home b, .mini-home[data-home=bl] b { left: 0; bottom: 0; }
[data-home=tr] .mini-home b, .mini-home[data-home=tr] b { right: 0; top: 0; }
[data-home=tl] .mini-home b, .mini-home[data-home=tl] b { left: 0; top: 0; }
.mini { position: relative; display: block; width: 100%; aspect-ratio: 1.9; border-radius: var(--gk-r-sm); overflow: hidden; background: var(--field); border: 3px solid var(--frame-a); }
.mini i { position: absolute; top: 0; width: 25%; height: 62%; clip-path: polygon(8% 0, 92% 0, 50% 100%); background: var(--point-a); }
.mini i:nth-child(2) { left: 25%; background: var(--point-b); } .mini i:nth-child(3) { left: 50%; } .mini i:nth-child(4) { left: 75%; background: var(--point-b); }
.mini .checker { top: auto; bottom: 6%; width: 22%; left: 16%; box-shadow: inset 0 0 0 1px var(--c3); }
.mini .checker.dark { left: 62%; }
.mini-piece, .mini-pair { position: relative; display: block; width: 100%; height: 34px; }
.mini-piece .checker, .mini-pair .checker { top: 2px; width: 30px; left: calc(50% - 15px); box-shadow: inset 0 0 0 1px var(--c3), var(--gk-shadow-1); }
.mini-pair .checker.light { left: calc(50% - 32px); } .mini-pair .checker.dark { left: calc(50% + 2px); }
.gk-seg .mini-home { width: 54px; max-width: 80%; flex: none; border-width: 2px; margin-bottom: 3px; }
.gk-seg .mini { width: 62px; flex: none; border-width: 2px; margin-bottom: 3px; }
.gk-seg .mini-piece { width: 34px; flex: none; } .gk-seg .mini-pair { width: 70px; flex: none; }
/* The look pop-up: each list of tiles wraps into rows (app.js gives the number of columns). */
.look-seg { grid-auto-flow: row; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
.look-seg button { gap: 4px; padding: 7px 3px 6px; }
.look-seg button b { font-size: var(--gk-text-xs); line-height: 1.25; white-space: normal; }

/* ---------- Upright screens: the players on top, the board, then the actions and the turn line ---------- */
@media (orientation: portrait) {
  .stage { flex-direction: column; gap: 10px; padding-top: 10px; }
  .board-wrap { width: 100%; }
  .side { display: contents; }
  .seats { order: -1; grid-template-columns: 1fr 1fr; }
  .seats, .play { width: min(100%, 560px); align-self: center; }
  .actions { flex-wrap: nowrap; }
  .actions .gk-btn { min-width: 0; font-size: var(--gk-text-sm); }
  .talk { text-align: center; }
}
/* A phone: small plates, two to a row. */
@media (max-width: 599px) {
  .gk-seat { padding: 6px 9px; gap: 7px; border-radius: 12px; } .gk-seat-note { display: none; }
  .seat-mark { width: 24px; height: 24px; } .gk-seat-score { min-width: 0; font-size: var(--gk-text-md); }
}
/* An upright tablet: the players on one side under the board, the actions and the turn on the other. */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: portrait) {
  .stage { gap: 16px; padding-top: 16px; }
  .side { display: flex; flex-direction: row; align-items: center; width: 100%; max-width: 760px; align-self: center; gap: 18px; }
  .seats { flex: 3; width: auto; grid-template-columns: 1fr; }
  .play { flex: 2; min-width: 0; width: auto; }
  .gk-turn { font-size: var(--gk-text-lg); }
}
/* A tablet on its side: a narrower column beside the board. */
@media (min-width: 600px) and (max-width: 1023px) and (orientation: landscape) { .side { width: 256px; } }
/* A sideways phone. */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { gap: 12px; padding-top: 6px; padding-bottom: max(6px, var(--gk-safe-bottom)); }
  .side { width: 236px; gap: 8px; }
  .gk-seat { padding: 5px 10px; } .gk-seat-note { display: none; } .seat-mark { width: 24px; height: 24px; }
  .play { gap: 6px; } .talk { min-height: 0; }
}
/* A board or checker set the player does not own yet (a shop skin): shown, marked 💎, and pressing it opens the shop. */
.look-seg button.locked { opacity: .62; }
