.sudohint-import {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  font-family: inherit;
}

.sudohint-import-fab,
.sudohint-import-primary,
.sudohint-import-secondary,
.sudohint-import-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 650;
  letter-spacing: 0;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.sudohint-import-fab {
  min-height: 44px;
  padding: 0 16px;
  color: white;
  background: #2563eb;
  box-shadow: 0 12px 28px rgb(15 23 42 / 22%);
}

.sudohint-import-fab:hover,
.sudohint-import-primary:hover,
.sudohint-import-secondary:hover,
.sudohint-import-close:hover {
  transform: translateY(-1px);
}

.sudohint-import-backdrop {
  position: fixed;
  inset: 0;
  z-index: 81;
  background: rgb(15 23 42 / 44%);
}

.sudohint-import-dialog {
  position: fixed;
  right: 18px;
  bottom: 76px;
  z-index: 82;
  display: grid;
  width: min(420px, calc(100vw - 32px));
  gap: 12px;
  padding: 18px;
  color: var(--color-text, hsl(var(--foreground, 222 47% 11%)));
  background: var(--color-card, hsl(var(--card, 0 0% 100%)));
  border: 1px solid var(--color-border, hsl(var(--border, 214 32% 91%)));
  border-radius: 8px;
  box-shadow: 0 22px 60px rgb(15 23 42 / 24%);
}

.sudohint-import-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sudohint-import-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
}

.sudohint-import-close {
  width: 32px;
  height: 32px;
  color: var(--color-muted, hsl(var(--muted-foreground, 215 16% 47%)));
  border: 1px solid var(--color-border, hsl(var(--border, 214 32% 91%)));
  background: transparent;
}

.sudohint-import-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-muted, hsl(var(--muted-foreground, 215 16% 47%)));
}

.sudohint-import-text {
  width: 100%;
  min-height: 188px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  line-height: 1.4;
  color: inherit;
  background: var(--color-bg, hsl(var(--background, 0 0% 100%)));
  border: 1px solid var(--color-border, hsl(var(--border, 214 32% 91%)));
  border-radius: 8px;
  outline: none;
  resize: vertical;
}

.sudohint-import-text:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgb(37 99 235 / 16%);
}

.sudohint-import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sudohint-import-primary,
.sudohint-import-secondary {
  min-height: 38px;
  padding: 0 13px;
}

.sudohint-import-primary {
  color: white;
  background: #2563eb;
}

.sudohint-import-secondary {
  color: var(--color-text, hsl(var(--foreground, 222 47% 11%)));
  border: 1px solid var(--color-border, hsl(var(--border, 214 32% 91%)));
  background: transparent;
}

.sudohint-import-status {
  min-height: 18px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #dc2626;
}

.sudohint-import-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  max-width: min(460px, calc(100vw - 32px));
  padding: 11px 14px;
  color: white;
  background: #111827;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgb(15 23 42 / 24%);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.sudohint-import-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 520px) {
  .sudohint-import {
    right: 12px;
    bottom: 12px;
  }

  .sudohint-import-dialog {
    right: 12px;
    bottom: 66px;
  }

  .sudohint-import-actions {
    justify-content: stretch;
  }

  .sudohint-import-primary,
  .sudohint-import-secondary {
    flex: 1;
  }
}

/* Product polish: keep the generated app's layout, but give it a calmer
   reading surface and a more deliberate hierarchy. */
:root {
  --sudohint-ink: #172033;
  --sudohint-muted: #647089;
  --sudohint-line: #dfe5ef;
  --sudohint-blue: #3458d4;
  --sudohint-blue-soft: #edf2ff;
}

body {
  background:
    radial-gradient(circle at 8% 0%, rgb(94 120 220 / 10%), transparent 28rem),
    linear-gradient(180deg, #f7f9fc 0%, var(--color-bg, #f4f3ef) 22rem);
}

button,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(52 88 212 / 28%);
  outline-offset: 2px;
}

.app-header {
  padding: 14px max(20px, calc((100vw - 1180px) / 2));
  background: rgb(248 250 253 / 88%);
  border-bottom-color: rgb(210 218 232 / 72%);
}

.app-title {
  letter-spacing: -0.035em;
}

