:root {
  --bg: #fef8f3;
  --panel: #ffffff;
  --ink: #2c3e50;
  --muted: #5a6c7d;
  --accent: #1a4d6d;
  --accent-strong: #0d3b56;
  --line: #e2e8f0;
  --paper-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

h1,
h2,
h3 {
  font-family: 'Orbitron', sans-serif;
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app-shell {
  max-width: 1400px;
  margin: 1rem auto;
  padding: 0 0.5rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--paper-shadow);
}

.controls {
  padding: 1.2rem;
}

.controls h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.12;
}

.controls p {
  margin: 0.8rem 0 1rem;
  color: var(--muted);
}

.field-row {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.is-hidden {
  display: none;
}

label {
  font-size: 0.87rem;
  font-weight: 700;
}

.radio-row {
  display: grid;
  gap: 0.35rem;
}

.radio-row label {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #c8c2b7;
  border-radius: 10px;
  padding: 0.56rem 0.65rem;
  background: #fffefc;
}

textarea {
  resize: vertical;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.export-groups {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.3rem;
}

.export-heading {
  margin: 0.25rem 0 0;
  font-size: 0.98rem;
  color: var(--ink);
}

.export-group h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.export-group .button-row {
  margin-top: 0.45rem;
}

button {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 0.58rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.hint {
  margin-top: 0.9rem;
  font-size: 0.86rem;
}

.ai-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

.ai-dialog::backdrop {
  background: rgba(18, 16, 24, 0.48);
}

.ai-dialog-card {
  width: min(640px, calc(100vw - 2rem));
  background: #fffefc;
  border: 1px solid #d7d0c2;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.22);
}

.ai-dialog-card h3 {
  margin: 0 0 0.65rem;
}

.ai-prompt-output {
  width: 100%;
  min-height: 120px;
}

.output {
  padding: 1.2rem;
  overflow-x: auto;
}

.output-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.output h2 {
  margin: 0;
  font-size: 1.5rem;
}

.output #metaLine {
  color: var(--muted);
  font-size: 0.88rem;
}

.missing-words {
  margin: 0.4rem 0 0;
  min-height: 1.1rem;
  color: #8e2a2a;
  font-size: 0.88rem;
  text-align: right;
  margin-left: auto;
}

.grid-wrap {
  margin-top: 0.9rem;
  display: block;
  width: fit-content;
  background: white;
}

.grid-canvas {
  display: block;
}

.cell {
  background: white;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
}

.cell.filled {
  background: white;
  border-top: 1px solid #4a4a4a;
  border-left: 1px solid #4a4a4a;
}

.cell.filled.edge-right {
  border-right: 1px solid #4a4a4a;
}

.cell.filled.edge-bottom {
  border-bottom: 1px solid #4a4a4a;
}

.cell.block {
  background: white;
}

.cell .num {
  position: absolute;
  left: 2px;
  top: 1px;
  font-size: 0.5rem;
  font-weight: 700;
  color: #444;
}

.clues {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.clues h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.clues ol {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

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

@media print {
  body {
    background: white;
  }

  .controls {
    display: none;
  }

  .app-shell {
    display: block;
    margin: 0;
  }

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