/* =============================================
   Sudoku Printable Generator — Main Stylesheet
   ============================================= */

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

:root {
  --blue: #d65a31;
  --blue-dark: #8f3417;
  --blue-light: #fff2e8;
  --black: #1d1b19;
  --gray-700: #4d443f;
  --gray-500: #776d66;
  --gray-200: #d7cfc7;
  --gray-100: #f5efe7;
  --white: #fffdf8;
  --paper: #fffaf1;
  --canvas: #efe2cf;
  --olive: #26413c;
  --olive-soft: #dbe6df;
  --gold: #ebb54a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(58, 33, 18, 0.10);
  --shadow-tight: 0 10px 24px rgba(58, 33, 18, 0.08);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  color: var(--black);
  background:
    radial-gradient(circle at top left, rgba(235, 181, 74, 0.18), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(38, 65, 60, 0.12), transparent 26%),
    linear-gradient(180deg, #fffaf4 0%, #f6ecdf 100%);
  line-height: 1.6;
  font-size: 16px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(38, 65, 60, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(38, 65, 60, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.28), transparent 78%);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== HERO ===== */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(235, 181, 74, 0.24), transparent 20%),
    radial-gradient(circle at 82% 24%, rgba(255, 250, 241, 0.12), transparent 22%),
    linear-gradient(135deg, #18332f 0%, #26413c 40%, #d65a31 100%);
  color: #fff7ef;
  text-align: center;
  padding: 96px 20px 100px;
}

.hero::before,
.hero::after {
  content: '';
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.hero::before {
  width: 420px;
  height: 420px;
  right: -120px;
  top: -160px;
  background: rgba(255, 250, 241, 0.08);
}

.hero::after {
  width: 300px;
  height: 300px;
  left: -120px;
  bottom: -150px;
  background: rgba(235, 181, 74, 0.18);
}

.hero .container {
  position: relative;
  z-index: 1;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 247, 239, 0.25);
  border-radius: 999px;
  background: rgba(255, 247, 239, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero-kicker::before,
.hero-kicker::after {
  content: '';
  width: 12px;
  height: 1px;
  background: currentColor;
}

.hero h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  line-height: 1.05;
  max-width: 840px;
  margin-left: auto;
  margin-right: auto;
  text-wrap: balance;
}

.hero-sub {
  font-size: 1.125rem;
  opacity: 0.94;
  max-width: 650px;
  margin: 0 auto 36px;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.hero-highlights {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-highlights span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 247, 239, 0.1);
  border: 1px solid rgba(255, 247, 239, 0.16);
  font-size: 0.84rem;
  font-weight: 700;
}

.btn-hero {
  display: inline-block;
  background: var(--white);
  color: var(--olive);
  padding: 15px 30px;
  border-radius: 999px;
  font-size: 1.0625rem;
  font-weight: 800;
  text-decoration: none;
  transition: background 0.2s, transform 0.12s, box-shadow 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(16, 24, 21, 0.18);
}

.btn-hero:hover {
  background: #fff4d9;
  transform: translateY(-1px);
}

.btn-hero-secondary {
  background: rgba(255, 247, 239, 0.12);
  color: #fff7ef;
  border-color: rgba(255, 247, 239, 0.28);
}

.btn-hero-secondary:hover {
  background: rgba(255, 247, 239, 0.2);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.1s, opacity 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, #eb7d4f 100%);
  color: #fffaf4;
  box-shadow: 0 14px 24px rgba(214, 90, 49, 0.22);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
  box-shadow: 0 16px 28px rgba(143, 52, 23, 0.26);
}

.btn-secondary {
  background: rgba(255, 250, 241, 0.92);
  color: var(--olive);
  border: 1px solid rgba(38, 65, 60, 0.18);
  box-shadow: 0 10px 18px rgba(38, 65, 60, 0.08);
}
.btn-secondary:hover:not(:disabled) {
  background: #fff3e8;
  border-color: rgba(214, 90, 49, 0.24);
}

.btn-generate {
  display: block;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  padding: 15px;
  font-size: 1.0625rem;
  justify-content: center;
}

/* ===== SECTIONS ===== */
.section {
  position: relative;
  padding: 72px 0;
}

.section-white { background: rgba(255, 253, 248, 0.78); }
.section-gray  { background: rgba(245, 239, 231, 0.88); }

.section h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(1.85rem, 3.4vw, 2.5rem);
  font-weight: 700;
  text-align: center;
  margin-bottom: 18px;
  color: var(--black);
  letter-spacing: -0.03em;
}

.section h3,
.section h4 {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--black);
  letter-spacing: -0.02em;
}

