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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #0f172a;
  color: #e5e7eb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 1.5rem 2rem;
  background: linear-gradient(90deg, #1f2937, #111827);
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.app-header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.app-header p {
  color: #9ca3af;
}

.nav-links {
  display: flex;
  gap: 0.75rem;
}

.nav-link {
  font-size: 0.9rem;
  color: #9ca3af;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: #e5e7eb;
  border-color: #1f2937;
}

.nav-link.active {
  background-color: #0f172a;
  border-color: #1f2937;
  color: #e5e7eb;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.5rem 1.5rem;
}

.vocab-panel,
.crossword-panel {
  background-color: #020617;
  border-radius: 0.75rem;
  border: 1px solid #1e293b;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.vocab-panel h2,
.crossword-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.vocab-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.vocab-controls input,
.vocab-controls select {
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
  background-color: #020617;
  color: #e5e7eb;
  font-size: 0.85rem;
}

.vocab-controls input::placeholder {
  color: #6b7280;
}

.vocab-table-container {
  flex: 1;
  overflow: auto;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.vocab-table th,
.vocab-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #0f172a;
  vertical-align: top;
}

.vocab-table th {
  position: sticky;
  top: 0;
  background-color: #020617;
  z-index: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.2rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  border: 1px solid transparent;
  cursor: pointer;
}

.status-green {
  background-color: #064e3b;
  border-color: #22c55e;
  color: #bbf7d0;
}

.status-yellow {
  background-color: #78350f;
  border-color: #facc15;
  color: #fef3c7;
}

.status-red {
  background-color: #7f1d1d;
  border-color: #ef4444;
  color: #fecaca;
}

.crossword-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.crossword-header-left {
  display: flex;
  flex-direction: column;
}

.puzzle-controls {
  display: flex;
  gap: 0.4rem;
}

.puzzle-select {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #1f2937;
  background-color: #020617;
  color: #e5e7eb;
  font-size: 0.8rem;
}

.mode-button,
.primary-button {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #1f2937;
  background-color: #020617;
  color: #e5e7eb;
  font-size: 0.8rem;
  cursor: pointer;
}

.mode-button.active {
  background-color: #075985;
  border-color: #38bdf8;
}

.primary-button {
  background-color: #16a34a;
  border-color: #22c55e;
  color: #ecfdf5;
}

.primary-button:hover {
  background-color: #15803d;
}

.crossword-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

.crossword-grid-container {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  background-color: #020617;
  border-radius: 0.5rem;
  border: 1px solid #1e293b;
  padding: 0.75rem 1rem;
  overflow: auto;
}

.crossword-grid {
  display: grid;
  gap: 2px;
}

.grid-cell {
  position: relative;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #020617;
  border: 1px solid #1f2937;
}

.grid-cell.empty {
  background-color: #020617;
  border-color: #020617;
}

.cell-label {
  position: absolute;
  top: 0.5px;
  left: 1px;
  font-size: 0.55rem;
  color: #d1d5db;
  pointer-events: none;
}

.grid-cell input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1rem;
  color: #e5e7eb;
  text-transform: uppercase;
}

.grid-cell input:focus {
  outline: 2px solid #38bdf8;
  outline-offset: -2px;
}

.solution-visible .grid-cell input {
  color: #22c55e;
}

.solved-letter {
  color: #22c55e;
}

.crossword-clues-container {
  background-color: #020617;
  border-radius: 0.5rem;
  border: 1px solid #1e293b;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crossword-clues-container h3 {
  margin-bottom: 0.4rem;
}

.clues-list {
  flex: 1;
  overflow: auto;
  font-size: 0.85rem;
}

.clues-section-title {
  margin: 0.25rem 0 0.2rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

.clue-item {
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid #0f172a;
}

.clue-label {
  font-weight: 600;
  margin-right: 0.3rem;
}

.clue-definition {
  color: #e5e7eb;
}

.clue-usage {
  color: #a5b4fc;
  margin-top: 0.15rem;
  font-size: 0.8rem;
}

.clue-meta {
  color: #9ca3af;
  margin-top: 0.15rem;
  font-size: 0.75rem;
}

.clue-solved {
  color: #22c55e;
}

.word-list-view {
  flex: 1;
  overflow: auto;
  font-size: 0.85rem;
  margin-top: 0.4rem;
}

.word-list-item {
  padding: 0.3rem 0.2rem;
  border-bottom: 1px solid #0f172a;
}

.word-list-item strong {
  margin-right: 0.3rem;
}

.hidden {
  display: none;
}

.popup-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.popup-overlay.hidden {
  display: none;
}

.popup-dialog {
  background-color: #020617;
  border-radius: 0.75rem;
  border: 1px solid #1e293b;
  padding: 1rem 1.25rem;
  max-width: 24rem;
  width: 100%;
  color: #e5e7eb;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.popup-dialog h3 {
  margin-bottom: 0.5rem;
}

.popup-dialog > #usage-popup-content > div + div {
  margin-top: 0.5rem;
}

.popup-close-button {
  margin-top: 0.75rem;
  width: 100%;
}

.app-footer {
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
  color: #6b7280;
  border-top: 1px solid #111827;
  background-color: #020617;
}

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

  .crossword-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .vocab-controls {
    flex-direction: column;
  }

  .puzzle-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .grid-cell {
    width: 1.7rem;
    height: 1.7rem;
  }
}
