/* ==========================================================================
   NEON FLOW — Styles
   Cyberpunk/neon aesthetic Flow Free style game
   ========================================================================== */

:root {
  /* Core palette */
  --bg-deep: #050a12;
  --bg-base: #0d1b2a;
  --bg-panel: #112240;
  --bg-panel-hover: #173055;
  --bg-elevated: #1a2d4a;
  --fg-primary: #e8f4fd;
  --fg-secondary: #a0c4e8;
  --fg-muted: #6b8ba9;
  --accent-cyan: #00ffc8;
  --accent-cyan-dim: #00cc9f;
  --accent-blue: #00b4ff;
  --accent-purple: #b873ff;
  --accent-orange: #ff9f1c;
  --accent-pink: #ff4d94;
  --accent-red: #ff3860;
  --accent-green: #2ecc71;
  --border-subtle: #1e3a5f;
  --border-bright: #00ffc8;
  --glow-cyan: rgba(0, 255, 200, 0.6);
  --glow-blue: rgba(0, 180, 255, 0.5);
  --glow-purple: rgba(184, 115, 255, 0.5);
  --shadow-soft: rgba(0, 0, 0, 0.3);
  --shadow-hard: rgba(0, 0, 0, 0.6);

  /* Node colors (8 distinct colors for up to 8 pairs) */
  --node-1: #00ffc8;  /* Cyan */
  --node-2: #ff4d94;  /* Hot pink */
  --node-3: #ff9f1c;  /* Orange */
  --node-4: #00b4ff;  /* Electric blue */
  --node-5: #b873ff;  /* Purple */
  --node-6: #2ecc71;  /* Green */
  --node-7: #ff3860;  /* Red */
  --node-8: #fff038;  /* Yellow */

  /* Node glows */
  --glow-1: rgba(0, 255, 200, 0.7);
  --glow-2: rgba(255, 77, 148, 0.7);
  --glow-3: rgba(255, 159, 28, 0.7);
  --glow-4: rgba(0, 180, 255, 0.7);
  --glow-5: rgba(184, 115, 255, 0.7);
  --glow-6: rgba(46, 204, 113, 0.7);
  --glow-7: rgba(255, 56, 96, 0.7);
  --glow-8: rgba(255, 240, 56, 0.7);

  /* Typography */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Monaco', 'Consolas', monospace;
  --font-ui: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Sizing */
  --header-h: 64px;
  --gap: 16px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 350ms ease;

  /* Board */
  --cell-size: clamp(36px, 6vw, 56px);
  --cell-gap: 2px;
  --board-max: 90vw;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-base: 0ms;
    --transition-slow: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg-primary);
  background: var(--bg-deep);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

kbd {
  font-family: var(--font-mono);
  font-size: 0.75em;
  padding: 0.15em 0.4em;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--accent-cyan);
  white-space: nowrap;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img, svg { display: block; max-width: 100%; }

/* ==========================================================================
   Background Effects
   ========================================================================== */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 255, 200, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 200, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(0, 255, 200, 0.08), transparent),
    radial-gradient(ellipse 50% 60% at 80% 80%, rgba(184, 115, 255, 0.06), transparent),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(0, 180, 255, 0.04), transparent);
  pointer-events: none;
  z-index: 1;
}

.app-shell {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--gap);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ==========================================================================
   Header
   ========================================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 var(--gap);
  background: linear-gradient(180deg, rgba(17, 34, 64, 0.9), rgba(17, 34, 64, 0.3));
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  margin-bottom: var(--gap);
  position: relative;
  overflow: hidden;
}

.topbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  opacity: 0.5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark svg { width: 40px; height: 40px; }

.brand-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, var(--fg-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-name span { color: var(--accent-cyan); -webkit-text-fill-color: var(--accent-cyan); }

.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-button, .quiet-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--fg-secondary);
  transition: all var(--transition-fast);
}

.icon-button { padding: 10px; }

.icon-button svg, .quiet-button svg { width: 20px; height: 20px; }