.app-title::after {
  content: "Learn the logic";
  display: block;
  margin-top: -2px;
  color: var(--color-text-muted, #6b6966);
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.1;
}

.app-main {
  grid-template-columns: minmax(420px, 560px) minmax(300px, 380px);
  justify-content: center;
  gap: clamp(24px, 5vw, 72px);
  padding: clamp(28px, 5vw, 64px) 24px 72px;
  max-width: 1180px;
}

.left-col {
  gap: 18px;
}

.controls-bar,
.hint-controls {
  gap: 10px;
}

.controls-bar {
  padding: 6px;
  border: 1px solid var(--sudohint-line);
  border-radius: 14px;
  background: rgb(255 255 255 / 70%);
  box-shadow: 0 8px 24px rgb(33 50 83 / 5%);
}

.difficulty-selector {
  border: 0;
  background: transparent;
}

.diff-btn {
  min-height: 34px;
}

.diff-btn.active {
  color: var(--sudohint-blue);
  background: var(--sudohint-blue-soft);
  box-shadow: none;
}

.generate-btn {
  min-height: 38px;
  border-radius: 10px;
}

.btn-hint {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 700;
  background: rgb(255 255 255 / 72%);
}

.toggle-btn {
  min-height: 38px;
  border-radius: 10px;
}

.sudoku-grid {
  border-radius: 16px;
  box-shadow: 0 20px 45px rgb(34 49 81 / 14%), 0 2px 5px rgb(34 49 81 / 8%);
}

.sudoku-cell {
  border-color: rgb(203 211 226 / 78%);
}

.right-col {
  padding-top: 52px;
}

.hint-panel,
.hint-empty,
.technique-ref,
.hint-history {
  border-radius: 16px;
  box-shadow: 0 10px 28px rgb(34 49 81 / 7%);
}

.hint-empty {
  min-height: 260px;
  justify-content: center;
  background: rgb(255 255 255 / 66%);
}

.sudohint-import-fab {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgb(255 255 255 / 24%);
  border-radius: 12px;
  background: var(--sudohint-blue);
  box-shadow: 0 14px 30px rgb(38 61 139 / 25%);
}

.sudohint-import-fab:hover,
.sudohint-import-primary:hover {
  background: #2949b8;
}

.sudohint-import-backdrop {
  background: rgb(19 29 50 / 52%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sudohint-import-dialog {
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  padding: 24px;
  gap: 14px;
  border: 1px solid var(--sudohint-line);
  border-radius: 20px;
  box-shadow: 0 28px 80px rgb(17 31 61 / 24%);
  transform: translate(-50%, -50%);
}

/* Author styles override the browser's default [hidden] rule, so make the
   closed state explicit for the modal and backdrop. */
.sudohint-import-dialog[hidden],
.sudohint-import-backdrop[hidden] {
  display: none !important;
}

.sudohint-import-head {
  align-items: flex-start;
}

.sudohint-import-kicker {
  margin: 0 0 3px;
  color: var(--sudohint-blue);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.sudohint-import-head h2 {
  color: var(--sudohint-ink);
  font-size: 1.3rem;
  letter-spacing: -0.025em;
}

.sudohint-import-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.4rem;
  line-height: 1;
}

.sudohint-import-help {
  margin: -4px 0 2px;
  color: var(--sudohint-muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

.sudohint-editor-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 360px);
  aspect-ratio: 1;
  margin: 2px auto;
  overflow: hidden;
  border: 2px solid var(--sudohint-ink);
  border-radius: 10px;
  background: var(--sudohint-ink);
  box-shadow: 0 8px 18px rgb(33 50 83 / 10%);
}

.sudohint-editor-cell {
  width: 100%;
  min-width: 0;
  padding: 0;
  color: var(--sudohint-ink);
  background: #fff;
  border: 0;
  border-right: 1px solid #d9dfeb;
  border-bottom: 1px solid #d9dfeb;
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: clamp(1rem, 4vw, 1.35rem);
  font-weight: 700;
  text-align: center;
}

.sudohint-editor-cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 2px solid var(--sudohint-ink);
}

.sudohint-editor-cell:nth-child(n + 19):nth-child(-n + 27),
.sudohint-editor-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid var(--sudohint-ink);
}

.sudohint-editor-cell:focus {
  position: relative;
  z-index: 1;
  background: var(--sudohint-blue-soft);
  box-shadow: inset 0 0 0 2px var(--sudohint-blue);
  outline: none;
}

.sudohint-import-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sudohint-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sudohint-import-divider::before,
.sudohint-import-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--sudohint-line);
}

