/* Maze Play — bright, kid-friendly, mobile-first */

:root {
  color-scheme: light;
  --teal: #1f8a7e;
  --teal-deep: #14665d;
  --coral: #ff6b4a;
  --coral-deep: #e85130;
  --sun: #ffc857;
  --sky: #7ec8e3;
  --cream: #fff8ef;
  --ink: #243037;
  --ink-soft: #4a5c66;
  --wall: #1f8a7e;
  --path: #ff6b4a;
  --hint: #f4a261;
  --solution: #5c7cfa;
  --floor: #ffffff;
  --panel: rgba(255, 255, 255, 0.65);
  --panel-border: rgba(255, 255, 255, 0.8);
  --btn-secondary-bg: #fff;
  --btn-ghost-bg: rgba(255, 255, 255, 0.72);
  --btn-ghost-border: rgba(36, 48, 55, 0.08);
  --modal-bg: #fff;
  --emoji-btn-bg: #f4f7f8;
  --shadow: 0 10px 28px rgba(36, 48, 55, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", "Fredoka", system-ui, sans-serif;
  --touch: 48px;
  --pad: clamp(12px, 3vw, 24px);
  --page-bg:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(126, 200, 227, 0.55), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(255, 200, 87, 0.45), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(31, 138, 126, 0.18), transparent 55%),
    linear-gradient(165deg, #e8f6fb 0%, var(--cream) 45%, #ffe8d6 100%);
}

/* Higher specificity than :root so dark vars always win on desktop & mobile */
html[data-theme="dark"] {
  color-scheme: dark;
  --teal: #3ecfbe;
  --teal-deep: #7ee0d4;
  --coral: #ff7d5e;
  --coral-deep: #ff9a82;
  --sun: #ffd36a;
  --sky: #5aa8c4;
  --cream: #142028;
  --ink: #eef4f6;
  --ink-soft: #a8b8c0;
  --wall: #3ecfbe;
  --path: #ff7d5e;
  --hint: #f4a261;
  --solution: #8aa0ff;
  --floor: #1a2830;
  --panel: rgba(20, 32, 40, 0.78);
  --panel-border: rgba(255, 255, 255, 0.08);
  --btn-secondary-bg: #1a2830;
  --btn-ghost-bg: rgba(26, 40, 48, 0.85);
  --btn-ghost-border: rgba(255, 255, 255, 0.1);
  --modal-bg: #1a2830;
  --emoji-btn-bg: #243038;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --page-bg:
    radial-gradient(ellipse 90% 55% at 50% -15%, rgba(62, 207, 190, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 40% at 100% 10%, rgba(255, 125, 94, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 35% at 0% 80%, rgba(255, 211, 106, 0.08), transparent 50%),
    linear-gradient(180deg, #0a1218 0%, #142028 45%, #1a2830 100%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  min-height: 100%;
  background-color: #e8f6fb;
  background-image: var(--page-bg);
  background-attachment: scroll;
}

html[data-theme="dark"] {
  background-color: #0a1218;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* —— Brand —— */
.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(20, 102, 93, 0.22);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 2.75rem);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--teal-deep);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .brand {
  text-shadow: none;
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.daily-chip {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--sun);
  color: #243037;
  font-weight: 800;
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}

.theme-swap {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--btn-ghost-border);
  background: var(--btn-ghost-bg);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
  user-select: none;
  flex-shrink: 0;
  z-index: 2;
}

.theme-swap input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.theme-icon {
  font-size: 1.15rem;
  line-height: 1;
  grid-area: 1 / 1;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

/* checked = light: show sun; unchecked = dark: show moon */
.theme-swap input:checked ~ .theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-swap input:checked ~ .theme-icon-moon {
  opacity: 0;
  transform: rotate(-45deg) scale(0.6);
}

.theme-swap input:not(:checked) ~ .theme-icon-sun {
  opacity: 0;
  transform: rotate(45deg) scale(0.6);
}

.theme-swap input:not(:checked) ~ .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* —— Game hub nav (home + game buttons) —— */
.game-nav {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.nav-home {
  flex: 0 0 auto;
  width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.nav-home.is-active,
.nav-home:hover {
  background: var(--floor);
}

.game-nav-primary {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

@media (max-width: 520px) {
  .game-nav-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.game-nav-btn {
  min-height: var(--touch);
  padding: 8px 6px;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 2.6vw, 0.92rem);
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: manipulation;
}

.game-nav-emoji {
  font-size: 1.05rem;
  line-height: 1;
}

.game-nav-label {
  display: block;
}

.game-nav-btn.is-active,
.game-nav-btn[aria-pressed="true"] {
  background: var(--floor);
  color: var(--teal-deep);
  box-shadow: 0 2px 8px rgba(36, 48, 55, 0.1);
}

[data-theme="dark"] .game-nav-btn.is-active {
  color: #7fd9cc;
}

.sound-toggle {
  width: var(--touch);
  min-height: var(--touch);
  border: none;
  border-radius: 999px;
  background: var(--btn-ghost-bg);
  outline: 2px solid var(--btn-ghost-border);
  font-size: 1.15rem;
  cursor: pointer;
  touch-action: manipulation;
}

.game-panel[hidden] {
  display: none !important;
}

.game-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 14px;
}

/* —— Landing —— */
.landing-panel {
  gap: 18px;
}

.landing {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 4px;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.landing-mark {
  width: clamp(56px, 14vw, 72px);
  height: clamp(56px, 14vw, 72px);
  flex-shrink: 0;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(20, 102, 93, 0.25);
}

.landing-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 700;
  color: var(--teal-deep);
  letter-spacing: -0.02em;
}

.landing-lead {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.landing-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.landing-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 200px;
  width: 100%;
  padding: 20px 22px;
  border: none;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.55)),
    var(--panel);
  border: 2px solid var(--panel-border);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.landing-card:hover,
.landing-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(36, 48, 55, 0.16);
  outline: none;
}

.landing-card:nth-child(1) .landing-card-art { background: rgba(31, 138, 126, 0.18); }
.landing-card:nth-child(2) .landing-card-art { background: rgba(255, 107, 74, 0.18); }
.landing-card:nth-child(3) .landing-card-art { background: rgba(92, 124, 250, 0.18); }
.landing-card:nth-child(4) .landing-card-art { background: rgba(255, 200, 87, 0.28); }
.landing-card:nth-child(5) .landing-card-art { background: rgba(199, 125, 255, 0.2); }

.landing-card-art {
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 2.8rem;
}

.landing-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.landing-card-title {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4.5vw, 1.6rem);
  font-weight: 700;
  color: var(--ink);
}

.landing-card-blurb {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-soft);
}

/* —— Quick controls above canvas —— */
.quick-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.diff-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.diff-preset {
  min-height: var(--touch);
  padding: 8px 4px;
  border-radius: 12px;
  border: 2px solid var(--btn-ghost-border);
  background: var(--btn-ghost-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.diff-preset.is-active,
.diff-preset[aria-pressed="true"] {
  background: rgba(255, 200, 87, 0.35);
  border-color: var(--sun);
  color: #7a5600;
}

[data-theme="dark"] .diff-preset.is-active {
  color: #ffd36a;
}

.size-kid-label {
  margin-left: 6px;
  color: var(--ink-soft);
  font-weight: 700;
}

.maze-panel {
  position: relative;
}

.maze-undo-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--btn-ghost-border);
  background: var(--modal-bg);
  color: var(--ink);
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

.maze-undo-btn[hidden] {
  display: none !important;
}

.celebrate-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border-radius: calc(var(--radius) + 4px);
  background: rgba(255, 248, 239, 0.92);
  text-align: center;
  animation: celebrate-pop 0.35s ease;
}

[data-theme="dark"] .celebrate-overlay {
  background: rgba(15, 28, 36, 0.92);
}

.celebrate-overlay[hidden] {
  display: none !important;
}

.celebrate-emoji {
  font-size: 3rem;
  line-height: 1;
  animation: celebrate-bounce 0.7s ease infinite alternate;
}

.celebrate-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  color: var(--teal-deep);
}