.section > .container > h3 {
  font-size: clamp(1.3rem, 2vw, 1.65rem);
  margin-top: 34px;
  margin-bottom: 12px;
  text-align: center;
}

.section > .container > h4 {
  font-size: clamp(1.02rem, 1.4vw, 1.18rem);
  margin-top: 24px;
  margin-bottom: 10px;
  color: var(--olive);
  text-align: center;
}

.section > .container > h2 + p {
  max-width: 760px;
  margin: 0 auto 26px;
  text-align: center;
}

.section > .container > h3 + p,
.section > .container > h4 + p {
  margin-top: 0;
  margin-bottom: 18px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.section > .container > p + h3,
.section > .container > p + h4 {
  margin-top: 30px;
}

.section > .container > p,
.section .faq-body p,
.section .guide-card p,
.section .step p {
  color: var(--gray-700);
  text-align: center;
}

.section .guide-card,
.section .benefits-list li,
.section .faq-item,
.section .faq-body,
.section .faq-item summary {
  text-align: center;
}

/* ===== TOOL SECTION — Two-Column Layout ===== */
.tool-section {
  background:
    linear-gradient(180deg, rgba(38, 65, 60, 0.08), rgba(38, 65, 60, 0.02)),
    linear-gradient(180deg, #f9f3ea, #efe3d5);
  padding: 0;
  border-top: 1px solid var(--gray-200);
  border-bottom: 1px solid var(--gray-200);
}

.tool-wrapper {
  display: flex;
  align-items: stretch;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 640px;
  gap: 12px;
}

/* ---- LEFT: Preview Panel ---- */
.tool-preview-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 20px 28px 32px;
  gap: 10px;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.tool-preview-panel::before {
  content: 'Live sheet preview';
  align-self: flex-start;
  margin-bottom: 4px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(38, 65, 60, 0.08);
  color: var(--olive);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.preview-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--olive);
  font-weight: 800;
  min-height: 22px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preview-meta-row span:not(.meta-dot) {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.85);
  border: 1px solid rgba(38, 65, 60, 0.12);
}

.meta-dot { color: rgba(38, 65, 60, 0.35); }

.paper-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* White paper with shadow — A4 aspect ratio */
.paper-sheet {
  background: linear-gradient(180deg, #fffdfa 0%, #fff7ed 100%);
  box-shadow:
    0 18px 40px rgba(61, 34, 17, 0.12),
    0 6px 18px rgba(61, 34, 17, 0.08),
    0 0 0 1px rgba(38, 65, 60, 0.08);
  border-radius: 10px;
  /* Fill available height, maintain A4 ratio */
  height: min(calc(100vh - 130px), 800px);
  width: calc(min(calc(100vh - 130px), 800px) / 1.4142);
  overflow: hidden;
  position: relative;
  transition: width 0.2s, height 0.2s;
}

.paper-sheet::before {
  content: '';
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(214, 90, 49, 0.09);
  border-radius: 6px;
  pointer-events: none;
}

.paper-sheet.letter { width: calc(min(calc(100vh - 130px), 800px) / 1.2941); }
.paper-sheet.a5     { width: calc(min(calc(100vh - 130px), 800px) / 1.4142); }
.paper-sheet.legal  { width: calc(min(calc(100vh - 130px), 800px) / 1.6471); }
.paper-sheet.tabloid{ width: calc(min(calc(100vh - 130px), 800px) / 1.5455); }
.paper-sheet.a3     { width: calc(min(calc(100vh - 130px), 800px) / 1.4142); }

.paper-content {
  width: 100%;
  height: 100%;
  padding: 5% 5% 4%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.paper-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c4c9d4;
  font-size: 0.8125rem;
  letter-spacing: 0.03em;
}

.paper-hdr {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid rgba(38, 65, 60, 0.12);
  padding-bottom: 2.5%;
  margin-bottom: 3%;
  flex-shrink: 0;
}

.paper-hdr-title {
  font-size: clamp(0.45rem, 1.2vw, 0.8rem);
  font-weight: 700;
  color: var(--olive);
  letter-spacing: -0.01em;
}

.paper-hdr-sub {
  font-size: clamp(0.38rem, 0.9vw, 0.65rem);
  color: rgba(38, 65, 60, 0.55);
}

.paper-puzzle-grid {
  flex: 1;
  display: grid;
  gap: 2% 3%;
  grid-auto-rows: 1fr;
  min-height: 0;
}

.paper-puzzle-grid.pcols-1 { grid-template-columns: 1fr; }
.paper-puzzle-grid.pcols-2 { grid-template-columns: repeat(2, 1fr); }
.paper-puzzle-grid.pcols-3 { grid-template-columns: repeat(3, 1fr); }

.paper-content.large-print .paper-puzzle-grid {
  gap: 3.5% 4%;
}

.paper-content.large-print .paper-puzzle-item .sudoku-table td {
  font-size: clamp(0.34rem, 1vw, 0.72rem) !important;
}

/* ---- Variant: Diagonal (X-Sudoku) ---- */
.paper-puzzle-item .sudoku-table td.variant-diag {
  background-color: rgba(59, 130, 246, 0.10);
}

/* ---- Variant: Windoku (Hyper Sudoku) ---- */
.paper-puzzle-item .sudoku-table td.variant-window {
  background-color: rgba(139, 92, 246, 0.12);
}

/* ---- Variant: Odd/Even ---- */
.paper-puzzle-item .sudoku-table td.variant-odd {
  background: radial-gradient(circle, rgba(192,132,252,0.22) 65%, transparent 66%);
}
.paper-puzzle-item .sudoku-table td.variant-even {
  background: rgba(134,239,172,0.22);
}

/* ---- Variant: Center Dot ---- */
.paper-puzzle-item .sudoku-table td.variant-center-dot {
  background: radial-gradient(circle, rgba(160,140,220,0.20) 55%, transparent 60%);
}

/* ---- Variant: Asterisk ---- */
.paper-puzzle-item .sudoku-table td.variant-asterisk {
  background-color: rgba(255, 210, 120, 0.22);
}

/* ---- Variant: Kropki — dots between cells ---- */
.paper-puzzle-item .sudoku-table td.kr-hr-b,
.paper-puzzle-item .sudoku-table td.kr-hr-w { position: relative; }
.paper-puzzle-item .sudoku-table td.kr-hr-b::after,
.paper-puzzle-item .sudoku-table td.kr-hr-w::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 2;
}
.paper-puzzle-item .sudoku-table td.kr-hr-b::after {
  background: #222;
}
.paper-puzzle-item .sudoku-table td.kr-hr-w::after {
  background: #fff;
  border: 1.2px solid #333;
}
.paper-puzzle-item .sudoku-table td.kr-vr-b,
.paper-puzzle-item .sudoku-table td.kr-vr-w { position: relative; }
.paper-puzzle-item .sudoku-table td.kr-vr-b::before,
.paper-puzzle-item .sudoku-table td.kr-vr-w::before {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  z-index: 2;
}
.paper-puzzle-item .sudoku-table td.kr-vr-b::before {
  background: #222;
}
.paper-puzzle-item .sudoku-table td.kr-vr-w::before {
  background: #fff;
  border: 1.2px solid #333;
}

/* ---- Variant: Consecutive — bars between cells ---- */
.paper-puzzle-item .sudoku-table td.cs-hr { position: relative; }
.paper-puzzle-item .sudoku-table td.cs-hr::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 3px;
  background: #333;
  border-radius: 1px;
  z-index: 2;
}
.paper-puzzle-item .sudoku-table td.cs-vr { position: relative; }
.paper-puzzle-item .sudoku-table td.cs-vr::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 10px;
  background: #333;
  border-radius: 1px;
  z-index: 2;
}

