:root {
  --bg: #eef2f5;
  --bg-accent: #eef2f5;
  --panel: #ffffff;
  --panel-muted: #f5f8fa;
  --text: #182533;
  --muted: #657789;
  --line: #d7e0e6;
  --accent: #115d73;
  --accent-soft: #e0edf2;
  --ok: #1d8a57;
  --ok-soft: #dcf2e7;
  --bad: #b43b2d;
  --bad-soft: #f9e5e2;
  --debug: #e8c030;
  --debug-soft: #fbf3d4;
  --debug-dark: #6b5310;
  --font-ui: "Manrope", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-head: "Avenir Next", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --shadow-soft: 0 12px 24px rgba(23, 40, 58, 0.08);
  --shadow-hover: 0 14px 28px rgba(23, 40, 58, 0.12);
  --radius-sm: 4px;
  --radius-md: 5px;
  --radius-lg: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

body {
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  padding: 0;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
}

.mobile-select {
  min-width: 0;
  width: 100%;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  padding: 1.6rem 0.6rem 1.4rem 1rem;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.nav-item {
  font-family: var(--font-ui);
  color: var(--text);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0.64rem 0.72rem;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(23, 40, 58, 0.08);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.nav-item:hover {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(23, 40, 58, 0.13);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent), 0 5px 12px rgba(17, 93, 115, 0.18);
}

.nav-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-name {
  font-size: 0.95rem;
  font-weight: 640;
  line-height: 1.2;
}

.nav-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-check {
  width: 1rem;
  min-width: 1rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ok);
  line-height: 1.1;
  margin-top: 0.08rem;
}

.nav-check.hidden {
  width: 0;
  min-width: 0;
}

.nav-check.solved {
  color: var(--ok);
}

.main {
  background: var(--bg);
  padding: 1.6rem 1.6rem 1.6rem 1rem;
}

.page-container {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.block {
  position: relative;
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease;
}

.block.status-correct {
  border-color: #7fbf9d;
}

.block.status-incorrect {
  border-color: #d5847c;
}

.block h1,
.block h2,
.block h3 {
  font-family: var(--font-head);
  margin: 0 0 0.78rem;
  letter-spacing: -0.01em;
}

.block p,
.block li {
  line-height: 1.58;
}

.media-wrap img:not(.image-inline) {
  width: 100%;
  display: block;
  margin-inline: auto;
  border-radius: var(--radius-lg);
  border: 0;
  background: #000;
}

.media-wrap img.image-inline {
  display: block;
  background: transparent;
}

.media-wrap video {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - var(--sticky-top-offset, 57px) - 2rem);
  height: auto;
  display: block;
  margin-inline: auto;
  border-radius: var(--radius-lg);
  border: 0;
  background: #000;
}

.media-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  --blk-gap: 0.6rem;
}

.image-group-block {
  padding: 0.75rem;
}

.image-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, calc(50% - 0.25rem)), 1fr));
  gap: 0.5rem;
}

.image-group-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  border-radius: var(--radius-sm);
  display: block;
}

.riddle-image {
  display: block;
  max-width: 100%;
  align-self: flex-start;
  border-radius: var(--radius-sm);
}

.image-inline {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  align-self: flex-start;
  border-radius: var(--radius-sm);
}

.btn {
  border: 0;
  background: #eef3f6;
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

.btn:hover {
  background: #e6edf1;
  box-shadow: 0 8px 16px rgba(23, 40, 58, 0.12);
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.danger {
  background: linear-gradient(180deg, #c24434, #b43b2d);
  color: #fff;
}

.btn.primary:hover {
  background: #0d5266;
}

.riddle-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  --blk-gap: 1.15rem;
}

.section-floating-check {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border-radius: 0 var(--radius-lg) 0 var(--radius-md);
  font-size: 1.05rem;
  font-weight: 800;
  color: #115634;
  border: 0;
  background: rgba(127, 191, 157, 0.35);
  box-shadow: 0 2px 8px rgba(17, 86, 52, 0.18);
  pointer-events: none;
}

.section-floating-check.is-hidden {
  display: none;
}

.section-floating-check.is-incorrect {
  color: #7e2a22;
  background: rgba(213, 132, 124, 0.35);
  box-shadow: 0 2px 8px rgba(180, 59, 45, 0.18);
}

.question-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

/* Color swatches */
.color-swatch {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  vertical-align: middle;
  margin: 0 0.2em;
  flex-shrink: 0;
}

/* Custom color dropdown */
.color-dropdown {
  position: relative;
}

.color-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.52rem 0.72rem;
  background: var(--panel);
  border: 1.5px solid #c8d4dd;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 640;
  color: var(--text);
  text-align: left;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.color-dropdown-trigger:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 93, 115, 0.14);
}