.sudohint-import-label {
  color: var(--sudohint-muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.sudohint-import-text {
  min-height: 68px;
  padding: 10px 12px;
  border-color: var(--sudohint-line);
  border-radius: 10px;
  font-size: 0.82rem;
}

.sudohint-import-text::placeholder {
  color: #9aa5b8;
}

.sudohint-import-actions {
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.sudohint-import-primary,
.sudohint-import-secondary,
.sudohint-import-quiet {
  min-height: 40px;
  border-radius: 10px;
}

.sudohint-import-primary {
  margin-left: auto;
  padding: 0 16px;
  background: var(--sudohint-blue);
}

.sudohint-import-secondary,
.sudohint-import-quiet {
  padding: 0 11px;
  color: var(--sudohint-blue);
  border: 1px solid #cbd6f4;
  background: var(--sudohint-blue-soft);
}

.sudohint-import-quiet {
  color: var(--sudohint-muted);
  border-color: var(--sudohint-line);
  background: transparent;
}

.sudohint-import-status {
  margin: 0;
  color: #287a4b;
}

.sudohint-import-status.is-error {
  color: #c0393d;
}

.sudohint-import-toast {
  bottom: 24px;
  border-radius: 10px;
  background: #172033;
}

@media (max-width: 768px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px 16px 96px;
  }

  .right-col {
    padding-top: 0;
  }
}

/* One enduring visual system: linen paper, Prussian-blue ink, and restrained
   copper details. These selectors intentionally win over both the generated
   app theme and the operating-system colour preference. */
:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: light !important;
  --color-bg: #f7f2e8;
  --color-surface: #fffaf2;
  --color-surface-2: #fae4c2;
  --color-surface-offset: #fae4c2;
  --color-surface-offset-2: #f4bf98;
  --color-surface-dynamic: #e7c6a8;
  --color-divider: #d9b99a;
  --color-border: #bc8764;
  --color-text: #0e213f;
  --color-text-muted: #5b493d;
  --color-text-faint: #856d5d;
  --color-text-inverse: #f7f2e8;
  --color-primary: #0e213f;
  --color-primary-hover: #1c3967;
  --color-primary-active: #08162b;
  --color-primary-highlight: #fae4c2;
  --color-success: #38644c;
  --color-success-highlight: #dfeadb;
  --color-error: #9b4138;
  --color-error-highlight: #f7ded6;
  --color-orange: #bc8764;
  --color-orange-highlight: #fae4c2;
  --color-blue: #0e213f;
  --color-blue-highlight: #e2eaf4;
  --color-hint-target: #0e213f;
  --color-hint-target-bg: #fae4c2;
  --color-hint-highlight-bg: #fff3d8;
  --color-hint-elim-bg: #f7ded6;
  --sudohint-ink: #0e213f;
  --sudohint-muted: #5b493d;
  --sudohint-line: #d9b99a;
  --sudohint-blue: #0e213f;
  --sudohint-blue-soft: #fae4c2;
}

body {
  background: #f7f2e8;
}

.app-header,
.controls-bar,
.hint-panel,
.hint-empty,
.technique-ref,
.hint-history,
.sudohint-import-dialog {
  box-shadow: 0 10px 26px rgb(14 33 63 / 8%);
}

.sudohint-import-backdrop {
  background: rgb(14 33 63 / 42%);
}

[data-testid="theme-toggle"] {
  display: none !important;
}

/* Final visual system: neutral surfaces, one accent, and a readable system
   font. Keep these tokens at the end so both generated and custom UI use the
   same palette. */
:root,
[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-surface-2: #ffffff;
  --color-surface-offset: #eef0f3;
  --color-surface-offset-2: #e4e7ec;
  --color-surface-dynamic: #d9dee6;
  --color-divider: #e1e5ea;
  --color-border: #b8c3d0;
  --color-text: #1f2937;
  --color-text-muted: #475467;
  --color-text-faint: #667085;
  --color-text-inverse: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-active: #1e40af;
  --color-primary-highlight: #eff6ff;
  --color-hint-target: #2563eb;
  --color-hint-target-bg: #eff6ff;
  --font-display: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0f141b;
  --color-surface: #171e27;
  --color-surface-2: #1d2632;
  --color-surface-offset: #222d3a;
  --color-surface-offset-2: #2a3747;
  --color-surface-dynamic: #36465a;
  --color-divider: #3a4a5d;
  --color-border: #53657a;
  --color-text: #f8fafc;
  --color-text-muted: #c4d0df;
  --color-text-faint: #94a3b8;
  --color-text-inverse: #111418;
  --color-primary: #83b3ff;
  --color-primary-hover: #adcbff;
  --color-primary-active: #d5e4ff;
  --color-primary-highlight: #213d68;
  --color-hint-target: #83b3ff;
  --color-hint-target-bg: #213d68;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-bg: #0f141b;
    --color-surface: #171e27;
    --color-surface-2: #1d2632;
    --color-surface-offset: #222d3a;
    --color-surface-offset-2: #2a3747;
    --color-divider: #3a4a5d;
    --color-border: #53657a;
    --color-text: #f8fafc;
    --color-text-muted: #c4d0df;
    --color-text-faint: #94a3b8;
    --color-text-inverse: #111418;
    --color-primary: #83b3ff;
    --color-primary-hover: #adcbff;
    --color-primary-active: #d5e4ff;
    --color-primary-highlight: #213d68;
    --color-hint-target: #83b3ff;
    --color-hint-target-bg: #213d68;
  }
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
}

.app-header {
  background: var(--color-surface);
  border-bottom-color: var(--color-divider);
}

.app-title,
.hint-technique,
.hint-empty-title,
.complete-content h2,
.hint-description,
.history-desc {
  font-family: var(--font-display);
}

