:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --found-bg: #dcfce7;
  --found-color: #166534;
  --solution-bg: #fef08a;
  --solution-color: #854d0e;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 2rem 1rem;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 2rem;
}

.app-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.025em;
}

.app-header p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-top: 0.25rem;
}

/* Layout */
.main-content {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 2rem;
  align-items: start;
}

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

/* Control Panel */
.control-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.label-hint {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea {
  resize: vertical;
  min-height: 160px;
}

/* Range Slider */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.slider-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-secondary.active {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde047;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: #f1f5f9;
}

/* Worksheet Panel */
.worksheet-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.worksheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
}

.worksheet-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.action-bar {
  display: flex;
  gap: 0.75rem;
}

.action-bar .btn {
  width: auto;
}

/* Grid Layout */
.grid-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 2.5rem;
  user-select: none;
}

.word-search-grid {
  display: grid;
  gap: 4px;
  background: #f1f5f9;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.cell {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.1rem;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.cell:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.cell.selecting {
  background: var(--primary);
  color: white;
}

.cell.found {
  background: var(--found-bg);
  color: var(--found-color);
}

.cell.solution {
  background: var(--solution-bg);
  color: var(--solution-color);
}

/* Clues List */
.clues-container {
  margin-top: 1.5rem;
}

.clues-heading {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

.clues-list {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.clues-list li {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #334155;
}

.clues-list li.found-word {
  text-decoration: line-through;
  opacity: 0.6;
}

.word-blank {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: var(--primary);
  padding: 0 0.2rem;
}

/* Print Styles */
@media print {
  body {
    background: white;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .main-content {
    display: block;
  }

  .worksheet-panel {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .worksheet-header {
    border-bottom: 2px solid #000;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
  }

  .worksheet-title {
    font-size: 2rem;
    color: #000;
  }

  .grid-wrapper {
    margin-bottom: 2rem;
  }

  .word-search-grid {
    background: transparent;
    border: none;
    gap: 2px;
    padding: 0;
  }

  .cell {
    border: 1px solid #cbd5e1;
    box-shadow: none;
    color: #000 !important;
    background: transparent !important;
  }

  .word-blank {
    color: #000;
  }

  .clues-list li {
    font-size: 1rem;
    color: #000;
  }
}