/* Nine Men's Morris (Dokuz Taş) — board, men, trays (prefix dt-). Theme tokens + own wood palette for light/dark.
 * Geometry is fixed: the wrap's width comes from the viewport only (small viewport height, which ignores the mobile
 * browser bar), the strip has a fixed height and everything that comes and goes (banners, markers) is an overlay. */
.dt-wrap { --dt-wood: #f3dcb2; --dt-wood-2: #e8c995; --dt-rim: #b98a52; --dt-rim-2: #8f6435; --dt-line: #6b4a2b; --dt-dot: #6b4a2b;
  --dt-chrome: 290px; --dt-strip: 34px;
  width: min(100%, 540px, max(232px, calc(100vh - var(--dt-chrome))));
  width: min(100%, 540px, max(232px, calc(100svh - var(--dt-chrome))));
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-inline: auto; flex: none; }
:root[data-theme="dark"] .dt-wrap { --dt-wood: #4a3a29; --dt-wood-2: #3d3022; --dt-rim: #2c2218; --dt-rim-2: #1d160f; --dt-line: #d8bf95; --dt-dot: #d8bf95; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dt-wrap { --dt-wood: #4a3a29; --dt-wood-2: #3d3022; --dt-rim: #2c2218; --dt-rim-2: #1d160f; --dt-line: #d8bf95; --dt-dot: #d8bf95; } }

/* ---------- strip: men in hand / on the board / removed, and the phase of the side to move ---------- */
.dt-strip { width: 100%; height: var(--dt-strip); flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 6px; container-type: inline-size; container-name: dtstrip; min-width: 0; }
.dt-tray { --c: var(--brand); --cd: #a93a20; display: flex; align-items: center; gap: 2px; min-width: 0; padding: 4px 6px; border-radius: 12px; height: 100%;
  background: var(--surface-2); border: 2px solid transparent; box-shadow: 0 2px 0 var(--line); transition: border-color .25s, background .25s; }
.dt-tb { --c: var(--blue); --cd: #1d4396; justify-content: flex-end; flex-direction: row-reverse; }
.dt-ta { justify-self: start; } .dt-tb { justify-self: end; }
.dt-tray.dt-now { border-color: var(--c); }
.dt-slot { flex: none; width: clamp(5px, 2.7cqw, 15px); aspect-ratio: 1; border-radius: 50%; box-sizing: border-box; }
.dt-slot.dt-in { background: var(--c); box-shadow: 0 1.5px 0 var(--cd); }
.dt-slot.dt-on { border: 2px solid var(--c); opacity: .75; }
.dt-slot.dt-lost { background: var(--line-2); opacity: .55; transform: scale(.62); }
.dt-chip { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 30cqw; height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--line-2); font-size: 12.5px; font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.dt-ctxt { overflow: hidden; text-overflow: ellipsis; }
.dt-cdot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.dt-cb .dt-cdot { background: var(--blue); }
.dt-chip.dt-off .dt-cdot { background: var(--ink-3); }

/* ---------- board ---------- */
.dt-frame { position: relative; width: 100%; flex: none; padding: 3.2%; border-radius: 18px; box-sizing: border-box;
  background: linear-gradient(160deg, var(--dt-rim), var(--dt-rim-2)); box-shadow: 0 6px 0 rgba(0, 0, 0, .22), var(--shadow); }
.dt-board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: visible; touch-action: manipulation;
  background:
    repeating-linear-gradient(97deg, rgba(120, 70, 20, .045) 0 3px, transparent 3px 11px),
    radial-gradient(120% 90% at 30% 20%, var(--dt-wood), var(--dt-wood-2));
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .08), inset 0 3px 0 rgba(255, 255, 255, .25); }
.dt-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.dt-lines rect, .dt-lines line { fill: none; stroke: var(--dt-line); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.dt-dots circle { fill: var(--dt-dot); }
.dt-mill { stroke-width: 15; stroke-linecap: round; opacity: .5; }
.dt-ma { stroke: var(--brand); } .dt-mb { stroke: var(--blue); }
.dt-mnew { opacity: .85; animation: dtmill .9s ease-out both; }
@keyframes dtmill { 0% { opacity: 0; stroke-width: 4; } 40% { opacity: 1; stroke-width: 26; } 100% { opacity: .85; stroke-width: 15; } }

/* points: invisible full-cell buttons (keyboard focus, labels). Pointer taps are resolved by the frame to the nearest
   point within 0.8 cell, so each point's real target is as large as its neighbours allow (≥ 1 cell, up to 1.6 cells) */
.dt-pts, .dt-men { position: absolute; inset: 0; }
.dt-men { pointer-events: none; }
.dt-pt { position: absolute; width: calc(100% / 7); height: calc(100% / 7); transform: translate(-50%, -50%); margin: 0; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: default; -webkit-tap-highlight-color: transparent; z-index: 2; color: inherit; }
.dt-pt:focus { outline: none; }
.dt-pt:focus-visible::before { content: ""; position: absolute; inset: 6%; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--ink); }
.dt-live .dt-pt.dt-hot { cursor: pointer; }
/* legal destination */
.dt-pt.dt-tgt::after { content: ""; position: absolute; left: 50%; top: 50%; width: 34%; height: 34%; border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--brand); opacity: .55; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); animation: dtdot 1.4s ease-in-out infinite alternate; }
.dt-me-b .dt-pt.dt-tgt::after { background: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 25%, transparent); }
@keyframes dtdot { from { transform: translate(-50%, -50%) scale(.82); } to { transform: translate(-50%, -50%) scale(1.06); } }
@media (hover: hover) { .dt-live .dt-pt.dt-tgt:hover::after { opacity: .9; width: 56%; height: 56%; } }
/* last move: where it came from and where a man was removed */
.dt-pt.dt-lastfrom::after, .dt-pt.dt-lastrem::after { content: ""; position: absolute; left: 50%; top: 50%; width: 40%; height: 40%; border-radius: 50%;
  transform: translate(-50%, -50%); border: 2.5px dashed var(--dt-line); opacity: .55; box-sizing: border-box; }
