/* Diamond King — game.css */

/* ── Reset + Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cell:          58px;
  --piece:         46px;
  --board-active:  #E8E3D4;
  --board-inactive:#1C1A15;
  --kingdom-p1:    #D8E0F0;   /* subtle blue tint — your home row */
  --kingdom-p2:    #F0D8D8;   /* subtle red tint — opponent's home row */
  --valid-move:    rgba(80,200,100,0.30);
  --selected-ring: #D4A010;
  --last-from:     rgba(200,200,80,0.18);
  --last-to:       rgba(200,200,80,0.35);
  --invincible-clr:#C8A200;
  --piece-p1-bg:   #F2EDD8;
  --piece-p1-txt:  #1C1A15;
  --piece-p2-bg:   #1A1714;
  --piece-p2-txt:  #C8A200;
  --ui-bg:         #111009;
  --ui-text:       #E8E3D4;
  --ui-muted:      #7A756A;
  --ui-border:     #2E2B22;
  --radius:        6px;
}

/* ── Page layout ───────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: 'Georgia', serif;
}

#app { min-height: 100vh; display: flex; flex-direction: column; align-items: center; }

.screen { display: none; width: 100%; max-width: 700px; padding: 2rem 1rem; }
.screen.active { display: block; }

/* ── Setup screen ──────────────────────────────────────────────────────────── */
#screen-setup { text-align: center; }
#screen-setup h1 {
  font-size: 2.4rem;
  letter-spacing: .12em;
  color: var(--invincible-clr);
  margin-bottom: .3rem;
}
#screen-setup .subtitle {
  color: var(--ui-muted);
  font-style: italic;
  margin-bottom: 2rem;
  font-size: .95rem;
}

.setup-card {
  background: #1A1812;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius);
  padding: 1.8rem 2rem;
  display: inline-block;
  text-align: left;
  min-width: 300px;
}
.setup-row { margin-bottom: 1.2rem; }
.setup-row label { display: block; color: var(--ui-muted); font-size: .82rem; margin-bottom: .4rem; letter-spacing: .05em; }
.setup-row select {
  width: 100%;
  background: #111009;
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  padding: .5rem .7rem;
  border-radius: 4px;
  font-size: .95rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  background: #1A1812;
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  padding: .55rem 1.3rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #262318; border-color: #5A5540; }
.btn-primary {
  background: #2A2006;
  border-color: var(--invincible-clr);
  color: var(--invincible-clr);
  font-size: 1rem;
  padding: .65rem 2rem;
  margin-top: .5rem;
  width: 100%;
}
.btn-primary:hover { background: #3A2E08; }
.btn-danger { border-color: #884444; color: #CC7777; }
.btn-danger:hover { background: #1E1212; }

/* ── Game screen ───────────────────────────────────────────────────────────── */
#screen-game { padding: 1rem; }

#game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem .2rem;
  margin-bottom: .7rem;
  border-bottom: 1px solid var(--ui-border);
}
#game-status { font-size: 1rem; color: var(--ui-text); }
#turn-indicator { font-size: .82rem; color: var(--ui-muted); }

#board-container {
  display: flex;
  justify-content: center;
  margin-bottom: .8rem;
}

/* ── Board ─────────────────────────────────────────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(10, var(--cell));
  grid-template-rows:    repeat(10, var(--cell));
  border: 2px solid #302C20;
  box-shadow: 0 4px 24px rgba(0,0,0,.7);
}

/* ── Cells ─────────────────────────────────────────────────────────────────── */
.cell {
  width: var(--cell);
  height: var(--cell);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell.inactive { background: var(--board-inactive); }
.cell.active   { background: var(--board-active); cursor: pointer; }
.cell.kingdom-p1.active { background: var(--kingdom-p1); }
.cell.kingdom-p2.active { background: var(--kingdom-p2); }

/* Last-move tint */
.cell.last-from { background: color-mix(in srgb, var(--last-from) 100%, var(--board-active)) !important; }
.cell.last-to   { background: color-mix(in srgb, var(--last-to) 100%, var(--board-active)) !important; }

/* Valid destination dot */
.cell.valid-move::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--valid-move);
  pointer-events: none;
}
.cell.valid-move:not(:has(.piece))::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(80,200,100,0.55);
  pointer-events: none;
}

/* Selected cell ring */
.cell.selected::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid var(--selected-ring);
  pointer-events: none;
  z-index: 10;
}

/* Invincible cell pulse */
.cell.has-invincible::before {
  content: '';
  position: absolute;
  inset: 0;
  animation: inv-pulse 1.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes inv-pulse {
  0%,100% { background: rgba(200,162,0,0); }
  50%      { background: rgba(200,162,0,0.22); }
}

/* ── Shield labels ─────────────────────────────────────────────────────────── */
/* Corner label — always visible */
.shield-label {
  position: absolute;
  top: 3px; left: 4px;
  font-size: 9px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  opacity: .75;
  color: #333;
  pointer-events: none;
  line-height: 1;
  z-index: 2;
}

/* Centered watermark — shows on empty squares only */
.shield-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  opacity: .18;
  pointer-events: none;
  z-index: 1;
  color: #222;
}

/* ── Pieces ────────────────────────────────────────────────────────────────── */
.piece {
  position: relative;
  z-index: 5;
  width:  var(--piece);
  height: var(--piece);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s;
  cursor: pointer;
}
.piece:hover { transform: scale(1.06); }

.piece.player-1 { background-image: url('../img/Diamond_King_Pieces_white.svg'); }
.piece.player-2 { background-image: url('../img/Diamond_King_Pieces_black.svg'); }

/* Prime pieces get a subtle gold tint overlay */
.piece.prime::after {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,162,0,0.18) 0%, transparent 70%);
  pointer-events: none;
}

/* Promoted dot */
.piece.promoted::before {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--invincible-clr);
  z-index: 6;
}

.piece-label {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -.02em;
  pointer-events: none;
  line-height: 1;
  position: relative;
  z-index: 6;
}
.piece.player-1 .piece-label { color: #1C1A15; }
.piece.player-2 .piece-label { color: #C8A200; }

/* ── Game controls ─────────────────────────────────────────────────────────── */
#game-controls {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  padding: .3rem .2rem;
}

/* ── End screen ────────────────────────────────────────────────────────────── */
#screen-end {
  text-align: center;
  padding-top: 4rem;
}
#end-title { font-size: 2rem; color: var(--invincible-clr); margin-bottom: .8rem; }
#end-message { color: var(--ui-muted); margin-bottom: 2rem; }

/* ── Report modal ──────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: #1A1812;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 90%;
  max-width: 420px;
}
.modal-content h3 { margin-bottom: .8rem; font-size: 1.1rem; }
.modal-content textarea {
  width: 100%;
  background: #111009;
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  padding: .6rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: .9rem;
  resize: vertical;
  min-height: 90px;
  margin-bottom: .8rem;
}
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #2A2608;
  border: 1px solid var(--invincible-clr);
  color: var(--invincible-clr);
  padding: .6rem 1.1rem;
  border-radius: 4px;
  font-size: .9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s, transform .3s;
  z-index: 200;
}
.toast.visible { opacity: 1; transform: translateY(0); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 620px) {
  :root { --cell: 36px; --piece: 28px; }
  .piece-label { font-size: 7px; }
  .shield-label { font-size: 5px; }
  #screen-setup h1 { font-size: 1.8rem; }
}
