/* Hidato Specific Styles - Aligned with Puzzle Common */
:root {
  --grid-border: var(--border-color);
  --cell-bg: var(--panel-bg);
  --cell-border: var(--border-color);
  --highlight-bg: var(--bg-secondary);
  --selected-bg: #dbeafe;
  /* Light blue */
  --path-color: #10b981;
  /* Emerald */
  --circled-bg: #f59e0b;
  /* Amber */
  --valid-move-bg: #dcfce7;
  --invalid-move-bg: #fee2e2;
  --error-color: #ef4444;
}

[data-theme='dark'] {
  --selected-bg: #1e3a8a;
  --path-color: #34d399;
  --circled-bg: #b45309;
  --valid-move-bg: #064e3b;
  --invalid-move-bg: #7f1d1d;
}

/* Board Area */
.board-wrap {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1;
  position: relative;
  margin: 0 auto;
}

.hidato-grid {
  display: grid;
  /* grid-template-columns set by JS */
  gap: 2px;
  background-color: var(--grid-border);
  border: 2px solid var(--grid-border);
  padding: 2px;
  border-radius: var(--border-radius-md);
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidato-cell {
  background-color: var(--cell-bg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 24px;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.1s;
  aspect-ratio: 1;
}

.hidato-cell:hover {
  background-color: var(--highlight-bg);
}

.hidato-cell.selected {
  background-color: var(--selected-bg);
  border: 2px solid var(--game-accent);
  z-index: 10;
}

.hidato-cell.valid-move {
  background-color: var(--valid-move-bg);
}

.hidato-cell.invalid-move {
  background-color: var(--invalid-move-bg);
  animation: shake 0.3s;
}

/* Start/End Circles */
.hidato-cell.circled {
  background-color: var(--circled-bg);
  color: #fff;
  border-radius: 50%;
  transform: scale(0.85);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hidato-cell.fixed {
  font-weight: 800;
  color: var(--text-primary);
}

.hidato-cell.new-number {
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* SVG Path Overlay */
.path-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.path-line {
  stroke: var(--path-color);
  stroke-width: 4px;
  stroke-linecap: round;
  opacity: 0.6;
}

/* Mode Selector */
.mode-selector {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.mode-selector select {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  width: 100%;
  cursor: pointer;
  text-align-last: center;
  /* iOS Fix */
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 3000;
  white-space: nowrap;
}

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

/* Animations */
@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

@keyframes popIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Mobile Optimizations (< 600px) */
@media (max-width: 600px) {
  .hidato-cell {
    font-size: 18px;
  }

  .hidato-cell.circled {
    font-size: 16px;
  }

  .stats-bar {
    gap: 2px;
  }

  .stat-card {
    padding: 4px 2px;
  }

  .stat-label {
    font-size: 8px;
  }

  .stat-value {
    font-size: 13px;
  }

  .stat-value svg {
    width: 14px;
    height: 14px;
  }

  .action-btn {
    padding: 6px 2px;
  }

  .action-label {
    font-size: 8px;
  }

  .action-btn svg {
    width: 18px;
    height: 18px;
  }

  .action-btn.active {
    background-color: var(--text-primary);
    color: var(--bg-primary);
  }

  .action-btn.active svg {
    stroke-width: 3px;
  }

  .game-title {
    font-size: 18px;
  }

  .mode-selector select {
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .hidato-cell {
    font-size: 14px;
  }

  .path-line {
    stroke-width: 2px;
  }
}