/* ============================================================
   The Forge of Hephaestus — Web Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #1a0f0a;
  --panel:       #2d1b0e;
  --board-bg:    #1a0f08;
  --cell:        #4a3728;
  --cell-hover:  #5a4535;
  --anvil:       #2a2a2a;
  --crucible:    #4a1a1a;
  --legal:       #4a5a35;
  --last-move:   #ff9d00;
  --text:        #f4e4c1;
  --muted:       #b8956a;
  --dim:         #5c3a1e;
  --accent:      #ff9d00;
  --player:      #ffaa33;
  --ai:          #6699cc;
  --btn:         #cc6600;
  --btn-hover:   #dd7700;
  --border:      #5c3a1e;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

/* ── Header ── */
.header { text-align: center; margin-bottom: 20px; }
.title {
  font-family: 'Cinzel', serif;
  font-size: clamp(18px, 3vw, 26px);
  color: var(--accent);
  letter-spacing: 0.04em;
}
.subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* ── Body layout ── */
.body {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* ── Board Area ── */
.board-area { flex: 0 0 auto; }

.col-labels {
  display: flex;
  margin-left: 28px;   /* align with board (row-label width) */
  margin-bottom: 4px;
}
.col-label {
  width: 54px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  font-weight: 500;
}

.board-wrap { display: flex; gap: 0; }

.row-labels {
  display: flex;
  flex-direction: column;
  width: 28px;
  justify-content: space-around;
}
.row-label {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 12px;
  font-weight: 500;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 54px);
  grid-template-rows: repeat(8, 54px);
  gap: 2px;
  background: var(--board-bg);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 2px;
}

/* ── Cells ── */
.cell {
  width: 54px;
  height: 54px;
  border-radius: 3px;
  background: var(--cell);
  position: relative;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cell:hover { background: var(--cell-hover); }
.cell.anvil  { background: var(--anvil); }
.cell.crucible { background: var(--crucible); }
.cell.legal  { background: var(--legal); cursor: pointer; }
.cell.legal:hover { filter: brightness(1.2); }
.cell.last-move { background: var(--last-move); }
.cell.no-click { cursor: default; pointer-events: none; }

/* Special corner badge */
.cell-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

/* Legal move dot */
.legal-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(180, 255, 140, 0.4);
  pointer-events: none;
}

/* ── Pieces ── */
.piece {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), opacity 0.2s;
  position: relative;
  z-index: 1;
}
.piece.player-piece {
  background: var(--player);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.piece.ai-piece {
  background: var(--ai);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.piece.flip-anim {
  animation: flip 0.3s ease-in-out;
}
@keyframes flip {
  0%   { transform: scaleX(1); }
  50%  { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}
@keyframes place {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.piece.place-anim { animation: place 0.25s ease-out; }

/* ── Status bar ── */
.status-bar {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(45, 27, 14, 0.8);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  min-height: 36px;
}

/* ── Sidebar ── */
.sidebar {
  flex: 1 1 220px;
  min-width: 220px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Panel ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px 12px;
}
.panel-title {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.panel-sep {
  height: 1px;
  background: var(--dim);
  margin: 6px 0 8px;
}

/* Score */
.score-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.score-icon { font-size: 14px; }
.score-name { flex: 1; font-size: 12px; }
.score-value { font-family: 'Cinzel', serif; font-size: 22px; font-weight: 700; }
.player-color { color: var(--player); }
.ai-color     { color: var(--ai); }

/* Turn */
.turn-row { display: flex; align-items: center; gap: 10px; }
.turn-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s;
}
.turn-name { font-size: 13px; color: var(--text); }

/* Legend */
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.legend-swatch {
  width: 14px; height: 14px;
  border-radius: 2px;
  border: 1px solid;
  flex-shrink: 0;
}
.legend-text { font-size: 11px; color: var(--muted); }

/* Stats */
.stats-text { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* Log */
.panel-log { flex: 1; }
.log {
  max-height: 140px;
  overflow-y: auto;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}
.log::-webkit-scrollbar { width: 4px; }
.log::-webkit-scrollbar-track { background: transparent; }
.log::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 2px; }

/* Buttons */
.btn-new {
  width: 100%;
  padding: 10px;
  background: var(--btn);
  color: white;
  border: none;
  border-radius: 4px;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, transform 0.08s;
}
.btn-new:hover { background: var(--btn-hover); transform: translateY(-1px); }
.btn-new:active { transform: translateY(0); }

.depth-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.depth-label { color: var(--muted); font-size: 12px; }
.depth-input {
  width: 56px;
  padding: 4px 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  text-align: center;
}
.depth-input:focus { outline: none; border-color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 36px 40px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  animation: pop 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.modal-icon  { font-size: 48px; margin-bottom: 12px; }
.modal-title { font-family: 'Cinzel', serif; font-size: 20px; color: var(--accent); margin-bottom: 8px; }
.modal-msg   { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 20px; }
.modal-btn   { max-width: 180px; margin: 0 auto; }

/* ── Thinking overlay ── */
.thinking {
  opacity: 0.7;
  pointer-events: none;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .body { flex-direction: column; align-items: center; }
  .sidebar { max-width: 100%; width: 100%; }
  .cell { width: 42px; height: 42px; }
  .board { grid-template-columns: repeat(8, 42px); grid-template-rows: repeat(8, 42px); }
  .col-label { width: 44px; }
  .row-label  { height: 44px; }
  .piece { width: 32px; height: 32px; font-size: 16px; }
}