.icon-button:hover, .quiet-button:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.icon-button:focus-visible, .quiet-button:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.icon-button[aria-pressed="true"] .sound-on-icon { display: none; }
.icon-button:not([aria-pressed="true"]) .sound-off-icon { display: none; }

.quiet-button span { font-size: 0.875rem; font-weight: 500; }

@media (max-width: 520px) {
  .quiet-button span { display: none; }
  .quiet-button { padding: 10px; }
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  text-align: center;
  padding: calc(var(--gap) * 2) var(--gap);
  margin-bottom: var(--gap);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-cyan);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.eyebrow span { animation: pulse 2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero h1 em {
  font-style: normal;
  font-family: var(--font-mono);
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% auto;
  animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero-progress {
  max-width: 400px;
  margin: 0 auto;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 8px;
  color: var(--fg-secondary);
}

.progress-copy strong { color: var(--accent-cyan); font-family: var(--font-mono); }

.progress-track {
  height: 6px;
  background: var(--bg-panel);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 2px;
  transition: width var(--transition-slow);
  box-shadow: 0 0 12px var(--glow-cyan);
}

/* ==========================================================================
   Layout
   ========================================================================== */
.game-layout {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  height: fit-content;
  max-height: 100%;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.panel-heading > div { min-width: 0; }

.panel-kicker {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-cyan);
  margin: 0 0 4px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

.count-badge, .guide-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.guide-icon svg { width: 20px; height: 20px; stroke: currentColor; }

/* Level List */
.level-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.level-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.level-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent-cyan);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--transition-base);
}

.level-item:hover,
.level-item:focus-visible {
  border-color: var(--accent-cyan);
  background: var(--bg-panel-hover);
}

.level-item:hover::before,
.level-item:focus-visible::before,
.level-item.active::before {
  transform: scaleY(1);
}

.level-item.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 255, 200, 0.1);
}

.level-item.completed .level-num::after {
  content: '✓';
  margin-left: 6px;
  color: var(--accent-cyan);
  font-size: 0.75em;
}

.level-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.level-item.active .level-num,
.level-item.completed .level-num {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.level-info { flex: 1; min-width: 0; }

.level-name {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--fg-muted);
  margin-top: 2px;
}

.level-item.active .level-meta { color: var(--accent-cyan); }

.level-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--fg-secondary);
  line-height: 1.5;
}

.tip-node {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--glow-cyan);
  flex-shrink: 0;
  margin-top: 3px;
  animation: node-pulse 1.5s ease-in-out infinite;
}

@keyframes node-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; }
}

.tip-sprout { display: none; }

/* Buttons */
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: var(--bg-deep);
  border: none;
  box-shadow: 0 4px 20px var(--glow-cyan);
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px var(--glow-cyan);
}

.primary-button:active { transform: translateY(0); }

.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.primary-button svg { width: 18px; height: 18px; }

.secondary-button {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--fg-secondary);
}

.secondary-button:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.secondary-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.secondary-button svg { width: 18px; height: 18px; }

#endless-button { width: 100%; margin-top: 8px; }

/* ==========================================================================
   Board Area
   ========================================================================== */
.board-area { display: flex; flex-direction: column; min-height: 0; }

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--gap);
  flex-wrap: wrap;
}

.level-heading { display: flex; flex-direction: column; gap: 2px; }

#level-kicker { margin: 0; }

#level-title { margin: 0; font-size: 1.25rem; font-weight: 600; }

.metrics {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-width: 80px;
  text-align: center;
}

.metric span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.metric strong {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.metric-time strong { font-variant-numeric: tabular-nums; }

/* Board Frame */
.board-frame {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.board-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent-cyan);
  opacity: 0.4;
  transition: opacity var(--transition-base);
}

.board-frame:hover .board-corner { opacity: 0.8; }

.corner-tl { top: -12px; left: -12px; border-right: none; border-bottom: none; border-radius: var(--radius-lg) 0 0 0; }
.corner-tr { top: -12px; right: -12px; border-left: none; border-bottom: none; border-radius: 0 var(--radius-lg) 0 0; }
.corner-bl { bottom: -12px; left: -12px; border-right: none; border-top: none; border-radius: 0 0 0 var(--radius-lg); }
.corner-br { bottom: -12px; right: -12px; border-left: none; border-top: none; border-radius: 0 0 var(--radius-lg) 0; }

