/* ------------------------------------------------------------------ */
/* Kensington — visual style                                           */
/* ------------------------------------------------------------------ */

:root {
  --bg-1: #262b34;
  --bg-2: #14171c;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-border: rgba(255, 255, 255, 0.12);
  --ink: #e8e4da;
  --ink-dim: #a8a294;
  --red: #d24a3c;
  --red-deep: #9c1710;
  --blue: #3a5bd9;
  --blue-deep: #16267c;
  --gold: #e8b84b;
  --board-ivory: #ece5d4;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 70% 20%, var(--bg-1), var(--bg-2) 75%);
  background-attachment: fixed;
}

.app {
  display: flex;
  gap: 28px;
  align-items: stretch;
  justify-content: center;
  padding: 28px;
  min-height: 100vh;
}

/* ------------------------------------------------------------------ */
/* Side panel                                                          */
/* ------------------------------------------------------------------ */

.panel {
  width: 300px;
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.masthead h1 {
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 500;
  letter-spacing: 2px;
  margin: 4px 0 0;
  color: var(--ink);
}

.masthead .tagline {
  margin: 4px 0 0;
  color: var(--ink-dim);
  font-size: 14px;
  letter-spacing: 0.4px;
}

.status-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(6px);
}

.turn-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.turn-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: 0 0 26px;
  box-shadow: inset -3px -4px 6px rgba(0,0,0,.35), inset 3px 4px 6px rgba(255,255,255,.3),
              0 2px 5px rgba(0,0,0,.4);
}

.turn-chip.red  { background: radial-gradient(circle at 35% 30%, #ff9d8a, var(--red) 55%, var(--red-deep)); }
.turn-chip.blue { background: radial-gradient(circle at 35% 30%, #93a7f5, var(--blue) 55%, var(--blue-deep)); }
.turn-chip.thinking { animation: chipPulse 1.1s ease-in-out infinite; }

@keyframes chipPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.82); }
}

.turn-text {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .3px;
}

.phase-text {
  margin-top: 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--ink-dim);
}

.message {
  margin-top: 10px;
  font-size: 14.5px;
  line-height: 1.45;
  min-height: 42px;
  color: var(--ink);
}

.message .gold { color: var(--gold); font-weight: 600; }

/* reserves -------------------------------------------------------- */

.reserves {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px 16px;
}

