/* ── Global ──────────────────────────────────────────────────────────────── */

body {
  min-height: 100vh;
}

.site-brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  color: var(--pico-primary);
  text-decoration: none;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  background: rgba(41, 84, 254, 0.15);
  border: 1px solid var(--pico-secondary);
}
.flash.error {
  background: rgba(220, 50, 50, 0.15);
  border-color: #dc3232;
}

/* ── Home / hero ─────────────────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 1rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  color: var(--pico-primary);
  margin: 0;
  letter-spacing: 0.04em;
}

.tagline {
  color: var(--pico-muted-color);
  font-size: 1.1rem;
  margin: 0;
}

.rules {
  max-width: 520px;
  color: var(--pico-muted-color);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}
.rules em {
  color: var(--pico-color);
  font-style: normal;
}

/* ── Game layout ─────────────────────────────────────────────────────────── */

.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
}


/* ── Player bars ─────────────────────────────────────────────────────────── */

.player-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(90vw, 560px);
  padding: 0.4rem 0.75rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: 6px;
}

.player-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.white-dot { background: #f9f2f4; border: 1px solid #888; }
.black-dot { background: #1c0d4b; border: 1px solid #888; }

.timer {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--pico-muted-color);
  transition: color 0.3s;
}
.timer.active { color: var(--pico-primary); }
.timer.low    { color: #ff4455; }

/* ── Chess board ─────────────────────────────────────────────────────────── */

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(90vw, 560px);
  height: min(90vw, 560px);
  border: 3px solid var(--pico-primary);
  border-radius: 3px;
  user-select: none;
  flex-shrink: 0;
}

.chess-board.flipped {
  transform: rotate(180deg);
}
.chess-board.flipped .piece {
  transform: rotate(180deg);
}

.sq {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.sq.light { background-color: #b8a8d8; }
.sq.dark  { background-color: #4a2fa0; }

.sq.selected        { background-color: var(--pico-primary) !important; }
.sq.last-move       { background-color: rgba(41, 84, 254, 0.5) !important; }
.sq.last-move-from  { background-color: rgba(232, 252, 10, 0.5) !important; }
.sq.in-check        { background-color: rgba(220, 50, 50, 0.6) !important; }

.sq.legal-target::after {
  content: '';
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: rgba(232, 252, 10, 0.55);
  pointer-events: none;
}
.sq.legal-target.has-piece::after {
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: rgba(232, 252, 10, 0.25);
  border: 3px solid rgba(232, 252, 10, 0.7);
  box-sizing: border-box;
}

.sq.protect-my           { outline: 3px solid var(--pico-primary); outline-offset: -3px; }
.sq.protect-their        { outline: 3px solid var(--pico-secondary); outline-offset: -3px; }
.sq.protect-target-valid { outline: 3px dashed var(--pico-secondary); outline-offset: -3px; opacity: 0.85; }

.piece {
  width: 85%;
  height: 85%;
  object-fit: contain;
  pointer-events: none;
}

/* ── Status area ─────────────────────────────────────────────────────────── */

.status-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(90vw, 560px);
}

.phase-banner {
  text-align: center;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  color: var(--pico-muted-color);
}
.phase-banner.move       { border-color: var(--pico-primary); color: var(--pico-primary); }
.phase-banner.protection { border-color: var(--pico-secondary); color: #8aacff; }
.phase-banner.waiting    { border-color: var(--pico-card-border-color); }
.phase-banner.finished   { border-color: var(--pico-card-border-color); }

.skip-notice {
  display: none;
  padding: 0.6rem 0.75rem;
  background: rgba(220, 50, 50, 0.15);
  border: 1px solid #dc3232;
  border-radius: 6px;
  color: #ff6677;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
}

.protection-info {
  padding: 0.5rem 0.75rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: 6px;
}
.prot-label {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin: 0 0 0.4rem;
}
.prot-pieces {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.prot-piece-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.prot-arrow {
  color: var(--pico-muted-color);
  font-size: 1rem;
}

.invite-label {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin: 0 0 0.3rem;
}
.invite-row {
  display: flex;
  gap: 0.4rem;
}
.invite-row input {
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  flex: 1;
  min-width: 0;
}
.invite-row button {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  white-space: nowrap;
}

/* ── Promotion picker ────────────────────────────────────────────────────── */

.promotion-picker {
  position: fixed;
  inset: 0;
  background: rgba(28, 13, 75, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.promo-options {
  display: flex;
  gap: 0.75rem;
  background: var(--pico-card-background-color);
  border: 2px solid var(--pico-primary);
  border-radius: 10px;
  padding: 1rem;
}

.promo-btn {
  width: 72px;
  height: 72px;
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
}
.promo-btn:hover {
  border-color: var(--pico-primary);
  background: rgba(232, 252, 10, 0.1);
}
.promo-btn img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

/* ── Game over overlay ───────────────────────────────────────────────────── */

.game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 13, 75, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.game-over-card {
  text-align: center;
  padding: 2rem 3rem;
  border: 2px solid var(--pico-primary);
  max-width: 380px;
  width: 90vw;
}

.game-over-card h2 {
  color: var(--pico-primary);
  margin-bottom: 1.5rem;
}

/* ── Forfeit button ──────────────────────────────────────────────────────── */

#forfeit-section {
  display: none;
  text-align: right;
}

.forfeit-btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  color: #ff6677;
  border-color: #ff6677;
}
.forfeit-btn:hover {
  background: rgba(220, 50, 50, 0.15);
  border-color: #ff4455;
  color: #ff4455;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