/* ---- Variant: Greater Than — inequality signs between cells ---- */
.paper-puzzle-item .sudoku-table td.gt-hr-gt,
.paper-puzzle-item .sudoku-table td.gt-hr-lt { position: relative; }
.paper-puzzle-item .sudoku-table td.gt-hr-gt::after,
.paper-puzzle-item .sudoku-table td.gt-hr-lt::after {
  content: '>';
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 700;
  color: #555;
  z-index: 2;
  line-height: 1;
}
.paper-puzzle-item .sudoku-table td.gt-hr-lt::after {
  content: '<';
}
.paper-puzzle-item .sudoku-table td.gt-vr-gt,
.paper-puzzle-item .sudoku-table td.gt-vr-lt { position: relative; }
.paper-puzzle-item .sudoku-table td.gt-vr-gt::before,
.paper-puzzle-item .sudoku-table td.gt-vr-lt::before {
  content: '\2228';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: #555;
  z-index: 2;
  line-height: 1;
}
.paper-puzzle-item .sudoku-table td.gt-vr-lt::before {
  content: '\2227';
}

/* ---- Variant: Jigsaw — region colours (drawn inline, but fallback classes) ---- */
/* DOM colours are set via style.backgroundColor in js; these are print fallbacks */

.paper-content.font-small .paper-puzzle-item .sudoku-table td {
  font-size: clamp(0.20rem, 0.60vw, 0.42rem) !important;
}

