/* ------------------------------------------------------------------ */
/* The table page: one screen, no scrolling. The table in the middle,  */
/* your hand standing along the bottom edge.                           */
/* ------------------------------------------------------------------ */

html, body { height: 100%; overflow: hidden; }
/* the whole screen is the table: its own colour, edge to edge */
html { --paper-now: color-mix(in srgb, var(--paper-deep) 55%, var(--paper)); }
.play-page .bar::before { display: none; } /* nothing scrolls under the bar here */

main.play { position: fixed; inset: 0; }

/* placed by play.js: as big as fits between the bar and your hand */
.play-table {
  position: absolute;
  left: 50%;
  top: 44px;
  translate: -50% 0;
}
.play-table .seat-label { display: none; } /* the winds in the middle say who's who */

/* the others' hands, set back toward the screen's edges (--reach, from play.js);
   a hand laid open grows in toward the table, not out off the screen */
.play-table .b-rack { top: calc(50% + var(--a) + 3.6cqw + var(--reach, 0px)); }
.play-table .b-rack.open { margin-top: calc(var(--tw) * var(--tile-depth) * 4 - var(--th) - var(--dp)); }

/* each wind in the middle has its name under it, very small, turned to its seat */
.play-table .b-center .wind { display: grid; justify-items: center; }
.play-table .b-center .wind small {
  margin-top: 0.45cqw;
  font: 500 max(7px, 0.9cqw) / 1 var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.play-table .board { background: none; box-shadow: none; border-radius: 0; }

/* the same tile as the one you're hovering, wherever it lies on the table */
.board .tile.match > .face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: calc(var(--w) * var(--tile-radius));
  background: color-mix(in srgb, var(--blue) 30%, transparent);
  pointer-events: none;
}

/* where a dragged tile will land */
.b-pond .tile.b-landing { animation-duration: 0.9s; }


/* called sets: out in each player's band, in their right-hand corner —
   their outer edge on the hand's, their far end at the corner (--corner,
   from play.js). North's corner runs down toward your hand, so it stops
   short of it; yours sit just over your hand, out to the same corner. */
.play-table .b-melds {
  top: calc(50% + var(--a) + 3.6cqw + var(--reach, 0px) + var(--tw) * var(--tile-depth) * 4 - var(--th) - var(--dp));
  right: calc(50% - var(--corner, 40cqw));
}
.play-table .b-side.s3 .b-melds { right: calc(50% - var(--corner-left, 40cqw)); }
.play-table .b-side.s1 .b-melds { right: calc(50% - var(--corner-right, 40cqw)); }
.play-table .b-side.s0 .b-melds { top: calc(50% + var(--a) - var(--D) + 1.5cqw); }

/* the plate in the middle: the dora indicator and the tiles left */
.c-info {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  gap: 0.8cqw;
}
.c-info .tile { --tw: 2.9cqw; margin: 0 0 calc(var(--w) * var(--tile-depth)); }
.c-wall { font: 500 max(9px, 1.5cqw) / 1 var(--sans); letter-spacing: 0.08em; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* Calls, the result of a hand, notes                                  */
/* ------------------------------------------------------------------ */

/* what you can say right now — pon, chi, ron, tsumo, riichi — above your hand */
.callbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--hand-h, 90px) + 36px);
  z-index: 12;
  transform: translateX(-50%); /* (translate is the fade-in's) */
  display: flex;
  gap: 10px;
  animation: note-in 0.4s var(--ease) both;
}
/* how a note comes in (the book's, kept here since the table doesn't load its stylesheet) */
@keyframes note-in {
  from { opacity: 0; translate: 0 4px; filter: blur(2px); }
  to { opacity: 1; translate: 0 0; filter: none; }
}
.call {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 64px;
  padding: 9px 16px 8px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  box-shadow: 0 6px 18px rgba(60, 40, 15, 0.1);
  color: var(--ink);
  cursor: pointer;
  transition: translate 0.2s var(--ease), box-shadow 0.2s, border-color 0.2s;
}
.call:hover { translate: 0 -2px; box-shadow: 0 9px 22px rgba(60, 40, 15, 0.14); border-color: var(--ink-3); }
.call b { font-size: 21px; line-height: 1; letter-spacing: 0.06em; }
.call span { font: 500 9.5px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); }
.call-ron b, .call-tsumo b, .call-riichi b { color: var(--red); }
/* more than one kan to choose from: each button shows its tile */
.call .tile { --tw: 17px; margin: 0 0 calc(var(--w) * var(--tile-depth)); }
.call-skip { align-content: center; }
.call-skip span { font-size: 10.5px; color: var(--ink-2); }
.call[aria-pressed="true"] { border-color: var(--red); background: var(--red-soft); }

