:root {
  /* Height of Android's Back/Home bar (or the iPhone home line). Newer WebViews give env(); older ones
     get --safe-area-inset-bottom from Capacitor; the larger wins. */
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px)); /* status bar, same way */
  --bg-app: #080b12;
  --bg-card: #0f1422;
  --bg-canvas: #090d16;
  --board-border: rgba(0, 240, 255, 0.15);
  --board-shadow: 0 0 35px rgba(0, 240, 255, 0.07);
  --text-main: #f0f6fc;
  --text-muted: #687799;
  --border-subtle: rgba(100, 116, 139, 0.22);
  --color-accent: #00f0ff;
  --color-primary: #00f0ff;
  --color-gold: #ffe600;
  --color-danger: #ff0077;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Noto Sans', 'Noto Sans Devanagari', 'Hiragino Sans', 'Noto Sans JP', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.3s ease;
}

/* Header */
.game-header {
  padding-top: max(calc(var(--safe-top) + 16px), 48px);
  padding-bottom: 12px;
  padding-left: max(env(safe-area-inset-left, 0px), 18px);
  padding-right: max(env(safe-area-inset-right, 0px), 18px);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.3s ease;
}

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

/* Level Select Pill */
.level-select-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(120, 130, 150, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 30px;
  padding: 6px 14px 6px 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-main);
  font-family: inherit;
}

.level-select-pill:hover {
  background: rgba(120, 130, 150, 0.16);
  transform: translateY(-1px);
}

