/* Erizosridor en línea — estilos (PC primero, también se ve bien en celular) */
:root {
  --cell: 56px;
  --groove: 12px;
  --bg: #14161c;
  --panel: #1e222c;
  --panel2: #262b38;
  --text: #f2f0ea;
  --muted: #9aa3b2;
  --accent: #f5b942;
  --accent-ink: #241a05;
  --team-a: #e5484d;
  --team-b: #3b82f6;
  --wood-light: #eccfa5;
  --wood-dark: #cf9a63;
  --groove-color: #7a4e28;
  --wall: #4a2c14;
  --wall-edge: #2e1a0a;
  --ok: #37c978;
  --bad: #ef4444;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #262c3d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.app { max-width: 1080px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---------- Botones ---------- */
.btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #3a4152;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover { background: #2f3547; border-color: #556; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #d99a1f; font-weight: 700; }
.btn.primary:hover { background: #ffcb5c; }
.btn.big { padding: 13px 20px; font-size: 16px; width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
kbd { background: #111; border: 1px solid #444; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; }

/* ---------- Lobby ---------- */
.lobby-card {
  max-width: 560px; margin: 6vh auto 0; background: var(--panel);
  border: 1px solid #31364a; border-radius: 18px; padding: 34px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.lobby-card h1 { font-size: 44px; text-align: center; letter-spacing: 1px; }
.subtitle { text-align: center; color: var(--muted); margin: 8px 0 26px; font-size: 16px; }
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text] {
  width: 100%; background: #12141b; color: var(--text);
  border: 1px solid #3a4152; border-radius: 10px; padding: 12px 14px;
  font-size: 16px; outline: none;
}
input[type=text]:focus { border-color: var(--accent); }
#nameInput { margin-bottom: 18px; }
#codeInput { text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }
.mode-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.btn.mode-pick { padding: 11px 4px; font-size: 15px; font-weight: 700; }
.btn.mode-pick.active { background: var(--accent); color: var(--accent-ink); border-color: #d99a1f; }
.mode-note { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 18px; }
.lobby-actions { display: flex; flex-direction: column; gap: 12px; }
.join-row { display: flex; gap: 10px; }
.join-row .btn { width: auto; white-space: nowrap; }
.error { color: #ff7b7b; font-size: 14px; margin-top: 12px; text-align: center; }
.howto { margin-top: 24px; border-top: 1px solid #31364a; padding-top: 16px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.howto ul { margin: 12px 0 0 20px; color: #cfd4de; line-height: 1.65; font-size: 15px; }
.credit { margin-top: 22px; font-size: 12px; color: #6b7280; text-align: center; }

/* ---------- Juego ---------- */
.game-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.game-title { font-size: 24px; font-weight: 800; }
.room-code { color: var(--accent); letter-spacing: 2px; font-size: 20px; }
.header-btns { display: flex; gap: 8px; }
.waiting-bar {
  background: #2a2410; border: 1px solid #6b5518; color: #ffe1a1;
  border-radius: 10px; padding: 12px 16px; margin-bottom: 14px; font-size: 15px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.turn-banner {
  text-align: center; font-size: 19px; font-weight: 700; padding: 10px;
  border-radius: 10px; margin-bottom: 16px; background: var(--panel);
  border: 1px solid #31364a;
}
.turn-banner.my-turn { background: #3a2f07; border-color: var(--accent); color: #ffd97a; }
.turn-banner.their-turn { color: var(--muted); }
.game-main { display: flex; gap: 26px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* Etiquetas de coordenadas */
.col-labels, .row-labels { color: var(--muted); font-size: 12px; font-weight: 700; }
.col-labels { display: grid; grid-template-columns: repeat(8, var(--cell) var(--groove)) var(--cell); width: calc(9 * var(--cell) + 8 * var(--groove)); }
.col-labels span { text-align: center; }
.row-labels { display: grid; grid-template-rows: repeat(8, var(--cell) var(--groove)) var(--cell); height: calc(9 * var(--cell) + 8 * var(--groove)); }
.row-labels span { display: flex; align-items: center; justify-content: center; width: 18px; }
.board-row { display: flex; gap: 6px; }

/* Tablero 17x17: 9 casillas + 8 ranuras */
.board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell) var(--groove)) var(--cell);
  grid-template-rows: repeat(8, var(--cell) var(--groove)) var(--cell);
  background: linear-gradient(145deg, #9c6b3d, var(--groove-color));
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.15);
  user-select: none;
}
.cell {
  background: var(--wood-light);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  cursor: default; position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.cell.dark { background: var(--wood-dark); }
.cell.goal-a { box-shadow: inset 0 0 0 2px rgba(229,72,77,.55); }
.cell.goal-b { box-shadow: inset 0 0 0 2px rgba(59,130,246,.55); }
.cell.legal { cursor: pointer; }
.cell.legal::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(20, 120, 60, .55); box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}
.cell.legal:hover { background: #ffe9a8; }
.cell.legal:hover::after { background: var(--ok); }

/* Peones */
.pawn {
  width: 74%; height: 74%; border-radius: 50%; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.45), inset 0 -4px 8px rgba(0,0,0,.3), inset 0 3px 6px rgba(255,255,255,.35);
}
.pawn.team-a { background: radial-gradient(circle at 35% 30%, #ff7a7e, var(--team-a) 60%, #a11f24); }
.pawn.team-b { background: radial-gradient(circle at 35% 30%, #7db4ff, var(--team-b) 60%, #1d4fa1); }
.pawn.mine { outline: 3px solid #fff; outline-offset: 1px; }

/* Ranuras de muro (clicables en modo muro) */
.wall-slot { border-radius: 3px; z-index: 3; }
.wall-slot.h { grid-column: span 3; }
.wall-slot.v { grid-row: span 3; }
body.wall-mode .wall-slot { cursor: pointer; }
body.wall-mode .wall-slot:hover:not(.placed) { background: rgba(255,255,255,.35); }
.wall-slot.preview-ok { background: rgba(55,201,120,.75) !important; box-shadow: 0 0 0 2px #1f7a48; }
.wall-slot.preview-bad { background: rgba(239,68,68,.75) !important; box-shadow: 0 0 0 2px #7f1d1d; }
.wall-slot.placed {
  background: linear-gradient(180deg, #6b4423, var(--wall) 55%, #33200e);
  box-shadow: 0 3px 8px rgba(0,0,0,.5), inset 0 0 0 1px var(--wall-edge);
}
.wall-slot.placed.h { border-top: 2px solid #8a5f36; border-bottom: 2px solid #241304; }
.wall-slot.placed.v { border-left: 2px solid #8a5f36; border-right: 2px solid #241304; }

/* Barra de modo */
.mode-bar { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.btn.mode.active { background: var(--accent); color: var(--accent-ink); border-color: #d99a1f; font-weight: 700; }
.walls-badge { background: rgba(0,0,0,.3); border-radius: 20px; padding: 1px 8px; font-size: 13px; }
.mode-hint { color: var(--muted); font-size: 13px; }

/* Panel lateral */
.side-panel { width: 280px; display: flex; flex-direction: column; gap: 14px; }
.teams { display: flex; flex-direction: column; gap: 10px; }
.team-box { background: var(--panel); border: 1px solid #31364a; border-radius: 12px; padding: 12px 14px; }
.team-box h3 { font-size: 15px; margin-bottom: 8px; }
.team-box.team-a h3 { color: #ff8a8e; }
.team-box.team-b h3 { color: #7db4ff; }
.team-list { display: flex; flex-direction: column; gap: 6px; }
.player-card {
  background: var(--panel2); border: 1px solid #31364a; border-radius: 10px;
  padding: 8px 10px; display: flex; justify-content: space-between; align-items: center;
}
.player-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.player-card .pname { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.team-a { background: var(--team-a); } .dot.team-b { background: var(--team-b); }
.dot.off { background: #555; }
.online { font-size: 11px; color: var(--ok); }
.online.off { color: var(--muted); }
.pwalls { font-size: 13px; color: var(--muted); }
.pwalls b { color: var(--text); font-size: 16px; }
.waiting-slot { color: var(--muted); font-size: 14px; font-style: italic; padding: 4px 2px; }
.log-box { background: var(--panel); border: 1px solid #31364a; border-radius: 12px; padding: 12px 14px; }
.log-box h3 { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.move-log { list-style: none; max-height: 220px; overflow-y: auto; font-size: 14px; line-height: 1.9; }
.move-log li { border-bottom: 1px solid #2a2f3d; }
.move-log li:last-child { border-bottom: none; }
.move-log .who-a { color: #ff8a8e; font-weight: 700; }
.move-log .who-b { color: #7db4ff; font-weight: 700; }

/* Victoria */
.win-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.win-card {
  background: var(--panel); border: 1px solid var(--accent); border-radius: 18px;
  padding: 34px 40px; text-align: center; max-width: 420px; width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.win-emoji { font-size: 56px; }
.win-card h2 { margin: 8px 0 6px; font-size: 28px; }
.win-card p { color: var(--muted); margin-bottom: 20px; }
.win-card .btn { margin-top: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  :root { --cell: 34px; --groove: 8px; }
  .lobby-card h1 { font-size: 34px; }
  .game-main { gap: 16px; }
  .side-panel { width: 100%; max-width: 420px; }
  .turn-banner { font-size: 16px; }
  .pawn { font-size: 14px; }
}