.controls-bar,
.hint-empty,
.hint-panel,
.technique-ref,
.hint-history {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.controls-bar {
  box-shadow: 0 4px 14px rgb(16 24 40 / 5%);
}

.sudohint-import {
  top: 10px;
  right: max(68px, calc((100vw - 1180px) / 2 + 58px));
  bottom: auto;
}

.sudohint-import-fab {
  color: #ffffff;
  background: var(--color-primary);
  border-color: transparent;
  box-shadow: 0 5px 14px rgb(37 99 235 / 22%);
}

.sudohint-import-dialog {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
}

.sudohint-import-head h2 {
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.sudohint-import-close {
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

.sudohint-import-kicker,
.sudohint-import-primary,
.sudohint-import-secondary {
  color: var(--color-primary);
}

.sudohint-import-primary,
.sudohint-import-fab {
  color: #ffffff;
  background: var(--color-primary);
}

.sudohint-import-primary:hover,
.sudohint-import-fab:hover {
  background: var(--color-primary-hover);
}

.sudohint-import-secondary {
  background: var(--color-primary-highlight);
  border-color: var(--color-border);
}

.sudohint-import-quiet {
  color: var(--color-text-muted);
  background: transparent;
  border-color: var(--color-border);
}

.sudohint-import-help,
.sudohint-import-label,
.sudohint-import-divider,
.sudohint-import-close {
  color: var(--color-text-muted);
}

.sudohint-import-text,
.sudohint-editor-cell {
  color: var(--color-text);
  background: var(--color-bg);
  border-color: var(--color-border);
}

.sudohint-editor-grid {
  background: var(--color-text);
  border-color: var(--color-text);
}

.sudohint-editor-cell:nth-child(3n):not(:nth-child(9n)),
.sudohint-editor-cell:nth-child(n + 19):nth-child(-n + 27),
.sudohint-editor-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-color: var(--color-text);
}

@media (max-width: 520px) {
  .sudohint-import {
    top: 8px;
    right: 58px;
  }
}

/* Desktop information flow: board first, technique reference underneath;
   the active hint remains beside the board where it is immediately useful. */
@media (min-width: 769px) {
  .app-main {
    grid-template-rows: auto auto;
    column-gap: clamp(28px, 5vw, 64px);
    row-gap: 16px;
    align-items: start;
  }

  .left-col {
    grid-column: 1;
    grid-row: 1;
  }

  .right-col {
    display: contents;
  }

  .right-col > .hint-panel,
  .right-col > .hint-empty {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .right-col > .technique-ref {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    width: 100%;
    max-width: 560px;
  }

  .right-col > .hint-history {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
  }
}

@media (min-width: 769px) and (max-height: 820px) {
  .app-main {
    grid-template-rows: none;
    row-gap: 0;
    align-items: center;
  }

  .left-col {
    grid-column: auto;
    grid-row: auto;
  }

  .right-col {
    display: flex;
    max-width: 440px;
  }

  .right-col > .hint-panel,
  .right-col > .hint-empty,
  .right-col > .technique-ref,
  .right-col > .hint-history {
    grid-column: auto;
    grid-row: auto;
    width: auto;
    max-width: none;
  }
}

/* The page may grow naturally: use the full device width, keep spacing tight,
   and let the reference content continue below the board when needed. */
html,
body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  min-height: 100dvh;
}

.app-root {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

.app-main {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 460px);
  grid-template-rows: auto auto;
  gap: 18px clamp(24px, 4vw, 56px);
  width: 100%;
  max-width: 1360px;
  padding: 24px clamp(16px, 3vw, 40px) 40px;
  overflow: visible;
}

.right-col {
  overflow: visible;
}

@media (min-width: 769px) {
  :root {
    --cell-size: clamp(32px, min(6.5vw, calc((100vw - 520px) / 9)), 58px);
  }

  .app-main {
    align-items: start;
  }

  .left-col {
    grid-column: 1;
    grid-row: 1;
  }

  .right-col {
    display: contents;
    max-width: none;
  }

  .right-col > .hint-panel,
  .right-col > .hint-empty {
    grid-column: 2;
    grid-row: 1;
  }

  .right-col > .technique-ref {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .right-col > .hint-history {
    grid-column: 2;
    grid-row: 2;
  }
}

@media (max-width: 768px) {
  :root {
    --cell-size: clamp(30px, 10.4vw, 52px);
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 24px;
    padding: 18px 16px 40px;
  }

  .left-col {
    grid-column: auto;
    grid-row: auto;
  }

  .right-col,
  .right-col:has(.hint-panel) {
    position: static;
    inset: auto;
    z-index: auto;
    display: flex;
    grid-column: auto;
    grid-row: auto;
    max-width: none;
    padding: 0;
    background: transparent;
  }

  .right-col:has(.hint-panel) .technique-ref,
  .right-col:has(.hint-panel) .hint-history {
    display: block;
  }

  .technique-list .ref-item:nth-child(odd),
  .technique-list .ref-item:last-child {
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
  }

  .header-left {
    gap: 8px;
    min-width: 0;
  }

  .logo {
    width: 32px;
    height: 32px;
  }

  .app-title {
    font-size: 1.05rem;
  }

  .header-right {
    gap: 4px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .sudohint-import {
    top: 7px;
    right: 52px;
  }

  .sudohint-import-fab {
    min-height: 40px;
    padding: 0 11px;
    border-radius: 10px;
    font-size: 0.82rem;
  }

  .sudohint-import-fab svg {
    width: 14px;
    height: 14px;
  }

  .app-main {
    gap: 20px;
    padding: 16px 12px 32px;
  }

  .left-col {
    width: min(100%, 480px);
    margin-inline: auto;
    gap: 14px;
  }

  .controls-bar {
    gap: 8px;
    padding: 5px;
    border-radius: 12px;
  }

  .difficulty-selector {
    flex: 1;
  }

  .diff-btn {
    flex: 1;
    padding-inline: 10px;
  }

  .controls-bar .generate-btn {
    min-height: 36px;
    padding-inline: 12px;
  }

  .hint-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .btn-hint,
  .toggle-btn {
    width: 100%;
    min-height: 42px;
    justify-content: center;
    padding-inline: 8px;
    white-space: nowrap;
  }

  .sudoku-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .sudoku-grid,
  .grid-placeholder {
    max-width: 100%;
  }

  .numpad {
    width: min(100%, calc(var(--cell-size) * 9 + 5px));
    margin-inline: auto;
  }

  /* Use the actual available width on phones instead of summing fixed cell
     widths. This keeps the ninth column inside the viewport. */
  .sudoku-grid,
  .grid-placeholder {
    width: min(100%, calc(100vw - 24px));
    height: auto;
    aspect-ratio: 1;
  }

  .sudoku-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    grid-template-rows: repeat(9, minmax(0, 1fr));
  }

  .sudoku-cell {
    width: auto;
    height: auto;
  }

  .numpad {
    width: min(100%, calc(100vw - 24px));
  }
}

.sudohint-editor-cell:focus {
  color: var(--color-text) !important;
  background: var(--color-primary-highlight) !important;
  box-shadow: inset 0 0 0 2px var(--color-primary) !important;
  outline: none;
}

/* Final layout override: content determines page height, so the document can
   scroll when the reference section extends beyond the viewport. */
html,
body {
  height: auto !important;
  min-height: 100%;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

body {
  min-height: 100dvh;
}

.app-root {
  height: auto !important;
  min-height: 100dvh;
  overflow: visible !important;
}

.app-main {
  grid-template-rows: auto auto;
  align-items: start;
  gap: 18px clamp(24px, 4vw, 56px);
  width: 100%;
  max-width: 1360px;
  padding: 24px clamp(16px, 3vw, 40px) 40px;
  overflow: visible !important;
}

.right-col {
  overflow: visible;
}

@media (min-width: 769px) {
  :root {
    --cell-size: clamp(32px, min(6.5vw, calc((100vw - 520px) / 9)), 58px);
  }

  .left-col {
    grid-column: 1;
    grid-row: 1;
  }

  .right-col {
    display: contents;
    max-width: none;
  }

  .right-col > .hint-panel,
  .right-col > .hint-empty {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .right-col > .technique-ref {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .right-col > .hint-history {
    grid-column: 2;
    grid-row: 2;
  }
}

@media (max-width: 768px) {
  :root {
    --cell-size: clamp(30px, 10.4vw, 52px);
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 24px;
    padding: 18px 16px 40px;
  }

  .left-col {
    grid-column: auto;
    grid-row: auto;
  }

  .right-col,
  .right-col:has(.hint-panel) {
    position: static;
    inset: auto;
    z-index: auto;
    display: flex;
    grid-column: auto;
    grid-row: auto;
    max-width: none;
    padding: 0;
    background: transparent;
  }

  .right-col:has(.hint-panel) .technique-ref,
  .right-col:has(.hint-panel) .hint-history {
    display: block;
  }
}

/* Keep the supplied palette fixed even if the compiled app changes the
   data-theme attribute after startup. */
:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: light !important;
  --color-bg: #f7f2e8;
  --color-surface: #fffaf2;
  --color-surface-2: #fae4c2;
  --color-surface-offset: #fae4c2;
  --color-surface-offset-2: #f4bf98;
  --color-surface-dynamic: #e7c6a8;
  --color-divider: #d9b99a;
  --color-border: #bc8764;
  --color-text: #0e213f;
  --color-text-muted: #5b493d;
  --color-text-faint: #856d5d;
  --color-text-inverse: #f7f2e8;
  --color-primary: #0e213f;
  --color-primary-hover: #1c3967;
  --color-primary-active: #08162b;
  --color-primary-highlight: #fae4c2;
  --color-success: #38644c;
  --color-success-highlight: #dfeadb;
  --color-error: #9b4138;
  --color-error-highlight: #f7ded6;
  --color-orange: #bc8764;
  --color-orange-highlight: #fae4c2;
  --color-blue: #0e213f;
  --color-blue-highlight: #e2eaf4;
  --color-hint-target: #0e213f;
  --color-hint-target-bg: #fae4c2;
  --color-hint-highlight-bg: #fff3d8;
  --color-hint-elim-bg: #f7ded6;
  --sudohint-ink: #0e213f;
  --sudohint-muted: #5b493d;
  --sudohint-line: #d9b99a;
  --sudohint-blue: #0e213f;
  --sudohint-blue-soft: #fae4c2;
}

body {
  background: #f7f2e8;
}

.app-header,
.controls-bar,
.hint-panel,
.hint-empty,
.technique-ref,
.hint-history,
.sudohint-import-dialog {
  box-shadow: 0 10px 26px rgb(14 33 63 / 8%);
}

.sudohint-import-backdrop {
  background: rgb(14 33 63 / 42%);
}

[data-testid="theme-toggle"] {
  display: none !important;
}

@media (max-width: 520px) {
  .app-header {
    padding-inline: 16px;
  }

  .app-title::after {
    display: none;
  }

  .app-main {
    gap: 24px;
  }

  .controls-bar {
    flex-wrap: wrap;
  }

  .controls-bar .generate-btn {
    flex: 1;
  }

  .sudohint-import-dialog {
    padding: 18px;
  }

  .sudohint-import-actions {
    flex-wrap: wrap;
  }

  .sudohint-import-primary {
    width: 100%;
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Keep the application in a single viewport. The puzzle scales with the
   available height so the board, controls, and hint panel remain visible. */
html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 0;
}

.app-root {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-header {
  flex: 0 0 auto;
}

.app-main {
  min-height: 0;
  overflow: hidden;
  padding-top: clamp(16px, 3vh, 32px);
  padding-bottom: clamp(16px, 3vh, 32px);
}

.left-col,
.right-col {
  min-height: 0;
}

.right-col {
  padding-top: 0;
  overflow: hidden;
  max-width: 440px;
}

.technique-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.technique-list .ref-item {
  min-width: 0;
  padding: 9px 12px;
}

.technique-list .ref-item:nth-child(odd) {
  border-right: 1px solid var(--color-divider);
}

.technique-list .ref-item:nth-last-child(-n + 2) {
  border-bottom: none;
}

.technique-list .ref-desc {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  line-height: 1.45;
}

.technique-list .ref-item-header {
  justify-content: space-between;
}

.technique-example-trigger {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 2px 8px;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: 7px;
  background: transparent;
  font-size: 0.7rem;
  font-weight: 700;
}

.technique-example-trigger:hover {
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  background: var(--color-primary);
}

.sudohint-example-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sudohint-example-modal[hidden] {
  display: none !important;
}

.sudohint-example-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(8 12 18 / 68%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.sudohint-example-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 22px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 30%);
}

.sudohint-example-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sudohint-example-head h2 {
  margin: 0;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.7rem);
}

.sudohint-example-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 9px;
  font-size: 1.35rem;
  line-height: 1;
}

.sudohint-example-summary {
  margin: 14px 0 18px;
  color: var(--color-text-muted);
  line-height: 1.55;
}

.sudohint-example-reading {
  margin: -8px 0 18px;
  padding: 9px 11px;
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 8px 8px 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.sudohint-example-frames {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sudohint-example-frame {
  padding: 14px;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.sudohint-example-frame-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.sudohint-example-frame-head strong {
  color: var(--color-text);
  font-size: 0.95rem;
}

.sudohint-example-frame-head span {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.sudohint-example-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  width: min(100%, 440px);
  aspect-ratio: 1;
  margin-inline: auto;
  overflow: hidden;
  border: 2px solid var(--color-text);
  border-radius: 10px;
}

.sudohint-example-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  position: relative;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  font-size: clamp(0.52rem, 1.8vw, 0.78rem);
  text-align: center;
}

.sudohint-example-cell.box-even {
  background: var(--color-surface);
}

.sudohint-example-cell.box-odd {
  background: var(--color-surface-offset-2);
}

.sudohint-example-cell.context {
  color: var(--color-text-faint);
  opacity: 0.56;
}

.sudohint-example-cell:nth-child(3n):not(:nth-child(9n)) {
  border-right: 2px solid var(--color-text);
}

.sudohint-example-cell:nth-child(n + 19):nth-child(-n + 27),
.sudohint-example-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid var(--color-text);
}

.sudohint-example-cell.target {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

.sudohint-example-cell.cause {
  color: var(--color-orange);
  background: var(--color-orange-highlight);
  box-shadow: inset 0 0 0 2px var(--color-orange);
}

.sudohint-example-cell.elimination {
  color: var(--color-error);
  background: var(--color-error-highlight);
  box-shadow: inset 0 0 0 2px var(--color-error);
}

.sudohint-example-given {
  color: var(--color-text);
  font-size: clamp(1.15rem, 2.5vw, 1.7rem);
  font-weight: 850;
  line-height: 1;
}

.sudohint-example-label {
  max-width: 100%;
  padding: 1px;
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.05;
}

.sudohint-example-context {
  font-size: 0.9em;
  line-height: 1;
}

.sudohint-example-cell:not(.target):not(.cause):not(.elimination) .sudohint-example-label,
.sudohint-example-candidates {
  color: var(--color-text-muted);
  font-size: 0.72em;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* Candidate digits should read like pencil marks, not a compressed number. */
.sudohint-example-pencil-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  width: 78%;
  height: 78%;
  color: var(--color-text-muted);
}

.sudohint-example-pencil {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  font-size: clamp(0.43rem, 1.25vw, 0.68rem);
  font-weight: 750;
  line-height: 1;
}

.sudohint-example-cell.target .sudohint-example-pencil-grid,
.sudohint-example-cell.cause .sudohint-example-pencil-grid,
.sudohint-example-cell.elimination .sudohint-example-pencil-grid {
  color: currentColor;
}

.sudohint-example-pencil.is-removed {
  position: relative;
  font-weight: 850;
  text-decoration: none;
}

.sudohint-example-pencil.is-removed::after {
  position: absolute;
  top: 50%;
  left: 8%;
  width: 94%;
  height: 2px;
  background: currentColor;
  content: "";
  opacity: 0.9;
  transform: rotate(-42deg);
  transform-origin: center;
}

/* Use the same clear 3×3 rhythm in the playable board. */
.candidates-grid {
  padding: 3px;
  gap: 1px;
}

.candidate {
  color: var(--color-text-muted);
  font-weight: 650;
}

/* Make the next helpful action unmistakable. */
.btn-hint:not(:disabled) {
  color: #fff;
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: 0 5px 16px color-mix(in srgb, var(--color-primary) 34%, transparent);
}

.btn-hint:not(:disabled):hover {
  color: #fff;
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--color-primary) 42%, transparent);
}

.btn-hint:disabled {
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border-color: var(--color-border);
  opacity: 0.82;
}

/* Local image-grid detection preview. */
.sudohint-image-import {
  order: -1;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-offset);
}

.sudohint-import-head {
  order: -2;
}

.sudohint-image-divider {
  order: 0;
}

.sudohint-import-help,
.sudohint-editor-grid,
.sudohint-import-divider:not(.sudohint-image-divider),
.sudohint-import-label,
.sudohint-import-text {
  order: 1;
}

.sudohint-import-actions,
.sudohint-import-status {
  order: 2;
}

.sudohint-image-import summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.sudohint-image-import summary svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: var(--color-primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  fill: none;
}

.sudohint-image-import summary::marker {
  color: var(--color-primary);
}

.sudohint-image-import summary span {
  padding: 2px 6px;
  color: var(--color-primary);
  border: 1px solid color-mix(in srgb, var(--color-primary) 45%, var(--color-border));
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sudohint-image-import p {
  margin: 9px 0 0;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.sudohint-image-select {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 10px;
  padding: 0 10px;
  color: #fff;
  border-radius: 7px;
  background: var(--color-primary);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
}

.sudohint-image-select:hover {
  background: var(--color-primary-hover);
}

.sudohint-image-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.sudohint-image-preview {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
}

.sudohint-image-canvas {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.sudohint-straightened-preview {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 38%, var(--color-border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
}

.sudohint-straightened-preview > p {
  margin: 0 0 7px;
  color: var(--color-text);
}

.sudohint-straightened-canvas {
  display: block;
  width: min(100%, 360px);
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--color-bg);
}

.sudohint-cell-analysis {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface-offset);
}

.sudohint-cell-analysis > p {
  margin: 0;
}

.sudohint-cell-analysis-summary {
  color: var(--color-text);
  font-weight: 650;
}

.sudohint-cell-analysis-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 252px);
  margin: 8px auto;
  border: 1px solid var(--color-border);
}

.sudohint-cell-analysis-cell {
  aspect-ratio: 1;
  padding: 0;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
}

.sudohint-cell-analysis-cell:hover,
.sudohint-cell-analysis-cell:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.sudohint-cell-analysis-cell:nth-child(3n) {
  border-right-width: 2px;
}

.sudohint-cell-analysis-cell:nth-child(n + 19):nth-child(-n + 27),
.sudohint-cell-analysis-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom-width: 2px;
}

.sudohint-cell-analysis-cell.is-digit,
.sudohint-cell-analysis-key .is-digit {
  background: #3b82f6;
}

.sudohint-cell-analysis-cell.is-pencil,
.sudohint-cell-analysis-key .is-pencil {
  background: #f59e0b;
}

.sudohint-cell-analysis-key {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  color: var(--color-text-muted) !important;
  font-size: 0.72rem !important;
}

.sudohint-cell-analysis-key span {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 3px 0 0;
  border-radius: 50%;
  vertical-align: -1px;
}

.sudohint-cell-analysis-key .is-empty {
  border: 1px solid var(--color-text-muted);
  background: transparent;
}

.sudohint-digit-review {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 38%, var(--color-border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--color-primary) 5%, var(--color-surface));
}

.sudohint-digit-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sudohint-digit-review-head strong {
  color: var(--color-text);
  font-size: 0.8rem;
}

.sudohint-digit-review .sudohint-digit-review-help,
.sudohint-digit-review .sudohint-digit-review-summary {
  margin: 3px 0 0;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.sudohint-use-recognized {
  min-height: 32px;
  padding: 0 10px;
  color: #fff;
  border: 1px solid var(--color-primary);
  border-radius: 7px;
  background: var(--color-primary);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.sudohint-digit-review-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 288px);
  margin: 9px auto;
  overflow: hidden;
  border: 2px solid var(--color-text);
  border-radius: 4px;
}

.sudohint-digit-review-cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  color: var(--color-text);
  border: 0;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  text-align: center;
  font: inherit;
  font-size: 1rem;
  font-weight: 750;
}

