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

:root {
  --bg-deep: #0d0d1a;
  --bg-main: #1a1a2e;
  --bg-panel: #16213e;
  --grid-line: #0f3460;
  --grid-line-thick: #1a5276;
  --fill-color: #e94560;
  --fill-hover: #ff6b81;
  --mark-color: #4a6fa5;
  --text-primary: #e0e0e0;
  --text-dim: #6a7b8b;
  --text-accent: #e94560;
  --success: #2ecc71;
  --warning: #f39c12;
  --level2-fill: #00d2ff;
  --level3-fill: #f9ca24;
  --cell-empty: #0f1729;
  --cell-hover-row: rgba(233, 69, 96, 0.08);
  --cell-hover-col: rgba(233, 69, 96, 0.08);
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-main);
  border-bottom: 2px solid var(--grid-line);
  flex-shrink: 0;
  min-height: 50px;
}

#game-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: var(--text-accent);
  text-shadow: 0 0 10px rgba(233, 69, 96, 0.5);
  letter-spacing: 1px;
}

#breadcrumb {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: 'Press Start 2P', monospace;
}

#breadcrumb span {
  cursor: pointer;
  transition: color 0.2s;
}

#breadcrumb span:hover {
  color: var(--text-accent);
}

#breadcrumb .active {
  color: var(--fill-color);
  text-shadow: 0 0 6px rgba(233, 69, 96, 0.4);
}

#stats-area {
  display: flex;
  gap: 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
}

#timer { color: var(--success); }
#mistakes { color: var(--warning); }
#hints-left { color: var(--level2-fill); }

#main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: 180px;
  background: var(--bg-main);
  border-right: 2px solid var(--grid-line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

#puzzle-info, #progress-info {
  font-size: 11px;
  color: var(--text-dim);
  padding: 8px;
  background: var(--bg-panel);
  border-radius: 4px;
  line-height: 1.6;
}

#puzzle-info strong, #progress-info strong {
  color: var(--text-primary);
}

.sidebar-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 10px 12px;
  border: 2px solid var(--grid-line);
  background: var(--bg-panel);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  text-align: center;
}

.sidebar-btn:hover {
  background: var(--grid-line);
  border-color: var(--fill-color);
}

.sidebar-btn.danger {
  border-color: #c0392b;
}

.sidebar-btn.danger:hover {
  background: #c0392b;
}

#puzzle-select {
  margin-top: auto;
}

#puzzle-select label {
  font-size: 10px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}

#puzzle-set-select {
  width: 100%;
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 2px solid var(--grid-line);
  padding: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  border-radius: 4px;
}

#canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#canvas {
  cursor: crosshair;
  image-rendering: pixelated;
}

#toolbar {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-main);
  border-top: 2px solid var(--grid-line);
  flex-shrink: 0;
}

.tool-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border: 2px solid var(--grid-line);
  background: var(--bg-panel);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

.tool-btn:hover {
  border-color: var(--fill-color);
}

.tool-btn.active-fill {
  border-color: var(--fill-color);
  box-shadow: 0 0 8px rgba(233, 69, 96, 0.4);
}

.tool-btn.active-mark {
  border-color: var(--mark-color);
  box-shadow: 0 0 8px rgba(74, 111, 165, 0.4);
}

#footer {
  text-align: center;
  padding: 4px;
  background: var(--bg-deep);
  flex-shrink: 0;
}

#footer a {
  color: var(--text-dim);
  font-size: 10px;
  text-decoration: none;
}

#footer a:hover {
  color: var(--text-accent);
}

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

#victory-overlay, #confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
}

#victory-content, #confirm-content {
  background: var(--bg-main);
  border: 3px solid var(--fill-color);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  max-width: 420px;
  z-index: 1001;
}

#victory-content h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: var(--fill-color);
  margin-bottom: 16px;
  line-height: 1.6;
}

#victory-stats {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.8;
}

#confirm-content p {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  margin-bottom: 16px;
}

#confirm-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1002;
}

/* Mobile */
@media (max-width: 768px) {
  #sidebar { display: none; }
  
  #game-title { font-size: 10px; }
  #stats-area { font-size: 8px; gap: 8px; }
  #breadcrumb { font-size: 8px; }
  
  .tool-btn { font-size: 10px; padding: 6px 10px; }
  
  #header { padding: 6px 10px; }
}