/* =========================================================================
   style.css — Dark Mode (#0f172a), 3D isometric cube, 2D grids, animations.
   ========================================================================= */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(100, 116, 139, 0.2);
  backdrop-filter: blur(10px);
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f43f5e, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header .subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
}

.header-buttons {
  display: flex;
  gap: 10px;
}

/* --- Buttons --- */
.btn {
  padding: 8px 18px;
  border: 1px solid rgba(100, 116, 139, 0.3);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
}

.btn-primary {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  background: rgba(59, 130, 246, 0.3);
}

.btn-lang {
  font-size: 0.8rem;
  min-width: 50px;
}

/* --- Main Layout --- */
.main {
  display: flex;
  gap: 24px;
  padding: 24px;
  height: calc(100vh - 80px);
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

/* --- 3D Cube Panel --- */
.cube-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 400px;
}

.rotate-hint {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 8px;
}

/* --- 3D Scene --- */
.scene {
  perspective: 1000px;
  width: 400px;
  height: 400px;
}

.cube-wrapper {
  width: 100%;
  height: 100%;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cube-scene {
  position: relative;
  width: 240px;
  height: 240px;
  transform-style: preserve-3d;
  transform: rotateX(60deg) rotateZ(45deg);
  transition: transform 0.05s linear;
}

.cube-scene.dragging {
  transition: none;
}

/* --- Nodes (spheres) --- */
.node {
  will-change: background, box-shadow;
}

.node.p1 {
  background: #f43f5e !important;
  box-shadow:
    0 0 8px rgba(244, 63, 94, 0.8),
    0 0 16px rgba(244, 63, 94, 0.5),
    0 0 24px rgba(244, 63, 94, 0.3);
}

.node.p2 {
  background: #3b82f6 !important;
  box-shadow:
    0 0 8px rgba(59, 130, 246, 0.8),
    0 0 16px rgba(59, 130, 246, 0.5),
    0 0 24px rgba(59, 130, 246, 0.3);
}

.node.highlighted {
  box-shadow:
    0 0 12px rgba(250, 204, 21, 1),
    0 0 24px rgba(250, 204, 21, 0.7),
    0 0 36px rgba(250, 204, 21, 0.4) !important;
  transform: scale(1.3);
  z-index: 10;
}

/* Winning pulse animation */
@keyframes winnerPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 12px currentColor, 0 0 24px currentColor;
  }
  50% {
    transform: scale(1.5);
    box-shadow: 0 0 24px currentColor, 0 0 48px currentColor, 0 0 72px currentColor;
  }
}

.node.winner-pulse {
  animation: winnerPulse 0.8s ease-in-out infinite;
}

.node.win-p1 {
  background: #22c55e !important;
  box-shadow:
    0 0 16px rgba(34, 197, 94, 1),
    0 0 32px rgba(34, 197, 94, 0.7),
    0 0 48px rgba(34, 197, 94, 0.4);
  width: 20px !important;
  height: 20px !important;
}

.node.win-p2 {
  background: #22c55e !important;
  box-shadow:
    0 0 16px rgba(34, 197, 94, 1),
    0 0 32px rgba(34, 197, 94, 0.7),
    0 0 48px rgba(34, 197, 94, 0.4);
  width: 20px !important;
  height: 20px !important;
}

/* --- Edge wireframe --- */
.edge {
  pointer-events: none;
}

/* --- Status Bar --- */
.status-bar {
  text-align: center;
  margin-top: 16px;
}

#status {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 8px;
  display: inline-block;
}

.status-p1 {
  color: #f43f5e;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.status-p2 {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-win-p1 {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  font-size: 1.3rem;
}

.status-win-p2 {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  font-size: 1.3rem;
}

.status-draw {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

#ai-time {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 6px;
  display: none;
}

/* --- 2D Control Panel --- */
.control-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 280px;
  max-width: 350px;
}

.control-panel h2 {
  font-size: 1rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* --- 2D Grids --- */
.grids-2d {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.level {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 10px;
  padding: 10px;
}

.level-label {
  font-size: 0.75rem;
  color: #64748b;
  text-align: center;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.grid-2d {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.cell-2d {
  aspect-ratio: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(100, 116, 139, 0.25);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.cell-2d:hover:not(.occupied) {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
  transform: scale(1.05);
}

.cell-2d.occupied {
  cursor: not-allowed;
}

.cell-2d.p1 {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.5);
  box-shadow: inset 0 0 12px rgba(244, 63, 94, 0.3);
}

.cell-2d.p2 {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: inset 0 0 12px rgba(59, 130, 246, 0.3);
}

/* --- Info Section --- */
.info-section {
  margin-top: 8px;
  padding: 12px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-radius: 10px;
}

.info-section h3 {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.info-section p {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.5;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main {
    flex-direction: column;
    height: auto;
    padding: 12px;
  }

  .cube-panel {
    min-width: unset;
  }

  .scene {
    width: 320px;
    height: 320px;
  }

  .control-panel {
    max-width: 100%;
  }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #0f172a;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}

/* --- Messages --- */
#messages {
  display: none;
}