.sudohint-digit-review-cell:nth-child(3n) {
  border-right: 2px solid var(--color-text);
}

.sudohint-digit-review-cell:nth-child(n + 19):nth-child(-n + 27),
.sudohint-digit-review-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid var(--color-text);
}

.sudohint-digit-review-cell.is-pencil,
.sudohint-digit-review-cell.is-empty {
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-surface-offset) 75%, var(--color-surface));
}

.sudohint-digit-review-cell.is-uncertain {
  color: #9a5b00;
  background: color-mix(in srgb, #f59e0b 24%, var(--color-surface));
}

.sudohint-digit-review-actions {
  display: flex;
  justify-content: flex-end;
}

.sudohint-use-recognized {
  width: 100%;
}

/* The rectified 9×9 board is intentionally reviewable inside the import
   dialog, so the dialog itself must remain scrollable on shorter screens. */
.sudohint-import-dialog {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sudohint-image-import .sudohint-image-status {
  margin-top: 8px;
}

.sudohint-image-status.is-error {
  color: var(--color-error);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

/* Technique list: compact cards rather than a stretched spreadsheet. */
.technique-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
  background: var(--color-surface);
}

.technique-list .ref-item,
.technique-list .ref-item:nth-child(odd),
.technique-list .ref-item:nth-last-child(-n + 2) {
  min-height: 88px;
  padding: 12px 14px;
  gap: 7px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-offset);
}

.technique-list .ref-item:hover {
  background: var(--color-surface-offset-2);
  border-color: var(--color-primary);
}

.technique-list .ref-item-header {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  justify-content: initial;
  gap: 10px;
}

.technique-list .ref-name {
  min-width: 0;
  flex: none;
  font-size: 0.93rem;
  font-weight: 720;
  line-height: 1.2;
  text-align: left;
}

.technique-list .ref-desc {
  padding-left: 18px;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.technique-example-trigger {
  min-height: 30px;
  padding: 4px 9px;
  border-color: var(--color-border);
  border-radius: 7px;
  font-size: 0.73rem;
}

@media (max-width: 768px) {
  .technique-list {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  .technique-list .ref-item,
  .technique-list .ref-item:nth-child(odd),
  .technique-list .ref-item:nth-last-child(-n + 2) {
    min-height: 0;
    padding: 11px 12px;
    border-bottom: 1px solid var(--color-border);
  }
}

.sudohint-example-removed {
  color: currentColor;
  font-weight: 850;
  text-decoration-thickness: 2px;
}

.sudohint-example-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 16px;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.sudohint-example-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sudohint-example-legend i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
}

.sudohint-example-legend i.given {
  background: var(--color-text-muted);
}

.sudohint-example-legend i.candidate {
  border: 1px solid var(--color-text-muted);
  background: transparent;
}

.sudohint-example-legend i.context {
  background: var(--color-text-faint);
}

.sudohint-example-legend i.target {
  background: var(--color-primary);
}

.sudohint-example-legend i.cause {
  background: var(--color-orange);
}

.sudohint-example-legend i.elimination {
  background: var(--color-error);
}

@media (max-width: 768px) {
  .technique-example-trigger {
    min-height: 30px;
  }

  .sudohint-example-dialog {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 16px;
    border-radius: 14px;
  }

  .sudohint-example-frame {
    padding: 10px;
  }

  .sudohint-example-frame-head span {
    font-size: 0.78rem;
  }
}

@media (max-width: 768px) {
  .technique-list {
    grid-template-columns: 1fr;
  }

  .technique-list .ref-item:nth-child(odd) {
    border-right: 0;
  }

  .technique-list .ref-item:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--color-divider);
  }

  .technique-list .ref-item:last-child {
    border-bottom: 0;
  }
}

