:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-2: #38bdf8;
  --border: #334155;
  --danger: #f87171;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #020617, var(--bg));
  color: var(--text);
}

.page {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 24px;
  background: rgba(2, 6, 23, 0.92);
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.content {
  padding: 24px;
}

h1, h2, h3 { margin-top: 0; }
.muted { color: var(--muted); }
.panel {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.22);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.stats-box {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.error { color: var(--danger); }

label {
  display: block;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
}

input, textarea, button {
  width: 100%;
  margin-top: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
}

textarea { resize: vertical; }

button {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  border: none;
  cursor: pointer;
  font-weight: 700;
}
button.secondary {
  background: linear-gradient(135deg, var(--accent-2), #0284c7);
}
button:hover { filter: brightness(1.05); }

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.tab {
  width: auto;
  padding: 10px 16px;
  background: #243244;
}
.tab.active {
  background: linear-gradient(135deg, var(--accent-2), #0ea5e9);
}

.grid-container {
  display: grid;
  gap: 2px;
  background: #475569;
  padding: 2px;
  border-radius: 14px;
  overflow: auto;
}

.cell {
  min-width: 42px;
  min-height: 42px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  text-transform: uppercase;
  background: white;
  color: #111827;
}

.cell.black {
  background: #0b1220;
  color: #f8fafc;
}

.cell.clue-cell {
  align-items: stretch;
  justify-content: stretch;
  padding: 4px;
  font-size: 10px;
  line-height: 1.05;
  overflow: hidden;
  flex-direction: column;
  gap: 4px;
}

.clue {
  display: flex;
  gap: 3px;
  align-items: flex-start;
}

.clue span {
  color: #67e8f9;
  font-weight: 900;
}

.clue em {
  color: #93c5fd;
  font-style: normal;
}

.saved-list {
  display: grid;
  gap: 10px;
}

.saved-item {
  text-align: left;
  background: #182433;
  display: grid;
  gap: 4px;
}

.saved-item strong {
  font-size: 14px;
}

.saved-item span {
  color: var(--muted);
  font-size: 12px;
}

.placeholder {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.placeholder.small {
  padding: 8px;
}

.clue-container.hidden,
.grid-container.hidden {
  display: none;
}

.clue-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.clue-columns ol {
  margin: 0;
  padding-left: 22px;
}

.clue-columns li {
  margin-bottom: 8px;
  color: var(--text);
}

.db-info {
  margin: 0;
  white-space: pre-wrap;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 700px) {
  .grid-two,
  .actions,
  .clue-columns,
  .status-bar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .cell {
    min-width: 32px;
    min-height: 32px;
    font-size: 14px;
  }

  .cell.clue-cell {
    font-size: 8px;
  }
}