.paper-content.font-large .paper-puzzle-item .sudoku-table td {
  font-size: clamp(0.38rem, 1.22vw, 0.82rem) !important;
}

.paper-puzzle-item {
  container-type: size;
  position: relative;
  overflow: hidden;
}

.paper-puzzle-item .puzzle-table-wrap {
  width: 100%; /* fallback for older browsers */
  width: min(100cqw, 92cqh);
  aspect-ratio: 1 / 1;
  position: relative;
}

/* SVG overlays (Thermo / Arrow) must scale with the container,
   not keep fixed pixel dimensions from the initial afterRender call. */
.paper-puzzle-item .puzzle-table-wrap > svg {
  width: 100%;
  height: 100%;
}

.paper-puzzle-item .sudoku-table {
  width: 100%;
  height: 100%;
}

.paper-puzzle-num {
  font-size: clamp(0.3rem, 0.8vw, 0.6rem);
  color: #ced4da;
  line-height: 1;
}

/* Sudoku table inside the paper preview —
   Inherits separate-border approach from base .sudoku-table.
   Overrides only sizes and colours for the miniature preview. */
.paper-puzzle-item .sudoku-table td {
  border-right: 1px solid #ddd !important;
  border-bottom: 1px solid #ddd !important;
  border-left: none !important;
  border-top: none !important;
  font-size: clamp(0.28rem, 0.9vw, 0.6rem) !important;
  font-weight: 700;
  padding: 0;
  line-height: 1;
}