.color-dropdown-label {
  flex: 1;
  min-width: 0;
}

.color-dropdown-arrow {
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
  transition: transform 120ms ease;
}

.color-dropdown-trigger[aria-expanded="true"] .color-dropdown-arrow {
  transform: rotate(180deg);
}

.color-dropdown-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid #c8d4dd;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(23, 40, 58, 0.12);
  padding: 0.3rem;
  display: none;
  flex-direction: column;
  gap: 0.1rem;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
}

.color-dropdown-panel.is-open {
  display: flex;
}

.color-dropdown-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 640;
  color: var(--text);
  text-align: left;
  transition: background 0.1s ease;
}

.color-dropdown-option:hover {
  background: var(--accent-soft);
}

.color-dropdown-option.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.question-wrap.ok {
  box-shadow: none;
}

.question-wrap.bad {
  box-shadow: none;
}

.question-prompt p {
  margin: 0 0 0.9rem;
}

.question-prompt p:last-child {
  margin-bottom: 0;
}

.question-prompt li {
  margin: 0.18rem 0;
}

.single-choice-options {
  display: grid;
  gap: 0.5rem;
}

.riddle-box .question-prompt,
.riddle-box .single-choice-options {
  padding-right: 0;
}

.riddle-input {
  width: 100%;
  border: 1px solid #c8d4dd;
  border-radius: var(--radius-md);
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  outline: none;
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.riddle-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 93, 115, 0.14);
}

.riddle-input.ok {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px rgba(29, 138, 87, 0.13);
}

.riddle-input.bad {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(180, 59, 45, 0.13);
}

.status-chip {
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.28rem 0.52rem;
  width: fit-content;
  border-radius: 999px;
  border: 0;
  color: var(--muted);
  background: #edf2f5;
}

.status-chip.icon-only {
  min-width: 1.8rem;
  width: 1.8rem;
  padding: 0.2rem 0;
  text-align: center;
  border-radius: var(--radius-sm);
}

.status-chip.ok {
  color: #115634;
  background: var(--ok-soft);
}

.status-chip.bad {
  color: #7e2a22;
  background: var(--bad-soft);
}

.multi-options {
  display: grid;
  gap: 0.48rem;
}

.option-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.option-row input {
  margin-top: 0.2rem;
}

.page-actions {
  margin-top: 0.4rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.debug-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  border: 3px dashed var(--debug);
  background: var(--debug-soft);
}

.debug-actions .btn {
  background: var(--debug);
  color: var(--debug-dark);
}

.debug-actions .btn:hover {
  background: #d8b020;
}

.debug-only {
  border: 3px dashed var(--debug) !important;
  background: var(--debug-soft) !important;
}

.debug-only-inline {
  border: 3px dashed var(--debug);
  background: var(--debug-soft);
  border-radius: var(--radius-md);
  padding: 0.6rem;
  margin: 0.4rem 0;
}

.debug-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--debug-dark);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.debug-only-image {
  outline: 3px dashed var(--debug);
  outline-offset: -3px;
}

.section-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.text-block {
  line-height: 1.58;
}

.empty-state {
  color: var(--muted);
  font-size: 0.96rem;
}

/* Mobile navigation — custom dropdown (replaces Choices.js) */

.mobile-nav-trigger {
  flex: 1 1 0;
  min-width: 0;
}

.mobile-nav-arrow {
  margin-left: auto;
  flex-shrink: 0;
  align-self: center;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
  transition: transform 120ms ease;
}

.mobile-nav-arrow.is-open {
  transform: rotate(180deg);
}

.mobile-nav-panel {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--sticky-top-offset, 57px);
  bottom: 0;
  z-index: 25;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(23, 40, 58, 0.14);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  overflow-y: auto;
}

.mobile-nav-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: none;
}

.mobile-nav-overlay.is-open {
  display: block;
}

@media (max-width: 860px) {
  .topbar {
    display: flex;
    z-index: 30;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 1rem;
  }

  .block {
    border-radius: var(--radius-lg);
    padding: 1rem;
  }

  .sidebar {
    background: var(--bg);
  }
}

/* Lightbox */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.82);
  overflow: auto;
  overscroll-behavior: contain;
}

.lightbox-overlay.is-open {
  display: block;
}

.lightbox-inner {
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem;
  box-sizing: border-box;
}

.lightbox-img {
  display: block;
  max-width: none;
  max-height: none;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  cursor: zoom-out;
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.6rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  z-index: 201;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Fireworks */
.fireworks-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: none;
}