.level-icon {
  font-size: 20px;
  width: 32px;
  height: 32px;
  background: rgba(120, 130, 150, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.level-icon:active {
  transform: scale(0.9);
}

.level-pill-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.level-number-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
}

.level-name-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron-down {
  color: var(--text-muted);
  margin-left: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dev Mode Pill */
.dev-mode-pill {
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  color: #d97706;
  cursor: pointer;
  transition: all 0.18s ease;
  animation: pulse-dev 2s infinite;
}

@keyframes pulse-dev {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Icon Buttons */
.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(120, 130, 150, 0.08);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
}

.icon-btn:hover {
  background: rgba(120, 130, 150, 0.16);
  transform: scale(1.06);
}

/* Hint Button & Badge */
.hint-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.hint-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f59e0b;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease;
}

.hint-btn.disabled .hint-badge {
  background: #94a3b8;
}

.hidden {
  display: none !important;
}

/* Theme Picker Dropdown */
.theme-picker-wrapper {
  position: relative;
}

.theme-dropdown {
  position: absolute;
  top: 46px;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.theme-dropdown.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.theme-option:hover {
  background: rgba(120, 130, 150, 0.12);
}

.theme-option.active {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

.theme-opt-icon {
  font-size: 16px;
}

/* In-Game HUD Bar */
.in-game-hud {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(120, 130, 150, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 16px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.hud-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.hud-item.lives {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.lives-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 3px;
}

.life-heart {
  font-size: 15px;
  line-height: 1;
  filter: grayscale(1) opacity(0.25);
  transform: scale(0.9);
  transition: filter 0.25s ease, transform 0.25s ease;
  user-select: none;
}

.life-heart.active {
  filter: none;
  opacity: 1;
  transform: scale(1);
}

.life-heart.lost-anim {
  animation: heartShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes heartShake {
  0%, 100% { transform: scale(1) rotate(0deg); }
  20% { transform: scale(1.3) rotate(-15deg); filter: drop-shadow(0 0 6px rgba(255, 42, 85, 0.8)); }
  40% { transform: scale(1.2) rotate(15deg); }
  60% { transform: scale(0.95) rotate(-8deg); }
  80% { transform: scale(0.9) rotate(0deg); filter: grayscale(1) opacity(0.3); }
}

.hud-item.stars {
  flex-direction: row;
  gap: 3px;
}

.star {
  font-size: 18px;
  color: rgba(120, 130, 150, 0.25);
  transition: color 0.2s ease, transform 0.2s ease;
}

.star.active {
  color: var(--color-gold);
}

.star.big {
  font-size: 32px;
}

/* Main Game Area */
.game-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Canvas Viewport */
.canvas-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  background: var(--bg-canvas);
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  transition: background-color 0.3s ease;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: block;
  touch-action: none;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

/* Celebration & Game Over Overlays */
.level-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  z-index: 100;
}

.level-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.level-overlay.game-over {
  background: rgba(18, 5, 12, 0.85);
}

.overlay-card {
  position: relative;
  background: var(--bg-card);
  padding: 28px 28px;
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  transform: translateY(20px) scale(0.92);
  transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  max-width: 85%;
  width: 340px;
  pointer-events: none;
  touch-action: auto;
  z-index: 101;
}

.level-overlay.show .overlay-card {
  transform: translateY(0) scale(1);
  pointer-events: auto !important;
}

.over-heart { font-size: 64px; line-height: 1; margin: 4px 0 6px; filter: drop-shadow(0 6px 14px rgba(255, 0, 80, 0.35)); animation: over-crack 0.7s 0.2s ease-out both; }
@keyframes over-crack { 0% { transform: scale(0.4); opacity: 0; } 55% { transform: scale(1.15) rotate(-6deg); opacity: 1; } 75% { transform: scale(0.95) rotate(4deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .over-heart { animation: none; } }
.game-over-card {
  border: 1px solid rgba(255, 42, 85, 0.35);
  box-shadow: 0 12px 42px rgba(255, 42, 85, 0.22);
}

.game-over-card h3 {
  color: #ff3366 !important;
}

.overlay-sparkle {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 20px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.star-rating-banner {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.chances-rating-banner {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.chance-heart {
  font-size: 20px;
  line-height: 1;
  filter: grayscale(1) opacity(0.25);
  transform: scale(0.9);
  transition: transform 0.25s ease, filter 0.25s ease;
  user-select: none;
}

.chance-heart.big {
  font-size: 32px;
}

.chance-heart.active {
  filter: none;
  opacity: 1;
  transform: scale(1.08);
}

.chance-heart.broken {
  filter: none;
  opacity: 0.65;
  transform: scale(0.95);
}

.overlay-card h3 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.overlay-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.overlay-stats {
  display: flex;
  justify-content: space-around;
  background: rgba(120, 130, 150, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.overlay-stats.compact { justify-content: center; gap: 12px; background: none; padding: 0; margin-bottom: 16px; }
.overlay-stats.compact .stat-box { flex-direction: row; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: rgba(120, 130, 150, 0.1); }
.overlay-stats.compact .stat-ico { width: 18px; height: 18px; color: var(--text-muted); }
.overlay-stats.compact .stat-box.wrong .stat-ico { color: #d0473f; }
.overlay-stats.compact .stat-box.wrong.none .stat-ico { color: var(--text-muted); }
.overlay-buttons .btn.icon-only { width: 58px; min-width: 58px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.overlay-buttons .btn.icon-next { min-width: 150px; display: inline-flex; align-items: center; justify-content: center; }
.stat-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.overlay-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  position: relative;
  z-index: 60;
  touch-action: auto;
}

.overlay-buttons button {
  touch-action: manipulation;
  pointer-events: none;
  position: relative;
  z-index: 61;
}

.level-overlay.show .overlay-buttons button,
.quest-ceremony.show .overlay-buttons button {
  pointer-events: auto !important;
}

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn.sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn.primary {
  background: var(--text-main);
  color: var(--bg-card);
}

.btn.primary:hover {
  opacity: 0.9;
}

.btn.secondary {
  background: rgba(120, 130, 150, 0.1);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn.secondary:hover {
  background: rgba(120, 130, 150, 0.18);
}

.btn.success {
  background: var(--color-success, #10b981);
  color: var(--color-on-success, #ffffff);
  box-shadow: 0 4px 14px var(--color-success-shadow, rgba(16, 185, 129, 0.35));
}

.btn.success:hover {
  background: var(--color-success, #10b981);
  filter: brightness(0.92);
  transform: translateY(-1px);
}

.btn.danger {
  background: #ef4444;
  color: #ffffff;
}

.btn.danger:hover {
  background: #dc2626;
}

.full-width {
  width: 100%;
}

/* Footer / Controls */
.game-footer {
  padding-top: 12px;
  padding-bottom: max(calc(var(--safe-bottom) + 22px), 24px); /* room above Back/Home (owner 2026-12-03) */
  padding-left: 20px;
  padding-right: 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.btn-bubble {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  background: rgba(120, 130, 150, 0.12);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-bubble:hover {
  background: rgba(120, 130, 150, 0.16);
  transform: scale(1.03);
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(120, 130, 150, 0.08);
  padding: 3px 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.speed-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 4px;
}

.speed-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Modals */
.level-select-modal,
.dev-modal,
.settings-modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 950; /* above the home screen (900): settings, quests and the calendar open from it */
}

.level-select-modal.show,
.dev-modal.show,
.settings-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.modal-sheet,
.dev-sheet {
  position: relative;
  width: 100%;
  max-width: 580px;
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  padding: 22px 20px 32px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 82vh;
  overflow-y: auto;
}

.level-select-modal.show .modal-sheet,
.dev-modal.show .dev-sheet,
.settings-modal.show .modal-sheet {
  transform: translateY(0);
}

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

.sheet-title-group h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.sheet-title-group p {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(120, 130, 150, 0.08);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.level-card {
  background: rgba(120, 130, 150, 0.06);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.level-card:hover {
  background: rgba(120, 130, 150, 0.14);
  transform: translateY(-2px);
  border-color: var(--color-primary);
}

.level-card.current {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.08);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.card-num {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 2px;
}

.card-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.card-diff {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(120, 130, 150, 0.12);
  color: var(--text-muted);
  margin-bottom: 6px;
}

.card-stars {
  font-size: 12px;
  color: rgba(120, 130, 150, 0.25);
  display: flex;
  gap: 2px;
}

.card-stars .star.active {
  color: var(--color-gold);
}

.card-chances {
  font-size: 11px;
  display: flex;
  gap: 2px;
}

.card-heart {
  filter: grayscale(1) opacity(0.25);
  transform: scale(0.9);
  transition: transform 0.2s ease, filter 0.2s ease;
  user-select: none;
}

.card-heart.active {
  filter: none;
  opacity: 1;
  transform: scale(1);
}

/* Dev Controls Drawer */
.dev-controls-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dev-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.dev-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.dev-select {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
}

.dev-btn-group {
  display: flex;
  gap: 6px;
}

.dev-btn-pill {
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(120, 130, 150, 0.08);
  color: var(--text-main);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dev-btn-pill.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #ffffff;
}

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

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: rgba(120, 130, 150, 0.25);
  border-radius: 20px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-control input:checked + .toggle-slider {
  background: #3b82f6;
}

.toggle-control input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* Settings Modal Specifics */
.settings-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-card.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.player-avatar {
  font-size: 26px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.player-status {
  font-size: 12px;
  color: var(--text-muted);
}

.badge-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-radius: 12px;
  white-space: nowrap;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0 4px 2px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.settings-row-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-row-label span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.settings-row-label small {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-footer {
  text-align: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.settings-footer p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* App Startup Splash Screen */
.app-splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #121417;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.app-splash-screen.fade-out {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
}

/* The same slim-arrow mark as the home screen, in night ink with the one gold arrow */
.splash-mark { width: 132px; height: 132px; display: block; margin-bottom: 22px; }
.splash-mark .hm-dots { fill: #ece8df; opacity: 0.14; }
.splash-mark .b { fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.splash-mark .h { stroke-width: 3; stroke-linejoin: round; }
.splash-mark .hm-ink .b, .splash-mark .hm-ink .h { stroke: #ece8df; }
.splash-mark .hm-ink .h { fill: #ece8df; }
.splash-mark .hm-gold .b, .splash-mark .hm-gold .h { stroke: #f0b93f; }
.splash-mark .hm-gold .h { fill: #f0b93f; }
.splash-mark .hm-gold { filter: drop-shadow(0 0 5px rgba(240,185,63,0.45)); }

.splash-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 -0.12em 6px 0;
  color: #ece8df;
}

.splash-subtitle {
  font-size: 14px;
  font-weight: 500;
  color: #8d8a83;
  margin: 0 0 32px;
}

.splash-progress {
  width: 130px;
  height: 3px;
  background: rgba(236, 232, 223, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 40px;
}

.splash-progress-inner {
  width: 100%;
  height: 100%;
  background: #f0b93f;
  animation: splashProgress 1.2s ease-in-out forwards;
}

.splash-footer-brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: #6b6862;
}

@keyframes splashProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(0); }
}

@media (max-width: 1024px) {
  body {
    padding: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .app-container {
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    border: none;
    max-width: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .canvas-wrapper {
    flex: 1;
    min-height: 0;
  }
}

@media (max-width: 600px) {
  .game-header {
    padding-top: max(calc(var(--safe-top) + 16px), 24px);
    padding-bottom: 8px;
    padding-left: max(env(safe-area-inset-left, 0px), 16px);
    padding-right: max(env(safe-area-inset-right, 0px), 16px);
  }
  .in-game-hud {
    padding: 6px 14px;
    margin-top: 6px;
  }
  .game-footer {
    padding-top: 10px;
    padding-bottom: max(calc(var(--safe-bottom) + 18px), 20px);
    padding-left: 16px;
    padding-right: 16px;
    justify-content: center;
  }
}

@media (min-width: 1025px) {
  body {
    padding: 24px;
  }
  .app-container {
    max-width: 640px;
    height: 94vh;
    max-height: 900px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
  }
}

/* First-play coaching banner */
.coach-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color: #f8fafc;
  pointer-events: auto;
}
.coach-banner[hidden] {
  display: none;
}
.coach-banner.pop {
  animation: coachPop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes coachPop {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.coach-body {
  flex: 1;
  min-width: 0;
}
.coach-step {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fbbf24;
  margin-bottom: 3px;
}
.coach-text {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
}
.coach-skip {
  flex: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.coach-skip:active {
  transform: scale(0.95);
}

/* Floating Toast Notification */
.toast-notification {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-24px);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-accent-soft, rgba(0, 240, 255, 0.35));
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  color: #f8fafc;
  padding: 8px 18px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
  white-space: nowrap;
}

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

.toast-icon {
  font-size: 15px;
}

/* Dev Analytics & Funnel Card */
.dev-analytics-card {
  background: rgba(15, 20, 34, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dev-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dev-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
}

.dev-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric-item {
  background: rgba(120, 130, 150, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.metric-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.metric-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.dev-funnel-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.funnel-box-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.funnel-table-scroll {
  max-height: 140px;
  overflow-y: auto;
}

.funnel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.funnel-table th {
  text-align: left;
  padding: 4px 6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}

.funnel-table td {
  padding: 4px 6px;
  color: var(--text-main);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.funnel-table td.drop-rate {
  font-weight: 700;
  color: #f43f5e;
}

.funnel-table td.drop-rate.good {
  color: #10b981;
}

.dev-endpoint-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dev-label-sm {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.dev-input-row {
  display: flex;
  gap: 6px;
}

.dev-text-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 11px;
}

.dev-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

/* ---------- Thumb-friendly layout ---------- */

/* Level number badge in the level pill */
.level-badge {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

/* Progress row: bar, cleared/total, hearts */
.progress-hud {
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 14px;
}
.progress-track {
  flex: 1;
  min-width: 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(120, 130, 150, 0.18);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--color-accent, #00f0ff);
  transition: width 0.35s ease;
}
.progress-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.progress-icon {
  color: var(--color-accent, currentColor);
  flex: none;
}
.progress-left {
  font-weight: 600;
  color: var(--text-muted);
}

/* Bottom action bar: Restart and Hint share the thumb zone */
.game-footer {
  justify-content: center;
}
.game-footer .btn-bubble {
  flex: 1;
  max-width: 190px;
  justify-content: center;
  position: relative;
  white-space: nowrap;
}
.game-footer .hint-badge {
  position: static;
  margin-left: 2px;
}
.game-footer .hint-btn.disabled {
  opacity: 0.55;
}

/* Theme choices inside Settings > Appearance */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.theme-grid .theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(120, 130, 150, 0.06);
  color: var(--text-main);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.theme-grid .theme-option.active {
  border-color: var(--color-accent, #00f0ff);
  box-shadow: 0 0 0 1px var(--color-accent, #00f0ff) inset;
}

/* Restart asks for a second tap */
.game-footer .btn-bubble.confirm {
  background: #d7263d;
  border-color: #d7263d;
  color: #ffffff;
  animation: restartNudge 0.3s ease;
}
@keyframes restartNudge {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-3px); }
  70% { transform: translateX(3px); }
}

/* Level pill is display-only (no level picker) */
.level-pill-static {
  cursor: default;
  padding-right: 16px;
}
.level-pill-static:hover {
  background: rgba(120, 130, 150, 0.08);
  transform: none;
}

/* ---------- Power-up bar ---------- */
.btn[hidden],
.btn-bubble[hidden] {
  display: none !important;
}
.game-footer {
  gap: 8px;
}
.game-footer .power-btn {
  flex: 1 1 0;
  min-width: 0;
  max-width: 120px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border-radius: 16px;
  font-size: 11.5px;
  line-height: 1;
}
.game-footer .power-btn svg {
  flex: none;
}
.power-label {
  white-space: nowrap;
}
.power-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  background: var(--text-main);
  color: var(--bg-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.power-btn.empty .power-badge {
  background: var(--color-accent, #f59e0b);
  color: var(--bg-card);
}
.power-btn.locked {
  opacity: 0.5;
}
.power-btn.locked .power-badge {
  background: transparent;
  box-shadow: none;
  font-size: 11px;
}
.game-footer .power-btn.active {
  background: var(--color-accent-soft, rgba(0, 240, 255, 0.35));
  border-color: var(--color-accent, #00f0ff);
  box-shadow: 0 0 0 1px var(--color-accent, #00f0ff) inset;
}

/* ---------- Coins ---------- */
.coin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  vertical-align: -2px;
  background: radial-gradient(circle at 35% 30%, #ffe9a3 0%, #f2b531 45%, #c47f12 100%);
  box-shadow: inset 0 0 0 1.5px rgba(150, 95, 10, 0.55);
}
.coin-lg {
  width: 44px;
  height: 44px;
  box-shadow: inset 0 0 0 3px rgba(150, 95, 10, 0.5);
}
.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(120, 130, 150, 0.08);
  color: var(--text-main);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.overlay-reward {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 14px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}
.overlay-reward:empty {
  display: none;
}
.overlay-reward { flex-wrap: wrap; }
.overlay-reward .reward-none { font-size: 13px; font-weight: 600; color: var(--text-muted, #8a8f98); }
.overlay-reward .coin {
  width: 18px;
  height: 18px;
}

/* ---------- Stacked overlay buttons (continue, power-up sheet) ---------- */
.overlay-buttons.stacked {
  flex-direction: column;
  align-items: stretch;
}
.overlay-buttons.stacked .btn {
  width: 100%;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.ghost {
  background: transparent;
  color: var(--text-muted);
}
.power-sheet-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--color-accent, currentColor);
}
.power-sheet-icon svg {
  width: 44px;
  height: 44px;
}

/* ---------- Ad preview (stand-in until real rewarded ads) ---------- */
.ad-preview {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: rgba(10, 12, 18, 0.82);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ad-preview.show {
  opacity: 1;
}
.ad-preview-card {
  width: 320px;
  max-width: 100%;
  padding: 24px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-main);
  text-align: center;
}
.ad-preview-card h3 {
  margin: 8px 0 6px;
  font-size: 18px;
}
.ad-preview-card p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.ad-preview-tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ad-preview-count {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 3px solid var(--color-accent, #00f0ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
}
.ad-preview-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.power-badge[hidden] { display: none; }

/* ---------- Pinch-to-zoom coaching ---------- */
.pinch-coach {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 16px 10px 12px;
  border-radius: 999px;
  background: var(--text-main);
  color: var(--bg-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: auto; /* a tap on it closes it, never reaches the arrows below */
  cursor: pointer;
  animation: coachIn 0.3s ease;
}
.pinch-coach[hidden] {
  display: none;
}
.pinch-coach p {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}
/* Two fingers spread (the board grows: zoom in), then pinch together (it shrinks: zoom out) */
.pinch-coach:not(.no-touch) { flex-direction: column; gap: 4px; border-radius: 22px; padding: 10px 18px 12px; }
.pinch-demo { width: 150px; height: auto; color: var(--bg-card); }
.pinch-demo .pz-board { transform-origin: 70px 50px; transform-box: view-box; animation: pzBoard 3s ease-in-out infinite; }
.pinch-demo .pz-f1 { animation: pzF1 3s ease-in-out infinite; }
.pinch-demo .pz-f2 { animation: pzF2 3s ease-in-out infinite; }
.pinch-coach.pinch-out .pinch-demo * { animation-delay: -1.5s; }
.pinch-coach.no-touch .pinch-demo { display: none; }
@keyframes pzBoard { 0%, 10% { transform: scale(0.75); } 45%, 60% { transform: scale(1.3); } 95%, 100% { transform: scale(0.75); } }
@keyframes pzF1 { 0%, 10% { transform: translate(56px, 62px); } 45%, 60% { transform: translate(30px, 88px); } 95%, 100% { transform: translate(56px, 62px); } }
@keyframes pzF2 { 0%, 10% { transform: translate(84px, 38px); } 45%, 60% { transform: translate(110px, 12px); } 95%, 100% { transform: translate(84px, 38px); } }

@keyframes coachIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* =========================================================
   Minimal layout (round icon buttons, no boxes)
   ========================================================= */
.game-header.minimal {
  padding-top: max(calc(var(--safe-top) + 16px), 24px); /* room below the status bar (owner 2026-12-03) */
  padding-bottom: 6px;
  padding-left: max(env(safe-area-inset-left, 0px), 16px);
  padding-right: max(env(safe-area-inset-right, 0px), 16px);
  background: var(--bg-canvas);
  border-bottom: none;
}
.game-header.minimal .top-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}
.round-btn {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: var(--chip-bg, rgba(120, 130, 150, 0.14));
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}
.round-btn:active {
  transform: scale(0.92);
}
.round-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.round-btn[hidden] {
  display: none !important;
}
.round-btn.lg {
  width: 56px;
  height: 56px;
}
.level-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
}
.level-num {
  min-width: 30px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.game-header.minimal .lives-container {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}
.game-header.minimal .life-heart {
  width: 24px;
  height: 24px;
  font-size: 0;
  color: #e8505b;
  filter: none;
  opacity: 0.18;
  transform: scale(0.85);
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
}
.game-header.minimal .life-heart svg {
  width: 100%;
  height: 100%;
  display: block;
}
.game-header.minimal .life-heart:not(.active) {
  /* A lost heart: an empty red outline, readable on paper and on night */
  color: #e8505b;
  opacity: 0.75;
}
.game-header.minimal .life-heart:not(.active) path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.game-header.minimal .life-heart.active {
  opacity: 1;
  transform: scale(1);
}
.game-header.minimal .header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
}
.game-header.minimal .coin-pill {
  height: 40px;
  border: none;
  background: var(--chip-bg, rgba(120, 130, 150, 0.14));
  padding: 0 12px 0 10px;
}
.coin-pill.bump {
  animation: coinBump 0.25s ease;
}
@keyframes coinBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.game-header.minimal .progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 0 2px;
}
.game-header.minimal .progress-track {
  height: 5px;
  background: var(--chip-bg, rgba(120, 130, 150, 0.14));
}
.game-header.minimal .progress-count {
  font-size: 12px;
  color: var(--text-muted);
  gap: 3px;
}

/* Footer: restart left, power-ups right, no bar */
.game-footer.minimal {
  background: var(--bg-canvas);
  border-top: none;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 6px;
  padding-bottom: max(calc(var(--safe-bottom) + 12px), 18px);
  padding-left: max(env(safe-area-inset-left, 0px), 18px);
  padding-right: max(env(safe-area-inset-right, 0px), 18px);
}
.power-cluster {
  display: flex;
  gap: 12px;
}
.game-footer.minimal .power-badge {
  top: -3px;
  right: -3px;
}
.game-footer.minimal .round-btn.active {
  background: var(--color-accent, #00f0ff);
  color: var(--bg-card);
}
.game-footer.minimal .round-btn.confirm {
  background: #d7263d;
  color: #fff;
  animation: restartNudge 0.3s ease;
}
.power-btn.pop-in {
  animation: powerPop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes powerPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Level title briefly replaces the hearts in the top bar when a level opens */
.level-caption {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  white-space: nowrap;
  max-width: 44%;
}
.level-caption.show {
  opacity: 1;
}
.game-header.minimal .lives-container {
  transition: opacity 0.4s ease;
}
.top-bar.captioning .lives-container {
  opacity: 0;
}
.level-caption-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent, var(--text-muted));
}
.level-caption-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

/* Coins flying into the counter */
.fly-coin {
  position: fixed;
  z-index: 700;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  pointer-events: none;
}

/* Profile stats in Settings */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 4px;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 14px;
  background: var(--chip-bg, rgba(120, 130, 150, 0.12));
  text-align: center;
}
.profile-stat-num {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}
.profile-stat-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Picture reveal: win card thumbnail and Settings album */
.overlay-picture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 4px 0 10px;
  color: var(--color-accent, var(--text-main));
  font-size: 13px;
}
.overlay-picture[hidden] {
  display: none;
}
.overlay-picture span {
  color: var(--text-muted);
}
.overlay-picture b {
  color: var(--text-main);
}
.overlay-picture-art {
  width: 56px;
  height: 84px;
}
.album-count {
  float: right;
  font-weight: 700;
  color: var(--text-muted);
}
.album-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.album-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border-radius: 12px;
  background: var(--chip-bg, rgba(120, 130, 150, 0.1));
  color: var(--color-accent, var(--text-main));
  font-size: 11px;
  font-weight: 600;
}
.album-item svg {
  width: 100%;
  max-width: 44px;
  height: auto;
  aspect-ratio: 2 / 3;
}
.album-item span {
  color: var(--text-muted);
}
.album-item.locked b {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  aspect-ratio: 2 / 3;
  font-size: 20px;
  color: var(--text-muted);
  opacity: 0.5;
}
.collected-pics {
  margin: 6px 0 14px;
}
.collected-pics-head {
  display: flex;
  justify-content: space-between;
  margin: 4px 2px 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
}
.collected-pics .album-count {
  float: none;
}

/* ---------- Daily puzzle ---------- */
.daily-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e8505b;
  box-shadow: 0 0 0 2px var(--bg-canvas);
}
.daily-dot[hidden] {
  display: none;
}
.back-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px 0 10px;
  border: none;
  border-radius: 999px;
  background: var(--chip-bg, rgba(120, 130, 150, 0.14));
  color: var(--text-main);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.back-pill[hidden] {
  display: none;
}
.daily-body {
  padding: 4px 20px max(calc(var(--safe-bottom) + 18px), 22px);
}
.daily-month {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 12px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}
.daily-month .round-btn {
  width: 34px;
  height: 34px;
}
.daily-weekdays,
.daily-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  text-align: center;
}
.daily-weekdays span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.daily-grid {
  margin: 6px 0 16px;
}
.daily-day {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.4;
  cursor: default;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.daily-day.playable {
  opacity: 1;
  color: var(--text-main);
  background: var(--chip-bg, rgba(120, 130, 150, 0.14));
  cursor: pointer;
}
.daily-day.solved {
  opacity: 1;
  background: var(--color-accent, #2a9d8f);
  color: var(--bg-card);
}
.daily-day.solved::after {
  content: '✓';
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 10px;
  width: 15px;
  height: 15px;
  line-height: 15px;
  border-radius: 50%;
  background: var(--text-main);
  color: var(--bg-card);
}
.daily-day.today {
  box-shadow: 0 0 0 2px var(--text-main) inset;
}
.daily-day.selected {
  box-shadow: 0 0 0 3px var(--color-accent, #2a9d8f);
}
.daily-day.empty {
  visibility: hidden;
}
.daily-note {
  margin: 12px 2px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: center;
}

/* Header fits a fourth button on narrow phones */
.game-header.minimal .round-btn {
  width: 38px;
  height: 38px;
}
.game-header.minimal .coin-pill {
  height: 38px;
  padding: 0 10px 0 9px;
  font-size: 13px;
}
.game-header.minimal .life-heart {
  width: 21px;
  height: 21px;
}
@media (max-width: 380px) {
  .game-header.minimal .round-btn {
    width: 33px;
    height: 33px;
  }
  .game-header.minimal .coin-pill {
    height: 33px;
    padding: 0 8px;
    gap: 4px;
  }
  .game-header.minimal .life-heart {
    width: 18px;
    height: 18px;
  }
  .level-num {
    min-width: 24px;
    font-size: 15px;
  }
}

/* Hearts live on the progress row; the level title briefly covers that row */
.game-header.minimal .progress-row {
  position: relative;
  min-height: 26px;
  margin-top: 8px;
}
.game-header.minimal .progress-row .lives-container {
  position: static;
  transform: none;
  flex: none;
  gap: 3px;
  margin-left: 2px;
}
.game-header.minimal .progress-row .life-heart {
  width: 20px;
  height: 20px;
}
.game-header.minimal .progress-row > * {
  transition: opacity 0.35s ease;
}
.game-header.minimal .progress-row.captioning > :not(.level-caption) {
  opacity: 0;
}
.game-header.minimal .progress-row .level-caption {
  inset: 0;
  left: 0;
  top: 0;
  transform: none;
  max-width: none;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}
.game-header.minimal .progress-row .level-caption-name {
  font-size: 15px;
}


/* Language picker */
.lang-select {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 6px 10px; border-radius: 10px; max-width: 48%;
  background: var(--chip-bg-solid, #fff); color: inherit;
  border: 1px solid rgba(128, 128, 128, 0.35);
}
.update-icon { font-size: 34px; }

/* Time-bomb intro animation */
.fuse-demo { position: relative; width: 120px; height: 120px; margin: 0 auto 6px; }
.fuse-bomb { animation: fuse-wobble 0.5s ease-in-out infinite alternate; transform-origin: 50% 70%; }
.fuse-spark { animation: fuse-flicker 0.12s steps(2) infinite; transform-origin: 104px 10px; }
.fuse-ring { animation: fuse-drain 5s linear infinite; }
.fuse-count { position: absolute; left: 0; top: 18px; width: 112px; height: 100px; display: grid; place-items: center; pointer-events: none; }
.fuse-count span { grid-area: 1 / 1; color: #fff; font-weight: 800; font-size: 34px; opacity: 0; animation: fuse-num 5s linear infinite; }
.fuse-count span:nth-child(2) { animation-delay: 1s; }
.fuse-count span:nth-child(3) { animation-delay: 2s; color: #ff9f0a; }
.fuse-count span:nth-child(4) { animation-delay: 3s; color: #ff6b61; }
.fuse-count span:nth-child(5) { animation-delay: 4s; color: #ff3b30; }
@keyframes fuse-wobble { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes fuse-flicker { 0% { transform: scale(0.75); } 100% { transform: scale(1.25); } }
@keyframes fuse-drain { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 100; } }
@keyframes fuse-num { 0%, 19% { opacity: 1; transform: scale(1); } 20%, 100% { opacity: 0; transform: scale(1.3); } }
@media (prefers-reduced-motion: reduce) {
  .fuse-bomb, .fuse-spark, .fuse-ring, .fuse-count span { animation: none; }
  .fuse-count span:first-child { opacity: 1; }
}

/* Feature replay: way back to the player's own level */
.replay-return { margin-left: 6px; font-weight: 800; }

/* Rainbow arrow intro animation: the rainbow arrow flies off, two arrows follow it */
.rainbow-demo { width: 160px; height: 90px; margin: 0 auto 6px; overflow: hidden; }
.rainbow-demo .rb-main { animation: rb-fly 2.4s ease-in infinite; }
.rainbow-demo .rb-f1 { animation: rb-fly 2.4s ease-in infinite; animation-delay: 0.25s; }
.rainbow-demo .rb-f2 { animation: rb-fly 2.4s ease-in infinite; animation-delay: 0.45s; }
@keyframes rb-fly { 0%, 30% { transform: translateX(0); opacity: 1; } 70% { transform: translateX(150px); opacity: 1; } 71%, 85% { transform: translateX(150px); opacity: 0; } 86%, 100% { transform: translateX(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .rainbow-demo g { animation: none; } }
.twister-demo { width: 160px; height: 90px; margin: 0 auto 6px; }
.twister-demo .tw-head { transform-origin: 80px 45px; transform-box: view-box; animation: tw-turn 4s infinite; }
@keyframes tw-turn { 0%, 26% { transform: rotate(0deg); } 33%, 59% { transform: rotate(90deg); } 66%, 93% { transform: rotate(270deg); } 100% { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .twister-demo .tw-head { animation: none; } }
.mirror-demo { width: 160px; height: 90px; margin: 0 auto 6px; }
.mirror-demo .mr-dart { offset-path: path('M60 70 H112 V10'); offset-rotate: auto; animation: mr-fly 2.4s ease-in infinite; }
@keyframes mr-fly { 0% { offset-distance: 0%; opacity: 1; } 85% { opacity: 1; } 100% { offset-distance: 100%; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mirror-demo .mr-dart { animation: none; offset-distance: 30%; } }

/* ---------- Home screen ---------- */
.home-screen {
  position: fixed; inset: 0; z-index: 900; display: none; flex-direction: column;
  align-items: center; padding: calc(var(--safe-top) + 14px) 20px calc(var(--safe-bottom) + 18px);
  background: var(--bg-app); color: var(--text-main); overflow-y: auto;
}
.home-screen.show { display: flex; animation: home-in 0.25s ease-out; }
@keyframes home-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
.home-top { width: 100%; max-width: 440px; display: flex; justify-content: flex-end; gap: 8px; }
@keyframes card-nudge { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.mode-new { flex: none; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px;
  background: #e3b23c; color: #1a1408; animation: sc-pulse 1.8s ease-in-out infinite; }
.mode-new[hidden] { display: none; }
/* Win card: introduces a mode the player hasn't opened yet (main.js showReveal) */
.overlay-reveal { display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 8px; align-items: center;
  margin: 12px 0 14px; padding: 12px; border-radius: 16px; text-align: left;
  background: rgba(227,178,60,0.14); border: 1px solid rgba(227,178,60,0.45); animation: qc-rise 0.5s 0.6s ease-out both; }
.overlay-reveal[hidden] { display: none; }
.reveal-art { grid-row: 1 / span 2; width: 64px; height: 64px; border-radius: 12px; background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.reveal-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.reveal-text b { font-size: 14px; }
.reveal-text small { font-size: 12px; opacity: 0.75; line-height: 1.35; }
.reveal-go { justify-self: start; padding: 8px 16px; font-size: 14px; margin: 0; width: auto; }

.home-top { width: 100%; max-width: 440px; display: flex; justify-content: flex-end; gap: 8px; }
.home-hero { display: flex; flex-direction: column; align-items: center; margin: auto 0 24px; padding-top: 2vh; }
.home-mark { width: min(240px, 56vw, 29vh); height: auto; display: block; } /* 20% smaller, tighter board (owner 2026-11-29) */
.home-mark .hm-dots { fill: var(--text-main); opacity: 0.14; }
.home-mark .b { fill: none; stroke-width: 8.5; stroke-linecap: round; stroke-linejoin: round; } /* lines keep their weight at the smaller size */
.home-mark .h { stroke-width: 3; stroke-linejoin: round; }
.home-mark .hm-ink .b, .home-mark .hm-ink .h { stroke: var(--text-main); }
.home-mark .hm-ink .h { fill: var(--text-main); }
.home-mark .hm-gold .b, .home-mark .hm-gold .h { stroke: var(--hero-gold, var(--color-accent)); }
.home-mark .hm-gold .h { fill: var(--hero-gold, var(--color-accent)); }
.home-mark .hm-gold { filter: drop-shadow(0 0 6px var(--hero-glow, transparent)); }
/* The name is a quiet signature under the board: the arrows and Play carry the screen */
.home-hero h1 { margin: 18px -0.32em 0 0; font-size: 20px; font-weight: 700; letter-spacing: 0.32em; line-height: 1; opacity: 0.55; }
.home-play {
  margin-top: auto; width: min(212px, 58vw); min-height: 68px; border-radius: 34px; border: 0; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 10px 20px;
  background: var(--color-success); color: var(--color-on-success);
  box-shadow: 0 14px 30px rgba(31,29,26,0.22), inset 0 -4px 0 rgba(0,0,0,0.25);
  animation: hp-breathe 2.8s ease-in-out infinite; transition: transform 0.12s ease;
}
.home-play:active { transform: scale(0.97); animation: none; }
.home-play b { font-size: 22px; font-weight: 800; line-height: 1.1; }
.home-play small { font-size: 13px; font-weight: 600; opacity: 0.72; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes hp-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
.home-dock { margin-top: 4vh; display: flex; justify-content: center; gap: 28px; width: 100%; max-width: 440px; }
.dock-btn { position: relative; width: 116px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--text-main); }
.dock-btn[hidden] { display: none; }
.dock-art { position: relative; width: 60px; height: 60px; border-radius: 50%; margin-bottom: 6px; display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); box-shadow: 0 4px 12px rgba(31,29,26,0.08); transition: transform 0.12s ease; }
.dock-btn:active .dock-art { transform: scale(0.94); }
.dock-btn b { font-size: 14px; font-weight: 700; line-height: 1.2; text-align: center; }
.dock-btn small { font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; color: var(--text-muted); }
/* Story wears a round crop of its next land's painting, ringed in gold: the one colourful thing here */
.dock-art.painted { background-size: cover; background-position: center; background-color: #6b5a44;
  box-shadow: 0 0 0 3px var(--bg-app), 0 0 0 5px var(--color-accent), 0 6px 16px rgba(31,29,26,0.18); }
.story-btn small { color: var(--color-accent); filter: brightness(0.85); }
.dock-btn .mode-dot { position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: #d7263d; border: 2px solid var(--bg-app); box-sizing: border-box; }
.dock-btn .mode-dot[hidden] { display: none; }
.dock-btn .mode-new { position: absolute; top: -6px; left: calc(50% + 14px); font-size: 10px; padding: 3px 7px; }
.dock-lock { display: none; }
/* Locked: the painting fades to a sepia print and a small padlock sits on it */
.dock-btn.locked .dock-art { opacity: 0.6; }
.dock-btn.locked .dock-art.painted { opacity: 1; filter: sepia(0.85) grayscale(0.35) brightness(1.08) contrast(0.85); }
.dock-btn.locked .dock-lock { display: flex; position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center;
  background: var(--text-main); color: var(--bg-app); filter: none; }
.dock-btn.locked .dock-lock::before { content: ''; width: 11px; height: 12px;
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 12'%3E%3Cpath d='M2.5 5V3.5a3 3 0 0 1 6 0V5h.5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1zm1.5 0h3V3.5a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 12'%3E%3Cpath d='M2.5 5V3.5a3 3 0 0 1 6 0V5h.5a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1zm1.5 0h3V3.5a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center / contain no-repeat; }
.dock-btn.locked .mode-dot, .dock-btn.locked .mode-new { display: none; }
.dock-btn.nudge { animation: card-nudge 0.4s ease-in-out; }
.home-hint { min-height: 40px; margin: 14px 0 0; max-width: 320px; text-align: center; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--text-muted); opacity: 0; transition: opacity 0.25s ease; }
.home-hint.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .home-play { animation: none; } }

/* ---------- Quests sheet ---------- */
.quest-body { padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
.quest-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; border: 0; width: 100%; text-align: left; font: inherit; color: inherit; background: rgba(128,128,128,0.10); cursor: pointer; }
.quest-card .q-icon { font-size: 30px; flex: none; }
.quest-card .q-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.quest-card .q-text b { font-size: 16px; }
.quest-card .q-text small { font-size: 12px; opacity: 0.7; }
.quest-card .q-bar { height: 6px; border-radius: 3px; background: rgba(128,128,128,0.25); overflow: hidden; margin-top: 6px; }
.quest-card .q-bar i { display: block; height: 100%; background: var(--color-accent); }
.quest-card.locked { opacity: 0.5; }
.quest-card .q-state { font-weight: 800; font-size: 13px; flex: none; }
.quest-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.quest-grid button { aspect-ratio: 1; border-radius: 12px; border: 0; font: inherit; font-weight: 800; font-size: 15px; color: inherit; background: rgba(128,128,128,0.12); cursor: pointer; position: relative; }
.quest-grid button.done { background: rgba(52,199,89,0.18); }
.quest-grid button.next { background: var(--color-success); color: var(--color-on-success); }
.quest-grid button:disabled { opacity: 0.35; cursor: default; }
.quest-grid button small { position: absolute; bottom: 3px; left: 0; right: 0; font-size: 8px; letter-spacing: -1px; }
.quest-intro { font-size: 14px; opacity: 0.75; margin: 0 0 4px; }

/* Toasts on the progress row: same place as the level title, never over the maze */
.game-header.minimal .progress-row .toast-notification {
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  padding: 5px 14px;
  font-size: 12.5px;
  max-width: calc(100% - 4px);
  z-index: 5;
}
.game-header.minimal .progress-row .toast-notification.show {
  transform: translate(-50%, -50%) scale(1);
}
.game-header.minimal .progress-row .toast-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-header.minimal .progress-row.toasting > :not(.toast-notification) {
  opacity: 0;
}

/* Boss level (last level of every quest) */
.boss-crown { font-size: 44px; line-height: 1; margin: 2px auto 4px; animation: boss-bob 1.6s ease-in-out infinite; }
.boss-icons { font-size: 22px; letter-spacing: 6px; margin-bottom: 4px; }
@keyframes boss-bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-5px) rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .boss-crown { animation: none; } }
.quest-grid button.boss { background: linear-gradient(135deg, #ffd66b, #f0a830); color: #4a2a00; font-size: 18px; }
.quest-grid button.boss:disabled { opacity: 0.55; }

/* Quest list: the next level reads as "tap to play", plus one big Play button */
.quest-grid button.next { box-shadow: 0 0 0 3px rgba(52,199,89,0.35); animation: q-next-pulse 1.6s ease-in-out infinite; }
.quest-grid button .q-play { position: absolute; top: 3px; left: 5px; font-size: 9px; opacity: 0.9; }
@keyframes q-next-pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px rgba(52,199,89,0.35); } 50% { transform: scale(1.06); box-shadow: 0 0 0 7px rgba(52,199,89,0.12); } }
.quest-play { display: block; width: 100%; margin: 14px 0 4px; font-size: 16px; padding: 14px; }
@media (prefers-reduced-motion: reduce) { .quest-grid button.next { animation: none; } }

/* Quest complete ceremony */
.quest-ceremony { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 35%, rgba(255,214,107,0.35), rgba(20,16,10,0.72) 70%); }
.quest-ceremony.show { display: flex; }
.qc-card { position: relative; width: min(360px, 100%); background: var(--bg-card, #fbf7ef); color: var(--text-main, inherit); border-radius: 26px;
  padding: 26px 20px 18px; text-align: center; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,0.35); }
.qc-rays { position: absolute; left: 50%; top: 64px; width: 420px; height: 420px; margin: -210px 0 0 -210px; pointer-events: none;
  background: repeating-conic-gradient(rgba(255,196,60,0.22) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: qc-spin 14s linear infinite; }
.qc-trophy { position: relative; font-size: 72px; line-height: 1; }
.qc-title { position: relative; font-size: 26px; font-weight: 800; margin-top: 6px; }
.qc-name { position: relative; font-size: 17px; font-weight: 700; opacity: 0.85; margin-top: 2px; }
.qc-stats { position: relative; font-size: 13px; opacity: 0.7; margin-top: 4px; }
.qc-chest { position: relative; display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 14px; border-radius: 999px;
  background: linear-gradient(135deg, #ffd66b, #f0a830); color: #4a2a00; font-weight: 800; font-size: 14px; }
.qc-chest[hidden] { display: none; }
.qc-next { position: relative; margin-top: 16px; }
.qc-next[hidden] { display: none; }
.qc-next-label { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-success, #34c759); }
.qc-next-card { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 12px; border-radius: 16px; background: rgba(128,128,128,0.1); text-align: left; }
.qc-next-icon { font-size: 34px; }
.qc-lock { font-size: 18px; }
.qc-next-text { display: flex; flex-direction: column; }
.qc-next-text b { font-size: 16px; }
.qc-next-text small { font-size: 12px; opacity: 0.7; }
.qc-soon { position: relative; font-size: 14px; opacity: 0.8; margin: 14px 0 0; }
.qc-soon[hidden] { display: none; }
.quest-ceremony .overlay-buttons { position: relative; margin-top: 16px; }
.quest-ceremony .overlay-buttons button[hidden] { display: none; }
.quest-ceremony.play .qc-card { animation: qc-pop 0.55s cubic-bezier(.2,1.4,.4,1) both; }
.quest-ceremony.play .qc-trophy { animation: qc-trophy 0.9s 0.15s cubic-bezier(.2,1.5,.4,1) both, qc-float 2.4s 1.1s ease-in-out infinite; }
.quest-ceremony.play .qc-chest { animation: qc-pop 0.5s 0.7s cubic-bezier(.2,1.5,.4,1) both; }
.quest-ceremony.play .qc-next { animation: qc-rise 0.5s 1.1s ease-out both; }
.quest-ceremony.play .qc-lock { display: inline-block; animation: qc-unlock 0.7s 1.4s ease-in-out both; }
.quest-ceremony.play .overlay-buttons { animation: qc-rise 0.4s 1.5s ease-out both; }
@keyframes qc-spin { to { transform: rotate(360deg); } }
@keyframes qc-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes qc-trophy { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0); } }
@keyframes qc-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes qc-rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes qc-unlock { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-18deg) scale(1.2); } 60% { transform: rotate(14deg) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .quest-ceremony * { animation: none !important; } }

/* Saga map (Quests): the Arrow of Dawn with its feathers, then a winding path of lands */
.quest-body { position: relative; }
.dawn-arrow { display: block; width: min(260px, 82%); height: auto; margin: 0 auto; overflow: visible; }
.dawn-arrow .da-shaft { stroke: var(--text-main); stroke-width: 2.4; stroke-linecap: round; opacity: 0.75; }
.dawn-arrow .da-head { fill: #d9a520; }
.dawn-arrow .df { fill: none; stroke: var(--text-muted, #888); stroke-width: 1.1; stroke-dasharray: 2 2; opacity: 0.6; }
.dawn-arrow .df.on { fill: #e3b23c; stroke: #b07d12; stroke-dasharray: none; opacity: 1; }
.dawn-arrow .df.fresh { transform-box: fill-box; transform-origin: 70% 50%; animation: df-fly 0.9s 0.9s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes df-fly { from { transform: translate(40px, -60px) rotate(-70deg) scale(1.8); opacity: 0; } to { transform: none; opacity: 1; } }
.saga-head { position: sticky; top: -4px; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: -4px -16px 0; padding: 6px 16px 8px; background: var(--bg-card, #fbf7ef); box-shadow: 0 6px 10px -8px rgba(0,0,0,0.25); }
.saga-head .dawn-arrow { width: min(200px, 58%); margin: 0; }
.saga-goal { font-size: 13px; opacity: 0.75; margin: 0 8px; text-align: center; }
.saga-count { font-weight: 800; font-size: 14px; color: #b07d12; white-space: nowrap; }
.saga-cont { position: sticky; bottom: -20px; z-index: 3; margin: 0 -16px -20px; padding: 10px 16px 16px;
  background: linear-gradient(transparent, var(--bg-card, #fbf7ef) 35%); }
.saga-cont .quest-play { width: 100%; margin: 0; }
.saga-intro { text-align: center; padding: 18px 8px 8px; }
.saga-intro p { font-size: 15px; line-height: 1.5; margin: 14px 4px 18px; }
.saga-map { position: relative; flex: none; margin: 0 -6px 34px; }
.saga-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.saga-path path { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.saga-path .sp-all { stroke: var(--text-muted, #999); stroke-width: 3; stroke-dasharray: 2 9; opacity: 0.55; }
.saga-path .sp-lit { stroke: #e3b23c; stroke-width: 5; }
.saga-node { position: absolute; transform: translate(-50%, -28px); width: 46%; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; padding: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.saga-node .sn-dot { position: relative; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 27px; background: var(--bg-card, #fbf7ef); border: 3px solid var(--border-subtle, rgba(128,128,128,0.3)); box-shadow: var(--shadow-sm); }
.saga-node .sn-label { display: flex; flex-direction: column; line-height: 1.2; text-align: center; }
.saga-node .sn-label b { font-size: 13px; }
.saga-node .sn-label small { font-size: 11px; opacity: 0.65; }
.saga-node .sn-dot.art { width: 68px; height: 68px; padding: 0; background-size: cover; background-position: center; }
.sn-art { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.sn-badge { position: absolute; left: -6px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-style: normal; background: var(--bg-card, #fbf7ef); box-shadow: var(--shadow-sm); }
.saga-node.locked .sn-dot.art { filter: grayscale(0.85) brightness(0.85); }
.saga-node.locked .sn-dot.art { font-size: 14px; }
.saga-node { transform: translate(-50%, -34px); }
.saga-node.done .sn-dot { border-color: #e3b23c; }
.saga-node.here .sn-dot { border-color: var(--color-accent); animation: sn-pulse 1.8s ease-in-out infinite; }
.saga-node.locked { opacity: 0.45; }
.saga-node.locked .sn-dot { font-size: 20px; }
.saga-node.finale .sn-dot { width: 64px; height: 64px; font-size: 32px; border-style: dashed; }
.saga-node.finale.open .sn-dot { border-color: #b0303a; border-style: solid; }
.sn-feather { position: absolute; right: -8px; top: -8px; font-size: 18px; font-style: normal; }
.sn-you { position: absolute; left: -16px; top: -12px; font-size: 22px; font-style: normal; animation: qc-float 1.6s ease-in-out infinite; }
@keyframes sn-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent) 45%, transparent); } 50% { box-shadow: 0 0 0 9px transparent; } }
/* Ceremony: the land's clue and the feather flying onto the arrow */
.qc-story { position: relative; margin-top: 8px; }
.qc-story[hidden] { display: none; }
.qc-land { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #b07d12; }
.qc-clue { font-size: 14px; font-style: italic; line-height: 1.45; margin: 6px 4px 8px; }
.qc-feather { font-size: 13px; font-weight: 800; margin-top: 2px; }
.quest-ceremony.play .qc-story { animation: qc-rise 0.5s 0.45s ease-out both; }
@media (prefers-reduced-motion: reduce) { .saga-node *, .dawn-arrow * { animation: none !important; } }

/* Story scenes (src/scenes.js): animated ink drawings over everything, always on a night backdrop */
.story-scene { --sc-ink: #ece5d6; --sc-dark: #1b1f29; position: fixed; inset: 0; z-index: 1200; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 56px 16px 24px; color: #ece5d6;
  background: radial-gradient(circle at 50% 38%, #1d2330, #0b0d13 75%); opacity: 0; transition: opacity 0.35s; cursor: pointer; }
.story-scene.show { opacity: 1; }
.story-scene.out { opacity: 0; }
.sc-skip { position: absolute; top: max(16px, var(--safe-top)); right: 16px; border: 0; border-radius: 999px; padding: 8px 14px;
  background: rgba(255,255,255,0.1); color: inherit; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.sc-sound { position: absolute; top: max(16px, var(--safe-top)); left: 16px; border: 0; border-radius: 999px; padding: 8px 14px;
  background: #e3b23c; color: #1a1408; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; animation: sc-pulse 1.6s ease-in-out infinite; }
.sc-stage { width: min(88vw, 52vh, 420px); aspect-ratio: 1; }
.sc-stage svg { width: 100%; height: 100%; overflow: visible; }
.sc-caption { max-width: 420px; min-height: 4.4em; margin: 0; text-align: center; font-size: 18px; line-height: 1.45; font-weight: 600; }
.sc-caption.in { animation: sc-cap 0.6s ease-out both; }
.sc-end { width: min(100%, 360px); margin: 0; font-size: 16px; padding: 14px; animation: sc-cap 0.5s 0.8s ease-out both; }
.sc-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sc-dots { display: flex; gap: 6px; }
.sc-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.22); transition: background 0.3s; }
.sc-dots i.on { background: #e3b23c; }
.sc-hint { font-size: 12px; opacity: 0.5; }
.sc-hint[hidden] { display: none; }
.story-scene svg g, .story-scene svg path, .story-scene svg circle, .story-scene svg text, .story-scene svg line { transform-box: fill-box; transform-origin: center; }
.sc-fade { animation: sc-fade 0.9s var(--t, 0s) ease-out both; }
.sc-rise { animation: sc-rise 1s var(--t, 0s) cubic-bezier(.2,.9,.3,1) both; }
.sc-draw { stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: sc-draw var(--d, 1.4s) var(--t, 0s) ease-in-out forwards; }
.sc-glow-g { filter: drop-shadow(0 0 3px rgba(227,178,60,0.7)); }
.sc-pulse { animation: sc-pulse 1.4s ease-in-out infinite; }
.sc-blink { animation: sc-pulse 2.2s ease-in-out infinite; }
.sc-twinkle { animation: sc-pulse 2.6s var(--t, 0s) ease-in-out infinite; }
.sc-taken { animation: sc-taken 2.2s var(--t, 0s) ease-in both; }
.sc-fly { animation: sc-fly 1.4s var(--t, 0s) cubic-bezier(.3,.1,.6,1) forwards; }
.sc-halo { animation: sc-fade 1s var(--t, 0s) both, sc-pulse 1.6s 1.6s ease-in-out infinite; }
.sc-toss { animation: sc-toss 1.2s var(--t, 0s) ease-in-out forwards; }
.sc-flash { opacity: 0; animation: sc-flash 0.9s var(--t, 0s) ease-out forwards; }
.sc-split { animation: sc-split 1.2s 1.0s ease-in forwards; }
.sc-pop { opacity: 0; animation: sc-pop 0.6s var(--t, 0s) cubic-bezier(.2,1.6,.4,1) forwards; }
.sc-shine { opacity: 0; filter: drop-shadow(0 0 8px #ffd66b); animation: sc-shine 2.2s var(--t, 0s) ease-in-out forwards; }
@keyframes sc-pop { from { opacity: 0; transform: scale(2.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
@keyframes sc-shine { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0.6; } }
.sc-sunrise { animation: sc-sun 3s var(--t, 0s) ease-out both; }
.sc-vanish { animation: sc-vanish 4s var(--t, 0s) ease-in forwards; }
.sc-crawl { stroke-dasharray: 40 400; animation: sc-crawl 3.2s linear infinite; filter: drop-shadow(0 0 4px #8a4fb8); }
@keyframes sc-cap { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sc-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes sc-draw { to { stroke-dashoffset: 0; } }
@keyframes sc-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes sc-taken { 0% { opacity: 1; transform: none; } 15% { transform: translate(0, -6px); } 100% { opacity: 0; transform: translate(170px, -96px) scale(0.25); } }
@keyframes sc-fly { to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--r)); } }
@keyframes sc-toss { 0% { transform: none; } 50% { transform: translate(26px, -60px) rotate(120deg); } 100% { transform: translate(52px, -18px) rotate(250deg) scale(0.8); opacity: 0; } }
@keyframes sc-flash { 0% { opacity: 0.95; transform: scale(0.2); } 100% { opacity: 0; transform: scale(3.5); } }
@keyframes sc-split { 0% { transform: none; opacity: 1; } 100% { transform: scale(1.6) rotate(25deg); opacity: 0; } }
@keyframes sc-sun { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 0.9; } }
@keyframes sc-vanish { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-30px) scale(1.1); filter: blur(4px); } }
@keyframes sc-crawl { from { stroke-dashoffset: 440; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .story-scene svg * { animation-duration: 0.01s !important; animation-iteration-count: 1 !important; } }
/* Painted shots: the picture with a slow camera move, soft glows and drifting motes */
.sc-paint { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: 18px; background: #11141c;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.06); animation: sc-fade 0.7s ease-out both; }
.sc-paint::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 50px 14px rgba(8,10,16,0.55); }
.sc-cam { position: absolute; inset: 0; transform-origin: var(--ox) var(--oy); animation: sc-kb var(--kb) ease-out both; }
.sc-cam img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; }
.sc-thumb { filter: blur(10px) saturate(1.1); transform: scale(1.06); }
.sc-full { opacity: 0; transition: opacity 0.6s ease-out; }
.sc-full.ready { opacity: 1; }
@keyframes sc-kb { from { transform: scale(var(--s0)) translate(0, 0); } to { transform: scale(var(--s1)) translate(var(--dx), var(--dy)); } }
.sc-gspot { position: absolute; width: calc(var(--r) * 2); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,214,107,0.55), rgba(255,214,107,0) 70%); mix-blend-mode: screen; animation: sc-breathe 2.4s ease-in-out infinite; }
.m-violet .sc-gspot { background: radial-gradient(circle, rgba(190,150,255,0.5), rgba(190,150,255,0) 70%); }
.sc-motes { position: absolute; inset: 0; pointer-events: none; }
.sc-motes i { position: absolute; width: var(--sz); height: var(--sz); border-radius: 50%; background: #ffd66b; box-shadow: 0 0 6px 1px rgba(255,214,107,0.8);
  opacity: 0; animation: sc-mote var(--d) var(--t) ease-in-out infinite; }
.m-violet .sc-motes i { background: #d4b8ff; box-shadow: 0 0 6px 1px rgba(190,150,255,0.8); }
@keyframes sc-mote { 0% { opacity: 0; transform: translate(0, 0); } 25% { opacity: 0.9; } 100% { opacity: 0; transform: translate(14px, -70px); } }
@keyframes sc-breathe { 0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) scale(0.9); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } }
.story-scene.loading .sc-stage { background: radial-gradient(circle, rgba(227,178,60,0.12), transparent 60%); border-radius: 18px; animation: sc-pulse 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .sc-cam, .sc-motes i, .sc-gspot { animation: none !important; } .sc-motes { display: none; } }
.saga-watch { display: block; margin: 4px auto 0; border: 0; background: none; color: #b07d12; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }

/* Quest complete, simplified: land painting, feather won, arrow, clue, one button */
.qc-landart { position: relative; width: 104px; height: 104px; margin: 4px auto 0; border-radius: 50%; background-size: cover; background-position: center;
  border: 4px solid #e3b23c; box-shadow: 0 10px 24px rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; font-size: 48px; }
.quest-ceremony.play .qc-landart { animation: qc-trophy 0.9s 0.15s cubic-bezier(.2,1.5,.4,1) both; }
.qc-card .qc-land { position: relative; margin-top: 12px; }
.qc-card .qc-title { font-size: 24px; margin-top: 2px; }
.qc-card .qc-arrow { position: relative; margin: 10px 0 4px; }
.qc-card .qc-clue { position: relative; margin: 6px 6px 0; }
.qc-card .qc-chest { padding: 5px 12px; font-size: 14px; margin-top: 12px; }
.qc-actions { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 16px; }
.qc-actions .btn { margin: 0; }
.qc-actions [hidden] { display: none; }
.qc-link { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 700; color: var(--text-muted, #777); padding: 8px; cursor: pointer; }
.quest-ceremony.play .qc-actions { animation: qc-rise 0.4s 1.1s ease-out both; }
.quest-ceremony.play .qc-clue { animation: qc-rise 0.5s 0.5s ease-out both; }

/* Lab (team-only prototypes) */
.lab-icon { font-size: 44px; text-align: center; margin-bottom: 6px; }
.lab-note { font-size: 11px; opacity: 0.6; margin-top: -4px; }
.lab-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; max-height: 52vh; overflow-y: auto; }
.lab-list .lab-pick { pointer-events: auto; font-size: 12px; padding: 10px 8px; }

/* Day & Night (lab): a banner centred above the board, and the board's light follows the clock */
.phase-banner {
  display: inline-flex; align-items: center; gap: 4px; flex: none; pointer-events: none;
  padding: 2px 8px 2px 6px; border-radius: 999px; white-space: nowrap;
  font: 800 11px/1.2 system-ui, sans-serif; color: #7a4a00;
  background: #ffe7b8;
  transition: background-color 0.4s ease, color 0.4s ease;
}
.phase-banner[hidden] { display: none; }
.phase-banner.night { background: #2c2f6b; color: #e3e6ff; }
.phase-banner .phase-icon { font-size: 12px; display: inline-block; }
.phase-banner.flip .phase-icon { animation: phase-spin 0.35s ease; }
.phase-banner.flip { animation: phase-pop 0.35s ease; }
@keyframes phase-spin { 0% { transform: rotate(-180deg) scale(0.3); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes phase-pop { 0% { transform: scale(0.9); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }
.canvas-wrapper.lab-day { background: color-mix(in srgb, var(--bg-canvas) 86%, #ffb43a); transition: background-color 0.18s ease; }
.canvas-wrapper.lab-night { background: color-mix(in srgb, var(--bg-canvas) 70%, #2a3290); transition: background-color 0.18s ease; }

/* ---------- Win celebration: rays, hearts landing one by one, title pop, count-ups ---------- */
.win-card { overflow: visible; }
.win-rays {
  position: absolute;
  left: 50%;
  top: 44px;
  width: 300px;
  height: 300px;
  margin: -150px 0 0 -150px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--color-accent, #9a6b2f) 26%, transparent) 0deg 9deg, transparent 9deg 22.5deg);
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%);
  mask: radial-gradient(circle, #000 18%, transparent 68%);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
  z-index: -1;
}
.level-overlay.show .win-rays {
  animation: winRaysIn 0.7s 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards, winRaysSpin 14s linear infinite;
}
@keyframes winRaysIn { to { opacity: 1; transform: scale(1); } }
@keyframes winRaysSpin { from { rotate: 0deg; } to { rotate: 360deg; } }

.win-card .chance-heart.big { font-size: 38px; }
.win-card.celebrating .chance-heart { filter: grayscale(1) opacity(0.22); transform: scale(0.8); transition: none; }
.win-card.celebrating .chance-heart.landed {
  filter: none;
  animation: heartLand 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}
@keyframes heartLand {
  0% { transform: scale(2.4) rotate(-14deg); opacity: 0; }
  55% { transform: scale(0.86) rotate(4deg); opacity: 1; }
  100% { transform: scale(1.1) rotate(0deg); opacity: 1; }
}
.win-card .chance-heart { position: relative; display: inline-block; }
.win-card .chance-heart.landed::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--color-accent, #9a6b2f);
  animation: heartRing 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes heartRing { from { transform: scale(0.4); opacity: 0.9; } to { transform: scale(1.7); opacity: 0; } }

.level-overlay.show .win-card h3 { animation: winTitle 0.55s 0.15s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
.level-overlay.show .win-card > p { animation: winFadeUp 0.45s 0.35s ease-out both; }
.level-overlay.show .win-card .overlay-stats { animation: winFadeUp 0.45s 0.45s ease-out both; }
.level-overlay.show .win-card .overlay-buttons { animation: winFadeUp 0.45s 0.9s ease-out both; }
.win-card .overlay-reward.pop { animation: winReward 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes winTitle {
  0% { transform: scale(0.3); opacity: 0; letter-spacing: 6px; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes winFadeUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes winReward {
  0% { transform: scale(0.2); opacity: 0; }
  60% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
/* flawless: a shine sweeps across the title */
.win-card.flawless h3 {
  background: linear-gradient(100deg, var(--text-main) 40%, var(--color-accent, #9a6b2f) 50%, var(--text-main) 60%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.level-overlay.show .win-card.flawless h3 {
  animation: winTitle 0.55s 0.15s cubic-bezier(0.2, 1.5, 0.4, 1) both, winShine 2.4s 0.9s ease-in-out infinite;
}
@keyframes winShine { from { background-position: 100% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) {
  .level-overlay.show .win-rays { animation: winRaysIn 0.3s forwards; }
}
.win-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 102;
}

/* ---------- The Story opens (playStoryUnlock) ---------- */
.unlock-veil { position: fixed; inset: 0; z-index: 5; background: rgba(8, 10, 18, 0.86); opacity: 0; transition: opacity 0.35s ease; }
.unlock-veil.show { opacity: 1; }
.dock-btn.unlocking { z-index: 6; }
.dock-btn.unlocking b, .dock-btn.unlocking small { color: #f4efe4; }
.dock-btn.glow .dock-art { box-shadow: 0 0 0 3px rgba(227,178,60,0.95), 0 0 34px 8px rgba(227,178,60,0.6); transition: box-shadow 0.8s ease; }
.unlock-grey { position: absolute; inset: 0; z-index: 0; border-radius: inherit; background-size: cover; background-position: center; background-color: #3a3a3e; background-blend-mode: luminosity; transition: opacity 1.4s ease; }
.unlock-grey.fade { opacity: 0; }
.unlock-lock { position: absolute; left: 50%; top: 50%; margin: -15px 0 0 -13px; font-size: 26px; line-height: 30px; z-index: 2; display: inline-block; }
.unlock-heart, .unlock-spark { position: fixed; z-index: 7; font-size: 22px; pointer-events: none; will-change: transform; }
.unlock-heart { color: #f5c84c; text-shadow: 0 0 10px rgba(245,200,76,0.9); }
.unlock-spark { font-size: 16px; }
.unlock-panel { position: fixed; left: 50%; z-index: 7; width: min(380px, calc(100% - 32px)); box-sizing: border-box; padding: 18px 18px 8px; border-radius: 22px; background: rgba(14, 16, 28, 0.94); box-shadow: 0 12px 40px rgba(0,0,0,0.5); transform: translate(-50%, 12px); opacity: 0; transition: opacity 0.4s ease, transform 0.4s ease; text-align: center; color: #f4efe4; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.unlock-panel.show { opacity: 1; transform: translate(-50%, 0); }
.unlock-panel b { font-size: 24px; font-weight: 800; }
.unlock-panel p { margin: 0 0 6px; font-size: 15px; opacity: 0.85; line-height: 1.4; }
.unlock-panel .btn { width: 100%; background: #e3b23c; color: #1b1608; border-color: #e3b23c; box-shadow: 0 6px 24px rgba(227,178,60,0.35); }
.unlock-later { background: none; border: 0; color: inherit; opacity: 0.7; font: inherit; font-size: 14px; padding: 8px; cursor: pointer; }

/* ---------- Daily login gift (maybeShowLoginGift) ---------- */
.gift-veil { display: flex; align-items: center; justify-content: center; padding: 16px; }
.gift-card { width: min(360px, 100%); background: var(--bg-card); color: var(--text-main); border-radius: 24px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.4); transform: scale(0.9); transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1); }
.gift-veil.show .gift-card { transform: scale(1); }
.gift-box { font-size: 52px; line-height: 1; animation: gift-bob 1.6s ease-in-out infinite; }
@keyframes gift-bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(4deg); } }
.gift-title { display: block; margin-top: 8px; font-size: 20px; font-weight: 800; }
.gift-amount { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 34px; font-weight: 800; margin: 6px 0 14px; }
.gift-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 10px; }
.gift-chip { border-radius: 10px; padding: 6px 0; background: var(--bg-subtle, rgba(0,0,0,0.05)); display: flex; flex-direction: column; gap: 2px; opacity: 0.75; }
.gift-chip small { font-size: 9px; font-weight: 700; opacity: 0.7; white-space: nowrap; }
.gift-chip b { font-size: 13px; }
.gift-chip.done { opacity: 0.5; }
.gift-chip.today { opacity: 1; background: #e3b23c; color: #1b1608; box-shadow: 0 0 0 2px rgba(227,178,60,0.4); }
.gift-tomorrow { margin: 0 0 14px; font-size: 13px; opacity: 0.7; }
.gift-unit { margin: -12px 0 12px; font-size: 13px; font-weight: 700; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.08em; }
.gift-chip b { display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.gift-chip b .coin { width: 10px; height: 10px; }
.gift-box.opening { animation: gift-shake 0.42s ease-in-out; }
@keyframes gift-shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg) scale(1.05); } 40% { transform: rotate(10deg) scale(1.1); } 60% { transform: rotate(-8deg) scale(1.12); } 80% { transform: rotate(6deg) scale(1.15); } }
.gift-box.burst { animation: gift-burst 0.5s ease-out forwards; }
@keyframes gift-burst { 0% { transform: scale(1.15); opacity: 1; } 40% { transform: scale(1.5); opacity: 1; filter: brightness(1.4); } 100% { transform: scale(0.9); opacity: 0.35; } }
.gift-coin { position: fixed; z-index: 8; width: 26px; height: 26px; pointer-events: none; will-change: transform; }
.gift-wallet { position: fixed; top: max(16px, var(--safe-top)); right: 16px; z-index: 8; display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 10px;
  border-radius: 999px; background: var(--bg-card); color: var(--text-main); font-size: 18px; box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0; transform: translateY(-12px); transition: opacity 0.3s ease, transform 0.3s ease; }
.gift-wallet.show { opacity: 1; transform: translateY(0); }
.gift-wallet .coin { width: 22px; height: 22px; }
.gift-wallet b { font-variant-numeric: tabular-nums; min-width: 3ch; }
.gift-wallet.bump { animation: gift-pill-bump 0.22s ease-out; }
@keyframes gift-pill-bump { 50% { transform: scale(1.12); } }
.gift-collect { width: 100%; background: #e3b23c; color: #1b1608; border-color: #e3b23c; }

/* ---------- Streak road (Daily screen) ---------- */
.streak-road { padding: 4px 10px 2px; margin-bottom: 10px; }
.road-track { position: relative; height: 58px; margin: 0 14px 0 4px; }
.road-line { position: absolute; left: 0; right: 0; top: 15px; height: 6px; border-radius: 3px; background: var(--border-subtle, rgba(0,0,0,0.1)); overflow: hidden; }
.road-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #e3b23c); border-radius: 3px; transition: width 0.6s ease; }
.road-node { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.road-gift { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--bg-card); border: 2px solid var(--border-subtle, rgba(0,0,0,0.12)); }
.road-node small { font-size: 10px; font-weight: 700; opacity: 0.65; white-space: nowrap; }
.road-node.reached .road-gift { background: #e3b23c; border-color: #e3b23c; color: #1b1608; font-weight: 800; }
.road-node.next .road-gift { border-color: #e3b23c; animation: road-pulse 1.4s ease-in-out infinite; }
@keyframes road-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(227,178,60,0.55); } 50% { box-shadow: 0 0 0 7px rgba(227,178,60,0); } }
.road-caption { margin: 2px 0 0; font-size: 13px; font-weight: 600; text-align: center; }

/* ---------- Magic Wand button ---------- */
.power-btn.wand-btn { box-shadow: 0 0 0 2px rgba(227,178,60,0.45), var(--shadow-sm, none); }
.btn.wand-go { background: #e3b23c; color: #1b1608; border-color: #e3b23c; box-shadow: 0 6px 20px rgba(227,178,60,0.35); font-weight: 800; }

/* ---------- Saga map: a living world (animateSagaMap) ---------- */
.saga-world { margin: 6px -10px 34px; border-radius: 22px; overflow: hidden; color: #f4efe4;
  background: linear-gradient(to bottom, #2f3d2c 0%, #34473f 22%, #34405a 50%, #232a48 75%, #121733 100%);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.45); }
.sw-bands, .sw-stars, .sw-clouds, .sw-flies { position: absolute; inset: 0; pointer-events: none; }
.sw-band { position: absolute; width: 300px; height: 230px; transform: translate(-50%, -50%); opacity: 0.5;
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent 100%); mask-image: radial-gradient(closest-side, #000 35%, transparent 100%); }
.sw-band img { width: 100%; height: 100%; object-fit: cover; filter: blur(14px) saturate(1.2); }
.sw-paint { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease; pointer-events: none; }
.saga-world.painted .sw-paint { opacity: 1; }
.saga-world.painted .sw-bands { display: none; }
.sw-stars { top: auto; height: 22%; }
.sw-stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff6d8; animation: sw-twinkle 3s ease-in-out infinite; animation-delay: var(--t); }
@keyframes sw-twinkle { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
.sw-clouds i { position: absolute; left: -45%; width: 60%; height: 90px; border-radius: 50%; opacity: 0.16;
  background: radial-gradient(ellipse at 30% 55%, #fff 0 30%, transparent 62%), radial-gradient(ellipse at 62% 45%, #fff 0 34%, transparent 66%);
  filter: blur(6px); animation: sw-drift var(--d) linear infinite; animation-delay: var(--t); }
@keyframes sw-drift { from { transform: translateX(0); } to { transform: translateX(260%); } }
.sw-flies i { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #ffe9a3; box-shadow: 0 0 8px 2px rgba(255,220,120,0.7);
  animation: sw-fly 5s ease-in-out infinite; animation-delay: var(--t); opacity: 0; }
@keyframes sw-fly { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 0.9; } 60% { opacity: 0.6; transform: translate(14px, -18px); } 100% { opacity: 0; transform: translate(-6px, -34px); } }
.saga-world .saga-path .sp-all { stroke: #f4efe4; opacity: 0.4; }
.saga-world .saga-path .sp-lit { stroke: #e3b23c; filter: drop-shadow(0 0 4px rgba(227,178,60,0.8)); }
.saga-world .saga-node { color: #f4efe4; }
.saga-world .saga-node .sn-label b { text-shadow: 0 1px 4px rgba(0,0,0,0.85); }
.saga-world .saga-node .sn-label small { opacity: 0.8; text-shadow: 0 1px 3px rgba(0,0,0,0.85); }
.saga-world .saga-node.locked { opacity: 0.6; }
.saga-world .saga-node .sn-dot { box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
.saga-world .saga-node.done .sn-dot { box-shadow: 0 0 0 2px #e3b23c, 0 0 22px rgba(227,178,60,0.55); }
.sn-ring { position: absolute; left: 50%; top: 34px; width: 84px; height: 84px; transform: translate(-50%, -50%) rotate(-90deg); pointer-events: none; z-index: 1; }
.sn-ring circle { fill: none; stroke: rgba(255,255,255,0.22); stroke-width: 4; }
.sn-ring .sr-done { stroke: #e3b23c; stroke-linecap: round; }
/* Lands not reached yet: their painting as a faded sepia ink print on cream paper (not coloured in
   yet), in a dashed ink ring. A land that has just opened starts as the
   sketch and its painting washes in from the centre (.inking -> .inked). */
.saga-world .saga-node.locked { opacity: 1; }
.saga-world .saga-node.locked .sn-dot.art,
.saga-world .saga-node.inking .sn-dot.art { filter: none; background-color: #f3ead6; background-image: none !important; border: 2px dashed rgba(244,239,228,0.75); box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
.saga-world .saga-node.locked .sn-art,
.saga-world .saga-node.inking .sn-art { filter: grayscale(1) contrast(1.3) brightness(1.2) sepia(0.6); mix-blend-mode: multiply; opacity: 0.85; }
.saga-world .saga-node.locked .sn-label { opacity: 0.65; }
.sn-color { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; clip-path: circle(0% at 50% 50%); transition: clip-path 1.8s cubic-bezier(0.3, 0.1, 0.3, 1); }
.saga-world .saga-node.inking.inked .sn-color { clip-path: circle(75% at 50% 50%); }
.saga-world .saga-node.inking.inked .sn-dot.art { border-style: solid; border-color: #e3b23c; transition: border-color 1.8s ease; }
.saga-world .saga-node.inking .sn-dot::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 3px #e3b23c, 0 0 30px 8px rgba(227,178,60,0.7); }
.saga-world .saga-node.inking.inked .sn-dot::after { animation: sw-bloom 1.8s ease-out; }
@keyframes sw-bloom { 0% { opacity: 0; transform: scale(0.7); } 35% { opacity: 1; } 100% { opacity: 0; transform: scale(1.5); } }
/* "You are here": a red map pin standing on the current land, its tip on the land's circle, a soft
   pulse where it touches (owner 2026-11-29: like a real map, replaces the floating 🏹) */
.saga-hero { position: absolute; z-index: 4; width: 30px; height: 40px; margin: -72px 0 0 -15px; pointer-events: none; }
.saga-hero span { position: absolute; inset: 0; display: block; transform-origin: 50% 100%; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.45)); animation: pin-bob 1.8s ease-in-out infinite; }
.saga-hero svg { display: block; }
.saga-hero .pin-pulse { position: absolute; left: 50%; bottom: -5px; width: 26px; height: 10px; margin-left: -13px; border-radius: 50%; background: rgba(229,72,59,0.55); animation: pin-pulse 1.8s ease-out infinite; }
@keyframes pin-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes pin-pulse { 0% { transform: scale(0.5); opacity: 0.9; } 100% { transform: scale(1.9); opacity: 0; } }
.saga-hero.walking span { animation: sw-step 0.32s ease-in-out infinite alternate; }
.saga-hero.walking .pin-pulse { display: none; }
@keyframes sw-step { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-5px) rotate(6deg); } }
.saga-hero.arrived span { animation: pin-drop 0.55s cubic-bezier(.3,1.6,.5,1); }
@keyframes pin-drop { 0% { transform: translateY(-22px) scale(0.9); } 100% { transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .saga-hero span, .saga-hero .pin-pulse { animation: none; } }
@media (prefers-reduced-motion: reduce) { .sw-clouds i, .sw-flies i, .sw-stars i { animation: none !important; } }

/* "Not now" must read as a live button even next to a greyed-out Buy */
.power-sheet .btn.ghost { color: var(--text-main); font-weight: 700; opacity: 0.9; }

.overlay-stats[hidden] { display: none; }
.win-card .overlay-reward { margin-top: 10px; }

/* Power intro demos (src/powerDemos.js) */
.power-sheet-icon.has-demo { margin: -4px 0 8px; }
.power-sheet-icon .power-demo { width: min(100%, 280px); height: auto; aspect-ratio: 240 / 150;
  --demo-ink: var(--text-main); --demo-btn: rgba(120,130,150,0.22); --demo-board: rgba(120,130,150,0.12); }
.power-demo .pd-hand { transform: translate(250px, 170px); }

/* Story mechanic intro demos (src/mechanicDemos.js) */
.has-mech { width: auto !important; height: auto !important; margin: -4px auto 8px !important; overflow: visible !important; display: flex; justify-content: center; }
.mech-demo { width: min(100%, 290px); height: auto; aspect-ratio: 240 / 140; --demo-ink: var(--text-main); --demo-board: rgba(120,130,150,0.12); }

/* Guided first use of a power (startCoach): spotlight, tapping hand, bubble */
.coach { position: fixed; inset: 0; z-index: 850; pointer-events: none; opacity: 0; transition: opacity 0.25s ease; }
.coach.show { opacity: 1; }
.coach-spot { position: fixed; border-radius: 50%; box-shadow: 0 0 0 3px #e3b23c, 0 0 18px 4px rgba(227,178,60,0.45); transition: left 0.35s ease, top 0.35s ease, width 0.35s ease, height 0.35s ease; }
.coach-hand { position: fixed; width: 0; height: 0; transition: left 0.35s ease, top 0.35s ease; }
.coach-hand span { position: absolute; left: -12px; top: 2px; font-size: 38px; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.45)); animation: coach-tap 1.1s ease-in-out infinite; transform-origin: 40% 10%; }
@keyframes coach-tap { 0%, 100% { transform: translate(5px, 7px) scale(1); } 45% { transform: translate(0, 0) scale(1); } 60% { transform: translate(0, 0) scale(0.84); } 75% { transform: translate(0, 0) scale(1); } }
.coach-hand.nudge span { animation: coach-nudge 0.35s ease-in-out, coach-tap 1.1s ease-in-out 0.35s infinite; }
@keyframes coach-nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
.coach-bubble { position: fixed; left: 50%; transform: translateX(-50%); max-width: min(320px, calc(100% - 32px)); padding: 10px 16px; border-radius: 16px;
  background: #f4efe4; color: #1b1608; font-size: 16px; font-weight: 800; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.4); transition: top 0.35s ease; }

/* Portrait only: a phone turned sideways sees a "turn upright" note over the game */
.rotate-notice { display: none; }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate-notice {
    display: flex; position: fixed; inset: 0; z-index: 10000; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    background: var(--bg-app, #f7f3ea); color: var(--text-main, #22252b); font-weight: 700; font-size: 18px; text-align: center; padding: 16px;
  }
  .rotate-phone { width: 34px; height: 58px; border: 3px solid currentColor; border-radius: 8px; animation: rotate-hint 2.4s ease-in-out infinite; }
}
@keyframes rotate-hint { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { .rotate-phone { animation: none; } }
.level-overlay.power-sheet.howto { z-index: 980; position: fixed; inset: 0; } /* "How it works" opens over the quest page (950) */

/* Home, three equal modes in fixed spots (Classic | Story | Daily): cards side by side */
.home-dock.modes3 { margin: 5vh 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 420px; }
.modes3 .dock-btn { width: auto; min-width: 0; padding: 16px 6px 14px; border-radius: 22px; background: var(--bg-card);
  box-shadow: 0 6px 18px rgba(31,29,26,0.08); transition: transform 0.12s ease; }
.modes3 .dock-btn:active { transform: scale(0.97); }
.modes3 .dock-btn:active .dock-art { transform: none; }
.modes3 .dock-art { width: 64px; height: 64px; background-color: var(--bg-app); box-shadow: none; }
.modes3 .dock-art.painted { background-color: #6b5a44; }
.modes3 .dock-art.painted { box-shadow: 0 0 0 3px var(--bg-card), 0 0 0 5px var(--color-accent); }
.modes3 .dock-btn b { font-size: 15px; }
.modes3 .dock-btn small { max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.modes3 .dock-btn .mode-new { left: auto; right: 8px; top: -8px; }
/* Classic's levels (main.js renderClassicLevels): the quest grid, scrolled to the next level */
.classic-grid { max-height: 46vh; overflow-y: auto; padding: 8px; }

/* Daily sheet, icons over words: streak / best chips; the empty note and caption take no room */
#dailyStreak { display: flex; gap: 8px; margin-top: 4px; }
.d-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: rgba(227,178,60,0.16); font-size: 14px; font-weight: 800; color: var(--text-main); }
.road-node { cursor: pointer; }
.road-node small { font-size: 12px; }
.road-caption:empty, .daily-note:empty { display: none; }
.road-caption { min-height: 0; }
#btnPlayDaily .coin { width: 16px; height: 16px; display: inline-block; vertical-align: -2px; }
/* The road runs on past the last released land into mist: more lands are coming (no names, no art) */
.saga-node.soon .sn-dot { border-style: dashed; border-color: rgba(244,239,228,0.55); background: rgba(244,239,228,0.10); font-size: 24px; animation: soon-breathe 2.6s ease-in-out infinite; }
.saga-node.soon .sn-label b { opacity: 0.8; font-weight: 700; }
@keyframes soon-breathe { 0%, 100% { transform: scale(1); opacity: 0.75; } 50% { transform: scale(1.06); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .saga-node.soon .sn-dot { animation: none; } }

/* ---------- Game toolbar, minimal (owner 2026-11-29: "more professional and minimal") ----------
   Restart alone on the left; the powers share one slim bar on the right. Line icons, no tiles;
   counts are small quiet badges, an empty power shows a small gold +. */
.game-footer.minimal { align-items: center; }
.game-footer.minimal .round-btn.lg { width: 48px; height: 48px; }
.game-footer.minimal #btnReset { background: var(--bg-card); box-shadow: inset 0 0 0 1px rgba(29,27,23,0.08); color: var(--text-main); }
.game-footer.minimal .power-cluster { gap: 2px; padding: 4px; border-radius: 999px; background: var(--bg-card); box-shadow: inset 0 0 0 1px rgba(29,27,23,0.08); }
.game-footer.minimal .power-cluster:not(:has(.power-btn:not([hidden]))) { display: none; }
.game-footer.minimal .power-btn { flex: none; width: 48px; height: 48px; max-width: none; padding: 0; border-radius: 50%; background: transparent; box-shadow: none; color: var(--text-main); }
.game-footer.minimal .power-btn.wand-btn { box-shadow: none; }
.game-footer.minimal .power-btn:active { background: rgba(29,27,23,0.06); }
.game-footer.minimal .power-badge { top: 4px; right: 3px; min-width: 15px; height: 15px; padding: 0 4px; font-size: 9.5px; font-weight: 800;
  background: var(--text-main); color: var(--bg-card); box-shadow: 0 0 0 2px var(--bg-card); }
.game-footer.minimal .power-btn.empty .power-badge { background: transparent; color: #B07D22; box-shadow: none; font-size: 13px; top: 2px; right: 4px; }
.game-footer.minimal .power-btn.locked .power-badge { background: transparent; box-shadow: none; font-size: 9px; }
.game-footer.minimal .power-btn.active { background: var(--text-main); color: var(--bg-card); }
.game-footer.minimal .power-btn.active .power-badge { background: var(--bg-card); color: var(--text-main); box-shadow: 0 0 0 2px var(--text-main); }
/* Top bar matches the toolbar: light card buttons with a hairline, not heavy tiles */
.game-header.minimal .round-btn, .game-header.minimal .coin-pill { background: var(--bg-card); box-shadow: inset 0 0 0 1px rgba(29,27,23,0.08); }
.game-header.minimal .round-btn:disabled { background: transparent; box-shadow: none; }
/* Streak road prizes show what they hold: the power's toolbar icon or the game coin */
.road-gift .road-icon { display: flex; color: var(--text-main); }
.road-gift .road-icon svg { width: 20px; height: 20px; }
.road-gift .coin { width: 20px; height: 20px; }
.road-caption .road-icon, .road-caption .coin { display: inline-flex; vertical-align: -4px; }
.road-caption .road-icon svg { width: 18px; height: 18px; }
.road-caption .coin { width: 16px; height: 16px; vertical-align: -2px; }

/* Painted toolbar icons (owner 2026-11-29, src/icons/*.webp from scripts' art folder icon-*.png) */
.tb-icon { width: 30px; height: 30px; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
#btnReset .tb-icon { width: 26px; height: 26px; filter: var(--icon-ink-filter, none); }
.game-footer.minimal .power-btn.active { background: rgba(29,27,23,0.08); color: var(--text-main); box-shadow: inset 0 0 0 2px var(--text-main); }
.game-footer.minimal .power-btn.active .power-badge { background: var(--text-main); color: var(--bg-card); box-shadow: 0 0 0 2px var(--bg-card); }
.power-btn.locked .tb-icon { filter: grayscale(1); }
.power-sheet-icon .tb-icon { width: 64px; height: 64px; margin: 0 auto; }
/* The game coin is the painted one everywhere */
.coin { background: url('icons/coin.webp') center / contain no-repeat; box-shadow: none; border-radius: 0; }
/* Painted icons inline in messages and buttons (src/gameIcons.js) */
.gi { width: 1.25em; height: 1.25em; vertical-align: -0.25em; display: inline-block; }
.toast-icon .gi { width: 22px; height: 22px; vertical-align: middle; }
/* Classic grid: locked levels ahead, the last rows fading out (the game goes on) */
.classic-grid { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 70px), rgba(0,0,0,0.15)); mask-image: linear-gradient(to bottom, #000 calc(100% - 70px), rgba(0,0,0,0.15)); }
.quest-grid button.ahead:disabled { opacity: 0.6; background: rgba(128,128,128,0.10); color: var(--text-muted); }
.quest-grid button .cl-pic { position: absolute; top: 3px; right: 4px; font-size: 10px; font-style: normal; line-height: 1; }
/* Home card paintings: rounded squares, no gold ring (owner 2026-11-29: circles + ring read as a WhatsApp story) */
.modes3 .dock-art.painted { border-radius: 18px; box-shadow: 0 4px 12px rgba(29,27,23,0.16); width: 72px; height: 72px; }
.modes3 .dock-btn.locked .dock-art.painted { box-shadow: 0 2px 6px rgba(29,27,23,0.10); }
.modes3 .dock-btn .mode-dot { top: -4px; right: -4px; }
/* Streak chip is a button; tapping it shows the streak card (current + best) */
button.d-chip { border: 0; font-family: inherit; font-size: 14px; font-weight: 800; color: var(--text-main); cursor: pointer; }
button.d-chip:active { transform: scale(0.96); }
.daily-sheet { position: relative; }
.streak-pop { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(29,27,23,0.35); border-radius: inherit; animation: sp-in 0.18s ease-out; }
.sp-card { display: flex; gap: 28px; padding: 22px 30px; border-radius: 22px; background: var(--bg-card); box-shadow: 0 16px 40px rgba(0,0,0,0.25); }
.sp-row { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 72px; }
.sp-ic { font-size: 30px; line-height: 1; }
.sp-row b { font-size: 34px; font-weight: 800; line-height: 1.1; color: var(--text-main); }
.sp-row small { font-size: 13px; font-weight: 600; color: var(--text-muted); }
@keyframes sp-in { from { opacity: 0; } to { opacity: 1; } }
/* Home mode tiles, option C (owner 2026-11-29): soft colour tiles with ink pictograms and one gold accent */
.modes3 .dock-art.mode-tile { width: 76px; height: 76px; background: none; box-shadow: none; border-radius: 22px; }
.modes3 .dock-art.mode-tile svg { width: 100%; height: 100%; display: block; }
.modes3 .dock-btn.locked .dock-art.mode-tile { opacity: 1; }
.modes3 .dock-btn.locked .dock-art.mode-tile svg { filter: grayscale(1) opacity(0.55); }

/* Budget phones (html.lite, src/perf.js): no live blur behind cards. Re-blurring the board every
   frame overloaded weak GPUs (startup ANR on a vivo, 2026-12-04); a slightly deeper tint instead. */
.lite .level-overlay,
.lite .modal-backdrop,
.lite .coach-banner,
.lite .toast-notification {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.lite .level-overlay { background: rgba(15, 23, 42, 0.82); }
.lite .modal-backdrop { background: rgba(15, 23, 42, 0.62); }

/* Website demo (src/webDemo.js): one Play button on the home screen, and the "get the app" card */
.web-demo .home-dock { display: none; }
.web-demo .home-hero { margin: auto 0 34px; padding-top: 0; } /* logo + Play sit together in the middle, no empty top (owner 2026-12-04) */
.web-demo .home-mark { width: min(300px, 72vw, 38vh); }
.web-demo .home-hero h1 { margin-top: 24px; font-size: 24px; }
.web-demo .demo-play { margin: 0 auto auto; }
.web-demo .home-hint { display: none; }
.demo-play { display: inline-flex; align-items: center; gap: 10px; margin: 8px auto 0; padding: 16px 46px; border: 0; border-radius: 999px;
  font: inherit; font-size: 22px; font-weight: 800; letter-spacing: 0.02em; cursor: pointer;
  background: var(--text-main); color: var(--bg-card); box-shadow: 0 10px 28px rgba(0,0,0,0.22); animation: demo-breathe 2.4s ease-in-out infinite; }
.demo-play[hidden] { display: none; }
.demo-play span { font-size: 18px; }
.demo-play:active { transform: scale(0.96); }
@keyframes demo-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .demo-play { animation: none; } }
.getapp-veil { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8, 10, 18, 0.72); opacity: 0; transition: opacity 0.25s ease; }
.getapp-veil.show { opacity: 1; }
.getapp-card { position: relative; width: min(360px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--bg-card); color: var(--text-main);
  border-radius: 24px; padding: 24px 18px 18px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; align-items: center; gap: 10px; transform: scale(0.92); transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1); }
.getapp-veil.show .getapp-card { transform: scale(1); }
.getapp-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.06); color: inherit; font-size: 15px; cursor: pointer; }
.getapp-icon { width: 84px; height: 84px; border-radius: 18px; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.getapp-title { font-size: 21px; font-weight: 800; line-height: 1.2; }
.getapp-more { display: flex; gap: 8px; justify-content: center; font-size: 24px; line-height: 1; margin: 2px 0 4px; }
.getapp-more span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: rgba(0,0,0,0.05); }
.getapp-play { display: block; width: min(250px, 100%); line-height: 0; }
.getapp-play img { width: 100%; height: auto; }
.getapp-android .getapp-play { width: min(290px, 100%); }
.getapp-qr { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 4px; }
.getapp-qr img { width: 132px; height: 132px; border-radius: 10px; background: #fff; padding: 6px; }
.getapp-qr small, .getapp-ios small { font-size: 12px; opacity: 0.75; }
.getapp-ios { width: 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.getapp-ios b { font-size: 15px; }
.getapp-row { display: flex; gap: 6px; }
.getapp-row input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-subtle); background: var(--bg-app); color: inherit; }
.getapp-notify { background: var(--text-main); color: var(--bg-card); white-space: nowrap; }
.getapp-msg:empty { display: none; }
.getapp-ios .getapp-ios, .getapp-card.getapp-ios > .getapp-ios { border-top: 0; padding-top: 4px; }
.getapp-again { margin-top: 2px; border: 0; background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 700; opacity: 0.65; padding: 8px 14px; cursor: pointer; }
