:root {
  color-scheme: dark;
  --bg: #10161f;
  --panel: #18222e;
  --ink: #f3efe6;
  --muted: #bbc6d4;
  --accent: #ff5a36;
  font-family: "Avenir Next", system-ui, sans-serif;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button,
input,
select {
  font: inherit;
}
button,
select {
  min-height: 44px;
  border: 1px solid #566477;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  background: #233142;
  color: var(--ink);
  cursor: pointer;
}
button:hover {
  background: #35465b;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #9ee8ff;
  outline-offset: 3px;
}
a {
  color: #a9dcf0;
}
p {
  line-height: 1.55;
}
h1,
h2 {
  line-height: 1.2;
}
h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.045em;
}
h1 span {
  color: var(--accent);
}
.queens-app {
  max-width: 1140px;
  margin: auto;
  padding: 1.25rem;
}
.game-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1.1rem;
}
.game-heading a {
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
}
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.title-row p {
  color: var(--muted);
  margin: 0 0 1rem;
}
.edition {
  font-size: 0.875rem;
  white-space: nowrap;
  border: 1px solid #566477;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
}
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(230px, 1fr);
  gap: 1.5rem;
  align-items: start;
}
.board-panel {
  min-width: 0;
  max-width: 580px;
}
.board-scroll { max-width:100%; overflow-x:auto; }
.cell-size-control { display:none; }
.board-top {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-variant-numeric: tabular-nums;
}
.board-top span {
  color: var(--muted);
  font-size: 0.875rem;
}
.board {
  display: grid;
  grid-template-columns: repeat(var(--size, 7), minmax(0, 1fr));
  aspect-ratio: 1;
  max-width: 580px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  touch-action: manipulation;
}
.cell {
  border: 1px solid #10161f33;
  border-radius: 0;
  background: var(--region);
  color: #10161f;
  position: relative;
  min-height: 0;
  padding: 0;
  font-size: clamp(1.4rem, 4vw, 2.5rem);
  line-height: 1;
  font-weight: 800;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
}
.cell:hover {
  background: var(--region);
  filter: brightness(1.13);
}
.cell.region-top {
  border-top: 3px solid #172431;
}
.cell.region-left {
  border-left: 3px solid #172431;
}
.cell small {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.cell.blocked .glyph {
  opacity: 0.32;
  font-size: 1.2rem;
}
.cell.marked .glyph {
  opacity: 1;
}
.cell.conflict {
  background: repeating-linear-gradient(
    45deg,
    #ffc7c7,
    #ffc7c7 7px,
    #e38989 7px,
    #e38989 14px
  );
  color: #6b0f1c;
}
.cell.hinted {
  box-shadow:
    inset 0 0 0 4px #fff,
    inset 0 0 0 7px #15283a;
}
.cell:focus-visible {
  outline: 4px solid #10161f;
  outline-offset: -5px;
  z-index: 1;
}
.tool-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.tool-row button {
  flex: 1;
  white-space: nowrap;
  font-size: 0.875rem;
}
button[aria-pressed="true"] {
  background: var(--ink);
  color: #10161f;
  border-color: var(--ink);
}
button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}
.feedback {
  padding: 0.8rem 0;
  line-height: 1.5;
  min-height: 4.7rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.share-panel { border: 1px solid #566477; border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.share-panel label { font-weight: 700; font-size: 0.875rem; }
.share-panel input { width: 100%; min-width: 0; min-height: 44px; margin-top: 8px; padding: 8px; background: var(--bg); color: var(--ink); border: 1px solid #566477; border-radius: 4px; }
.share-panel p { color: var(--muted); font-size: 0.875rem; margin-bottom: 0; }
.result {
  border-left: 4px solid var(--accent);
  background: var(--panel);
  padding: 1rem;
}
.result h2 {
  margin-top: 0;
  font-size: 1.4rem;
}
.play-controls {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.1rem;
  margin-top: 0.4rem;
}
.mode-switch {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.mode-switch button {
  flex: 1;
  font-size: 0.875rem;
}
.play-controls > label:not(.check-label) {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.play-controls > select,
.play-controls > .primary {
  width: 100%;
  margin-bottom: 0.75rem;
}
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
}
.actions button {
  font-size: 0.875rem;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  font-size: 0.875rem;
}
.check-label input {
  width: 20px;
  height: 20px;
}
details {
  margin-top: 1rem;
  border-top: 1px solid #46536a;
  padding-top: 1rem;
}
summary {
  cursor: pointer;
  min-height: 40px;
  font-weight: 700;
}
ol {
  padding-left: 1.3rem;
  line-height: 1.6;
}
details p,
.local-note {
  font-size: 0.875rem;
  color: var(--muted);
}
.next-game {
  font-size: 0.875rem;
  line-height: 1.5;
  display: block;
  margin-top: 1.2rem;
}
[hidden] {
  display: none !important;
}
@media (max-width: 720px) {
  .tool-row .cell-size-control { display:block; flex-basis:100%; }
  .board-scroll.large-cells .board { min-width:calc(var(--size, 7) * 48px + 6px); }
  .queens-app {
    padding: 12px;
  }
  .game-layout {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .title-row {
    display: block;
  }
  .edition {
    display: inline-block;
    margin-bottom: 0.4rem;
  }
  .game-heading span {
    display: none;
  }
  .board {
    width: 100%;
    max-width: none;
  }
  .play-controls {
    margin-top: 0;
  }
  .tool-row button {
    padding: 0.5rem 0.4rem;
  }
  .board-top {
    padding: 0.6rem 0;
  }
  .cell {
    font-size: 1.8rem;
  }
  .feedback {
    min-height: 0;
    padding: 0.7rem 0;
  }
  .title-row p {
    font-size: 0.95rem;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition:
      background 0.12s,
      box-shadow 0.12s;
  }
  .result {
    animation: reveal 0.25s ease-out;
  }
  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