.reserve {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reserve-label {
  width: 38px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.red-label  { color: #f08373; }
.blue-label { color: #8fa3f0; }

.dots { display: flex; gap: 4px; flex-wrap: wrap; }

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  transition: background .25s, box-shadow .25s;
}

.dot.full.red  { background: var(--red);  box-shadow: 0 0 4px rgba(210,74,60,.7); }
.dot.full.blue { background: var(--blue); box-shadow: 0 0 4px rgba(58,91,217,.7); }

/* buttons ---------------------------------------------------------- */

.buttons { display: flex; flex-direction: column; gap: 8px; }

.btn {
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}

.btn:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }

.btn.primary {
  background: linear-gradient(180deg, #f0c463, #d9a437);
  border-color: #b8862a;
  color: #2a1f08;
}

.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #f6cd72, #e2ad3f); }

.hidden { display: none !important; }

/* rules ------------------------------------------------------------ */

.rules {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 13.5px;
  color: var(--ink-dim);
}

.rules summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .3px;
  padding: 4px 0;
}

.rules ul { margin: 8px 0 6px; padding-left: 18px; }
.rules li { margin: 6px 0; line-height: 1.45; }
.rules strong, .rules em { color: var(--ink); }

/* ------------------------------------------------------------------ */
/* Board                                                               */
/* ------------------------------------------------------------------ */

.board-wrap {
  position: relative;
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board {
  width: min(86vmin, 820px);
  height: min(86vmin, 820px);
  display: block;
  border-radius: 26px;
  background:
    radial-gradient(closest-side at 50% 44%, #f4eee0, var(--board-ivory) 70%, #ddd3bd);
  box-shadow:
    0 24px 60px rgba(0,0,0,.5),
    inset 0 1px 0 rgba(255,255,255,.8),
    inset 0 -3px 12px rgba(120,100,60,.25);
}

/* cells */
.cell-square   { fill: #e2dac7; }
.cell-triangle { fill: #d8cfb8; }
.hex-white     { fill: #fbf8ef; }
.hex-red       { fill: #c2382c; }
.hex-blue      { fill: #2b46b4; }

.board-line {
  stroke: #57503f;
  stroke-width: 3.4;
  stroke-linecap: round;
  fill: none;
}

.hole {
  fill: #3b352a;
  stroke: rgba(255,255,255,.5);
  stroke-width: 1.4;
  transition: fill .15s;
}

/* invisible, larger click targets on top of everything */
.hit { fill: transparent; }
.hit.clickable { cursor: pointer; }
.hit.clickable:hover { fill: rgba(232,184,75,.3); }

/* stones ------------------------------------------------------------ */

.stone { pointer-events: none; }

.stone .body {
  stroke: rgba(0,0,0,.4);
  stroke-width: 1.5;
}

.stone.pop { animation: stonePop .28s cubic-bezier(.2,1.6,.4,1); transform-box: fill-box; transform-origin: center; }

@keyframes stonePop {
  0% { transform: scale(.4); }
  100% { transform: scale(1); }
}

.sel-ring {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-dasharray: 10 7;
  pointer-events: none;
  animation: spin 6s linear infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* hints & markers ---------------------------------------------------- */

.hint-ring {
  fill: rgba(232,184,75,.25);
  stroke: var(--gold);
  stroke-width: 3;
  pointer-events: none;
  animation: hintPulse 1.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

.reloc-glow {
  fill: none;
  stroke: var(--gold);
  stroke-width: 4;
  pointer-events: none;
  animation: hintPulse 1.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes hintPulse {
  0%, 100% { opacity: .95; transform: scale(1); }
  50% { opacity: .45; transform: scale(.88); }
}

.last-move-ring {
  fill: none;
  stroke: rgba(60, 50, 30, .85);
  stroke-width: 3;
  stroke-dasharray: 5 5;
  pointer-events: none;
}

.last-move-from {
  fill: rgba(60, 50, 30, .35);
  pointer-events: none;
}

.ghost-stone {
  pointer-events: none;
  animation: ghostFade 2s ease-out forwards;
}

@keyframes ghostFade {
  0%   { opacity: 0.28; }
  15%  { opacity: 0.24; }
  100% { opacity: 0; }
}

.mill-flash {
  fill: rgba(232,184,75,.4);
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linejoin: round;
  pointer-events: none;
  animation: millFade 1.6s ease-out forwards;
}

@keyframes millFade {
  0% { opacity: 1; }
  60% { opacity: .85; }
  100% { opacity: 0; }
}

.win-glow {
  fill: none;
  stroke: var(--gold);
  stroke-width: 10;
  stroke-linejoin: round;
  pointer-events: none;
  filter: drop-shadow(0 0 14px rgba(232,184,75,.95));
  animation: winPulse 1.6s ease-in-out infinite;
}

@keyframes winPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* overlay ------------------------------------------------------------ */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 14, .45);
  border-radius: 26px;
  backdrop-filter: blur(3px);
}

.overlay-card {
  background: linear-gradient(180deg, #2d323c, #1d2128);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 18px;
  padding: 30px 40px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
  animation: cardIn .3s cubic-bezier(.2,1.4,.4,1);
}

@keyframes cardIn {
  from { transform: scale(.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay-title {
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: 1px;
}

.overlay-title.red-wins  { color: #f08373; }
.overlay-title.blue-wins { color: #8fa3f0; }
.overlay-title.draw      { color: var(--gold); }

.overlay-sub {
  margin-top: 8px;
  color: var(--ink-dim);
  font-size: 15px;
}

.overlay-buttons {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ------------------------------------------------------------------ */
/* New-game dialog                                                     */
/* ------------------------------------------------------------------ */

dialog {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px;
  background: linear-gradient(180deg, #2d323c, #1d2128);
  color: var(--ink);
  padding: 26px 30px;
  width: min(420px, 92vw);
  box-shadow: 0 24px 70px rgba(0,0,0,.65);
}

dialog::backdrop {
  background: rgba(8, 9, 12, .6);
  backdrop-filter: blur(4px);
}

dialog h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: 1px;
  margin: 0 0 14px;
}

dialog fieldset {
  border: none;
  margin: 0 0 14px;
  padding: 0;
}

dialog legend {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--ink-dim);
  margin-bottom: 8px;
  padding: 0;
}

.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.seg label { flex: 1; min-width: 70px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
}

.seg span:hover { background: rgba(255,255,255,.1); }

.seg input:checked + span {
  background: rgba(232,184,75,.18);
  border-color: var(--gold);
  color: #f3d289;
}

.seg-level label { min-width: 48px; }

.level-slow span {
  color: #f08373;
  border-color: rgba(210, 74, 60, 0.35);
}
.level-slow span:hover { background: rgba(210, 74, 60, 0.12); }
.level-slow input:checked + span {
  background: rgba(210, 74, 60, 0.18);
  border-color: var(--red);
  color: #f08373;
}

.mini-stone {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.mini-red  { background: radial-gradient(circle at 35% 30%, #ff9d8a, var(--red) 55%, var(--red-deep)); }
.mini-blue { background: radial-gradient(circle at 35% 30%, #93a7f5, var(--blue) 55%, var(--blue-deep)); }

.hint-line {
  margin: 8px 2px 0;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.dialog-buttons .btn { min-width: 140px; }

fieldset.disabled { opacity: .35; pointer-events: none; }

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .app { flex-direction: column-reverse; align-items: center; padding: 14px; }
  .panel { width: min(94vw, 560px); flex: none; }
  #board { width: min(94vw, 94vmin); height: auto; aspect-ratio: 1; }
}
