/* Pink Chess - style.css */
:root {
  --pink-50: #fff5f9;
  --pink-100: #ffe4ef;
  --pink-200: #fbcfe0;
  --pink-400: #f48fb1;
  --pink-600: #e0517f;
  --pink-800: #ad1457;
  --red: #d90429;
  --purple: #7b2cbf;
  --ink: #4a1030;
  --muted: #8a3b62;
  --board: min(92vw, max(320px, calc(100vh - 330px)), 600px);
  --sq: calc(var(--board) / 8);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff7fb 0%, #ffe0ee 100%);
  min-height: 100vh;
}

header { text-align: center; padding: 18px 12px 4px; }
h1 { margin: 0; font-size: 2rem; color: var(--pink-800); letter-spacing: .5px; }
.crown { color: var(--purple); }
.sub { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.muted { color: var(--muted); font-size: .9rem; }

.layout {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  padding: 12px 16px 32px;
  flex-wrap: wrap;
}

/* ---------- Board ---------- */
.board-area { display: flex; flex-direction: column; gap: 10px; width: calc(var(--board) + 20px); }

.board {
  width: calc(var(--board) + 20px);
  height: calc(var(--board) + 20px);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 10px solid var(--pink-800);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(173, 20, 87, .25);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background-color: #ffffff; }
.sq.dark { background-color: var(--pink-400); }

.sq.last { background-image: linear-gradient(rgba(255, 196, 0, .38), rgba(255, 196, 0, .38)); }
.sq.selected { background-image: linear-gradient(rgba(123, 44, 191, .38), rgba(123, 44, 191, .38)); }
.sq.check { background-image: radial-gradient(circle, rgba(217, 4, 41, .9) 0%, rgba(217, 4, 41, .45) 45%, rgba(217, 4, 41, 0) 75%); }

.sq.movable, .sq.target, .sq.capture { cursor: pointer; }
.sq.movable:hover { box-shadow: inset 0 0 0 3px rgba(123, 44, 191, .45); }

.sq.target::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(123, 44, 191, .5);
}
.sq.capture::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: calc(var(--sq) * .08) solid rgba(123, 44, 191, .55);
}
.sq.target:hover::after { background: rgba(123, 44, 191, .8); }

.piece {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "DejaVu Sans", "Arial Unicode MS", serif;
  font-size: calc(var(--sq) * .8);
  line-height: 1;
  position: relative;
  z-index: 1;
  pointer-events: none;
  transition: transform .12s ease;
}
.piece.red {
  color: var(--red);
  text-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 3px 4px rgba(0, 0, 0, .35);
}
.piece.purple {
  color: var(--purple);
  text-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 3px 4px rgba(0, 0, 0, .35);
}
.sq.selected .piece { transform: scale(1.1); }
.piece.drop { animation: drop .18s ease-out; }
@keyframes drop { from { transform: scale(1.18); } to { transform: scale(1); } }

.coord {
  position: absolute;
  font-size: calc(var(--sq) * .17);
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.coord.rank { top: 3px; left: 4px; }
.coord.file { bottom: 3px; right: 4px; }
.sq.light .coord { color: var(--pink-600); }
.sq.dark .coord { color: #fff; }

/* ---------- Player cards ---------- */
.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 2px solid var(--pink-200);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(173, 20, 87, .08);
  transition: border-color .2s, box-shadow .2s;
}
.player-card.active {
  border-color: var(--pink-600);
  box-shadow: 0 0 0 3px rgba(224, 81, 127, .2), 0 6px 16px rgba(173, 20, 87, .15);
}

.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.dot.big { width: 18px; height: 18px; flex: none; }
.dot.red { background: var(--red); }
.dot.purple { background: var(--purple); }

.pinfo { flex: 1; min-width: 0; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thinking-tag { font-weight: 600; font-size: .8rem; color: var(--pink-600); margin-left: 6px; }

.captured {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "DejaVu Sans", serif;
  font-size: 1.15rem;
  min-height: 1.4em;
  line-height: 1.3;
  letter-spacing: -3px;
}
.cap.red { color: var(--red); }
.cap.purple { color: var(--purple); }
.adv { font-family: inherit; font-size: .8rem; color: var(--muted); margin-left: 8px; letter-spacing: 0; font-weight: 700; }

.clocks { text-align: right; min-width: 104px; }
.move-clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--pink-50);
  border-radius: 8px;
  padding: 2px 10px;
  display: inline-block;
}
.player-card.active .move-clock { background: var(--pink-100); color: var(--pink-800); }
.move-clock.low { color: #fff !important; background: var(--red) !important; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

.bar { height: 4px; background: var(--pink-100); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.bar > div { height: 100%; width: 100%; background: linear-gradient(90deg, var(--pink-600), var(--purple)); transition: width .2s linear; }
.total-row { font-size: .8rem; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.total-row b { color: var(--ink); }

/* ---------- Side panel ---------- */
.side { width: 330px; max-width: 94vw; display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: #fff;
  border: 2px solid var(--pink-200);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 12px rgba(173, 20, 87, .06);
}
.panel h2 { margin: 0 0 8px; font-size: 1.05rem; color: var(--pink-800); }
.label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 12px 0 6px;
}

button {
  font: inherit;
  cursor: pointer;
  border: 2px solid var(--pink-200);
  background: var(--pink-50);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover:not(:disabled) { border-color: var(--pink-400); background: var(--pink-100); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; }
.seg button.on { background: var(--pink-600); color: #fff; border-color: var(--pink-600); }
.seg button.on .dot { box-shadow: 0 0 0 2px #fff; }

.primary {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--pink-600), var(--purple));
  color: #fff;
  border: none;
  padding: 12px;
  font-size: 1rem;
}
.primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--pink-800), var(--purple)); }

.status { font-weight: 700; text-align: center; color: var(--pink-800); font-size: 1.05rem; }
.status.thinking::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.controls { display: flex; gap: 8px; }
.controls button { flex: 1; }

.moves ol {
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 0 0 0 34px;
  font-variant-numeric: tabular-nums;
}
.moves li { padding: 3px 4px; }
.moves li::marker { color: var(--muted); }
.moves li:nth-child(odd) { background: var(--pink-50); }
.moves li span { display: inline-block; width: 74px; }
.moves li span.latest { color: var(--pink-800); font-weight: 800; }
.moves p { margin: 0; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(74, 16, 48, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 18px;
  padding: 24px 28px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(74, 16, 48, .35);
  animation: pop .2s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { margin: 4px 0 6px; color: var(--pink-800); font-size: 1.4rem; }

.promo-choices { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.promo-choices button {
  width: 66px;
  height: 66px;
  padding: 0;
  font-size: 2.8rem;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "DejaVu Sans", serif;
}
.promo-choices button.red { color: var(--red); }
.promo-choices button.purple { color: var(--purple); }

.over-icon { font-size: 3rem; line-height: 1; color: var(--purple); }
.times { margin: 14px auto 6px; border-collapse: collapse; min-width: 240px; }
.times th, .times td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--pink-100); }
.times th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.times td:last-child, .times th:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 10px; }
.modal-actions button { flex: 1; margin-top: 0; }

/* ---------- Small screens ---------- */
@media (max-width: 780px) {
  :root { --board: min(88vw, 600px); }
  h1 { font-size: 1.6rem; }
  .layout { gap: 16px; padding: 8px 10px 24px; }
  .side { width: calc(var(--board) + 20px); }
  .move-clock { font-size: 1.3rem; }
  .clocks { min-width: 90px; }
}
