/* Rainbow Chess — frontend shell styling.
   A compact, self-contained stylesheet (no build step). The board's own styles
   are added with the board renderer in a later task. */

:root {
  --bg: #0f1320;
  --panel: #1a2030;
  --panel-2: #232c40;
  --text: #e7ecf5;
  --muted: #8b97ad;
  --accent: #6c8cff;
  --accent-2: #ff5fa2;
  --online: #3ddc84;
  --offline: #e2554f;
  --border: #2c3650;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(90deg, #1a2030, #21283c);
  border-bottom: 1px solid var(--border);
}

.app-title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ff5fa2, #6c8cff, #3ddc84);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.95rem;
}

.status {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status.online {
  background: rgba(61, 220, 132, 0.15);
  color: var(--online);
}

.status.offline {
  background: rgba(226, 85, 79, 0.15);
  color: var(--offline);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 22px;
  align-items: start;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
}

.variant-pick {
  display: flex;
  flex-direction: column;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  gap: 3px;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.9rem;
}

/* Users list */
.users-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 12px;
}

.user-name {
  font-weight: 600;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--text);
  transition: filter 0.15s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.15);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.challenge-btn {
  background: var(--accent);
  color: #0b1020;
}

button.primary {
  background: var(--accent);
  color: #0b1020;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Game area */
.game-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.board-root {
  position: relative;
  display: inline-block;
}

/* Status banner above the board (turn / check / result). */
.board-banner {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
}

.board-banner[data-tone="check"] {
  border-left-color: var(--accent-2);
  color: #ffd2e4;
}

.board-banner[data-tone="over"] {
  border-left-color: var(--online);
}

/* The 8x8 grid. A fixed, square aspect so pieces stay centered. */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(70vmin, 520px);
  aspect-ratio: 1 / 1;
  border: 3px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  user-select: none;
}

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

/* Light / dark squares — neutral so colour-mixed (Rainbow) pieces read clearly
   regardless of which half they sit in. */
.square.light {
  background: #b9c3d6;
}

.square.dark {
  background: #5d6b87;
}

/* A single glyph shape per piece type; the side is conveyed purely by fill
   colour so Rainbow's colour-mixed boards render each piece by its own colour. */
.piece {
  font-size: min(8vmin, 58px);
  line-height: 1;
  pointer-events: none;
}

.piece.white {
  color: #fbfcff;
  text-shadow:
    0 0 1px #1a1d24,
    0 1px 2px rgba(0, 0, 0, 0.55);
}

.piece.black {
  color: #14161c;
  text-shadow:
    0 0 1px #cfd6e6,
    0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Highlights */
.square.selected {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.square.last-move {
  background-image: linear-gradient(rgba(108, 140, 255, 0.32), rgba(108, 140, 255, 0.32));
}

.square.in-check {
  background-image: linear-gradient(rgba(255, 95, 162, 0.55), rgba(255, 95, 162, 0.55));
}

/* A legal move-to: a dot for an empty square, a ring for a capture. */
.square.move-target::after {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(15, 19, 32, 0.42);
}

.square.capture-target::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 4px solid rgba(15, 19, 32, 0.45);
  border-radius: 50%;
}

/* Promotion picker overlay */
.promotion-picker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  text-align: center;
  z-index: 5;
}

.promotion-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.promotion-options {
  display: flex;
  gap: 8px;
}

.promotion-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.promotion-option .piece {
  font-size: 34px;
}

.game-controls {
  display: flex;
  gap: 10px;
}

/* In-game header: active variant + both players and their colours. */
.game-info {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 2px;
}

/* Game-over offer: result line + "new game / back to menu" button. */
.game-over {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 4px;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--online);
  border-radius: 8px;
}

.game-over-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Incoming challenge prompt */
.challenge-prompt {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  text-align: center;
}

.challenge-prompt p {
  margin: 0 0 12px;
}

.challenge-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  max-width: 320px;
}

/* Footer: build/commit marker injected at image build time. */
.app-footer {
  padding: 14px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
}

#commit-sha {
  margin: 0;
  padding: 0;
}