.celebrate-detail {
  margin: 0;
  font-weight: 700;
  color: var(--ink-soft);
}

.celebrate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

@keyframes celebrate-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes celebrate-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

button,
.btn,
.detour-btn,
.diff-btn,
.category-btn,
a {
  touch-action: manipulation;
}

.app {
  overscroll-behavior: contain;
}

/* —— Maze —— */
.maze-panel {
  position: relative;
  display: flex;
  justify-content: center;
}

.maze-stage {
  width: min(100%, 560px);
  aspect-ratio: 1;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  outline: none;
  overscroll-behavior: none;
}

.maze-stage:focus-visible {
  box-shadow: var(--shadow), 0 0 0 3px rgba(31, 138, 126, 0.45);
}

.maze-svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  overflow: visible;
}

.maze-bg {
  fill: var(--floor);
}

.cell-floor {
  fill: transparent;
}

.maze-wall {
  stroke: var(--wall);
  stroke-linecap: square;
}

.icon-start,
.icon-end {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    "Twemoji Mozilla", sans-serif;
  pointer-events: none;
  user-select: none;
}

.user-path {
  stroke: var(--path);
  opacity: 0.92;
  filter: drop-shadow(0 0 4px rgba(255, 107, 74, 0.45));
  transition: d 40ms linear;
}