.dt-pt.dt-lastrem::after { border-style: dotted; border-color: var(--bad); opacity: .7; }
.dt-pt.dt-tgt.dt-lastfrom::after, .dt-pt.dt-tgt.dt-lastrem::after { border: 0; opacity: .55; }

/* ---------- men ---------- */
.dt-man { position: absolute; width: calc(100% / 7 * .7); aspect-ratio: 1; border-radius: 50%; translate: -50% -50%; box-sizing: border-box;
  transition: transform .16s var(--spring, ease-out), box-shadow .2s; }
.dt-man::before { content: ""; position: absolute; inset: 20%; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .32); }
.dt-a { background: radial-gradient(circle at 34% 28%, #ffb29f 0, #ff6b4a 44%, #e2502f 100%); box-shadow: 0 3px 0 #a93a20, 0 5px 8px rgba(0, 0, 0, .3); }
.dt-b { background: radial-gradient(circle at 34% 28%, #a8c5ff 0, #3d7bf7 44%, #2a5bc4 100%); box-shadow: 0 3px 0 #1d4396, 0 5px 8px rgba(0, 0, 0, .3); }
.dt-man.dt-lastto::after { content: ""; position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; border-radius: 50%; transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .92); box-shadow: 0 0 0 2px rgba(0, 0, 0, .15); }
.dt-live .dt-man.dt-can { box-shadow: 0 3px 0 var(--sh, #a93a20), 0 0 0 3px var(--surface), 0 0 0 5px color-mix(in srgb, var(--ink) 35%, transparent); }
.dt-live .dt-b.dt-can { --sh: #1d4396; }
.dt-man.dt-sel { transform: translateY(-4px) scale(1.12); box-shadow: 0 7px 0 rgba(0, 0, 0, .22), 0 0 0 3px #fff, 0 0 0 6px var(--ink), 0 10px 16px rgba(0, 0, 0, .3); z-index: 3; }
.dt-man.dt-pend { box-shadow: 0 3px 0 rgba(0, 0, 0, .25), 0 0 0 3px #fff, 0 0 0 6px color-mix(in srgb, var(--ink) 50%, transparent); }
.dt-man.dt-rem { animation: dtrem .9s ease-in-out infinite alternate; }
.dt-man.dt-rem::after { content: ""; position: absolute; inset: -18%; border-radius: 50%; border: 3px dashed var(--bad); box-sizing: border-box; animation: dtspin 6s linear infinite; }
@keyframes dtrem { from { transform: scale(1); } to { transform: scale(1.1); } }
@keyframes dtspin { to { transform: rotate(360deg); } }
.dt-man.dt-gone { animation: dtgone .52s cubic-bezier(.5, 0, .75, .3) both; z-index: 4; }
@keyframes dtgone { 0% { transform: scale(1); opacity: 1; } 35% { transform: scale(1.18) rotate(-8deg); opacity: 1; } 100% { transform: scale(.1) rotate(25deg); opacity: 0; } }
.dt-removing .dt-man:not(.dt-rem):not(.dt-pend) { filter: saturate(.55) brightness(.92); }

/* banners ("Mill!", "Flying!") are a pill over the strip, so they never hide a man that may be tapped; taps go through */
.dt-wrap { position: relative; }
.dt-wrap > .fx-banner.dt-pill { top: calc(var(--dt-strip) / 2); max-width: calc(100% - 8px); padding: 5px 14px 6px; border-radius: 999px; font-size: 15px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 3px 0 rgba(0, 0, 0, .28), var(--shadow); z-index: 6; }
.dt-wrap > .fx-banner.dt-pill small { display: inline; margin: 0 0 0 7px; font-size: 12.5px; font-weight: 600; opacity: .9; }

/* ---------- landscape phones: trays beside the board instead of above it ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  /* --dt-chrome here: sticky top bar (58) + status line and gaps (34) + a margin; the play area is scrolled under the
     top bar once per round (fit() in dokuztas.js), so the whole board is on screen at 740×360 */
  .dt-wrap { --dt-chrome: 100px; flex-direction: row; align-items: stretch; width: auto; height: min(540px, max(200px, calc(100vh - var(--dt-chrome)))); height: min(540px, max(200px, calc(100svh - var(--dt-chrome)))); }
  .dt-frame { width: auto; height: 100%; aspect-ratio: 1; padding: 3%; }
  .dt-board { width: 100%; height: 100%; }
  .dt-strip { order: -1; height: 100%; width: 44px; grid-template-columns: none; grid-template-rows: 1fr auto 1fr; container-type: normal; }
  .dt-tray { flex-direction: column; height: auto; width: 100%; padding: 6px 4px; align-self: stretch; justify-self: stretch; }
  .dt-tb { flex-direction: column-reverse; }
  .dt-ta { align-self: start; } .dt-tb { align-self: end; }
  .dt-slot { width: min(15px, calc((100svh - var(--dt-chrome) - 120px) / 22)); min-width: 6px; }
  .dt-chip { max-width: none; width: 100%; height: auto; padding: 6px 0; justify-content: center; }
  .dt-ctxt { display: none; }
  /* the pill goes beside the board, in the free space on its right (translate: the left edge, not the centre, is placed) */
  .dt-wrap > .fx-banner.dt-pill { top: 50%; left: calc(100% + 12px); translate: 50% 0; width: max-content; max-width: min(190px, calc(50vw - 170px));
    white-space: normal; text-align: left; border-radius: 14px; padding: 8px 12px 9px; font-size: 18px; }
  .dt-wrap > .fx-banner.dt-pill small { display: block; margin: 3px 0 0; font-size: 12px; }
}
@media (max-width: 520px) {
  .dt-frame { border-radius: 14px; }
  .dt-chip { font-size: 11.5px; padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .dt-pt.dt-tgt::after, .dt-man.dt-rem, .dt-man.dt-rem::after, .dt-mnew, .dt-man.dt-gone { animation: none; }
  .dt-man { transition: none; }
}
/* placing: every free point is legal, so the markers stay quiet */
.dt-placing .dt-pt.dt-tgt::after { width: 22%; height: 22%; opacity: .5; box-shadow: none; animation: none; }
/* narrow strips (phones ≤ ~340 px): the phase chip shows only the colour dot, the trays keep all nine slots */
@container dtstrip (max-width: 300px) {
  .dt-ctxt { display: none; }
  .dt-chip { padding: 0 7px; }
  .dt-tray { gap: 1.5px; padding: 4px 5px; }
}

/* wave16 integration: rooms on phones held sideways: the board column (games.css, width from --lh - --board-xl) gets
   the 40 px the side tray strip and its gap add to the square board (no horizontal overflow at 740x360) */
@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  #board:has(> .dt-wrap) { --board-xl: -40px; }
}
/* wave16 fix: small phones held sideways (568x320, 640x360): the bars' column left of the board was too narrow for the
   own name (20 of 88 px at 568x320), so the board is 24 px smaller there (wrap height and board column shrink together:
   wrap width = 100svh - --dt-chrome + 50 = --lh - --board-xl); sizes still depend on the viewport only */
@media (max-width: 640px) and (max-height: 420px) and (orientation: landscape) {
  body.in-room .dt-wrap { --dt-chrome: 124px; }
  body.in-room #board:has(> .dt-wrap) { --board-xl: -16px; }
}
/* wave18: phones held sideways: the bars' column beside the board is ~260 px, where "Sıra sende" / "À toi" and the
   "sen / toi" chip cut the player's own name to one letter (667x375). The turn tag takes the dot form (the status line
   under the opponent's bar says whose turn it is; the bar's border marks it too) and the "you" chip gives way below
   700 px, so the names keep their room. Bars only: no board size depends on this. */
@media (orientation: landscape) and (max-height: 500px) {
  #boardPanel:has(> #board > .dt-wrap) .pbar { gap: 8px; }
  #boardPanel:has(> #board > .dt-wrap) .pbar .ptag { font-size: 0; gap: 0; }
  #boardPanel:has(> #board > .dt-wrap) .pbar .ptag:not(.think)::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
  #boardPanel:has(> #board > .dt-wrap) .pbar .ptag .typing { gap: 4px; }
  #boardPanel:has(> #board > .dt-wrap) .pbar .ptag .typing i { width: 6px; height: 6px; }
  /* rooms: the presence word ('en ligne', 'conectado') becomes its green / grey dot (the word stays for screen readers) */
  #boardPanel:has(> #board > .dt-wrap) .pbar .pn small > .conn { font-size: 0; flex: none; }
  #boardPanel:has(> #board > .dt-wrap) .pbar .pn small > .conn::before { margin-right: 0; width: 8px; height: 8px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 700px) {
  #boardPanel:has(> #board > .dt-wrap) .pbar .pn b em { display: none; }
  #boardPanel:has(> #board > .dt-wrap) .pbar .psc { min-width: 18px; }
}