/* the end of a hand */
.result {
  position: fixed;
  left: 50%;
  top: 44%;
  z-index: 14;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(92vw, 560px);
  padding: 26px 30px 24px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px rgba(60, 40, 15, 0.18);
  text-align: center;
  animation: note-in 0.6s var(--ease) both;
}
.result .r-title { font-size: clamp(26px, 3vw, 34px); line-height: 1.1; font-weight: 330; font-variation-settings: "SOFT" 100, "WONK" 0; }
.result .r-hand { --tw: clamp(18px, 2.4vw, 28px); display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 4px 10px; margin: 6px 0 2px; }
.r-group { display: flex; gap: 1px; }
.r-win { margin-left: 4px; }
.r-win .tile { outline: 1.5px solid color-mix(in srgb, var(--red) 70%, transparent); outline-offset: 2px; }
.result .r-yaku { font-size: 16px; color: var(--ink-2); max-width: 30em; text-wrap: balance; }
.result .r-you { font: 500 11px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.r-deal {
  margin-top: 6px;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}
.r-wait { font-size: 15px; font-style: italic; color: var(--ink-3); }
.r-close {
  position: absolute;
  top: 10px;
  right: 14px;
  padding: 2px 6px;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
}
.r-close:hover { color: var(--ink); }
/* a drawn hand: a small card in the margin by the top bar, so the whole
   table — every set, every open hand — stays in view */
.result.r-draw {
  top: 62px;
  left: auto;
  right: 18px;
  transform: none;
  justify-items: end;
  gap: 7px;
  width: auto;
  max-width: min(250px, 42vw, max(150px, var(--side-room, 250px)));
  padding: 15px 18px 16px;
  border-radius: 16px;
  text-align: right;
}
.result.r-draw .r-title { font-size: 21px; }
.result.r-draw .r-yaku { font-size: 15px; }
.result.r-draw .r-deal { margin-top: 4px; padding: 9px 16px; }

/* connecting, out of time, not ready… */
.table-note {
  position: fixed;
  left: 50%;
  top: 14px;
  z-index: 21;
  translate: -50% 0;
  max-width: min(90vw, 620px);
  padding: 6px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink-2);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Your hand (play/hand.js)                                            */
/* ------------------------------------------------------------------ */

.hand-strip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: calc(var(--hand-h, 90px) + 56px); /* the tiles, and a band above them that still counts as the hand */
  --tw: var(--hand-w, 60px);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* each tile, standing straight up: a wrapper that slides and lifts, and a
   box inside that drops in when it's drawn */
.ht {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: var(--hand-w);
  height: var(--hand-h);
  cursor: grab;
  transition: transform 210ms cubic-bezier(0.3, 1.25, 0.45, 1);
  will-change: transform;
}
.ht.enter { transition: none; }
.ht-box {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ht .tile { position: absolute; left: 0; top: 0; margin: 0; }
/* in the hand you see just the face — no edge or back showing below it */
.ht .tile,
.hand-ghost .tile {
  box-shadow:
    inset 0 0 0 0.5px rgba(70, 50, 20, 0.14),
    0 calc(var(--w) * 0.03) calc(var(--w) * 0.14) rgba(60, 40, 15, calc(var(--tile-shadow) * 1.3));
}

/* lifted out by the pointer: the ghost carries it */
.ht.source { opacity: 0; }
.ht.dim .tile { opacity: 0.35; filter: grayscale(0.6); }
.ht.ready .tile { outline: 1.5px solid color-mix(in srgb, var(--green) 70%, transparent); outline-offset: -1.5px; }
.hand-strip.off .ht { cursor: default; }
.hand-strip.off .tile { filter: grayscale(0.5) brightness(0.92); }

.ht.drawn-in .ht-box { animation: ht-in 520ms cubic-bezier(0.25, 1.2, 0.4, 1); }
@keyframes ht-in {
  from { transform: translateY(-120px); }
}

/* the tile under your pointer while you drag it */
.hand-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 25;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 10px 12px rgba(60, 40, 15, 0.2)) drop-shadow(0 24px 30px rgba(60, 40, 15, 0.16));
}
.hand-ghost .tile { display: block; margin: 0; }

/* ------------------------------------------------------------------ */
/* A W N D — playing by itself, bottom left (play.js)                  */
/* ------------------------------------------------------------------ */

.autos {
  position: fixed;
  left: 16px;
  bottom: 14px;
  z-index: 12;
  display: grid;
  gap: 6px;
}
.autos button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: transparent;
  font: 500 10.5px/1 var(--sans);
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.autos button:hover { color: var(--ink); }
.autos button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink-3); background: rgba(255, 255, 255, 0.5); }
/* C is the table's, not yours: set a little apart; only the host can press it */
.autos .clock-toggle { margin-top: 6px; }
.autos button:disabled { cursor: default; opacity: 0.45; }

