/* Printable Mazes — screen layout + print sheet. Self-contained: .maze-* only. */

.maze-titlebar {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 8px 0 0;
}

.maze-titlebar h1 {
  margin: 0;
  font-size: 1.7rem;
}

.maze-titlebar p {
  margin: 0;
  font-size: 0.92rem;
  opacity: 0.75;
}

.maze-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 0;
}

.maze-controls {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 16px;
}

.maze-slider-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.maze-slider label {
  font-weight: 700;
}

.maze-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.maze-toolbar .maze-btn { flex: 1 1 130px; min-height: 44px; white-space: nowrap; }
.maze-option-group { display: block; }
.maze-option-group + .maze-option-group { border-top: 1px solid color-mix(in srgb, var(--text) 22%, transparent); padding-top: 16px; }
.maze-option-group summary { display: flex; align-items: baseline; gap: 0; margin: 0; font-size: 1rem; font-weight: 700; cursor: pointer; padding: 4px 0; list-style: none; }
.maze-option-group summary::-webkit-details-marker { display: none; }
.maze-summary-hint { font-weight: 400; font-size: 0.85em; opacity: 0.75; }
.maze-option-group summary::after { content: '+'; margin-left: auto; color: var(--accent); }
.maze-option-group[open] summary::after { content: '−'; }
.maze-option-group[open] > summary { color: var(--text); }
.maze-option-body { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; }
.maze-orientation { border: 0; padding: 0; margin: 0; min-width: 0; }
.maze-orientation legend { font-weight: 700; font-size: 0.88rem; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; position: relative; }
.maze-orientation-row { display: flex; gap: 6px; }
.maze-orientation-row label { flex: 1; font-size: 0.8rem; padding: 9px 5px; border: 1px solid color-mix(in srgb, var(--text) 30%, var(--card)); border-radius: 6px; background: color-mix(in srgb, var(--text) 12%, var(--card)); cursor: pointer; }
.maze-orientation-row label:has(:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.maze-orientation-row label { display: flex; align-items: center; gap: 5px; }
.maze-orientation input { accent-color: var(--accent); width: auto; margin: 0; }
.maze-landscape .maze-sheet { aspect-ratio: 4 / 3; }
.maze-portals .maze-orientation-row, .maze-doors .maze-orientation-row, .maze-checkpoints .maze-orientation-row, .maze-oneway .maze-orientation-row { flex-wrap: wrap; }
.maze-portals .maze-orientation-row label, .maze-doors .maze-orientation-row label, .maze-checkpoints .maze-orientation-row label, .maze-oneway .maze-orientation-row label { flex-basis: 70px; flex-direction: column; font-size: 0.75rem; }
.maze-oneway .maze-orientation-row label { flex-basis: 48px; padding-left: 3px; padding-right: 3px; }

.maze-shape label { font-weight: 700; }
.maze-shape select {
  width: 100%;
  padding: 8px;
  font: inherit;
  color: inherit;
  background: var(--card, transparent);
  border: 1px solid currentColor;
  border-radius: 6px;
  cursor: pointer;
}
.maze-shape-extras { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.maze-shape-extras[hidden] { display: none; }
#shape-note { margin: 0; font-size: 0.75rem; opacity: 0.8; }
#shape-note:empty { display: none; }
#race-note, #oneway-note { margin: 0.35rem 0 0; font-size: 0.75rem; opacity: 0.8; }
#race-note:empty, #oneway-note:empty { display: none; }

.maze-word label { display: block; font-weight: 700; margin-bottom: 6px; }
.maze-word-row { display: flex; gap: 8px; }
.maze-word-placement { margin-top: 12px; }
.maze-word-placement[hidden] { display: none; }
.maze-word input { min-width: 0; width: 100%; padding: 8px; font: inherit; color: inherit; background: transparent; border: 1px solid currentColor; border-radius: 6px; text-transform: uppercase; }
.maze-word p { margin: 5px 0 0; font-size: 0.75rem; opacity: 0.8; }
.maze-word p:empty { display: none; }

.maze-info {
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  font-style: italic;
  width: 18px;
  height: 18px;
  line-height: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--text);
  color: var(--card);
  opacity: 0.85;
  cursor: help;
  padding: 0;
}

.maze-info:hover,
.maze-info:focus-visible {
  opacity: 1;
}

.maze-tip {
  display: none;
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: 240px;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.45;
  background: var(--card, #fff);
  color: inherit;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.maze-info:hover + .maze-tip,
.maze-info:focus + .maze-tip {
  display: block;
}

.maze-gen-row {
  display: flex;
  gap: 8px;
}

.maze-gen-row .maze-btn {
  flex: 1 1 0;
  font-size: 0.85rem;
  padding: 7px 6px;
  white-space: nowrap;
}

.maze-slider input[type='range'] {
  width: 100%;
  accent-color: var(--accent, currentColor);
}

.maze-slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  opacity: 0.75;
  margin-top: 1px;
}

.maze-btn {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 14px;
  border: 1px solid color-mix(in srgb, var(--text) 30%, var(--card));
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 16%, var(--card));
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--text) 25%, transparent);
  cursor: pointer;
}

.maze-btn:hover,
.maze-btn:focus-visible {
  background: color-mix(in srgb, var(--text) 24%, var(--card));
}

