/* Ludus Coriovalli 3D Board Game Styles */

:root {
  /* HSL Colors */
  --bg-color: #060913;
  --bg-grid: rgba(255, 255, 255, 0.015);
  
  --panel-bg: rgba(14, 20, 38, 0.65);
  --panel-border: rgba(255, 255, 255, 0.06);
  --panel-hover-border: rgba(168, 85, 247, 0.35);
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dark: #475569;
  
  --accent-color: #d946ef;
  --accent-color-hover: #f0abfc;
  
  --font-main: 'Noto Sans KR', 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-card: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg-color: #f1f5f9;
  --bg-grid: rgba(15, 23, 42, 0.02);
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(15, 23, 42, 0.08);
  --panel-hover-border: rgba(217, 70, 239, 0.4);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dark: #cbd5e1;
  --shadow-card: 0 12px 40px 0 rgba(15, 23, 42, 0.05);
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
  transition: background-color 0.5s ease, color 0.3s ease;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: -2;
  pointer-events: none;
}

/* Ambient Glow Orbs */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(160px);
  z-index: -3;
  pointer-events: none;
  opacity: 0.2;
}

.bg-glow-purple {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #c084fc 0%, transparent 70%);
  top: -200px;
  left: 10%;
}

.bg-glow-blue {
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
  top: 20%;
  right: 5%;
}

/* Header Styles */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  margin: 1rem 1.5rem 0 1.5rem;
  border-radius: 50px;
  transition: var(--transition-smooth);
}

.glass-header {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
}

.logo-circle {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #d946ef 0%, #a855f7 100%);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 4px 10px rgba(217, 70, 239, 0.3);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-text {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.logo-text span {
  color: var(--accent-color);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  transition: var(--transition-smooth);
  text-decoration: none;
}

.btn-back-home {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-back-home:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-color);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-theme {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  padding: 0.5rem 1rem;
  color: var(--text-main);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-theme:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-color);
}

[data-theme="light"] .btn-back-home,
[data-theme="light"] .btn-theme {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.08);
}

.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
}

/* App Layout */
.app-container {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Lobby Card --- */
.lobby-card {
  padding: 2.25rem 2rem;
  max-width: 750px;
  margin: 1.5rem auto;
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.lobby-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.icon-accent {
  color: var(--accent-color);
  font-size: 1.5rem;
}

.lobby-section {
  margin-bottom: 1.5rem;
}

.lobby-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.faction-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-faction-toggle {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 1.25rem 1.5rem;
  border-radius: 16px;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.btn-faction-toggle i {
  font-size: 2.2rem;
  width: 48px;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.faction-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fac-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.fac-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-faction-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--accent-color);
}

.btn-faction-toggle.active {
  background: rgba(217, 70, 239, 0.08);
  border-color: var(--accent-color);
  box-shadow: 0 0 20px rgba(217, 70, 239, 0.12) inset;
}

.btn-faction-toggle.active i {
  color: var(--accent-color);
  text-shadow: 0 0 10px rgba(217, 70, 239, 0.4);
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

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

.lobby-select-wrapper {
  position: relative;
  width: 100%;
}

.lobby-select-wrapper select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  outline: none;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
}

.lobby-select-wrapper::after {
  content: '▼';
  font-size: 0.75rem;
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.difficulty-buttons {
  display: flex;
  gap: 0.75rem;
}

.btn-diff {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 0.85rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}

.btn-diff:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-diff.active {
  border-color: var(--accent-color);
  color: var(--accent-color-hover);
  background: rgba(217, 70, 239, 0.05);
}

.lobby-actions {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  border-top: 1px solid var(--panel-border);
  padding-top: 1.5rem;
}

.btn-start {
  background: linear-gradient(135deg, #d946ef 0%, #a855f7 100%);
  color: #fff;
  padding: 0.9rem 2.5rem;
  font-size: 1.05rem;
  border-radius: 50px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(217, 70, 239, 0.3);
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(217, 70, 239, 0.45);
}

/* --- In-Game Layout --- */
.game-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}

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

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-1 {
  gap: 1rem;
}

/* Turn Indicator Banner */
.turn-card {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.turn-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-color);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 70, 239, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(217, 70, 239, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 70, 239, 0); }
}

#turn-timer {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.players-dashboard {
  padding: 1.25rem 1.5rem;
}