.user-path.no-glow {
  filter: none;
}

.path-cursor {
  fill: var(--coral-deep);
  stroke: #fff;
  stroke-width: 2;
}

.hint-path {
  stroke: var(--hint);
  opacity: 0.9;
  animation: dash-flow 1.2s linear infinite;
}

.hint-dot {
  fill: var(--hint);
}

.solution-path {
  stroke: var(--solution);
  opacity: 0.75;
}

.collision-flash {
  fill: rgba(255, 107, 74, 0.45);
  animation: flash-fade 0.22s ease-out forwards;
  pointer-events: none;
}

@keyframes flash-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes dash-flow {
  to { stroke-dashoffset: -24; }
}

.record-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  background: var(--sun);
  color: #243037;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  animation: pop-in 0.35s ease-out;
  z-index: 2;
  pointer-events: none;
}

@keyframes pop-in {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* —— Buttons —— */
.primary-actions,
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.btn-primary {
  flex: 1 1 120px;
  background: var(--coral);
  color: #fff;
}

.btn-primary:hover {
  background: var(--coral-deep);
}

.btn-secondary {
  flex: 1 1 100px;
  background: var(--btn-secondary-bg);
  color: var(--teal-deep);
  border: 2px solid rgba(31, 138, 126, 0.25);
}

.btn-secondary.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.btn-ghost {
  flex: 1 1 auto;
  background: var(--btn-ghost-bg);
  color: var(--ink);
  border: 2px solid var(--btn-ghost-border);
}

.btn-ghost[aria-pressed="true"] {
  background: rgba(92, 124, 250, 0.18);
  border-color: rgba(92, 124, 250, 0.45);
  color: #3b4fbf;
}

[data-theme="dark"] .btn-ghost[aria-pressed="true"] {
  color: #b4c0ff;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  min-width: 44px;
  padding: 0;
  font-size: 1.5rem;
  line-height: 1;
  background: transparent;
  box-shadow: none;
  color: var(--ink-soft);
}

/* —— Toolbar —— */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 16px rgba(36, 48, 55, 0.06);
}

.control-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 800;
  margin-bottom: 6px;
}

.size-value {
  font-family: var(--font-display);
  color: var(--teal-deep);
}

.difficulty {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  background: rgba(31, 138, 126, 0.15);
  color: var(--teal-deep);
}

.difficulty[data-level="easy"] {
  background: rgba(107, 203, 119, 0.25);
  color: #2d6a38;
}

.difficulty[data-level="medium"] {
  background: rgba(255, 200, 87, 0.4);
  color: #7a5600;
}