.maze-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.maze-btn:active { transform: translateY(1px); box-shadow: none; }

.maze-btn--primary {
  font-weight: 700;
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

html[data-theme='modern'] .maze-btn--primary { color: #fff; }
.maze-btn--primary:hover, .maze-btn--primary:focus-visible { background: var(--accent); filter: brightness(0.9); }

.maze-btn--print {
  width: 100%;
  padding: 12px 14px;
  margin-top: 4px;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.maze-btn--small {
  font-size: 0.82rem;
  padding: 5px 10px;
  white-space: nowrap;
  flex: 0 0 auto;
  align-self: center;
}

.maze-btn[aria-pressed='true'] {
  background: var(--text);
  color: var(--card);
}

.maze-hint {
  flex: 1 1 auto;
  align-self: center;
  min-height: 1.2em;
  font-size: 0.85rem;
  opacity: 0.8;
  margin: 6px 0;
}

.maze-stage {
  padding: 12px 16px 16px;
}

.maze-stage-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 auto 10px;
  width: 100%;
}

.maze-sheet {
  aspect-ratio: 3 / 4;
  width: 100%;
  margin: 0 auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
  padding: 12px;
  box-sizing: border-box;
}

.maze-svg {
  width: 100%;
  height: 100%;
  display: block;
}

@media screen {
  #maze-sheet { cursor: zoom-in; }
  #maze-sheet:focus-visible { outline: 3px solid var(--accent, #b54b32); outline-offset: 4px; }
  body.maze-expanded { overflow: hidden; }
  .maze-popout {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #181818;
    color: #fff;
  }
  .maze-popout::backdrop { background: #181818; }
  .maze-popout-bar { height: 60px; padding: 10px 16px; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .maze-popout-bar p { margin: 0; font-size: 0.85rem; }
  .maze-popout-view { position: absolute; inset: 60px 16px 16px; display: flex; align-items: center; justify-content: center; }
  .maze-popout .maze-sheet { flex: none; margin: 0; }
}

.maze-svg .maze-walls {
  stroke: #111;
}

.maze-svg .maze-mark {
  fill: #111;
}

.maze-svg .maze-solution {
  stroke: #e05d3d;
  opacity: 0.85;
}

@media (max-width: 860px) {
  .maze-layout {
    grid-template-columns: 1fr;
  }
  .maze-controls {
    position: static;
  }
  .maze-sheet {
    width: 100%;
  }
}

/* ---------- print: the maze IS the page ---------- */

.maze-print-footer { display: none; }

@page {
  size: letter portrait;
  margin: 0;
}

@media screen {
  .maze-game { position: fixed; inset: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; box-sizing: border-box; border: 0; padding: 16px; background: #181818; color: #fff; }
  .maze-game[open] { display: flex; flex-direction: column; gap: 10px; }
  .maze-game::backdrop { background: #181818; }
  .maze-game-bar, .maze-game-hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .maze-game p { margin: 0; font: 14px/1.4 Arial, sans-serif; color: #ddd; }
  .maze-game-hud { font: 15px/1.4 Arial, sans-serif; }
  .maze-game-hud label { display: flex; align-items: center; gap: 6px; }
  .maze-game-hud input { width: auto; margin: 0; }
  #game-clock { font-variant-numeric: tabular-nums; }
  #game-board { flex: 1; min-height: 0; display: flex; justify-content: center; outline-offset: 2px; }
  #game-board .maze-svg { width: 100%; height: 100%; max-height: 100%; background: #fff; }
  #game-board .hide-trails, #game-board.hide-trails .game-trail { display: none; }
  .maze-game-pad { display: flex; gap: 8px; justify-content: center; }
  .maze-game-pad[hidden] { display: none; }
  .maze-game-pad button { min-width: 44px; min-height: 44px; font-size: 22px; touch-action: none; user-select: none; -webkit-user-select: none; }
  @media (min-width: 800px) { .maze-game-pad { display: none; } }
  @media (prefers-reduced-motion: reduce) { .game-player { transition: none !important; } }
}
@media print {
  .maze-game { display: none !important; }
  .aurora,
  .grid-overlay,
  .site-header,
  .site-footer,
  .maze-titlebar,
  .maze-toolbar,
  .maze-controls,
  .maze-stage-bar,
  .maze-hint {
    display: none !important;
  }

  .maze-popout { display: none !important; }
  body.maze-expanded { overflow: visible; }

  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0;
  }

  main.maze-page {
    position: fixed;
    inset: 0.5in;
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .maze-layout {
    display: block;
    margin: 0;
    height: 100%;
  }

  .maze-stage {
    position: relative;
    box-sizing: border-box;
    padding: 0 0 18pt;
    height: 100%;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .maze-sheet {
    aspect-ratio: auto;
    max-width: none;
    width: 100%;
    height: 100%;
    padding: 0;
    break-inside: avoid;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
  }

  .maze-svg {
    width: 100%;
    height: 100%;
    max-height: none;
  }

  .maze-print-footer {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    color: #333;
    text-align: center;
    font: 8pt/12pt Arial, sans-serif;
  }
  .maze-svg .maze-walls,
  .maze-svg .maze-mark {
    stroke: #000;
  }

  .maze-svg .maze-mark {
    fill: #000;
  }
}
