:root {
  --navy: #17324d;
  --navy-2: #234867;
  --cream: #fff8e8;
  --paper: #fffdf7;
  --yellow: #ffd95a;
  --yellow-2: #ffe99d;
  --coral: #ff7a70;
  --turquoise: #54d4d0;
  --lime: #b7dc6c;
  --pink: #f3a9cc;
  --blue: #91c9ff;
  --muted: #6e7c87;
  --shadow: 0 10px 0 rgba(23, 50, 77, .12);
  --soft-shadow: 0 7px 24px rgba(23, 50, 77, .12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--navy);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 1px 1px, rgba(23, 50, 77, .09) 1.2px, transparent 1.3px) 0 0 / 20px 20px,
    linear-gradient(180deg, #fff8e8 0%, #fffaf1 60%, #f8fbff 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(145, 201, 255, .95);
  outline-offset: 3px;
}

button:active {
  transform: translateY(2px);
}

.page-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.app-header {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  padding: 30px 36px;
  border: 4px solid var(--navy);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 83% 28%, rgba(255,255,255,.42) 0 7%, transparent 7.4%),
    radial-gradient(circle at 91% 50%, rgba(255,255,255,.26) 0 12%, transparent 12.4%),
    var(--yellow);
  box-shadow: var(--shadow);
}

.app-header::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -70px;
  width: 260px;
  height: 180px;
  border: 4px solid var(--navy);
  border-radius: 50%;
  background: var(--turquoise);
  opacity: .75;
}

.brand-chip {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  border: 3px solid var(--navy);
  border-radius: 999px;
  background: rgba(255,255,255,.78);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .08em;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border: 3px solid var(--navy);
  border-radius: 50%;
  background: var(--coral);
}


.header-actions {
  position: absolute;
  z-index: 6;
  top: 24px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 7px 12px;
  border: 3px solid var(--navy);
  border-radius: 12px;
  background: var(--paper);
  color: var(--navy);
  font-size: .78rem;
  font-weight: 950;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(23,50,77,.13);
  cursor: pointer;
}

.header-action:hover,
.header-action:focus-visible {
  transform: translateY(-1px);
}

.header-action-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: var(--yellow);
  font-size: .77rem;
  font-weight: 1000;
}

.last-bell-link {
  background: #dff0ff;
}

.last-bell-link img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.header-copy {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin-top: 20px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  font-size: .74rem;
  font-weight: 950;
  letter-spacing: .16em;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: .88;
  letter-spacing: -.055em;
  text-transform: uppercase;
}

.app-header h1 span {
  display: inline-block;
  padding: 0 .08em .05em;
  border: 4px solid var(--navy);
  border-radius: 16px;
  background: var(--paper);
  transform: rotate(-1.5deg);
}

.tagline {
  margin: 16px 0 0;
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 800;
}

.header-decoration {
  position: absolute;
  z-index: 3;
  right: 31px;
  top: auto;
  bottom: 25px;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: rotate(4deg);
}

.header-decoration span {
  display: grid;
  place-items: center;
  min-width: 56px;
  height: 48px;
  padding: 0 12px;
  border: 3px solid var(--navy);
  border-radius: 12px;
  background: var(--paper);
  font-size: 1.2rem;
  font-weight: 950;
  box-shadow: 0 5px 0 rgba(23,50,77,.13);
}

.header-decoration span:nth-of-type(2) {
  background: var(--pink);
}

.header-decoration span:nth-of-type(3) {
  background: var(--lime);
}

.header-decoration i {
  width: 10px;
  height: 10px;
  border: 3px solid var(--navy);
  border-radius: 50%;
  background: var(--coral);
}

.setup-panel,
.results-panel {
  margin-top: 24px;
  padding: clamp(22px, 4vw, 34px);
  border: 4px solid var(--navy);
  border-radius: var(--radius-xl);
  background: rgba(255,253,247,.94);
  box-shadow: var(--shadow);
}

.section-heading,
.results-topline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading h2,
.results-topline h2,
.dialog-topbar h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1;
  letter-spacing: -.035em;
}

.bank-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  border: 3px solid var(--navy);
  border-radius: 13px;
  background: var(--lime);
  box-shadow: 0 4px 0 rgba(23,50,77,.12);
}

.bank-badge strong {
  font-size: 1.35rem;
  line-height: 1;
}

.bank-badge span {
  max-width: 64px;
  font-size: .68rem;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr 1.2fr;
  gap: 16px;
}

.setting-card {
  min-width: 0;
  margin: 0;
  padding: 20px;
  border: 3px solid var(--navy);
  border-radius: var(--radius-lg);
  background: #fff;
}

.setting-syllables {
  background: linear-gradient(180deg, #fff 0%, #fff9e6 100%);
}

.setting-quantity {
  background: linear-gradient(180deg, #fff 0%, #f0fcfc 100%);
}

.setting-difficulty {
  background: linear-gradient(180deg, #fff 0%, #fff3f7 100%);
}

.setting-card legend {
  padding: 0 7px;
  font-size: 1.05rem;
  font-weight: 950;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 29px;
  height: 29px;
  margin-right: 5px;
  border: 2px solid var(--navy);
  border-radius: 9px;
  background: var(--yellow);
  font-size: .85rem;
}

.setting-help {
  min-height: 36px;
  margin: 2px 0 16px;
  color: #586976;
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.3;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.choice-btn,
.pill-btn {
  border: 3px solid var(--navy);
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(23,50,77,.18);
  cursor: pointer;
  font-weight: 950;
}

.choice-btn {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  font-size: 1.3rem;
}

.syllable-btn:nth-child(1) { background: #ffd9d5; }
.syllable-btn:nth-child(2) { background: #d7f6f4; }
.syllable-btn:nth-child(3) { background: #fff0ab; }
.syllable-btn:nth-child(4) { background: #e6f3c8; }
.syllable-btn:nth-child(5) { background: #f9d9ea; }

.choice-btn.is-selected,
.pill-btn.is-selected {
  color: #fff;
  background: var(--navy);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.2), 0 4px 0 rgba(23,50,77,.18);
  transform: translateY(-2px);
}

.pill-btn {
  min-width: 54px;
  height: 42px;
  padding: 0 15px;
  border-radius: 999px;
}

.custom-quantity {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
  font-size: .8rem;
  font-weight: 900;
}

.custom-quantity input {
  width: 100px;
  height: 40px;
  padding: 0 10px;
  border: 3px solid var(--navy);
  border-radius: 10px;
  background: #fff;
  color: var(--navy);
  font-weight: 900;
}

.difficulty-stack {
  display: grid;
  gap: 8px;
}

.difficulty-btn {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 51px;
  padding: 8px 11px;
  border: 3px solid var(--navy);
  border-radius: 13px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(23,50,77,.12);
}

.difficulty-btn .difficulty-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 2px solid var(--navy);
  border-radius: 8px;
  background: var(--yellow);
  font-size: .72rem;
}

.difficulty-btn strong,
.difficulty-btn small {
  display: block;
}

.difficulty-btn strong {
  font-size: .89rem;
}

.difficulty-btn small {
  margin-top: 2px;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 750;
}

.difficulty-btn.is-selected {
  background: var(--navy);
  color: #fff;
}

.difficulty-btn.is-selected small {
  color: rgba(255,255,255,.78);
}

.difficulty-btn.is-selected .difficulty-icon {
  background: var(--turquoise);
}

.generate-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 20px;
}

.generate-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-width: min(100%, 360px);
  padding: 16px 19px 16px 23px;
  border: 4px solid var(--navy);
  border-radius: 17px;
  background: var(--yellow);
  box-shadow: 0 7px 0 rgba(23,50,77,.18);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: .03em;
}

.generate-btn:hover {
  background: #ffe47c;
}

.generate-arrow {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--navy);
  border-radius: 10px;
  background: #fff;
  font-size: 1.25rem;
}

.mini-note {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}

.inline-message {
  min-height: 18px;
  margin-top: 11px;
  color: #a43e37;
  font-size: .78rem;
  font-weight: 850;
}

.results-panel[hidden] {
  display: none;
}

.set-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.summary-chip {
  padding: 7px 11px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--yellow-2);
  font-size: .72rem;
  font-weight: 900;
}

.summary-chip:nth-child(2) {
  background: #d7f6f4;
}

.summary-chip:nth-child(3) {
  background: #f9d9ea;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 18px;
  padding: 12px;
  border: 3px solid var(--navy);
  border-radius: 17px;
  background: #eef7ff;
}

.tool-btn {
  min-height: 40px;
  padding: 8px 13px;
  border: 2px solid var(--navy);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(23,50,77,.11);
}

.tool-btn:hover {
  background: #f8fbff;
}

.primary-tool {
  background: var(--yellow);
}

.print-tool {
  margin-left: auto;
  background: var(--lime);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 13px;
}

.word-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  min-height: 137px;
  padding: 18px 16px;
  overflow: hidden;
  border: 3px solid var(--navy);
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(23,50,77,.13);
  text-align: center;
}

.word-card::before {
  content: attr(data-number);
  position: absolute;
  left: 9px;
  top: 9px;
  display: grid;
  place-items: center;
  min-width: 27px;
  height: 27px;
  padding: 0 6px;
  border: 2px solid var(--navy);
  border-radius: 8px;
  background: var(--yellow);
  font-size: .68rem;
  font-weight: 950;
}

.word-card::after {
  content: attr(data-count) " syll.";
  position: absolute;
  right: 10px;
  top: 11px;
  color: var(--muted);
  font-size: .64rem;
  font-weight: 900;
  opacity: 0;
  transition: opacity .16s ease;
}

.word-card.is-revealed::after {
  opacity: 1;
}

.card-word {
  margin-top: 9px;
  font-size: clamp(1.5rem, 3vw, 2.15rem);
  font-weight: 950;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.card-split {
  min-height: 34px;
  margin-top: 10px;
  opacity: 0;
  transform: translateY(5px);
  transition: opacity .18s ease, transform .18s ease;
}

.word-card.is-revealed .card-word {
  color: #83909b;
  font-size: clamp(1.05rem, 2vw, 1.28rem);
}

.word-card.is-revealed .card-split {
  opacity: 1;
  transform: translateY(0);
}

.syllable-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.syllable-piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 33px;
  padding: 4px 9px;
  border: 2px solid var(--navy);
  border-radius: 9px;
  background: var(--yellow-2);
  font-size: .94rem;
  font-weight: 950;
}

.syllable-piece:nth-child(5n + 2) { background: #d7f6f4; }
.syllable-piece:nth-child(5n + 3) { background: #ffd9d5; }
.syllable-piece:nth-child(5n + 4) { background: #e6f3c8; }
.syllable-piece:nth-child(5n + 5) { background: #f9d9ea; }

.syllable-dot {
  font-weight: 950;
}

.results-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

kbd {
  display: inline-block;
  min-width: 22px;
  margin: 0 2px;
  padding: 2px 5px;
  border: 1px solid #aab5bf;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: .68rem;
  text-align: center;
}

.app-footer {
  padding: 18px 5px 0;
  color: #71808a;
  font-size: .67rem;
  font-weight: 750;
  text-align: center;
}

.app-footer p {
  margin: 3px 0;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(10, 28, 43, .78);
  backdrop-filter: blur(6px);
}

.overlay.is-open {
  display: grid;
}

.flash-shell {
  display: flex;
  flex-direction: column;
  width: min(1100px, 96vw);
  height: min(780px, 93vh);
  padding: 20px;
  border: 4px solid var(--navy);
  border-radius: 26px;
  background:
    radial-gradient(circle at 1px 1px, rgba(23,50,77,.08) 1px, transparent 1.2px) 0 0 / 20px 20px,
    var(--yellow);
  box-shadow: 0 18px 60px rgba(0,0,0,.28);
}

.flash-topbar,
.dialog-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.flash-label {
  display: inline-block;
  padding: 6px 10px;
  border: 2px solid var(--navy);
  border-radius: 9px;
  background: #fff;
  font-size: .75rem;
  font-weight: 950;
  letter-spacing: .12em;
}

.flash-counter {
  margin-left: 9px;
  font-size: .85rem;
  font-weight: 900;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid var(--navy);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

.flash-card {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin: 17px 0;
  padding: 30px;
  border: 4px solid var(--navy);
  border-radius: 24px;
  background: #fffdf7;
  cursor: pointer;
  box-shadow: inset 0 0 0 9px rgba(255,217,90,.2);
}

.flash-word {
  max-width: 100%;
  font-size: clamp(3.4rem, 10vw, 8.5rem);
  font-weight: 950;
  line-height: .95;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}

.flash-card.is-revealed .flash-word {
  margin-bottom: 24px;
  color: #82909a;
  font-size: clamp(2rem, 5vw, 4rem);
}

.flash-split {
  display: none;
  max-width: 100%;
}

.flash-card.is-revealed .flash-split {
  display: block;
}

.flash-split .syllable-piece {
  min-height: 54px;
  padding: 7px 15px;
  border-width: 3px;
  border-radius: 13px;
  font-size: clamp(1.7rem, 4vw, 3.2rem);
}

.flash-prompt {
  position: absolute;
  bottom: 128px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 850;
}

.flash-card.is-revealed .flash-prompt {
  display: none;
}

.flash-controls {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 1.2fr) 1fr;
  gap: 10px;
}

.flash-controls button {
  min-height: 50px;
  border: 3px solid var(--navy);
  border-radius: 13px;
  background: #fff;
  cursor: pointer;
  font-weight: 950;
}

.flash-controls .flash-reveal-btn {
  background: var(--turquoise);
}

/* Printable dialog */
.print-dialog {
  width: min(1060px, 96vw);
  max-height: 94vh;
  overflow: auto;
  padding: 22px;
  border: 4px solid var(--navy);
  border-radius: 24px;
  background: #f4f7fa;
  box-shadow: 0 18px 60px rgba(0,0,0,.28);
}

.dark-icon {
  background: var(--yellow);
}

.print-options {
  display: flex;
  align-items: end;
  gap: 18px;
  margin: 18px 0;
  padding: 14px;
  border: 3px solid var(--navy);
  border-radius: 15px;
  background: #fff;
}

.print-options > label:first-child {
  flex: 1;
}

.print-options label > span:first-child {
  display: block;
  margin-bottom: 6px;
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.print-options input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 2px solid var(--navy);
  border-radius: 9px;
  color: var(--navy);
  font-weight: 850;
}

.answer-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 850;
}

.answer-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  width: 47px;
  height: 27px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: #d9e0e6;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 17px;
  height: 17px;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}

.answer-toggle input:checked + .toggle-ui {
  background: var(--lime);
}

.answer-toggle input:checked + .toggle-ui::after {
  transform: translateX(20px);
}

.preview-stage {
  display: grid;
  gap: 18px;
}

.print-page {
  position: relative;
  width: min(100%, 794px);
  min-height: 1123px;
  margin: 0 auto;
  padding: 54px 56px 44px;
  border: 1px solid #ccd4db;
  background: white;
  box-shadow: var(--soft-shadow);
  color: var(--navy);
}

.print-brand {
  display: inline-block;
  padding: 6px 9px;
  border: 2px solid var(--navy);
  border-radius: 7px;
  background: var(--yellow-2);
  font-size: .61rem;
  font-weight: 950;
  letter-spacing: .1em;
}

.print-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 15px;
  border-bottom: 4px solid var(--navy);
}

.print-title-row h1 {
  margin: 0;
  font-size: 2.3rem;
  line-height: 1;
  letter-spacing: -.04em;
}

.print-title-row p {
  margin: 6px 0 0;
  color: #6f7f8b;
  font-size: .74rem;
  font-weight: 800;
}

.name-lines {
  display: grid;
  gap: 10px;
  min-width: 190px;
  font-size: .72rem;
  font-weight: 850;
}

.name-lines span {
  display: flex;
  align-items: end;
  gap: 7px;
}

.name-lines b {
  display: block;
  flex: 1;
  height: 18px;
  border-bottom: 1.7px solid var(--navy);
}

.print-instruction {
  margin: 17px 0;
  padding: 10px 12px;
  border: 2px solid var(--navy);
  border-radius: 10px;
  background: #f7fbff;
  font-size: .78rem;
  font-weight: 800;
}

.worksheet-grid,
.answer-grid {
  margin: 0;
  padding-left: 30px;
  column-count: 2;
  column-gap: 44px;
}

.worksheet-grid li,
.answer-grid li {
  break-inside: avoid;
  margin: 0 0 13px;
  padding-left: 5px;
  font-size: .85rem;
  font-weight: 850;
}

.worksheet-item-word {
  display: block;
  margin-bottom: 6px;
}

.response-line {
  display: block;
  width: 100%;
  height: 18px;
  border-bottom: 1.5px solid #80909d;
}

.answer-grid li {
  margin-bottom: 9px;
}

.answer-word {
  font-weight: 950;
}

.answer-arrow {
  margin: 0 7px;
  color: #8a98a3;
}

.answer-seg {
  font-weight: 850;
  letter-spacing: .02em;
}

.answer-page {
  min-height: 900px;
}

.answer-page.is-hidden {
  display: none;
}

.answer-title-row {
  margin-bottom: 20px;
}

.print-footer {
  position: absolute;
  left: 56px;
  right: 56px;
  bottom: 25px;
  padding-top: 8px;
  border-top: 1px solid #cbd5dc;
  color: #7a8994;
  font-size: .58rem;
  font-weight: 800;
  text-align: center;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.dialog-actions button {
  min-height: 46px;
  padding: 9px 18px;
  border: 3px solid var(--navy);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 950;
}

.secondary-action {
  background: #fff;
}

.print-action {
  background: var(--yellow);
}

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

  .setting-help {
    min-height: 0;
  }

  .app-header {
    min-height: 245px;
  }

  .header-decoration {
    right: 18px;
    top: auto;
    bottom: 18px;
  }

  .print-tool {
    margin-left: 0;
  }

  .results-footer {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 16px, 1180px);
    padding-top: 8px;
  }

  .app-header,
  .setup-panel,
  .results-panel {
    border-width: 3px;
    border-radius: 20px;
  }

  .app-header {
    padding: 22px 20px;
  }

  .brand-chip {
    font-size: .61rem;
  }

  .header-decoration {
    transform: scale(.82) rotate(4deg);
    transform-origin: right bottom;
  }

  .setup-panel,
  .results-panel {
    padding: 19px 15px;
  }

  .section-heading,
  .results-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .bank-badge {
    align-self: flex-start;
  }

  .generate-wrap {
    align-items: stretch;
    flex-direction: column;
  }

  .generate-btn {
    width: 100%;
  }

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

  .word-card {
    min-height: 124px;
    padding: 17px 9px 12px;
  }

  .card-word {
    font-size: 1.3rem;
  }

  .syllable-piece {
    padding: 3px 6px;
    font-size: .76rem;
  }

  .keyboard-hint {
    display: none;
  }

  .flash-shell {
    width: 100%;
    height: 96vh;
    padding: 13px;
    border-width: 3px;
    border-radius: 19px;
  }

  .flash-card {
    margin: 12px 0;
    padding: 17px;
    border-width: 3px;
  }

  .flash-controls {
    grid-template-columns: 1fr 1fr;
  }

  .flash-controls .flash-reveal-btn {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .print-dialog {
    padding: 14px;
  }

  .print-options {
    align-items: stretch;
    flex-direction: column;
  }

  .print-page {
    min-height: 900px;
    padding: 32px 26px;
  }

  .print-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .name-lines {
    width: 100%;
  }

  .worksheet-grid,
  .answer-grid {
    column-count: 1;
  }

  .print-footer {
    left: 26px;
    right: 26px;
  }
}

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

@media print {
  @page {
    size: A4 portrait;
    margin: 11mm;
  }

  html,
  body {
    background: #fff !important;
  }

  body * {
    visibility: hidden !important;
  }

  #printOverlay,
  #printOverlay *,
  .preview-stage,
  .preview-stage * {
    visibility: visible !important;
  }

  #printOverlay {
    position: static !important;
    display: block !important;
    padding: 0 !important;
    background: #fff !important;
    backdrop-filter: none !important;
  }

  .print-dialog {
    width: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .dialog-topbar,
  .print-options,
  .dialog-actions {
    display: none !important;
  }

  .preview-stage {
    display: block !important;
  }

  .print-page {
    width: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 5mm 4mm 7mm !important;
    border: 0 !important;
    box-shadow: none !important;
    page-break-after: always;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  .answer-page.is-hidden {
    display: none !important;
  }

  .print-footer {
    position: static !important;
    margin-top: 8mm;
  }

  .worksheet-grid,
  .answer-grid {
    column-count: 2;
  }

  .worksheet-grid li {
    margin-bottom: 5mm;
  }

  .response-line {
    height: 6mm;
  }

  .print-brand,
  .print-instruction {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}




/* ===== v17.5.1: first-visit tutorial prompt ===== */
.first-run-layer {
  position: fixed;
  inset: 0;
  z-index: 5200;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(23, 50, 77, .68);
  backdrop-filter: blur(5px);
}

.first-run-layer.is-open {
  display: grid;
}

.first-run-card {
  width: min(500px, calc(100vw - 32px));
  padding: 24px 24px 22px;
  border: 4px solid var(--navy);
  border-radius: 22px;
  background:
    radial-gradient(circle at 1px 1px, rgba(23,50,77,.06) 1px, transparent 1.2px) 0 0 / 18px 18px,
    var(--paper);
  box-shadow: 0 14px 0 rgba(0,0,0,.16), 0 24px 70px rgba(0,0,0,.24);
  text-align: center;
}

.first-run-badge {
  display: inline-flex;
  padding: 6px 11px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--yellow);
  font-size: .68rem;
  font-weight: 1000;
  letter-spacing: .12em;
}

.first-run-card h2 {
  margin: 14px 0 7px;
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  letter-spacing: -.035em;
}

.first-run-card p {
  margin: 0 auto;
  max-width: 420px;
  font-size: .98rem;
  font-weight: 750;
  line-height: 1.5;
}

.first-run-note {
  margin-top: 10px !important;
  color: var(--muted);
  font-size: .82rem !important;
}

.first-run-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
  margin-top: 20px;
}

.first-run-actions button {
  min-height: 48px;
  padding: 9px 14px;
  border: 3px solid var(--navy);
  border-radius: 12px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 950;
}

.first-run-skip {
  background: #fff;
}

.first-run-start {
  background: var(--yellow);
  box-shadow: 0 4px 0 rgba(23,50,77,.16);
}

.first-run-actions button:focus-visible {
  outline: 4px solid var(--turquoise);
  outline-offset: 3px;
}

@media (max-width: 520px) {
  .first-run-card {
    padding: 20px 17px 18px;
  }

  .first-run-actions {
    grid-template-columns: 1fr;
  }
}


/* ===== v1.3: tutorial mode + Last Bell navigation ===== */
.tutorial-layer {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  pointer-events: none;
}

.tutorial-layer.is-open {
  display: block;
}

.tutorial-shade {
  position: absolute;
  inset: 0;
  background: rgba(23, 50, 77, .16);
  pointer-events: auto;
}

.tutorial-spotlight {
  position: fixed;
  z-index: 5002;
  border: 5px solid var(--yellow);
  border-radius: 18px;
  box-shadow:
    0 0 0 4px var(--navy),
    0 0 0 9999px rgba(23, 50, 77, .56);
  transition: left .22s ease, top .22s ease, width .22s ease, height .22s ease;
  pointer-events: none;
}

.tutorial-card {
  position: fixed;
  z-index: 5004;
  left: 50%;
  bottom: 24px;
  width: min(430px, calc(100vw - 28px));
  padding: 18px 19px 17px;
  border: 4px solid var(--navy);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 10px 0 rgba(0,0,0,.16);
  transform: translateX(-50%);
  pointer-events: auto;
}

.tutorial-card.place-top {
  top: 22px;
  bottom: auto;
}

.tutorial-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-badge {
  display: inline-flex;
  padding: 5px 9px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: var(--yellow);
  font-size: .64rem;
  font-weight: 1000;
  letter-spacing: .11em;
}

.tutorial-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: #fff;
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

.tutorial-progress {
  display: flex;
  gap: 5px;
  margin-top: 13px;
}

.tutorial-progress span {
  flex: 1;
  height: 6px;
  border: 1.5px solid var(--navy);
  border-radius: 999px;
  background: #fff;
}

.tutorial-progress span.is-done {
  background: var(--turquoise);
}

.tutorial-progress span.is-current {
  background: var(--yellow);
}

.tutorial-step-label {
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: .67rem;
  font-weight: 950;
  letter-spacing: .12em;
}

.tutorial-card h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -.025em;
}

.tutorial-card > p:not(.tutorial-step-label) {
  margin: 8px 0 0;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.45;
}

.tutorial-actions {
  display: flex;
  justify-content: space-between;
  gap: 9px;
  margin-top: 16px;
}

.tutorial-actions button {
  min-height: 42px;
  padding: 8px 15px;
  border: 2.5px solid var(--navy);
  border-radius: 11px;
  font-size: .82rem;
  font-weight: 950;
  cursor: pointer;
}

.tutorial-back {
  background: #fff;
}

.tutorial-next {
  margin-left: auto;
  background: var(--yellow);
  box-shadow: 0 4px 0 rgba(23,50,77,.13);
}

.tutorial-tool {
  background: var(--yellow-2) !important;
}

.last-bell-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dff0ff !important;
  text-decoration: none;
}

@media (max-width: 760px) {
  .header-actions {
    top: 16px;
    right: 16px;
  }

  .header-action {
    min-height: 36px;
    padding: 6px 9px;
    font-size: .68rem;
  }

  .header-action img {
    width: 20px;
    height: 20px;
  }

  .tutorial-card {
    bottom: 12px;
    padding: 15px;
  }

  .tutorial-card.place-top {
    top: 12px;
  }
}

@media print {
  .tutorial-layer,
  .header-actions,
  .tutorial-tool,
  .last-bell-tool {
    display: none !important;
  }
}

/* ===== v1.2: dedicated one-screen classroom results ===== */
body.results-mode {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

body.results-mode .page-shell {
  width: 100%;
  height: 100dvh;
  padding: 10px;
}

body.results-mode .app-header,
body.results-mode .setup-panel,
body.results-mode .app-footer {
  display: none;
}

body.results-mode main {
  height: 100%;
}

body.results-mode .results-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 13px 16px 10px;
  overflow: hidden;
  border-width: 3px;
  border-radius: 20px;
  box-shadow: none;
}

body.results-mode .results-topline {
  align-items: center;
  margin-bottom: 8px;
}

body.results-mode .results-topline .section-kicker {
  margin-bottom: 3px;
  font-size: .62rem;
}

body.results-mode .results-topline h2 {
  font-size: clamp(1.45rem, 2.6vw, 2.1rem);
}

body.results-mode .summary-chip {
  padding: 5px 9px;
  font-size: .66rem;
}

body.results-mode .toolbar {
  flex-wrap: nowrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  padding: 7px;
  border-width: 2px;
  border-radius: 13px;
}

body.results-mode .tool-btn {
  min-height: 34px;
  padding: 6px 10px;
  border-width: 2px;
  border-radius: 9px;
  font-size: .71rem;
  white-space: nowrap;
}

body.results-mode .settings-tool {
  background: #fff;
}

body.results-mode .print-tool {
  margin-left: 0;
}

body.results-mode .last-bell-tool {
  margin-left: auto;
}

body.results-mode .word-grid {
  --grid-cols: 5;
  --grid-rows: 2;
  --grid-gap: 9px;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows), minmax(0, 1fr));
  gap: var(--grid-gap);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

body.results-mode .word-card {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 22px 10px 9px;
  border-width: 2.5px;
  border-radius: 15px;
  box-shadow: 0 3px 0 rgba(23,50,77,.13);
}

body.results-mode .word-card::before {
  left: 7px;
  top: 6px;
  min-width: 25px;
  height: 23px;
  padding: 0 5px;
  border-width: 1.8px;
  border-radius: 7px;
  font-size: .61rem;
}

body.results-mode .word-card::after {
  right: 8px;
  top: 8px;
  font-size: .57rem;
}

body.results-mode .card-word {
  max-width: 100%;
  margin-top: 2px;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  font-size: var(--word-size, 2rem);
  line-height: 1;
}

body.results-mode .word-card.is-revealed .card-word {
  font-size: var(--revealed-word-size, 1rem);
  line-height: 1;
}

body.results-mode .card-split {
  min-height: 0;
  margin-top: 6px;
}

body.results-mode .syllable-display {
  gap: 3px;
}

body.results-mode .syllable-piece {
  min-height: 25px;
  padding: 2px 6px;
  border-width: 1.7px;
  border-radius: 7px;
  font-size: clamp(.62rem, 1.2vw, .82rem);
}

body.results-mode .results-footer {
  align-items: center;
  margin-top: 7px;
  font-size: .62rem;
}

body.results-mode .word-grid[data-density="dense"] .word-card {
  padding: 17px 5px 5px;
  border-radius: 10px;
}

body.results-mode .word-grid[data-density="dense"] .word-card::before {
  left: 4px;
  top: 3px;
  min-width: 19px;
  height: 17px;
  padding: 0 3px;
  font-size: .48rem;
}

body.results-mode .word-grid[data-density="dense"] .word-card::after,
body.results-mode .word-grid[data-density="dense"] .results-footer {
  display: none;
}

body.results-mode .word-grid[data-density="dense"] .card-split {
  margin-top: 2px;
}

body.results-mode .word-grid[data-density="dense"] .syllable-piece {
  min-height: 18px;
  padding: 1px 3px;
  border-width: 1.3px;
  border-radius: 5px;
  font-size: .52rem;
}

@media (max-width: 760px) {
  body.results-mode .page-shell {
    width: 100%;
    padding: 6px;
  }

  body.results-mode .results-panel {
    padding: 9px 8px 7px;
    border-radius: 14px;
  }

  body.results-mode .results-topline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  body.results-mode .set-summary {
    display: none;
  }

  body.results-mode .toolbar {
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.results-mode .toolbar::-webkit-scrollbar {
    display: none;
  }

  body.results-mode .results-footer {
    display: none;
  }

  body.results-mode .results-panel {
    grid-template-rows: auto auto minmax(0, 1fr);
  }
}

@media print {
  body.results-mode {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.results-mode .page-shell {
    height: auto !important;
  }
}


@media (max-width: 620px) {
  .app-header {
    padding-top: 76px;
  }

  .header-actions {
    left: 16px;
    right: 16px;
    justify-content: flex-end;
  }
}