.board {
  display: grid;
  gap: var(--cell-gap);
  grid-template-columns: repeat(var(--grid-size, 5), var(--cell-size));
  grid-template-rows: repeat(var(--grid-size, 5), var(--cell-size));
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: var(--cell-gap);
  border: 1px solid var(--border-subtle);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.5),
    0 0 60px -20px var(--glow-cyan);
  position: relative;
}

.board::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue), var(--accent-purple));
  border-radius: var(--radius-md);
  z-index: -1;
  opacity: 0;
  filter: blur(8px);
  transition: opacity var(--transition-base);
}

.board:focus-within::before { opacity: 0.3; }

.cell {
  position: relative;
  background: var(--bg-panel);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.cell::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 255, 200, 0.05), transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.cell:hover::before,
.cell.active::before { opacity: 1; }

.cell.path { cursor: default; }

.cell.node {
  cursor: pointer;
  z-index: 2;
}

.cell.node::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 6px;
  border: 2px solid currentColor;
  animation: node-ring 2s ease-out infinite;
  pointer-events: none;
}

@keyframes node-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

.node-marker {
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    0 0 12px currentColor,
    0 0 24px currentColor,
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
  transition: transform var(--transition-fast);
}

.cell.node:hover .node-marker,
.cell.node:focus .node-marker { transform: scale(1.1); }

.cell.path-segment {
  background: currentColor !important;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4), 0 0 8px currentColor;
}

.cell.path-end {
  background: currentColor !important;
}

.cell.path-end::after {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 8px currentColor;
}

.cell.current-head {
  box-shadow: 0 0 0 2px var(--accent-cyan), 0 0 16px var(--glow-cyan);
  animation: head-pulse 1s ease-in-out infinite;
}

@keyframes head-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-cyan), 0 0 16px var(--glow-cyan); }
  50% { box-shadow: 0 0 0 4px var(--accent-cyan), 0 0 24px var(--glow-cyan); }
}

.cell.hint-highlight {
  animation: hint-flash 1s ease-in-out 3;
  z-index: 10;
}

@keyframes hint-flash {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-orange); }
  50% { box-shadow: 0 0 0 6px rgba(255, 159, 28, 0.4); }
}