/* Outer edges (preview) */
.paper-puzzle-item .sudoku-table td:first-child { border-left: 1px solid #333 !important; }
.paper-puzzle-item .sudoku-table tr:first-child td { border-top: 1px solid #333 !important; }
.paper-puzzle-item .sudoku-table td:last-child { border-right: 1px solid #333 !important; }
.paper-puzzle-item .sudoku-table tr:last-child td { border-bottom: 1px solid #333 !important; }

/* 3×3 box boundaries (preview) — use colour only, no width change */
.paper-puzzle-item .sudoku-table td.box-right  { border-right-color:  #333 !important; }
.paper-puzzle-item .sudoku-table td.box-bottom { border-bottom-color: #333 !important; }

.paper-more {
  margin-top: 2.5%;
  font-size: clamp(0.3rem, 0.75vw, 0.55rem);
  color: #ced4da;
  text-align: center;
  flex-shrink: 0;
}

/* ---- RIGHT: Settings Panel ---- */
.tool-settings-panel {
  flex: 0 0 360px;
  width: 360px;
  padding: 24px 24px 24px 16px;
  position: relative;
  top: auto;
  height: auto;
  max-height: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-self: flex-start;
}

.settings-card {
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(38, 65, 60, 0.10);
  border-radius: 26px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.settings-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 88px;
  background:
    radial-gradient(circle at 12% 30%, rgba(235, 181, 74, 0.16), transparent 32%),
    linear-gradient(135deg, rgba(38, 65, 60, 0.08), rgba(214, 90, 49, 0.10));
  pointer-events: none;
}

.settings-card > * {
  position: relative;
  z-index: 1;
}

.settings-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--olive);
  text-align: left;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 0;
}

.settings-title::after {
  content: 'Studio Controls';
  display: block;
  margin-top: 6px;
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(38, 65, 60, 0.58);
}

.settings-lead {
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-top: -2px;
  margin-bottom: 2px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 250, 241, 0.88);
  border: 1px solid rgba(38, 65, 60, 0.10);
  box-shadow: 0 8px 18px rgba(38, 65, 60, 0.05);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.setting-group:hover {
  border-color: rgba(214, 90, 49, 0.22);
  box-shadow: 0 12px 22px rgba(214, 90, 49, 0.08);
  transform: translateY(-1px);
}

.setting-note {
  font-size: 0.75rem;
  color: var(--gray-500);
  line-height: 1.45;
}

.s-label {
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--olive);
}

.paper-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(38, 65, 60, 0.18);
  background: rgba(255, 250, 241, 0.95);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: auto;
}
.paper-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(214, 90, 49, 0.12);
}

.setting-group .btn-group {
  gap: 8px;
}

#sizeGroup,
#difficultyGroup,
#fontSizeGroup,
#answersGroup,
#largePrintGroup,
#countGroup {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

#countGroup {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.setting-group .opt-btn {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 8px;
  font-size: 0.8125rem;
  text-align: center;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
}

.options-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.action-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.settings-feedback {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 16px 16px 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 243, 232, 0.98), rgba(255, 249, 241, 0.98));
  border: 1px solid rgba(214, 90, 49, 0.18);
  box-shadow: 0 12px 24px rgba(214, 90, 49, 0.08);
  color: var(--gray-700);
  text-align: center;
}

.settings-feedback[hidden] {
  display: none;
}

.settings-feedback.visible {
  animation: feedbackReveal 0.3s ease;
}

.settings-feedback p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
}

.settings-feedback a {
  color: var(--blue-dark);
  font-weight: 800;
  text-decoration: none;
}

.settings-feedback a:hover {
  text-decoration: underline;
}

@keyframes feedbackReveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 12px 14px;
  gap: 7px;
}

#downloadBtn,
#printBtn,
#refreshBtn {
  min-height: 48px;
}

.btn-ghost {
  background: rgba(255, 250, 241, 0.7);
  color: var(--gray-700);
  border: 1px dashed rgba(38, 65, 60, 0.24);
  font-weight: 700;
}

.btn-ghost:hover { background: #fff4e6; color: var(--olive); }

/* ===== BASE OPT-BTN (global — used in tool settings and standalone) ===== */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.opt-btn {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(38, 65, 60, 0.16);
  background: rgba(255, 250, 241, 0.95);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.15s;
  color: var(--gray-700);
}

.opt-btn:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
  transform: translateY(-1px);
}