.difficulty[data-level="hard"] {
  background: rgba(255, 107, 74, 0.22);
  color: #a33a22;
}

.difficulty[data-level="expert"] {
  background: rgba(36, 48, 55, 0.12);
  color: var(--ink);
}

[data-theme="dark"] .difficulty[data-level="easy"] {
  color: #9be0a4;
}

[data-theme="dark"] .difficulty[data-level="medium"] {
  color: #ffd36a;
}

[data-theme="dark"] .difficulty[data-level="hard"] {
  color: #ff9a82;
}

.size-range {
  width: 100%;
  height: 36px;
  accent-color: var(--teal);
  cursor: pointer;
}

.detour-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.detour-btn {
  min-height: 40px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 2px solid var(--btn-ghost-border);
  background: var(--btn-ghost-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.detour-btn:hover {
  border-color: rgba(42, 157, 143, 0.45);
}

.detour-btn[aria-pressed="true"] {
  background: rgba(42, 157, 143, 0.18);
  border-color: var(--teal);
  color: var(--teal-deep);
}

[data-theme="dark"] .detour-btn[aria-pressed="true"] {
  color: #7fd9cc;
}

@media (max-width: 380px) {
  .detour-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-weight: 700;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
}

.timer-display {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--teal-deep);
  min-width: 4.5rem;
}

.best-display {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* —— Shared parent tips —— */
.parent-tips,
.trace-parent-tips {
  margin: 4px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.parent-tips > summary,
.trace-parent-tips > summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--teal-deep);
  list-style: none;
}

.parent-tips > summary::-webkit-details-marker,
.trace-parent-tips > summary::-webkit-details-marker {
  display: none;
}

.parent-tips-body,
.trace-parent-tips-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.parent-tips-body p {
  margin: 0;
}

.footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.footer p {
  margin: 0;
}

.footer-howto {
  font-weight: 700;
  color: var(--ink-soft);
}

.footer-share {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.footer-share a {
  color: var(--teal-deep);
  text-underline-offset: 2px;
  font-weight: 800;
}

.footer-share a:hover {
  color: var(--coral);
}

.footer-meta {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  opacity: 0.9;
}

.footer-credits {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-soft);
  opacity: 0.85;
  max-width: 36rem;
  margin-inline: auto;
}

.footer-credits a {
  color: var(--teal-deep);
  text-underline-offset: 2px;
}

.footer-credits a:hover {
  color: var(--coral);
}

.footer-meta a {
  color: var(--teal-deep);
  text-underline-offset: 2px;
}

.footer-meta a:hover {
  color: var(--coral);
}

/* —— Modals —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(36, 48, 55, 0.45);
  backdrop-filter: blur(3px);
}

.modal[hidden] {
  display: none !important;
}

@media (min-width: 560px) {
  .modal {
    align-items: center;
  }
}

.modal-card {
  width: min(100%, 420px);
  max-height: min(85vh, 640px);
  overflow: auto;
  background: var(--modal-bg);
  color: var(--ink);
  border-radius: 20px 20px 16px 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  animation: slide-up 0.25s ease-out;
}

.modal-card-wide {
  width: min(100%, 480px);
}

.print-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.print-mode-tab {
  min-height: 44px;
  border-radius: 12px;
  border: 2px solid var(--btn-ghost-border);
  background: var(--btn-ghost-bg);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.print-mode-tab.is-active {
  background: rgba(31, 138, 126, 0.18);
  border-color: var(--teal);
  color: var(--teal-deep);
}

.print-bulk-help {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.bulk-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.bulk-row {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr auto;
  gap: 8px;
  align-items: end;
}

.bulk-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.bulk-select,
.bulk-count {
  display: block;
  width: 100%;
  height: 48px;
  min-height: 48px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 2px solid var(--btn-ghost-border);
  background-color: var(--emoji-btn-bg);
  color: var(--ink);
  padding: 0 12px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 44px;
}

.bulk-select {
  /* Native selects often ignore min-height; force equal control chrome */
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.25rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.bulk-count {
  -moz-appearance: textfield;
  appearance: textfield;
}

.bulk-count::-webkit-outer-spin-button,
.bulk-count::-webkit-inner-spin-button {
  margin: 0;
}

.bulk-remove {
  min-width: 0;
  padding: 0 12px;
  box-shadow: none;
}

.bulk-total {
  margin: 10px 0 0;
  text-align: center;
  font-weight: 800;
  color: var(--teal-deep);
}

@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.icon-grid h3 {
  margin: 12px 0 8px;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.emoji-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.emoji-btn {
  min-height: 44px;
  min-width: 44px;
  font-size: 1.35rem;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--emoji-btn-bg);
  cursor: pointer;
  color: inherit;
}

.emoji-btn.selected {
  border-color: var(--teal);
  background: rgba(31, 138, 126, 0.15);
  box-shadow: 0 0 0 2px rgba(31, 138, 126, 0.25);
}

.print-fieldset {
  border: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.print-fieldset legend {
  font-weight: 800;
  margin-bottom: 6px;
  padding: 0;
}

.radio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 10px;
  cursor: pointer;
}

.radio:hover {
  background: var(--emoji-btn-bg);
}

.radio input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

/* —— Toast & confetti —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%) translateY(12px);
  z-index: 50;
  padding: 12px 20px;
  background: var(--ink);
  color: var(--floor);
  font-weight: 700;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

[data-theme="dark"] .toast {
  background: #eef4f6;
  color: #142028;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  width: 100vw;
  height: 100vh;
}

/* —— Print —— */
.print-sheet {
  display: none;
}

@media print {
  @page {
    size: letter;
    margin: 0.5in;
  }

  html,
  body {
    background: #fff !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Hide app chrome with display:none so page-breaks work.
     (visibility:hidden + position:absolute breaks pagination in Chrome.) */
  body.printing .app,
  body.printing .modal,
  body.printing .toast,
  body.printing .confetti-canvas {
    display: none !important;
  }

  body.printing .print-sheet {
    display: block !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    color: #000;
    visibility: visible !important;
  }

  body.printing .print-sheet[hidden] {
    display: block !important;
  }

  .print-page {
    display: block;
    box-sizing: border-box;
    width: 100%;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }

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

  .print-page-separator {
    display: block;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    break-after: page;
    page-break-after: always;
  }

  .print-title {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 18pt;
    text-align: center;
    margin: 0 0 12pt;
    color: #000;
  }

  .print-maze-grid {
    display: grid;
    gap: 16pt;
    justify-items: center;
  }

  .print-sheet[data-layout="single"] .print-maze-grid,
  .print-sheet[data-layout="bulk"] .print-maze-grid {
    grid-template-columns: 1fr;
  }

  .print-sheet[data-layout="grid4"] .print-maze-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .print-sheet[data-layout="grid6"] .print-maze-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
  }

  .print-card {
    margin: 0 auto;
    page-break-inside: avoid;
    break-inside: avoid;
    width: 100%;
    max-width: 7.5in;
    text-align: center;
  }

  .print-card figcaption {
    font-size: 11pt;
    margin-bottom: 4pt;
    color: #000;
  }

  .print-maze {
    width: 100% !important;
    height: auto !important;
    max-height: 8in;
  }

  .print-sheet[data-layout="grid4"] .print-maze,
  .print-sheet[data-layout="grid6"] .print-maze {
    max-height: 3.2in;
  }

  .print-credit {
    margin-top: 18pt;
    text-align: center;
    font-size: 9pt;
    color: #666;
    font-family: Georgia, "Times New Roman", serif;
  }

  .maze-bg {
    fill: #fff !important;
  }

  .maze-wall {
    stroke: #000 !important;
  }

  .solution-path {
    stroke: #444 !important;
    stroke-dasharray: 6 4;
    opacity: 1 !important;
  }

  .user-path,
  .hint-path,
  .path-cursor,
  .collision-flash {
    display: none !important;
  }

  .icon-start,
  .icon-end {
    fill: #000;
  }
}

@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }

  .maze-stage {
    width: min(100%, 520px);
  }
}
