/* ═══════════════════════════════════════════════════════════
   caro.css — Co Caro (Gomoku VN) game styles
   ═══════════════════════════════════════════════════════════ */

/* ── Page layout ───────────────────────────────────────── */
.bc-table-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
@media (max-width: 900px) {
  .bc-table-layout { flex-direction: column; }
}
@media (orientation: landscape) and (max-width: 932px) and (pointer: coarse) {
  .bc-table-layout { flex-direction: row; }
  .bc-table-layout .bc-sidebar {
    width: 200px !important;
    height: 100dvh !important;
    border-left: 1px solid var(--gc-border, rgba(255,255,255,0.12));
    border-bottom: none;
  }
}

/* ── Table ─────────────────────────────────────────────── */
.bc-table {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 50%, #1e5a8a 0%, #0a1e3a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.bc-table::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-conic-gradient(rgba(255,255,255,0.03) 0% 25%, transparent 0% 50%) 0 0 / 40px 40px;
  transform: rotate(45deg) scale(1.5);
  pointer-events: none;
}

/* ── Board Wrap ────────────────────────────────────────── */
.caro-board-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 5;
  flex: 1;
  min-height: 0;
}

/* ── Player Bars ───────────────────────────────────────── */
.caro-player-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 10px;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  min-width: 200px;
  position: relative;
}
.caro-player-bar.active-turn {
  box-shadow: 0 0 0 2px var(--gc-cyan, #22d3ee), 0 0 16px rgba(34,211,238,0.25);
}
.caro-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.caro-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.caro-player-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gc-text-bright, #e8f0fa);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.caro-player-points {
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--gc-gold, #FFD700);
}
.caro-symbol {
  font-family: 'Bungee', cursive;
  font-size: 18px;
  margin-left: auto;
}
.caro-symbol.symbol-x { color: var(--gc-cyan, #22d3ee); }
.caro-symbol.symbol-o { color: var(--gc-red, #ef4444); }

/* Timer bar under player bar */
.caro-timer-bar {
  position: absolute;
  bottom: 0; left: 8px; right: 8px;
  height: 3px;
  border-radius: 0 0 6px 6px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.caro-timer-fill {
  height: 100%;
  background: var(--gc-green, #4ade80);
  border-radius: 2px;
  transition: width 1s linear, background 0.3s;
  width: 100%;
}
.caro-timer-fill.warn { background: var(--gc-gold, #f39c12); }
.caro-timer-fill.urgent {
  background: var(--gc-red, #ef4444);
  animation: pulse 0.5s infinite;
}

/* ── Board ─────────────────────────────────────────────── */
.caro-board {
  display: grid;
  gap: 0;
  background: rgba(0,0,0,0.25);
  border: 2px solid var(--gc-cyan, #22d3ee);
  border-radius: 4px;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.caro-board-container {
  overflow: auto;
  max-width: 100%;
  max-height: calc(100dvh - 200px);
  border-radius: 4px;
  position: relative;
}

.caro-cell {
  width: var(--cell-size, 32px);
  height: var(--cell-size, 32px);
  border: 1px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  font-family: 'Bungee', cursive;
  font-weight: 700;
  position: relative;
}
/* Ghost preview desktop */
@media (hover: hover) {
  .caro-cell:hover:not(.placed) {
    background: rgba(34, 211, 238, 0.12);
  }
  .caro-cell.my-turn:hover:not(.placed)::after {
    content: attr(data-ghost);
    opacity: 0.3;
    font-size: calc(var(--cell-size, 32px) * 0.55);
    font-family: 'Bungee', cursive;
    position: absolute;
  }
}
/* Mobile tap highlight */
.caro-cell:active:not(.placed) {
  background: rgba(34, 211, 238, 0.2);
}

.caro-cell.placed-x {
  color: var(--gc-cyan, #22d3ee);
  font-size: calc(var(--cell-size, 32px) * 0.55);
  text-shadow: 0 0 6px rgba(34,211,238,0.4);
}
.caro-cell.placed-o {
  color: var(--gc-red, #ef4444);
  font-size: calc(var(--cell-size, 32px) * 0.55);
  text-shadow: 0 0 6px rgba(239,68,68,0.4);
}
.caro-cell.placed {
  cursor: default;
}
.caro-cell.win-highlight {
  background: rgba(74, 222, 128, 0.3) !important;
  z-index: 2;
}
.caro-cell.last-move {
  box-shadow: inset 0 0 0 2px var(--gc-gold, #FFD700);
}
/* Place animation */
.caro-cell.just-placed {
  animation: stoneDrop 0.25s ease-out;
}
@keyframes stoneDrop {
  from { transform: scale(0); }
  60% { transform: scale(1.15); }
  to { transform: scale(1); }
}

/* ── Win SVG overlay ──────────────────────────────────── */
.caro-win-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}
.caro-win-svg line {
  stroke: var(--gc-green, #4ade80);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px var(--gc-green, #4ade80));
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: winLineReveal 0.6s ease-out forwards;
}
@keyframes winLineReveal {
  to { stroke-dashoffset: 0; }
}

/* ── Table Center (waiting state) ─────────────────────── */
.caro-table-center {
  text-align: center;
  z-index: 5;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.caro-status {
  font-size: 14px;
  color: var(--gc-muted, #6b8fb5);
  font-weight: 500;
  margin-bottom: 10px;
}
.caro-start-btn {
  font-size: 15px;
  padding: 10px 28px;
  border-radius: 10px;
  font-weight: 700;
  font-family: 'Be Vietnam Pro', sans-serif;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0a1e3a;
  box-shadow: 0 4px 16px rgba(245,158,11,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  animation: fadeInUp 0.3s ease;
}
.caro-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245,158,11,0.4);
}
.caro-start-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

/* ── Result overlay ───────────────────────────────────── */
.caro-result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.3s ease;
}
.caro-result-card {
  background: rgba(10,30,58,0.95);
  border: 1px solid var(--gc-border, rgba(255,255,255,0.12));
  border-radius: 16px;
  padding: 28px 40px;
  text-align: center;
  max-width: 340px;
  animation: fadeInUp 0.3s ease;
}
.caro-result-title {
  font-family: 'Bungee', cursive;
  font-size: 22px;
  margin-bottom: 8px;
}
.caro-result-title.win { color: var(--gc-gold, #FFD700); text-shadow: 0 0 12px rgba(255,215,0,0.4); }
.caro-result-title.lose { color: var(--gc-red, #ef4444); }
.caro-result-title.draw { color: var(--gc-muted, #8899aa); }
.caro-result-reason {
  font-size: 12px;
  color: var(--gc-muted, #6b8fb5);
  margin: 6px 0 10px;
}
.caro-result-vs {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 4px;
}
.caro-result-player {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
}
.caro-result-pname {
  font-size: 11px;
  color: var(--gc-muted, #6b8fb5);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-family: 'IBM Plex Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.caro-result-points {
  font-family: 'Bungee', cursive;
  font-size: 22px;
  font-weight: 800;
  color: var(--gc-text-bright, #e8f0fa);
  line-height: 1;
}
.caro-result-diff {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
}
.caro-result-diff.positive { color: var(--gc-green, #4ade80); }
.caro-result-diff.negative { color: var(--gc-red, #ef4444); }
.caro-result-divider {
  width: 1px;
  background: rgba(255,255,255,0.12);
  margin: 4px 0;
  position: relative;
}
.caro-result-divider span {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Bungee', cursive;
  font-size: 9px;
  color: var(--gc-muted, #6b8fb5);
  background: rgba(10,30,58,0.95);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  letter-spacing: .1em;
  white-space: nowrap;
}

/* ── Draw offer modal ─────────────────────────────────── */
.caro-draw-modal {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10,30,58,0.95);
  border: 1px solid var(--gc-border, rgba(255,255,255,0.12));
  border-radius: 12px;
  padding: 20px 30px;
  text-align: center;
  z-index: 60;
  animation: fadeInUp 0.3s ease;
}
.caro-draw-modal h4 {
  margin: 0 0 12px;
  color: var(--gc-text-bright, #e8f0fa);
  font-size: 15px;
}
.caro-draw-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

/* ── Action buttons (in-game) ─────────────────────────── */
.caro-game-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  z-index: 6;
}
.caro-game-actions .bc-btn {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-family: 'Be Vietnam Pro', sans-serif;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.caro-game-actions .bc-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.caro-game-actions .bc-btn-secondary {
  background: rgba(200,221,240,0.08);
  border: 1px solid rgba(200,221,240,0.15);
  color: var(--gc-text, #c8ddf0);
}
.caro-game-actions .bc-btn-secondary:hover:not(:disabled) {
  background: rgba(200,221,240,0.14);
}

/* ── Animations ───────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .caro-player-bar {
    padding: 4px 10px;
    min-width: 160px;
  }
  .caro-avatar { width: 32px; height: 32px; }
  .caro-player-name { font-size: 11px; }
  .caro-symbol { font-size: 15px; }
  .caro-result-card { padding: 20px 24px; }
}

@media (max-width: 600px) {
  .caro-player-bar {
    padding: 3px 8px;
    min-width: 140px;
  }
  .caro-avatar { width: 28px; height: 28px; }
  .caro-player-name { font-size: 10px; max-width: 70px; }
  .caro-symbol { font-size: 13px; }
}

/* ── Utility ──────────────────────────────────────────── */
.hidden { display: none !important; }

@media (max-width: 760px) { .chat-panel { left: 10px; right: 10px; } }