.opt-btn.active {
  background: linear-gradient(135deg, var(--blue) 0%, #eb7d4f 100%);
  border-color: var(--blue-dark);
  color: #fffaf4;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(214, 90, 49, 0.22);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ===== SUDOKU TABLE (base) =====
   Uses border-collapse:separate + border-spacing:0 with single-side borders
   (right + bottom on each cell) to avoid subpixel rendering artifacts
   that plague border-collapse:collapse at small sizes. */
.sudoku-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
  border: none;
}

.sudoku-table td {
  text-align: center;
  vertical-align: middle;
  border: none;
  border-right: 1px solid #bbb;
  border-bottom: 1px solid #bbb;
  padding: 0;
  font-weight: 700;
  color: var(--black);
  line-height: 1;
}

/* Outer edges */
.sudoku-table td:first-child { border-left: 2px solid #111; }
.sudoku-table tr:first-child td { border-top: 2px solid #111; }
.sudoku-table td:last-child { border-right: 2px solid #111; }
.sudoku-table tr:last-child td { border-bottom: 2px solid #111; }

/* 3×3 box boundaries */
.sudoku-table td.box-right  { border-right:  2px solid #111; }
.sudoku-table td.box-bottom { border-bottom: 2px solid #111; }

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
}

.step {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.92), rgba(255, 246, 235, 0.98));
  border: 1px solid rgba(38, 65, 60, 0.10);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-tight);
}

.step-num {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--olive) 0%, #3d645d 100%);
  color: #fff9f2;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.step-title {
  font-size: 1.18rem;
  margin-bottom: 8px;
  font-family: 'Fraunces', Georgia, serif;
  color: var(--black);
  letter-spacing: -0.02em;
  font-weight: 700;
}

.step p  { color: var(--gray-700); font-size: 0.95rem; }

/* ===== DIFFICULTY GUIDE ===== */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}

.guide-card {
  border: 1px solid rgba(38, 65, 60, 0.12);
  border-radius: 24px;
  padding: 22px 18px;
  background: rgba(255, 252, 247, 0.92);
  box-shadow: var(--shadow-tight);
}

.guide-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guide-badge.easy   { background: #e2f2ea; color: #1f5948; }
.guide-badge.medium { background: #fdf0bf; color: #7a5311; }
.guide-badge.hard   { background: #fde1d3; color: #9b3f22; }
.guide-badge.evil   { background: #f8d8d1; color: #8c281d; }

.guide-card-title {
  font-size: 1.14rem;
  margin-bottom: 8px;
  color: var(--black);
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.guide-card p  { color: var(--gray-700); font-size: 0.9rem; line-height: 1.6; }

/* ===== BENEFITS ===== */
.benefits-list {
  list-style: none;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.benefits-list li {
  padding: 18px 22px;
  background: rgba(255, 252, 247, 0.92);
  border-radius: 20px;
  border-left: 4px solid var(--blue);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--gray-700);
  box-shadow: var(--shadow-tight);
}

.benefits-list li strong {
  display: block;
  margin-bottom: 2px;
  color: var(--black);
}

.benefit-title {
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
  margin-top: 30px;
  margin-bottom: 10px;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.02em;
  text-align: center;
}

/* ===== FAQ ===== */
.faq-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-item {
  border: 1px solid rgba(38, 65, 60, 0.12);
  border-radius: 20px;
  overflow: hidden;
  background: rgba(255, 252, 247, 0.92);
  box-shadow: var(--shadow-tight);
}

.faq-item summary {
  padding: 18px 20px;
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--black);
  user-select: none;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--blue);
  flex-shrink: 0;
  margin-left: 12px;
  transition: transform 0.2s;
}

.faq-item[open] summary::after { content: '−'; }

.faq-item summary:hover { background: #fff4e7; }

.faq-body { padding: 0 20px 16px; }
.faq-body p {
  color: var(--gray-700);
  font-size: 0.9375rem;
  line-height: 1.65;
}

/* ===== FOOTER ===== */
.footer {
  background:
    linear-gradient(180deg, #203833 0%, #182d29 100%);
  color: rgba(255, 247, 239, 0.78);
  text-align: center;
  padding: 36px 20px;
  font-size: 0.875rem;
  border-top: 1px solid rgba(255, 247, 239, 0.08);
}

/* ===== TYPE PICKER SECTION ===== */
.type-picker-section {
  background: rgba(255, 252, 247, 0.84);
  border-bottom: 2px solid var(--gray-200);
}

.tps-view {
  padding: 44px 0 40px;
}

.tps-view[hidden] { display: none; }

/* Grid view entrance */
#tpsGridView {
  animation: tpsFadeIn 0.22s ease;
}

/* Detail view slides in from right */
#tpsDetailView {
  animation: tpsSlideIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes tpsFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes tpsSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tps-header {
  text-align: center;
  margin-bottom: 32px;
}

.tps-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--black);
  margin-bottom: 10px;
}

.tps-sub {
  color: var(--gray-700);
  font-size: 1rem;
  max-width: 760px;
  margin: 0 auto;
}

/* ---- Type card grid ---- */
.type-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 0;
}

.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 18px 20px 16px;
  min-width: 110px;
  border: 1px solid rgba(38, 65, 60, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.95), rgba(255, 244, 229, 0.85));
  color: var(--black);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: center;
  line-height: 1.3;
  box-shadow: var(--shadow-tight);
}

