/* --- VARIABLES & MINIMALIST THEME --- */
:root {
  /* Core Palette - Dark & Clean */
  --bg-app: #0f172a;
  --bg-panel: #1e293b;
  --bg-card: #334155;

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Accents */
  --accent-primary: #3b82f6;
  /* Blue */
  --accent-success: #10b981;
  /* Green */
  --accent-warning: #f59e0b;
  /* Amber */
  --accent-danger: #ef4444;
  /* Red */
  --accent-gold: #fbbf24;

  /* Dimensions */
  --cell-size: 80px;
  --gap: 12px;
  --radius: 12px;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --trans-fast: 0.15s ease;
}

/* --- RESET & BASE --- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Background Layers */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.4;
  /* Subtle backdrop */
}

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.03;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
}

/* Garland (Christmas Lights) */
.garland-layer {
  position: absolute;
  top: -20px;
  left: 0;
  width: 100%;
  height: 120px;
  z-index: 0;
  /* Behind Header Content */
  pointer-events: none;
  opacity: 0.8;
}

/* --- APP LAYOUT --- */
.app-container {
  width: 100%;
  max-width: 1280px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  z-index: 1;
}

/* --- HEADER --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  background: rgba(30, 41, 59, 0.5);
  /* Subtle backing */
  backdrop-filter: blur(10px);
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.header-content h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* BUTTONS */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: var(--trans-fast);
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* --- MAIN GRID --- */
.app-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  /* Responsive: Board takes leftover, Sidebar fixed */
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  /* Stack on mobile */
  .app-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .header-actions {
    justify-content: center;
  }
}

/* --- BOARD --- */
.game-board {
  display: grid;
  grid-template-columns: repeat(6, var(--cell-size));
  gap: var(--gap);
  padding: 1.5rem;
  background: var(--bg-panel);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  position: relative;
  cursor: pointer;
  perspective: 1000px;
}

.tile {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #334155;
  /* Default Closed */
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cell:hover .tile {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.icon-img {
  width: 60%;
  height: 60%;
  opacity: 0.3;
  transition: 0.3s;
}

/* STATES */
/* 1. CLOSED: Default style above */

/* PROBABILITY LABEL */
.prob-label {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fbbf24;
  /* Gold text */
  background: rgba(15, 23, 42, 0.8);
  /* Dark background for contrast */
  padding: 2px 4px;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
  border: 1px solid rgba(251, 191, 36, 0.3);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* 2. OPEN (Safe) */
.cell.open .tile {
  background: #1e293b;
  border: 2px dashed var(--text-secondary);
}

.cell.open .icon-img {
  opacity: 0.6;
}

/* 3. CLUE (Yellow) */
.cell.hint-yellow .tile {
  border-color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
}

.cell.hint-yellow .icon-img {
  opacity: 0.9;
}

/* 4. GOAL (Snowman) */
.cell.goal .tile {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.1));
  border: 2px solid var(--accent-gold);
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.2);
}

.cell.goal .icon-img {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}

/* 5. RECOMMENDATION */
.cell.reco .tile {
  box-shadow: 0 0 0 3px var(--accent-success);
  z-index: 10;
}

.cell.reco::after {
  content: "★";
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent-success);
  color: #0f172a;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
}

/* --- SIDEBAR --- */
.app-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* RESULT CARD */
.result-card {
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 1.5rem;
  border-left: 4px solid var(--accent-success);
}

.result-card.hidden {
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--accent-success);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.result-main {
  margin-bottom: 0.5rem;
}

.res-coord {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.res-prob {
  font-size: 1rem;
  color: var(--text-secondary);
}

.result-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

/* LEGEND */
.legend-panel {
  background: var(--bg-panel);
  padding: 1.5rem;
  border-radius: 12px;
}

.legend-panel h3 {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.legend-list em {
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-left: auto;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
}

.dot-gray {
  border: 2px dashed var(--text-secondary);
  background: transparent;
}

.dot-yellow-dashed {
  border: 2px dashed var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
}

.dot-gold {
  border: 2px solid var(--accent-gold);
  background: var(--accent-gold);
}

.dot-closed {
  background: #334155;
}

.dot-reco {
  background: var(--accent-success);
  color: #0f172a;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* TIPS */
.tips-panel {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 8px;
}

/* CHRISTMAS GARLAND STYLES (Restored) */
.garland-wire {
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 2;
  fill: none;
}

.garland-drop {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
}

.garland-bulb {
  opacity: 0.8;
  transition: 0.5s;
}

.c-red {
  fill: #f87171;
  filter: drop-shadow(0 0 4px #ef4444);
}

.c-green {
  fill: #4ade80;
  filter: drop-shadow(0 0 4px #22c55e);
}

.c-blue {
  fill: #60a5fa;
  filter: drop-shadow(0 0 4px #3b82f6);
}

.c-gold {
  fill: #facc15;
  filter: drop-shadow(0 0 4px #eab308);
}

.c-purple {
  fill: #c084fc;
  filter: drop-shadow(0 0 4px #a855f7);
}

@keyframes twinkle {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.garland-bulb.odd {
  animation: twinkle 3s ease-in-out infinite alternate;
}

.garland-bulb.even {
  animation: twinkle 3s ease-in-out infinite 1.5s alternate;
}