/* ------------------------------------------------------------------ */
/* Small things in the corners of your eye                             */
/* ------------------------------------------------------------------ */

/* the top bar's one button: a hand that's already over */
.end-state {
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  padding: 6px 10px;
  font: 500 10px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
.end-state:hover { color: var(--ink); border-color: var(--ink-3); }

/* the waits, over the tile you're hovering */
.hand-chip {
  position: absolute;
  z-index: 70;
  transform: translateX(-50%);
  pointer-events: none;
  animation: note-in 0.18s var(--ease) both;
}
.hand-strip.dragging .hand-chip { display: none; }
.waits {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 10px 6px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  box-shadow: 0 0 0 1px var(--line), 0 8px 20px rgba(60, 40, 15, 0.12);
}
.waits .label { align-self: center; margin-right: 2px; }
.wait { --tw: 20px; display: grid; justify-items: center; gap: 3px; }
.wait .tile { margin: 0 0 calc(var(--w) * var(--tile-depth)); }
.wait b { font: 500 10px/1 var(--sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.wait.gone .tile { opacity: 0.4; }
.wait.gone b { color: var(--ink-3); }

/* your turn clock: a small number at the foot of your rightmost tile */
.clock {
  position: fixed;
  z-index: 12;
  font: 500 20px/1 var(--sans);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.clock small { margin-left: 3px; font-size: 11px; color: var(--ink-3); opacity: 0.7; }
.clock.low { color: var(--red); }
/* the same, for how long a call stays on offer: at the end of the call bar */
.callbar .call-clock { position: static; align-self: flex-end; margin: 0 0 4px 4px; }

/* a call: one small word, out from the caller's side of the table */
.toasts { position: fixed; inset: 0; z-index: 13; pointer-events: none; }
.toast {
  --dx: 0px;
  --dy: 0px;
  position: absolute;
  margin: 0;
  font-size: 30px;
  font-weight: 340;
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  color: var(--ink);
  animation: toast 1.9s var(--ease-soft) both;
}
.toast.win { color: var(--red); }
.toast.t0 { left: 50%; bottom: calc(var(--hand-h, 90px) + 44px); transform: translateX(-50%); --dy: 14px; }
/* your own word while the call bar is up (a kan can bring another offer at once): above it */
.callbar:not([hidden]) ~ .toasts .toast.t0 { bottom: calc(var(--hand-h, 90px) + 108px); }
.toast.t1 { right: 6vw; top: 50%; transform: translateY(-50%); --dx: 14px; }
.toast.t2 { left: 50%; top: 92px; transform: translateX(-50%); --dy: -14px; }
.toast.t3 { left: 6vw; top: 50%; transform: translateY(-50%); --dx: -14px; }
@keyframes toast {
  0% { opacity: 0; translate: var(--dx) var(--dy); filter: blur(2px); }
  16% { opacity: 1; translate: 0 0; filter: none; }
  72% { opacity: 1; translate: 0 0; }
  100% { opacity: 0; translate: calc(var(--dx) * -0.4) calc(var(--dy) * -0.4); }
}

/* top left: the dead wall's five dora places — indicators up, the rest down */
.doras {
  position: fixed;
  left: 16px;
  top: 52px;
  z-index: 12;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  --tw: 19px;
}
.doras .tile { margin: 0 0 calc(var(--w) * var(--tile-depth)); }

/* ------------------------------------------------------------------ */
/* The game: the plate, everyone's points, the review                  */
/* ------------------------------------------------------------------ */

/* on the plate: the hand of the game over the tiles left, the sticks under */
.c-round { font: 500 max(7px, 0.9cqw) / 1 var(--sans); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); }
.c-sticks { display: flex; align-items: center; gap: 0.45cqw; font: 500 max(8px, 1cqw) / 1 var(--sans); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.c-sticks b { font-weight: 500; margin-right: 0.5cqw; }
.c-sticks b:last-child { margin-right: 0; }
/* a stick: honba's 100 is dotted, a riichi bet's 1,000 has its one red dot */
.c-stick {
  position: relative;
  width: 3.2cqw;
  height: 0.55cqw;
  border-radius: 0.3cqw;
  background: linear-gradient(#fffdf8, #ede5d6);
  box-shadow: 0 0.1cqw 0 #dcd2bf, 0 0.2cqw 0.5cqw rgba(60, 40, 15, 0.14);
}
.c-stick.honba {
  background:
    radial-gradient(circle, var(--ink-3) 0 30%, transparent 34%) 0.35cqw 50% / 0.5cqw 0.5cqw repeat-x,
    linear-gradient(#fffdf8, #ede5d6);
}
.c-stick.bet::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.36cqw;
  height: 0.36cqw;
  border-radius: 50%;
  background: var(--red);
  translate: -50% -50%;
}

/* after a hand: everyone's points — the change, then where they stand */
.r-scores { display: grid; gap: 5px; width: min(100%, 290px); margin: 4px 0 0; }
.r-row {
  display: grid;
  grid-template-columns: 18px 1fr auto 62px;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
  line-height: 1.2;
  color: var(--ink-2);
  text-align: left;
}
.r-row > b { font-size: 13px; font-weight: 700; color: var(--ink-3); text-align: center; }
.r-row > b:not(.jp) { font: 500 11px/1 var(--sans); }
.r-row.me > span:nth-child(2) { color: var(--ink); }
.r-row em { font: 500 11px/1 var(--sans); font-style: normal; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.r-row em.up { color: var(--green); }
.r-row em.down { color: var(--red); }
.r-row > span:last-child { font: 500 12px/1 var(--sans); text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.r-end { color: var(--red); margin-top: 4px; }
.r-buttons { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 6px; }
.result .r-buttons .r-deal { margin-top: 0; }
.r-review { border: 0; padding: 4px 2px; background: none; font-size: 15px; font-style: italic; color: var(--ink-3); cursor: pointer; }
.r-review:hover { color: var(--ink); }
/* the drawn-hand card keeps small */
.result.r-draw .r-scores { width: 100%; gap: 3px; }
.result.r-draw .r-row { font-size: 13.5px; gap: 6px; grid-template-columns: 16px 1fr auto 54px; }
.result.r-draw .r-buttons { justify-content: flex-end; gap: 12px; }

/* the review: in the middle, a list to scroll */
.result.r-reviewing { width: min(92vw, 600px); max-height: min(84vh, 760px); overflow: auto; overscroll-behavior: contain; }
.rv-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rv-tab {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 11px 6px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.rv-tab[aria-pressed="true"] { border-color: var(--ink-3); background: rgba(255, 255, 255, 0.55); color: var(--ink); }
.rv-tab b { font-size: 12px; color: var(--ink-3); }
.rv-tab em { font: 500 10px/1 var(--sans); font-style: normal; color: var(--red); }
.rv-stats { font: 500 10px/1.5 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.rv-list { display: grid; gap: 12px; width: 100%; text-align: left; }
.rv-row { display: grid; gap: 7px; padding-top: 12px; border-top: 1px solid var(--line); }
.rv-head { font-size: 14px; color: var(--ink-3); }
.rv-head em { font-style: normal; }
.rv-head em.back { color: var(--red); }
.rv-head em.slow { color: var(--ink-2); }
.rv-hand { --tw: 21px; display: flex; flex-wrap: wrap; gap: 1px; }
.rv-cut { --tw: 21px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.rv-hand .tile, .rv-cut .tile { margin: 0 0 calc(var(--w) * var(--tile-depth)); }
.rv-clean { font-style: italic; color: var(--ink-3); text-align: center; }

/* ------------------------------------------------------------------ */
/* MAKA, bottom right: a grade over each tile of your hand             */
/* ------------------------------------------------------------------ */

.maka-bar {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 12;
  display: grid;
  justify-items: end;
  gap: 6px;
}
.maka-bar button {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  font: 500 10px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.maka-bar button:hover { color: var(--ink); }
.maka-bar button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink-3); background: rgba(255, 255, 255, 0.5); }
.maka-bar [data-maka-all] { padding: 4px 8px; font-size: 9px; }

/* a grade riding on a tile: live tiles that would improve the hand if it
   went, and that as a share of the best cut */
.ht-mark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  display: grid;
  justify-items: center;
  pointer-events: none;
}
.mk { gap: 2px; padding: 4px 0 3px; border-radius: 7px; background: color-mix(in srgb, var(--paper) 90%, transparent); box-shadow: 0 0 0 1px var(--line); }
.mk.empty { background: none; box-shadow: none; }
.mk b { font: 500 13px/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.mk i { font: 500 9px/1 var(--sans); font-style: normal; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.mk.best { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--green) 75%, transparent); }
.mk.best b { color: var(--green); }
.mk.worse { opacity: 0.7; }
.mk.worse b { color: var(--red); }
/* how far from ready, over the first tile's */
.mk-sum {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  white-space: nowrap;
  font: 500 10px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* with grades up, the waits sit over them */
.hand-strip.marked .hand-chip { margin-bottom: 36px; }

/* chi: when the discard makes more than one run, each shows its run */
.call-run { --tw: 15px; display: flex; gap: 1px; }
.call-run .tile { margin: 0 0 calc(var(--w) * var(--tile-depth)); }
.call-run .tile.taken { opacity: 0.5; }
