* { box-sizing: border-box; }
html, body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #1a1a1a;
  color: #eee;
}
a { color: #7fb3ff; }

.container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 { margin-top: 0; }

button {
  background: #2c2c2c;
  color: #eee;
  border: 1px solid #555;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}
button:hover { background: #3a3a3a; }
button.link {
  background: transparent;
  border: none;
  color: #7fb3ff;
  padding: 0;
  text-decoration: underline;
}

input, select {
  background: #2c2c2c;
  color: #eee;
  border: 1px solid #555;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  font: inherit;
}

form label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-right: 1rem;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.me { font-size: 0.9rem; color: #bbb; }

.create-card, .lobby-card {
  background: #242424;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}
.create-card form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }

.lobby-list { list-style: none; padding: 0; margin: 0; }
.lobby-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #333;
}
.lobby-list li:last-child { border-bottom: none; }
.muted { color: #888; }

/* Game page */
.game-layout {
  display: grid;
  grid-template-columns: minmax(320px, 560px) 280px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 820px) {
  .game-layout { grid-template-columns: 1fr; }
}

.board-wrap { width: 100%; }
.board-wrap #board { width: 100%; }

.side-panel {
  background: #242424;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 1rem;
}

.players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  background: #2c2c2c;
}
.player-row.active { outline: 2px solid #7fb3ff; }

/* #4: setup phase pills */
.setup-pill {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: #3a3a3a;
  color: #aaa;
  margin-left: 0.5rem;
}
.setup-pill.ready {
  background: #2f4a2a;
  color: #8d8;
}

.history {
  max-height: 240px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.9rem;
  background: #1a1a1a;
  padding: 0.5rem;
  border-radius: 4px;
  margin: 0.5rem 0 1rem;
  border: 1px solid #333;
}
.history .move { display: inline-block; margin-right: 0.5rem; }

.banner {
  background: #2b3b5a;
  border: 1px solid #4a6;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}
.banner.win  { background: #2f4a2a; border-color: #6a6; }
.banner.loss { background: #4a2a2a; border-color: #a66; }
.banner.draw { background: #3a3a2a; border-color: #aa6; }
.banner.info { background: #2b3b5a; border-color: #46a; }

.share {
  font-size: 0.85rem;
  color: #bbb;
  margin-bottom: 1rem;
  word-break: break-all;
}
.share input { width: 100%; margin-top: 0.25rem; }

.actions { display: flex; gap: 0.5rem; }

.variant-row {
  font-size: 0.9rem;
  color: #bbb;
  margin-bottom: 0.5rem;
}

.variant-info {
  background: #2b3b5a;
  border: 1px solid #46a;
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}
.variant-info b { color: #fff; }
.variant-info .picked {
  margin-top: 0.4rem;
  color: #e0b030;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.variant-info .picked.revealed { color: #ff7a7a; }
.variant-info.poisoned { background: #3b2a2a; border-color: #a66; }
.variant-info.poisoned .picked { color: #ff7a7a; }

/* #8: reveal warning */
.variant-info.reveal-warning {
  background: #4a3a1a;
  border-color: #c90;
  animation: pulse-warn 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-warn {
  from { border-color: #c90; }
  to   { border-color: #fc0; }
}

/* #2: confirm button for setup */
.setup-confirm-btn {
  background: #2f6a2f;
  border-color: #6a6;
  margin-bottom: 1rem;
  width: 100%;
  padding: 0.5rem;
  font-weight: bold;
}
.setup-confirm-btn:hover { background: #3a8a3a; }

/* #3: dim non-eligible squares during setup */
#board [data-square].setup-dim {
  filter: brightness(0.45);
}

/* Squares eligible for picking during the setup phase. */
#board [data-square].setup-eligible {
  cursor: pointer;
}
#board [data-square].setup-eligible:hover {
  box-shadow: inset 0 0 0 3px rgba(127, 179, 255, 0.7);
}

/* #2: selected pawn during setup (before confirm) */
#board [data-square].setup-selected {
  box-shadow: inset 0 0 0 3px #e0b030, 0 0 12px rgba(224, 176, 48, 0.7);
}

/* #6: last-move highlight */
#board [data-square].highlight-last-move {
  box-shadow: inset 0 0 0 3px rgba(155, 199, 0, 0.55);
}

/* #6: check highlight */
#board [data-square].highlight-check {
  box-shadow: inset 0 0 0 3px #e05050, 0 0 14px rgba(224, 80, 80, 0.8) !important;
}

/* Owner-only square markers for variant secrets. */
#board [data-square].highlight-poisoned {
  box-shadow: inset 0 0 0 3px #e05050, 0 0 10px rgba(224, 80, 80, 0.6);
}
#board [data-square].highlight-queen {
  box-shadow: inset 0 0 0 3px #e0b030, 0 0 10px rgba(224, 176, 48, 0.6);
}

/* #10: revealed opponent's poisoned pawn on game-end */
#board [data-square].highlight-revealed-poison {
  box-shadow: inset 0 0 0 3px #ff4040, 0 0 16px rgba(255, 64, 64, 0.9);
  animation: poison-pulse 0.8s ease-in-out 3;
}
@keyframes poison-pulse {
  0%, 100% { box-shadow: inset 0 0 0 3px #ff4040, 0 0 16px rgba(255, 64, 64, 0.9); }
  50%      { box-shadow: inset 0 0 0 4px #ff6060, 0 0 24px rgba(255, 64, 64, 1); }
}

/* #5: disguise marker — small pawn glyph on owner's hidden queen */
#board [data-square].hq-disguise {
  position: relative;
}
#board [data-square].hq-disguise::after {
  content: '\265F';
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 14px;
  line-height: 1;
  color: rgba(224, 176, 48, 0.85);
  pointer-events: none;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}
