/* The shadow follows the transparent silhouette of the collectible, in either theme. */
.scene .sprite:not(.taken) {
  filter: drop-shadow(0 1px 1px rgb(41 29 19 / 34%));
}
/* Lunar layers restore part of the original scene, including its painted shadow. */
body[data-case="lunar-shadow"] .scene .sprite { filter: none; }

html[data-theme="school-night"] {
  color-scheme: dark;
  --quest-bg: #12282b;
  --quest-surface: #1b3537;
  --quest-raised: #264548;
  --quest-text: #f4ecd9;
  --quest-muted: #b9c9c2;
  --quest-accent: #f1c46d;
  --quest-coral: #db8972;
  --quest-sage: #a7b68a;
  --quest-on-accent: var(--quest-bg);
  --quest-focus: var(--quest-accent);
  --quest-control-border: var(--quest-muted);
  --quest-decorative-border: rgb(185 201 194 / 22%);
  --quest-field: #102326;
  --quest-target-min: 44px;
  --quest-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --paper: var(--quest-bg);
  --ink: var(--quest-text);
  --muted: var(--quest-muted);
  --line: var(--quest-decorative-border);
  --gold: var(--quest-accent);
  --green: var(--quest-sage);
  --sans: var(--quest-font);
  accent-color: var(--quest-accent);
  scrollbar-color: #69827a var(--quest-bg);

  & ::selection { color: var(--quest-bg); background: var(--quest-accent); }
  & :is(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible { outline: 3px solid var(--quest-focus); outline-offset: 3px; }
  & .scene:focus-visible { outline-offset: -3px; }

  & :is(header, .playing header, .playbar, .paper, .story-sheet, .deduction, .rail, dialog, #notebook) {
    color: var(--quest-text);
    background-color: var(--quest-surface);
    border-color: var(--line);
  }
  & .playing { background: var(--quest-bg); }
  & .brandmark {
    background: var(--quest-bg);
    color: var(--quest-accent);
    box-shadow: inset 0 0 0 1px var(--line);
  }
  & .bar nav :is(a, button):hover { color: var(--quest-accent); }
  & .bar nav a.active { color: var(--quest-text); }
  & .bar nav a.active::after { background: var(--quest-accent); }
  & :is(.crumb, .crumb a, .crumb i, .progresslabel, .context, .archive-row small, .lead, .deduction-art span, .play-title small i) {
    color: var(--quest-muted);
  }
  & :is(.kind, .eyebrow, .assignment-info .eyebrow, .play-title small, .textlink, summary, .package-links a) {
    color: var(--quest-accent);
  }
  & :is(.assignment, .story-sheet p, .package-status) { color: var(--quest-text); }
  & :is(.tool, .playbar .tool, .secondary, .rules, .choice, .hero-actions .tool, .inventory button, .gallery-image) {
    background: var(--quest-surface);
    color: var(--quest-text);
    border-color: var(--quest-control-border);
  }
  & :is(.tool, .playbar .tool, .secondary, .rules, .choice, .hero-actions .tool, .inventory button, .gallery-image):hover:not(:disabled) {
    background: var(--quest-raised);
    color: var(--quest-accent);
  }
  & :is(.primary, .tool.primary) {
    background: var(--quest-accent);
    border-color: var(--quest-accent);
    color: var(--quest-on-accent);
  }
  & :is(.primary, .tool.primary):hover:not(:disabled) {
    background: #ffda8f;
    color: var(--quest-on-accent);
  }
  & .tool:disabled { opacity: .55; }
  & .hero {
    color: var(--quest-text);
    background-color: var(--quest-surface);
    border: 1px solid var(--line);
  }
  & .hero::after {
    background: linear-gradient(90deg, #12282b 2%, #12282bf7 24%, #12282bef 36%, #12282b75 57%, transparent 82%);
  }
  & .hero h1 { max-width: 8.8em; }
  & .hero p, & .meta { color: var(--quest-text); }
  & .meta svg, & .docket { color: var(--quest-accent); }
  & .meta b { color: var(--quest-muted); }
  & .docket { background: var(--quest-surface); border-color: #8c805c; }
  & :is(.card, .card:disabled) {
    background: var(--quest-surface);
    color: var(--quest-text);
    border-color: var(--line);
  }
  & .card:enabled:hover { border-color: var(--quest-accent); }
  & .cardpic, & .card:disabled .cardpic { background-color: var(--quest-raised); }
  & .card:disabled .cardcopy { opacity: 1; color: var(--quest-muted); }
  & .card:disabled .kind { color: var(--quest-muted); }
  & :is(.photo-num, .state, .print-label) {
    color: var(--quest-text);
    background: var(--quest-bg);
    border-color: var(--quest-muted);
  }

  & :is(.empty, .entry, .puzzle-text, .object-detail) {
    background-color: var(--quest-raised);
    color: var(--quest-text);
    border-color: var(--line);
  }
  & .puzzle-text { border-inline-start-color: var(--quest-accent); }
  & :is(.clue, .record) {
    background: #243f38;
    color: var(--quest-text);
    border-color: #758c70;
  }
  & :is(.record .kind, .clue .kind, .offline, .record-score) { color: var(--quest-sage); }
  & .bridge { border-color: var(--line); color: var(--quest-muted); }
  & .answerrow input, & dialog :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    background: var(--quest-field);
    border-color: var(--quest-control-border);
    color: var(--quest-text);
  }
  & input::placeholder { color: var(--quest-muted); opacity: 1; }

  & :is(.workfield, .pane, .scene) { background: var(--quest-field); }
  & .board-tools { color: var(--quest-text); }
  & .board-count { color: var(--quest-accent); }
  & .board-stats [data-score] { color: var(--quest-muted); }
  & .zoombar {
    color: var(--quest-text);
    background: var(--quest-surface);
    box-shadow: inset 0 0 0 1px var(--quest-control-border);
  }
  & .zoombar .tool { background: transparent; color: var(--quest-accent); }
  & .zoombar .tool:hover:not(:disabled) { background: var(--quest-raised); }
  & .chip {
    background: var(--quest-bg);
    border-color: var(--line);
    color: var(--quest-muted);
  }
  & .chip.found {
    background: #233f35;
    border-color: var(--quest-sage);
    color: var(--quest-sage);
  }
  & .chip.found:hover { background: var(--quest-raised); color: var(--quest-text); }
  & .scene .ring {
    border-color: var(--quest-accent);
    box-shadow: 0 0 0 1px var(--quest-bg), inset 0 0 0 1px var(--quest-bg);
  }
  & .cursor { border-color: var(--quest-text); background: rgb(18 40 43 / 55%); }
  & .flying-item {
    color: var(--quest-accent);
    background: var(--quest-raised);
    border: 1px solid var(--quest-muted);
  }
  & #feedback, & .mini-status { color: var(--quest-text); }
  & #feedback:not(:empty) { border-inline-start: 2px solid var(--quest-accent); padding-inline-start: 8px; }
  & #feedback[data-tone="miss"], & .mini-status[data-tone="miss"] { color: var(--quest-coral); }
  & #feedback[data-tone="miss"] { border-color: var(--quest-coral); }
  & dialog::backdrop { background: rgb(5 17 20 / 72%); }
  & #toast {
    background: var(--quest-raised);
    color: var(--quest-text);
    border-color: var(--quest-muted);
  }
}

html[data-quest-theme="lunar-shadow"] {
  --quest-bg: #0b1220;
  --quest-surface: #142234;
  --quest-raised: #1b3047;
  --quest-text: #edf1eb;
  --quest-muted: #afbecf;
  --quest-accent: #e6b45c;
  --quest-sage: #69b9bb;
  --quest-coral: #e7a097;
  --quest-decorative-border: rgb(175 190 207 / 22%);
  --quest-field: var(--quest-bg);
  & .hero::after { background: linear-gradient(90deg, #0b1220 2%, #0b1220f7 24%, #0b1220ef 36%, #0b122075 57%, transparent 82%); }
  & :is(.clue, .record, .chip.found) { background: var(--quest-raised); border-color: var(--quest-sage); }
}

@media (max-width: 600px) {
  html[data-theme="school-night"] .hero {
    display: flex;
    flex-direction: column;
    background: var(--quest-surface);
  }
  html[data-theme="school-night"] .hero::before {
    position: static;
    z-index: auto;
    display: block;
    width: 100%;
    height: clamp(140px, 39vw, 210px);
    background-size: cover;
    background-position: 56% 38%;
  }
  html[data-theme="school-night"] .hero::after { display: none; }
  html[data-theme="school-night"] .heroinner { padding: 20px 20px 23px; }
  html[data-theme="school-night"] .hero h1 {
    max-width: none;
    font-size: clamp(34px, 9vw, 51px);
    text-wrap: balance;
  }
}

@media (pointer: coarse) {
  html[data-theme="school-night"] :is(.playbar,.board-tools,.hint-tools) { --quest-target-min: 34px; }
  html[data-theme="school-night"] :is(.tool, .tool.square, .close, .chip.found, .primary, .secondary, .play-actions .tool, .short-tools .tool, .workfield .board-tools .zoombar .tool) {
    min-height: var(--quest-target-min);
  }
  html[data-theme="school-night"] :is(.tool.square, .close, .play-actions .tool, .workfield .board-tools .zoombar .tool) {
    min-width: var(--quest-target-min);
  }
  html[data-theme="school-night"] .board-tools:has(.zoombar) { min-height: var(--quest-target-min); max-height: none; }
}

@media (max-width: 480px) {
  html[data-theme="school-night"] .bar .install { width: 44px; min-height: 44px; }
  html[data-theme="school-night"] .bar .install svg { display: block; }
  html[data-theme="school-night"] .bar .install span {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  html[data-theme="school-night"] .bar nav :is(a, button) { min-width: 44px; }
}
@media (max-width: 374px) {
  html[data-theme="school-night"] .bar .brand { font-size: 0; gap: 0; }
}