@media (min-width: 769px) {
  :root {
    --cell-size: clamp(30px, min(6.5vw, calc((100dvh - 224px) / 9)), 58px);
  }

  .app-main {
    align-items: center;
  }

  .left-col {
    justify-content: center;
  }
}

@media (max-height: 720px) and (min-width: 769px) {
  .app-header {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .app-title::after {
    display: none;
  }

  .app-main {
    gap: 28px;
  }

  .controls-bar {
    padding: 3px;
  }

  .hint-empty {
    min-height: 190px;
    padding-block: 20px;
  }

}

@media (max-height: 720px) {
  .sudohint-import-dialog {
    gap: 8px;
    padding: 16px;
  }

  .sudohint-editor-grid {
    width: min(100%, 300px, calc(100dvh - 340px));
  }

  .sudohint-import-help {
    font-size: 0.76rem;
  }

  .sudohint-import-text {
    min-height: 50px;
  }
}

@media (max-width: 768px) {
  /* On narrow screens the app remains fixed-height; the editor and hint
     dialog are still available without introducing document scrolling. */
  .app-main {
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
    padding: 16px;
  }

  .left-col {
    min-height: 0;
  }

  .right-col {
    display: none;
    max-width: 100%;
  }

  .right-col:has(.hint-panel) {
    position: fixed;
    inset: 56px 0 0;
    z-index: 40;
    display: flex;
    padding: 18px 16px 24px;
    background: var(--color-bg, #f4f3ef);
  }

  .right-col:has(.hint-panel) .technique-ref,
  .right-col:has(.hint-panel) .hint-history {
    display: none;
  }

  .sudoku-wrapper,
  .sudoku-grid,
  .grid-placeholder {
    max-width: 100%;
  }

  :root {
    --cell-size: min(10.4vw, calc((100dvh - 205px) / 9));
  }
}

/* Final viewport behavior: let content define the page height and allow
   normal document scrolling when the reference section needs more room. */
html,
body {
  height: auto !important;
  min-height: 100%;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

body {
  min-height: 100dvh;
}

.app-root {
  height: auto !important;
  min-height: 100dvh;
  overflow: visible !important;
}

.app-main {
  grid-template-rows: auto auto;
  align-items: start;
  gap: 18px clamp(24px, 4vw, 56px);
  width: 100%;
  max-width: 1360px;
  padding: 24px clamp(16px, 3vw, 40px) 40px;
  overflow: visible !important;
}

.right-col {
  overflow: visible;
}

@media (min-width: 769px) {
  :root {
    --cell-size: clamp(32px, min(6.5vw, calc((100vw - 520px) / 9)), 58px);
  }

  .left-col {
    grid-column: 1;
    grid-row: 1;
  }

  .right-col {
    display: contents;
    max-width: none;
  }

  .right-col > .hint-panel,
  .right-col > .hint-empty {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .right-col > .technique-ref {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  .right-col > .hint-history {
    grid-column: 2;
    grid-row: 2;
  }
}

@media (max-width: 768px) {
  :root {
    --cell-size: clamp(30px, 10.4vw, 52px);
  }

  .app-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 24px;
    padding: 18px 16px 40px;
  }

  .left-col {
    grid-column: auto;
    grid-row: auto;
  }

  .right-col,
  .right-col:has(.hint-panel) {
    position: static;
    inset: auto;
    z-index: auto;
    display: flex;
    grid-column: auto;
    grid-row: auto;
    max-width: none;
    padding: 0;
    background: transparent;
  }

  .right-col:has(.hint-panel) .technique-ref,
  .right-col:has(.hint-panel) .hint-history {
    display: block;
  }
}