.path-layer {
  position: absolute;
  inset: var(--cell-gap);
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

.path-svg {
  width: 100%;
  height: 100%;
}

/* Win/Perfect Overlays */
.win-overlay, .perfect-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 10, 18, 0.95);
  backdrop-filter: blur(10px);
  z-index: 20;
  animation: overlay-in 0.3s ease-out;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.win-card, .perfect-card {
  background: var(--bg-panel);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 400px;
  text-align: center;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px var(--glow-cyan);
  animation: card-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.win-symbol, .perfect-symbol {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.perfect-symbol {
  font-size: 48px;
  animation: spark 1s ease-in-out infinite;
}

@keyframes spark {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(5deg); }
}

.win-card .panel-kicker { margin: 0 0 8px; color: var(--accent-green); }
.perfect-card .panel-kicker { margin: 0 0 8px; color: var(--accent-orange); }

.win-card h3, .perfect-card h3 { margin: 0 0 16px; font-size: 1.5rem; }

.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.stat-item { display: flex; flex-direction: column; gap: 4px; }

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.win-actions, .perfect-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.win-summary { margin: 16px 0; color: var(--fg-secondary); }
.win-summary strong { color: var(--accent-cyan); }

.perfect-text { margin: 16px 0; color: var(--fg-secondary); font-size: 0.9rem; }

/* Board Controls */
.board-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin-top: var(--gap);
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.control-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.keyboard-hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.keyboard-hint span { color: var(--border-subtle); }

@media (max-width: 600px) {
  .board-controls { flex-direction: column; align-items: stretch; }
  .control-buttons { justify-content: center; }
  .keyboard-hint { text-align: center; white-space: normal; }
}

/* ==========================================================================
   Guide Panel
   ========================================================================== */
.guide-panel { overflow-y: auto; }

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.steps li { display: flex; gap: 12px; }

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: var(--bg-deep);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.steps li div { flex: 1; }

.steps strong { display: block; margin-bottom: 4px; font-size: 0.875rem; }
.steps p { margin: 0; font-size: 0.8rem; color: var(--fg-secondary); line-height: 1.5; }

.scoring {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.scoring h3 { margin: 0 0 12px; font-size: 0.875rem; font-weight: 600; color: var(--accent-cyan); }

.score-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.score-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.score-list li span { color: var(--fg-secondary); }
.score-list li strong { color: var(--fg-primary); font-family: var(--font-mono); }

.keyboard-card {
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.keyboard-card p { margin: 0 0 12px; font-size: 0.875rem; font-weight: 600; color: var(--accent-cyan); }

.keyboard-card > div {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.keyboard-card > div:last-child { border-bottom: none; }

.keyboard-card kbd { font-size: 0.65em; }
.keyboard-card span { color: var(--fg-secondary); }

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap);
  margin-top: var(--gap);
  font-size: 0.8rem;
  color: var(--fg-muted);
  border-top: 1px solid var(--border-subtle);
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.footer-status i {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--fg-secondary);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: all var(--transition-base);
  z-index: 100;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { border-color: var(--accent-green); color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); color: var(--accent-red); }
.toast.info { border-color: var(--accent-cyan); color: var(--accent-cyan); }

/* ==========================================================================
   Help Dialog
   ========================================================================== */
dialog {
  background: var(--bg-panel);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: 520px;
  width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px var(--glow-cyan);
  color: var(--fg-primary);
}

dialog::backdrop {
  background: rgba(5, 10, 18, 0.85);
  backdrop-filter: blur(4px);
}

dialog[open] { animation: dialog-in 0.3s ease-out; }

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.help-dialog {
  padding: 32px;
  overflow-y: auto;
  max-height: 85vh;
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  font-size: 1.25rem;
  color: var(--fg-muted);
  transition: all var(--transition-fast);
}

.dialog-close:hover {
  background: var(--bg-panel-hover);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.help-dialog .panel-kicker { margin: 0 0 8px; }
.help-dialog h2 { margin: 0 0 12px; font-size: 1.5rem; }
.help-dialog > p { margin: 0 0 24px; color: var(--fg-secondary); }

.help-dialog h3 { margin: 24px 0 12px; font-size: 1rem; color: var(--accent-cyan); }

.help-dialog ul { margin: 0 0 16px; padding-left: 20px; line-height: 1.8; }
.help-dialog li { margin-bottom: 8px; color: var(--fg-secondary); }
.help-dialog li strong { color: var(--fg-primary); }
.help-dialog kbd { font-size: 0.7em; }

.help-tip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin: 24px 0 0;
  font-size: 0.875rem;
  color: var(--fg-secondary);
}

.help-tip strong { color: var(--accent-orange); }

#start-playing-button { width: 100%; margin-top: 24px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .game-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .level-panel { order: 2; }
  .board-area { order: 1; }
  .guide-panel { order: 3; display: none; }
  .guide-panel.visible { display: flex; }
  .hero { order: 0; }
}

@media (max-width: 768px) {
  :root { --header-h: 56px; --gap: 12px; --cell-size: clamp(32px, 8vw, 48px); }

  .app-shell { padding: 12px; }

  .brand-name { font-size: 1rem; }

  .metrics { gap: 8px; width: 100%; }
  .metric { flex: 1; min-width: 0; padding: 6px 8px; }
  .metric strong { font-size: 1rem; }

  .board-header { padding: 10px 12px; }

  .win-card, .perfect-card { padding: 24px; margin: 16px; }

  .win-stats { grid-template-columns: 1fr; gap: 8px; }
}

/* ==========================================================================
   Hidden attribute fix
   ========================================================================== */
[hidden] {
  display: none !important;
}

/* ==========================================================================
   Focus Visible
   ========================================================================== */
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }