/* Preferencias, volumen, controles segmentados y reset. */
.game-header #sound {
  background: var(--color-surface);
  border-color: #cadde9;
  color: #355b78;
  font-weight: 700;
}
.game-header #sound[aria-pressed="true"] {
  background: #eaf7ed;
  border-color: #b5d8be;
  color: #326746;
}
@media (min-width: 851px) and (pointer: fine), (min-width: 1101px) {
  .game-header #sound {
    min-height: 34px;
    padding: 6px 13px;
    border-radius: 12px;
    font-size: calc(11px * var(--text-scale, 1));
  }
}
.settings-wrap {
  position: relative;
  flex: none;
  z-index: 30;
}
#settings-toggle {
  width: var(--header-control-size);
  height: var(--header-control-size);
  padding: 0;
  font-size: calc(22px * var(--text-scale, 1));
  border-radius: 10px;
  color: #426c8e;
}
.settings-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: min(330px, calc(100vw - 16px));
  background: var(--color-surface);
  border: 1px solid #bfd3e3;
  border-radius: 18px;
  box-shadow: 0 8px 28px #243c5730;
  color: var(--ad-ink-steel);
}
.settings-panel h2 {
  margin: 0 0 12px;
  font-size: calc(17px * var(--text-scale, 1));
}
.theme-options,
.text-options {
  display: flex;
  align-items: center;
  gap: 4px;
}
.settings-panel button {
  border: 1px solid #c8d8e4;
  background: #f0f5f9;
  color: var(--ad-ink-steel);
  border-radius: 9px;
  min-height: 34px;
  padding: 5px 8px;
  font-size: calc(12px * var(--text-scale, 1));
}
.theme-options button {
  flex: 1;
}
.theme-options [aria-pressed="true"] {
  background: var(--ad-tint-mint);
  color: var(--ad-ink-green);
  border-color: #8fc1aa;
}
.text-options output {
  font-size: calc(12px * var(--text-scale, 1));
  min-width: 40px;
  text-align: center;
}
#settings-reset {
  margin-left: auto;
  font-size: calc(11px * var(--text-scale, 1));
}
html[data-appearance="dark"] .theme-options [aria-pressed="true"] {
  background: #305e63;
  color: var(--ad-ink-green);
  border-color: #72a89c;
}
/* Settings: three compact, aligned groups with a quiet reset footer. */
.settings-panel {
  padding: 14px;
  max-height: calc(100svh - 64px);
  overflow-y: auto;
}
.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.settings-heading h2 {
  margin: 0;
  font-size: calc(18px * var(--text-scale, 1));
}
.settings-panel #settings-close {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border: 1px solid var(--ad-line-soft);
  border-radius: 13px;
  background: white;
  color: var(--color-ink-dialog);
  padding: 0;
  font-size: 28px;
}
.settings-panel h3 {
  margin: 12px 0 6px;
  font-size: calc(12px * var(--text-scale, 1));
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ad-ink-muted);
}
.settings-panel #sound {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 34px;
  padding: 4px 6px;
  font-size: calc(12px * var(--text-scale, 1));
  font-weight: 700;
  background: var(--color-surface);
  color: var(--ad-ink-steel);
  box-shadow: 0 1px 4px #35597515;
}
.settings-panel #sound[aria-pressed="true"] {
  background: var(--ad-tint-mint);
  color: var(--ad-ink-green);
}
#sound svg {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.volume-meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: #8bc4aa;
  border-radius: 3px;
}
.theme-options {
  gap: 3px;
  padding: 3px;
  background: #eff5fa;
  border: 1px solid var(--ad-line-soft);
  border-radius: 12px;
}
.settings-panel .theme-options button {
  border: 0;
  background: transparent;
  min-width: 0;
  padding: 5px 3px;
}
.settings-panel .theme-options [aria-pressed="true"] {
  background: var(--color-surface);
  color: #2b735d;
  box-shadow: 0 1px 4px #35597515;
}
.text-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--ad-line-soft);
  background: #eff5fa;
  border-radius: 12px;
}
.text-options output {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.settings-panel .text-options button {
  border: 0;
  background: transparent;
  font-size: calc(16px * var(--text-scale, 1));
}
.settings-panel #settings-reset {
  display: block;
  width: 100%;
  min-height: 30px;
  margin: 10px 0 0;
  padding: 5px;
  border: 0;
  border-top: 1px solid #e3ecf2;
  border-radius: 0;
  background: transparent;
  color: var(--ad-ink-muted);
  font-size: calc(11px * var(--text-scale, 1));
}
.settings-panel h3 small {
  margin-left: 4px;
  font-weight: 400;
  color: var(--ad-ink-muted);
}
/* Voice and effects levels: label, −, meter, value, +. */
.level-row {
  display: grid;
  grid-template-columns: 58px 34px minmax(0, 1fr) 40px 34px;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: calc(12px * var(--text-scale, 1));
  color: var(--ad-ink-soft);
}
.settings-panel .level-row button {
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--ad-surface-tint);
  font-size: calc(19px * var(--text-scale, 1));
  line-height: 1;
}
.level-row output {
  text-align: right;
  font-weight: 700;
  color: #347561;
  font-variant-numeric: tabular-nums;
}
.volume-meter {
  height: 6px;
  border-radius: 3px;
  background: #e5edf3;
  overflow: hidden;
}
/* Learning options: a label with an On/Off-style segmented choice. */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: calc(12px * var(--text-scale, 1));
  color: var(--ad-ink-soft);
}
.option-row > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.option-row small {
  font-size: calc(10.5px * var(--text-scale, 1));
  color: var(--ad-ink-muted);
}
.segmented-options {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 3px;
  background: #eff5fa;
  border: 1px solid var(--ad-line-soft);
  border-radius: 11px;
}
.settings-panel .segmented-options button {
  min-width: 58px;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
}
.settings-panel .segmented-options [aria-pressed="true"] {
  background: var(--color-surface);
  color: #2b735d;
  font-weight: 700;
  box-shadow: 0 1px 4px #35597515;
}
.settings-panel #clear-progress {
  width: 100%;
  min-height: 34px;
  border-color: #e2c4c0;
  background: #fdf3f1;
  color: #9a4b40;
}
.settings-panel #clear-progress.is-armed {
  background: #f6d9d4;
  border-color: #d58f84;
  color: #7d2f25;
  font-weight: 700;
}
.settings-note {
  margin: 6px 2px 0;
  font-size: calc(10.5px * var(--text-scale, 1));
  line-height: 1.35;
  color: var(--ad-ink-muted);
}
html[data-appearance="dark"] .settings-panel #settings-close {
  background: var(--ad-soft);
  border-color: var(--ad-line-blue);
  color: var(--ad-ink-blue);
}
html[data-appearance="dark"] .settings-panel .level-row button {
  background: var(--ad-surface-tint);
  color: #cfe1ef;
}
html[data-appearance="dark"] :is(.level-row, .option-row) {
  color: #c4d8e7;
}
html[data-appearance="dark"] .level-row output {
  color: #a7debf;
}
html[data-appearance="dark"] :is(.option-row small, .settings-note, .settings-panel h3 small) {
  color: #9fb8cb;
}
html[data-appearance="dark"] .settings-panel #clear-progress {
  background: #4a2f2f;
  border-color: #8a5a55;
  color: #ffd9d2;
}
html[data-appearance="dark"] .settings-panel #clear-progress.is-armed {
  background: #6b3732;
  color: #fff;
}
.settings-panel button:disabled {
  opacity: 0.5;
}
.settings-panel button:hover:enabled {
  filter: brightness(0.97);
}
html[data-appearance="dark"] :is(.theme-options, .text-options, .segmented-options) {
  background: #192e40;
  border-color: #456077;
}
html[data-appearance="dark"]
  .settings-panel
  :is(.theme-options button, .text-options button, .segmented-options button, .level-row button) {
  background: transparent;
  color: #cfe1ef;
}
html[data-appearance="dark"]
  .settings-panel
  :is(.theme-options, .segmented-options)
  [aria-pressed="true"],
html[data-appearance="dark"] .settings-panel #sound {
  background: #35586e;
  color: #e3f5ff;
}
html[data-appearance="dark"] .settings-panel #sound[aria-pressed="true"] {
  background: var(--ad-tint-mint);
  color: var(--ad-ink-green);
}
html[data-appearance="dark"] .volume-meter {
  background: #456077;
}
html[data-appearance="dark"] .settings-panel #settings-reset {
  background: transparent;
  border-color: #456077;
  color: #c4d8e7;
}
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  .settings-wrap {
    grid-row: 1;
  }

  #settings-toggle {
    height: var(--header-control-size);
    padding: 0;
    font-size: calc(22px * var(--text-scale, 1));
  }

  .settings-wrap {
    grid-column: 5;
  }

  #settings-toggle {
    width: var(--header-control-size);
  }

  .game-header :is(#mobile-reset, #settings-toggle) {
    width: var(--header-control-size);
    height: var(--header-control-size);
    min-height: var(--header-control-size);
    padding: 0;
    border: 1px solid var(--color-line-header);
    border-radius: 11px;
    background: var(--color-surface);
    color: #527e9f;
    box-shadow: none;
  }

  html[data-appearance="dark"] .game-header :is(#mobile-reset, #settings-toggle) {
    background: #2b455c;
    color: #e0edf6;
    border-color: #526e88;
  }
}
@media (max-width: 420px) {
  .game-header :is(#mobile-reset, #settings-toggle) {
    width: var(--header-control-size);
    height: var(--header-control-size);
    min-height: var(--header-control-size);
    border-radius: 10px;
  }
}
@media (min-width: 851px) and (pointer: fine), (min-width: 1101px) {
  .game-header .settings-wrap {
    order: 4;
  }
}
.settings-panel .settings-heading {
  position: sticky;
  top: -14px;
  z-index: 2;
  background: var(--color-surface);
  padding-top: 8px;
}
@media (min-width: 851px) and (pointer: fine), (min-width: 1101px) {
  .game-header :is(#settings-toggle, #mobile-reset) {
    width: var(--header-control-size);
    min-width: var(--header-control-size);
    height: var(--header-control-size);
    min-height: var(--header-control-size);
  }
}
@media (max-width: 850px) and (orientation: portrait) and (min-height: 800px),
  (pointer: coarse) and (max-width: 1100px) and (orientation: portrait) and (min-height: 800px) {
  .game-header :is(#mobile-reset, #settings-toggle) {
    width: var(--header-control-size);
    height: var(--header-control-size);
    min-height: var(--header-control-size);
  }
}
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  .game-header .settings-wrap {
    grid-column: 3;
    grid-row: 1;
  }
}
#settings-panel #mobile-reset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  height: auto;
  min-height: 44px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--ad-line-soft);
  border-radius: 12px;
  background: var(--ad-neutral-face);
  color: var(--color-ink-control);
  font-size: calc(13px * var(--text-scale, 1));
  font-weight: 700;
  text-align: left;
  box-shadow: none;
}
#settings-panel #mobile-reset small {
  font-size: calc(11px * var(--text-scale, 1));
  font-weight: 400;
  color: var(--ad-ink-muted);
}
html[data-appearance="dark"] #settings-panel #mobile-reset {
  background: var(--ad-soft);
  border-color: #526e88;
  color: var(--ad-ink-deep);
}
html[data-appearance="dark"] #settings-panel #mobile-reset small {
  color: var(--ad-ink-muted);
}
#settings-intro-download {
  display: block;
  margin: -2px 0 8px;
  font-size: calc(12px * var(--text-scale, 1));
  color: var(--ad-ink-soft);
  text-underline-offset: 3px;
}
html[data-appearance="dark"] #settings-intro-download {
  color: var(--ad-ink-soft);
}
/* Grown-ups' progress report. */
#settings-panel #open-report {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 9px 12px;
  border: 1px solid #b9d7c6;
  border-radius: 12px;
  background: #eef8f2;
  color: var(--ad-ink-green-2);
  font-size: calc(13px * var(--text-scale, 1));
  font-weight: 700;
  text-align: left;
}
#settings-panel #open-report small {
  font-size: calc(11px * var(--text-scale, 1));
  font-weight: 400;
  color: #4f7a62;
}
html[data-appearance="dark"] #settings-panel #open-report {
  background: #29463a;
  border-color: #5f9a79;
  color: var(--ad-ink-green-2);
}
html[data-appearance="dark"] #settings-panel #open-report small {
  color: #b6dcc6;
}
.game-header #settings-toggle {
  display: grid;
  place-items: center;
  background: var(--ad-soft-keep);
  color: #3772ae;
  border: 1px solid var(--ad-line);
  box-shadow: 0 2px 0 #cddfee;
  border-radius: 12px;
}
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  .game-header #settings-toggle {
    width: var(--header-control-size);
    height: var(--header-control-size);
    min-height: var(--header-control-size);
    box-sizing: border-box;
    border: 1px solid #b3cbea;
    border-radius: 14px;
  }
}
.game-header #settings-toggle {
  --tile-top: var(--ad-blue-top);
  --tile-face: var(--ad-blue-face);
}

.orientation-options small {
  display: block;
  font-size: 0.85em;
}
.settings-panel .orientation-options button {
  min-height: 48px;
}
@media (orientation: landscape) and (min-width: 900px) and (min-height: 501px) {
  .settings-panel .orientation-options button {
    min-height: 96px;
  }
}

/* A quiet, persistent badge; the adult chooses when to restart from Settings. */
#settings-toggle {
  position: relative;
}
#settings-toggle[data-update-available]::after {
  content: "↓";
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ad-tint-mint);
  color: var(--ad-ink-green);
  border: 1px solid var(--ad-ink-green);
  font: 700 16px/1 system-ui;
  pointer-events: none;
}
#app-update {
  padding: 10px;
  border: 1px solid var(--ad-line-soft);
  border-radius: 12px;
  background: var(--ad-soft);
}
#app-update p {
  margin: 0 0 8px;
}
#app-update button {
  width: 100%;
  min-height: 44px;
}
@media (orientation: landscape) and (min-width: 900px) and (min-height: 501px) {
  #settings-toggle[data-update-available]::after {
    width: 32px;
    height: 32px;
    font-size: 24px;
  }
  #app-update button {
    min-height: 88px;
  }
}
