/* Küre board: a 7×7 board on a slate tray, glossy Mor and Turuncu spheres, each home row tinted with its stones.
   Motion is transform/opacity only; body.reduced-motion and prefers-reduced-motion disable it. */
.kure {
  --kure-size: 480px;
  --kure-mor-hi: #e6d2ff;
  --kure-mor-mid: #8b4fe3;
  --kure-mor-lo: #3a0f7a;
  --kure-turuncu-hi: #ffe7c2;
  --kure-turuncu-mid: #f5901f;
  --kure-turuncu-lo: #9a4300;
  --kure-tray: #1f2f4a;
  --kure-tray-light: #3a5175;
  --kure-cell: #e9eef5;
  --kure-cell-alt: #dde4ee;
  --kure-danger: #d23b3b;
  --kure-gold: #ffc531;
  /* Seat 0 and seat 1 take the colour of their stones: Mor for the seat that starts. */
  --kure-0-hi: var(--kure-mor-hi); --kure-0-mid: var(--kure-mor-mid); --kure-0-lo: var(--kure-mor-lo);
  --kure-1-hi: var(--kure-turuncu-hi); --kure-1-mid: var(--kure-turuncu-mid); --kure-1-lo: var(--kure-turuncu-lo);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  color: var(--navy, #0b1628);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.kure[data-first="1"] {
  --kure-0-hi: var(--kure-turuncu-hi); --kure-0-mid: var(--kure-turuncu-mid); --kure-0-lo: var(--kure-turuncu-lo);
  --kure-1-hi: var(--kure-mor-hi); --kure-1-mid: var(--kure-mor-mid); --kure-1-lo: var(--kure-mor-lo);
}
.kure[data-turn="0"] { --kure-me: var(--kure-0-mid); }
.kure[data-turn="1"] { --kure-me: var(--kure-1-mid); }

/* ---------- Stage, tray and squares ---------- */
.kure-stage { display: grid; place-items: center; min-height: 0; min-width: 0; contain: size; }
.kure-frame { position: relative; }
.kure-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: calc(var(--kure-size) * .008);
  width: var(--kure-size);
  height: var(--kure-size);
  padding: calc(var(--kure-size) * .022);
  box-sizing: border-box;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, .16), transparent 55%),
    linear-gradient(160deg, var(--kure-tray-light), var(--kure-tray) 70%);
  border-radius: calc(var(--kure-size) * .04);
  box-shadow: 0 2px 0 rgba(255, 255, 255, .14) inset, 0 -5px 0 rgba(0, 0, 0, .25) inset, 0 20px 46px rgba(11, 27, 51, .26), 0 4px 0 #0e1626;
  touch-action: none;
}
.kure-cell {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  color: inherit;
  background: var(--kure-cell);
  border: 0;
  border-radius: calc(var(--kure-size) * .014);
  box-shadow: 0 -2px 0 rgba(0, 0, 0, .08) inset;
  font: inherit;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.kure-cell:nth-child(2n) { background: var(--kure-cell-alt); }
/* Home rows: each seat's starting row carries its stones' colour. */
.kure-cell[data-home="0"] { background: color-mix(in srgb, var(--kure-0-mid) 26%, var(--kure-cell)); }
.kure-cell[data-home="1"] { background: color-mix(in srgb, var(--kure-1-mid) 26%, var(--kure-cell)); }
.kure-cell:focus-visible { outline: 4px solid var(--focus, #ffbf3c); outline-offset: -2px; z-index: 1; }
.kure[data-interactive="true"] .kure-cell { cursor: pointer; }

/* ---------- Stones: shaded spheres with a highlight and a contact shadow ---------- */
.kure-stone {
  --hi: var(--kure-0-hi); --mid: var(--kure-0-mid); --lo: var(--kure-0-lo);
  position: absolute;
  inset: 10%;
  display: none;
  background: radial-gradient(circle at 34% 28%, #fff 0, var(--hi) 10%, var(--mid) 46%, var(--lo) 96%);
  border-radius: 50%;
  box-shadow: 0 calc(var(--kure-size) * .008) calc(var(--kure-size) * .012) rgba(0, 0, 0, .42), 0 -2px 5px rgba(0, 0, 0, .22) inset;
  transition: transform .18s var(--ease-bounce, ease), box-shadow .18s;
  pointer-events: none;
}
.kure-cell[data-seat] > .kure-stone, .kure-ghost { display: block; }
.kure-cell[data-seat="1"] > .kure-stone, .kure-ghost[data-seat="1"] { --hi: var(--kure-1-hi); --mid: var(--kure-1-mid); --lo: var(--kure-1-lo); }
.kure-ghost[data-seat="0"] { --hi: var(--kure-0-hi); --mid: var(--kure-0-mid); --lo: var(--kure-0-lo); }
/* Above the square's own marks (a taken stone may be the last one moved). */
.kure-board .kure-cell > .kure-stone.kure-ghost { z-index: 2; box-shadow: 0 0 0 4px var(--kure-danger), 0 0 calc(var(--kure-size) * .03) var(--kure-danger); }

/* ---------- Move marks ---------- */
.kure-cell.is-movable > .kure-stone { box-shadow: 0 0 0 3px rgba(255, 255, 255, .9), 0 0 0 5px var(--kure-me), 0 calc(var(--kure-size) * .008) calc(var(--kure-size) * .012) rgba(0, 0, 0, .42); }
.kure-cell.is-selected > .kure-stone { transform: translateY(-6%) scale(1.1); box-shadow: 0 0 0 4px var(--kure-gold), 0 calc(var(--kure-size) * .02) calc(var(--kure-size) * .024) rgba(0, 0, 0, .45); }
.kure-cell.is-target { cursor: pointer; }
.kure-cell.is-target::after { content: ""; position: absolute; inset: 31%; background: var(--kure-me); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--kure-me), 0 2px 4px rgba(0, 0, 0, .35); animation: kure-target 1.1s ease-in-out infinite; }
@keyframes kure-target { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.kure-cell.is-last-from::after { content: ""; position: absolute; inset: 30%; border: 3px dashed rgba(11, 22, 40, .45); border-radius: 50%; }
.kure-cell.is-last-to > .kure-stone { box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(11, 22, 40, .55), 0 calc(var(--kure-size) * .008) calc(var(--kure-size) * .012) rgba(0, 0, 0, .42); }
.kure-cell.is-danger::before { content: ""; position: absolute; inset: 3%; z-index: 1; border: 4px dashed var(--kure-danger); border-radius: 50%; animation: kure-danger 2s linear infinite; pointer-events: none; }
@keyframes kure-danger { to { transform: rotate(360deg); } }
.kure-cell.is-refused { animation: kure-refused .42s ease-in-out; }
.kure-cell.is-refused::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--kure-danger); font-size: calc(var(--kure-size) * .07); font-weight: 900; line-height: 1; }
@keyframes kure-refused { 0%, 100% { transform: none; } 25% { transform: translateX(-6%); } 50% { transform: translateX(5%); } 75% { transform: translateX(-3%); } }
.kure-cell.is-capturer > .kure-stone { box-shadow: 0 0 0 4px var(--kure-gold), 0 0 calc(var(--kure-size) * .035) var(--kure-gold); }
.kure-cell.is-winner > .kure-stone { box-shadow: 0 0 0 4px var(--kure-gold), 0 0 calc(var(--kure-size) * .05) var(--kure-gold); animation: kure-win .9s ease-in-out 3; }
@keyframes kure-win { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- Refusal bubble: at the edge of the board away from the tapped square ---------- */
.kure-hint {
  position: absolute;
  left: 50%;
  z-index: 3;
  max-width: calc(var(--kure-size) * .92);
  margin: 0;
  padding: 10px 18px;
  color: #fff;
  background: rgba(11, 22, 40, .94);
  border: 2px solid var(--kure-danger);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(11, 22, 40, .35);
  font-size: clamp(15px, calc(var(--kure-size) * .036), 22px);
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.kure-hint[data-at="top"] { top: calc(var(--kure-size) * .03); }
.kure-hint[data-at="bottom"] { bottom: calc(var(--kure-size) * .03); }
.kure-hint.is-shown { animation: kure-hint .22s cubic-bezier(.3, .7, .3, 1); }
@keyframes kure-hint { from { opacity: 0; transform: translateX(-50%) scale(.92); } to { opacity: 1; transform: translateX(-50%); } }

.kure-live { min-height: 1.3em; margin: 0; line-height: 1.3; color: var(--ink-soft, #3a4a5f); font-size: 14px; font-weight: 650; text-align: center; }

/* ---------- Player card score: own colour, four slots for the taken stones, and the count ---------- */
.kure-taken { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.kure-taken__slots { display: inline-flex; gap: 3px; }
.kure-taken__own, .kure-taken__slot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; }
.kure-taken__own { width: 20px; height: 20px; margin-right: 2px; }
.kure-taken__slot { box-sizing: border-box; border: 2px dashed var(--ink-soft, #3a4a5f); opacity: .55; }
.kure-taken__slot.is-full { border: 0; opacity: 1; }
.kure-taken__slot--mor { background: radial-gradient(circle at 34% 28%, #fff 0, var(--kure-mor-hi, #e6d2ff) 10%, var(--kure-mor-mid, #8b4fe3) 46%, var(--kure-mor-lo, #3a0f7a) 96%); }
.kure-taken__slot--turuncu { background: radial-gradient(circle at 34% 28%, #fff 0, var(--kure-turuncu-hi, #ffe7c2) 10%, var(--kure-turuncu-mid, #f5901f) 46%, var(--kure-turuncu-lo, #9a4300) 96%); }
.board-player__score b.kure-taken__count, .kure-taken__count { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- Reduced motion and high contrast ---------- */
body.reduced-motion .kure *, body.reduced-motion .kure *::before, body.reduced-motion .kure *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .kure *, .kure *::before, .kure *::after { animation: none !important; transition: none !important; } }
body.high-contrast .kure { --kure-tray: #000; --kure-tray-light: #000; --kure-cell: #fff; --kure-cell-alt: #fff; --kure-mor-hi: #5b1fb0; --kure-mor-mid: #5b1fb0; --kure-mor-lo: #5b1fb0; --kure-turuncu-hi: #f08a00; --kure-turuncu-mid: #f08a00; --kure-turuncu-lo: #f08a00; }
body.high-contrast .kure-cell { box-shadow: 0 0 0 1px #000 inset; }
body.high-contrast .kure-cell[data-home] { box-shadow: 0 0 0 4px var(--kure-0-mid) inset; background: #fff; }
body.high-contrast .kure-cell[data-home="1"] { box-shadow: 0 0 0 4px var(--kure-1-mid) inset; }
body.high-contrast .kure-stone { background: var(--mid); box-shadow: 0 0 0 3px #000; }
body.high-contrast .kure-cell.is-target::after { background: #000; border-color: #fff; box-shadow: 0 0 0 3px #000; }
body.high-contrast .kure-cell.is-danger::before { border-color: #000; border-width: 5px; }
body.high-contrast .kure-taken__slot--mor { background: #5b1fb0; }
body.high-contrast .kure-taken__slot--turuncu { background: #f08a00; }
@media (forced-colors: active) {
  .kure-cell { border: 1px solid CanvasText; }
  .kure-stone, .kure-taken__slot { forced-color-adjust: none; }
  .kure-cell.is-target::after, .kure-cell.is-danger::before { border-color: Highlight; }
}

/* ---------- Compact screens ---------- */
@media (max-width: 520px) {
  .kure { gap: 4px; }
  .kure-live { font-size: 12px; }
  /* Phones: the move sentence stays for screen readers only; the corner referee needs the space. */
  .arena-play--board .kure-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .kure-taken { gap: 4px; }
  .kure-taken__own, .kure-taken__slot { width: 12px; height: 12px; }
  .kure-taken__slots { gap: 2px; }
  .board-player__score b.kure-taken__count { font-size: 14px; }
}
/* Short landscape phones: the board takes the whole height (the move sentence is for screen readers only) and a
   thinner tray edge keeps every square at 44 px or more on 844 × 390. */
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  .arena-play--board > .kure { gap: 0; }
  .arena-play--board > .kure > .kure-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .arena-play--board > .kure .kure-board { padding: calc(var(--kure-size) * .012); gap: calc(var(--kure-size) * .006); }
  /* The player cards stand in a 210 px column beside the clock: smaller slots keep "n/4" clear of it. */
  .kure-taken { gap: 3px; }
  .kure-taken__own, .kure-taken__slot { width: 11px; height: 11px; }
  .kure-taken__own { margin-right: 0; }
  .kure-taken__slots { gap: 2px; }
  .board-player__score b.kure-taken__count { font-size: 14px; }
}

/* Dark theme: a deeper tray and dimmer squares; the stones keep their tones. */
html[data-theme="dark"] .kure {
  --kure-tray: #0b1220;
  --kure-tray-light: #24334f;
  --kure-cell: #c9d2df;
  --kure-cell-alt: #bcc6d5;
}