.type-card:hover {
  border-color: var(--blue);
  background: #fff2e8;
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow: 0 14px 28px rgba(214, 90, 49, 0.14);
}

.type-card.active {
  border-color: var(--blue-dark);
  background: linear-gradient(135deg, #fff2e8 0%, #ffe5d1 100%);
  color: var(--blue-dark);
  box-shadow: 0 0 0 4px rgba(214, 90, 49, 0.10), 0 16px 28px rgba(214, 90, 49, 0.12);
}

.type-card-icon {
  font-size: 1.625rem;
  line-height: 1;
}

.type-card-name {
  font-weight: 700;
  font-size: 0.9375rem;
}

.type-card-tagline {
  font-size: 0.7rem;
  color: var(--gray-500);
  line-height: 1.45;
  max-width: 100px;
}

.type-card.active .type-card-tagline { color: #b24a2c; }

/* ---- Detail view ---- */
.tps-detail-container {
  max-width: 680px;
}

.tps-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid rgba(38, 65, 60, 0.14);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 800;
  color: var(--gray-700);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-bottom: 36px;
  background: rgba(255, 252, 247, 0.92);
}

.tps-back-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
}

.tps-detail-hero {
  text-align: center;
  margin-bottom: 36px;
}

.tps-detail-icon {
  display: block;
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 16px;
  filter: drop-shadow(0 10px 18px rgba(214, 90, 49, 0.18));
}

.tps-detail-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--black);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.tps-detail-tagline {
  color: var(--gray-700);
  font-size: 1rem;
}

.tps-detail-rules {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tps-detail-rules li {
  position: relative;
  padding: 14px 18px 14px 44px;
  background: rgba(255, 252, 247, 0.92);
  border-left: 3px solid var(--blue);
  border-radius: 0 18px 18px 0;
  color: var(--gray-700);
  font-size: 0.9375rem;
  line-height: 1.6;
  box-shadow: var(--shadow-tight);
}

.tps-detail-rules li::before {
  content: '→';
  position: absolute;
  left: 16px;
  top: 14px;
  color: var(--blue);
  font-weight: 700;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 800px) {
  body::before {
    background-size: 28px 28px;
  }

  .tool-wrapper {
    flex-direction: column;
    gap: 0;
  }

  .tool-preview-panel {
    padding: 24px 20px 12px;
    position: static;
    height: auto;
    max-height: none;
  }

  .paper-stage {
    height: 65vw;
    max-height: 380px;
  }

  .paper-sheet {
    height: 100% !important;
    width: auto !important;
    aspect-ratio: auto;
  }

  .tool-settings-panel {
    flex: none;
    width: 100%;
    padding: 0 20px 32px;
    position: static;
    height: auto;
    max-height: none;
    justify-content: flex-start;
  }

  .section > .container > h3 {
    margin-top: 28px;
  }
}

@media (max-width: 640px) {
  .hero { padding: 68px 20px 74px; }
  .hero-actions { flex-direction: column; align-items: stretch; max-width: 320px; margin-left: auto; margin-right: auto; }
  .hero-highlights { gap: 8px; }
  .hero-highlights span { font-size: 0.77rem; }
  .section { padding: 48px 0; }
  .section > .container > h2 + p {
    margin-bottom: 22px;
  }
  .section > .container > h3 {
    font-size: 1.22rem;
    margin-top: 24px;
    margin-bottom: 10px;
  }
  .section > .container > h4 {
    margin-top: 18px;
    margin-bottom: 8px;
  }
  .type-card-grid { gap: 8px; }
  .type-card { min-width: 90px; padding: 14px 12px; }
  .type-card .type-card-icon { font-size: 1.6rem; }
  .type-card .type-card-name { font-size: 0.78rem; }
  .tps-detail-icon { font-size: 3rem; }
  .tps-detail-name { font-size: 1.4rem; }
  .tps-detail-rules li { padding: 16px 16px 16px 38px; }
  #sizeGroup,
  #difficultyGroup,
  #fontSizeGroup,
  #answersGroup,
  #largePrintGroup,
  #countGroup {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