.players-dashboard h3,
.controls-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.5rem;
  color: var(--text-muted);
}

.player-list-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hud-player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--panel-border);
  transition: var(--transition-smooth);
}

.hud-player-item.active {
  border-color: var(--accent-color);
  background: rgba(217, 70, 239, 0.05);
}

.hud-player-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.hud-player-icon {
  font-size: 1.15rem;
}

.color-hounds { color: #ffffff; }
.color-hares { color: #b1b1b7; }

.hud-player-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.hud-player-type {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.hud-player-status {
  font-size: 0.8rem;
  font-weight: 700;
}

/* Controls Card */
.controls-card {
  padding: 1.25rem 1.5rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.btn-control {
  width: 100%;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
  justify-content: flex-start;
  gap: 0.6rem;
}

.btn-control:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--accent-color);
}

.btn-control.active {
  border-color: var(--accent-color);
  background: rgba(217, 70, 239, 0.1);
  color: var(--accent-color-hover);
}

.btn-danger {
  border-color: rgba(244, 63, 94, 0.2);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: #f43f5e;
  color: #f43f5e;
}

.ai-speed-controller {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ai-speed-controller input[type="range"] {
  accent-color: var(--accent-color);
  width: 100%;
  cursor: pointer;
}

/* --- Center 3D Board Panel --- */
.board-3d-scene-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  min-height: 620px;
}

.scene-instructions {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 10;
  pointer-events: none;
}

/* 3D Scene Viewport */
.scene-3d {
  perspective: 1200px;
  width: 100%;
  height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

.scene-3d:active {
  cursor: grabbing;
}

.board-3d-wrapper {
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out;
}

/* The actual 3D Limestone Roman Slab */
.board-3d {
  position: relative;
  width: 500px;
  height: 300px;
  background: #eae4d8; /* Travertine Limestone Base */
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0,0,0,0.02) 0%, transparent 60%),
    linear-gradient(135deg, rgba(255,255,255,0.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(46, 38, 33, 0.03) 0%, transparent 40%);
  border-radius: 12px;
  transform-style: preserve-3d;
  box-shadow: 
    0 30px 60px rgba(0, 0, 0, 0.7),
    inset 0 0 40px rgba(46, 38, 33, 0.08);
  border: 1px solid #c2b5a1;
}

/* Slab Sides (Rough Stone Cliff) */
.slab-side {
  position: absolute;
  background: #cbbfae;
  background-image: linear-gradient(to bottom, #cbbfae, #9c8e7e);
  transform-style: preserve-3d;
  border: 1px solid rgba(0,0,0,0.2);
}

.slab-front {
  bottom: 0;
  left: 0;
  width: 500px;
  height: 32px;
  transform: rotateX(-90deg);
  transform-origin: bottom;
}

.slab-back {
  top: 0;
  left: 0;
  width: 500px;
  height: 32px;
  transform: rotateX(90deg);
  transform-origin: top;
}

.slab-left {
  top: 0;
  left: 0;
  width: 32px;
  height: 300px;
  transform: rotateY(-90deg);
  transform-origin: left;
}

.slab-right {
  top: 0;
  right: 0;
  width: 32px;
  height: 300px;
  transform: rotateY(90deg);
  transform-origin: right;
}

.slab-bottom {
  width: 500px;
  height: 300px;
  background: #736757;
  transform: translateZ(-32px);
}

/* Carved lines inside the stone slab */
.board-svg-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: translateZ(1px); /* Lay flat on slab surface */
  filter: drop-shadow(0 1.5px 1px rgba(255, 255, 255, 0.8));
}

.board-svg-lines line {
  stroke: #423830; /* Dark etched groove color */
  stroke-width: 4px;
  stroke-linecap: round;
}

/* Board Nodes/Vertices (Carved Small Cups) */
.board-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: translateZ(2px);
}

.board-node {
  position: absolute;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  background: #2e2621; /* Carved cup background */
  border: 2px solid #a39589;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.8);
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
  transform-style: preserve-3d;
}

.board-node:hover {
  transform: scale(1.1) translateZ(1px);
  border-color: #d946ef;
}

.board-node.valid-target {
  background: rgba(16, 185, 129, 0.3);
  border-color: #10b981;
  box-shadow: 
    0 0 10px rgba(16, 185, 129, 0.5),
    inset 0 3px 6px rgba(0, 0, 0, 0.5);
  animation: pulse-node 1.5s infinite alternate;
}

@keyframes pulse-node {
  0% { border-color: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4), inset 0 3px 6px rgba(0,0,0,0.5); }
  100% { border-color: #34d399; box-shadow: 0 0 18px rgba(16, 185, 129, 0.8), inset 0 3px 6px rgba(0,0,0,0.3); }
}

/* 3D Pieces ( 조약돌 Pebble Pieces ) Container */
.board-pieces {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  pointer-events: none;
}

.pebble-3d {
  position: absolute;
  transform-style: preserve-3d;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  margin-top: -16px;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  cursor: pointer;
  pointer-events: auto; /* Allow click on piece */
}

/* Active floating highlight for selected piece */
.pebble-3d.selected {
  animation: float-selected 1.5s ease-in-out infinite alternate;
}

@keyframes float-selected {
  0% { transform: translateY(0) translateZ(0); }
  100% { transform: translateY(-4px) translateZ(8px); }
}

/* 3D layered segment rendering for 조약돌 shape */
.pebble-slice {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  background: currentColor;
  transform-style: preserve-3d;
  pointer-events: none;
  border: 0.5px solid rgba(255, 255, 255, 0.15); /* Specular highlight rim */
}

.pebble-slice-base {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.pebble-slice-top {
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Glow ring under selected pebble */
.pebble-ring {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid currentColor;
  margin-left: -6px;
  margin-top: -6px;
  transform: translateZ(1.5px);
  opacity: 0;
  filter: blur(2px);
  box-shadow: 0 0 12px currentColor;
  transition: opacity 0.3s;
}

.pebble-3d.selected .pebble-ring {
  opacity: 0.95;
  animation: breathe-ring 2s ease-in-out infinite alternate;
}

@keyframes breathe-ring {
  0% { transform: translateZ(1.5px) scale(0.95); opacity: 0.6; }
  100% { transform: translateZ(1.5px) scale(1.05); opacity: 0.95; }
}

/* Faction Specific Styles mapping */
.faction-hound-piece {
  color: #ffffff; /* White Spy */
}
.faction-hound-piece .pebble-slice {
  border-color: rgba(255, 255, 255, 0.25);
}

.faction-hare-piece {
  color: #18181b; /* Black Spy */
}
.faction-hare-piece .pebble-slice {
  border-color: rgba(255, 255, 255, 0.08);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 9, 19, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.rules-card {
  padding: 2.25rem 2rem;
  width: 90%;
  max-width: 600px;
  border: 1px solid var(--panel-border);
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.winner-card {
  padding: 2.5rem;
  width: 90%;
  max-width: 450px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.modal-header i {
  color: var(--accent-color);
}

.modal-body {
  overflow-y: auto;
  flex-grow: 1;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  line-height: 1.6;
}

.modal-body h4 {
  color: var(--text-main);
  font-weight: 700;
  margin-top: 0.5rem;
}

.modal-body ul, .modal-body ol {
  padding-left: 1.25rem;
}

.modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

.winner-icon {
  width: 64px;
  height: 64px;
  background: rgba(217, 70, 239, 0.1);
  border: 1px solid rgba(217, 70, 239, 0.2);
  color: var(--accent-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: 0 0 20px rgba(217, 70, 239, 0.2);
}

.winner-title {
  font-size: 1.45rem;
  font-weight: 800;
}

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

.winner-actions {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.winner-actions button {
  flex: 1;
}

.main-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
  margin-top: auto;
}
