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

/* ── Focus States ── */
:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}
button:focus:not(:focus-visible) {
  outline: none;
}

:root {
  --primary-50:  #FCEFEA;
  --primary-100: #FBE0D6;
  --primary-200: #F4E6DF;
  --primary-300: #E8C9BC;
  --primary-400: #C8775F;
  --primary-500: #F2603C;
  --primary-600: #E8431F;
  --primary-700: #C23E22;
  --primary-800: #B5311A;
  --primary-900: #2A1E18;

  --secondary-50:  #ECE2FF;
  --secondary-100: #C9B3FF;
  --secondary-200: #B68CFF;
  --secondary-300: #A985FF;
  --secondary-400: #9F6BF5;
  --secondary-500: #8B5CF6;
  --secondary-600: #7C3AED;
  --secondary-700: #6D28D9;
  --secondary-800: #5B21B6;
  --secondary-900: #3A2D52;

  --accent-50:  #FBE0A8;
  --accent-100: #FFD97A;
  --accent-200: #FFD15C;
  --accent-300: #FFB627;
  --accent-400: #FFB300;
  --accent-500: #FFC23C;
  --accent-600: #C99700;
  --accent-700: #8A6D00;
  --accent-800: #7A4E00;
  --accent-900: #523900;

  --neutral-50:  #FAF5F2;
  --neutral-100: #F1E7E2;
  --neutral-200: #EDE5E0;
  --neutral-300: #E6D6CE;
  --neutral-400: #B6A59C;
  --neutral-500: #9C8B84;
  --neutral-600: #7A6A62;
  --neutral-700: #5A4A42;
  --neutral-800: #3A2A24;
  --neutral-900: #2A1E18;

  --success: #1F9D5B;
  --success-light: #E9F7EF;
  --success-border: #BFE8CF;
  --success-text: #1A7A45;
  --error:   #ef4444;
  --warning: #FFB300;

  --sp-0: 4px; --sp-1: 8px; --sp-2: 12px; --sp-3: 16px;
  --sp-4: 24px; --sp-5: 32px; --sp-6: 48px;

  --radius-sm: 9px; --radius-md: 13px; --radius-lg: 16px;
  --radius-xl: 20px; --radius-2xl: 22px; --radius-3xl: 26px; --radius-full: 9999px;

  --shadow-sm:  0 2px 6px rgba(180,90,60,0.08);
  --shadow-md:  0 4px 12px rgba(180,90,60,0.10);
  --shadow-lg:  0 10px 24px rgba(180,90,60,0.20);
  --shadow-xl:  0 14px 34px rgba(180,90,60,0.16);

  --font-heading: 'Fredoka', sans-serif;
  --font-body:    'Nunito', sans-serif;
}

html, body {
  height: 100%;
  background: var(--primary-50);
  color: var(--neutral-800);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overflow: hidden;
  touch-action: none;
}

/* ── Screen transitions ── */
.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.97);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
  z-index: 0;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  z-index: 1;
}

/* ════════════════════════════════════════
   MENU
════════════════════════════════════════ */
#menu {
  background: var(--primary-50);
  padding: env(safe-area-inset-top, var(--sp-4)) var(--sp-4) env(safe-area-inset-bottom, var(--sp-4));
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
}

/* ── Logo ── */
.menu-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  user-select: none;
}
.menu-logo-icon {
  width: 124px;
  height: 124px;
  border-radius: 30px;
  background: #181320;
  box-shadow: 0 10px 24px rgba(0,0,0,0.28);
  position: relative;
  overflow: hidden;
}
.menu-logo-quilt {
  position: absolute;
  inset: 15px;
  border-radius: 15px;
  overflow: hidden;
  opacity: 0.5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
}
.q-a { grid-column: 1/3; grid-row: 1/3; border-radius: 6px; background: linear-gradient(180deg, #FF6F45, #F2542D); }
.q-b { grid-column: 3/5; grid-row: 1/2; border-radius: 6px; background: linear-gradient(180deg, #FFD15C, #FFB627); }
.q-c { grid-column: 3/5; grid-row: 2/4; border-radius: 6px; background: linear-gradient(180deg, #B68CFF, #8B5CF6); }
.q-d { grid-column: 1/2; grid-row: 3/5; border-radius: 6px; background: linear-gradient(180deg, #B68CFF, #8B5CF6); }
.q-e { grid-column: 2/3; grid-row: 3/5; border-radius: 6px; background: linear-gradient(180deg, #FFD15C, #FFB627); }
.q-f { grid-column: 3/5; grid-row: 4/5; border-radius: 6px; background: linear-gradient(180deg, #FF6F45, #F2542D); }
.menu-logo-crown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-logo-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  margin-top: 10px;
}
.menu-logo-sub {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: #C8775F;
}
.menu-logo-main {
  font-family: var(--font-heading);
  font-size: clamp(2.4rem, 12vw, 3rem);
  font-weight: 700;
  letter-spacing: -1px;
  color: #2A1E18;
  margin-top: 2px;
}

.menu-level-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-100);
  padding: 7px 16px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  animation: fadeSlideUp 0.4s ease-out 0.3s both;
}
.level-pill-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  color: var(--primary-700);
}
.level-pill-stars {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-400);
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  animation: fadeSlideUp 0.4s ease-out 0.35s both;
}

.btn-continue {
  background: linear-gradient(180deg, #F2603C 0%, #E8431F 100%);
  color: white;
  border: none;
  border-radius: var(--radius-2xl);
  padding: 16px var(--sp-5);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(232,67,31,0.34), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.15s, box-shadow 0.15s;
  width: 100%;
}
.btn-continue:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(232,67,31,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-continue:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(232,67,31,0.3); }

.btn-zen-menu, .btn-instructions {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--neutral-800);
  background: #fff;
  border: none;
  border-radius: var(--radius-xl);
  padding: 14px var(--sp-5);
  width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
}
.btn-zen-menu:active, .btn-instructions:active { transform: scale(0.97); }

.zen-icon-badge {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #9F6BF5, #7C3AED);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
}
.instr-icon {
  font-size: 1.1rem;
}

.btn-settings {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--neutral-800);
  background: #fff;
  border: none;
  border-radius: var(--radius-xl);
  padding: 14px var(--sp-5);
  width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
}
.btn-settings:active { transform: scale(0.97); }
.settings-icon { font-size: 1.1rem; }

/* ── Theme Toggle ── */
.btn-theme {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 12px);
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 3px 10px rgba(180,90,60,0.12);
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 10;
}

/* ── Daily Card ── */
.daily-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--success-light);
  border: 1.5px solid var(--success-border);
  border-radius: var(--radius-2xl);
  padding: 18px;
  width: 100%;
  max-width: 340px;
  cursor: pointer;
  transition: transform 0.15s;
  animation: fadeSlideUp 0.5s ease-out 0.4s both;
}
.daily-card:active { transform: scale(0.97); }
.daily-card.daily-solved { cursor: default; }
.daily-card.daily-solved:active { transform: none; }
.daily-icon { font-size: 1.5rem; flex-shrink: 0; }
.daily-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.daily-label {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--success-text);
}
.daily-date {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: #5BA37C;
}
.daily-diff {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-700);
  text-transform: uppercase;
}
.daily-status {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
  flex-shrink: 0;
}

/* ════════════════════════════════════════
   INSTRUCTIONS OVERLAY
════════════════════════════════════════ */
.instructions-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  padding: var(--sp-4);
}
.instructions-overlay.visible { opacity: 1; pointer-events: auto; }

.instructions-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--sp-4) var(--sp-4);
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; gap: var(--sp-2);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.instructions-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--neutral-900);
  text-align: center;
}
.instructions-body {
  display: flex; flex-direction: column; gap: var(--sp-2);
  align-items: center;
}
.instructions-rules {
  list-style: none;
  display: flex; flex-direction: column; gap: var(--sp-1);
  width: 100%;
}
.instructions-rules li {
  display: flex; align-items: center; gap: var(--sp-1);
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--neutral-700);
  line-height: 1.4;
}
.rule-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.2; }
.btn-instructions-close {
  border: none;
  border-radius: var(--radius-2xl);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(180deg, #F2603C, #E8431F);
  color: white;
  box-shadow: 0 10px 22px rgba(232,67,31,0.34), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: filter 0.15s;
  width: 100%;
}
.btn-instructions-close:active { filter: brightness(0.9); }

.menu-stars {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--neutral-500);
  min-height: 1.2em;
}

/* ── Win Stars ── */
.win-stars {
  display: flex;
  gap: var(--sp-1);
  justify-content: center;
  min-height: 2rem;
}
.win-star {
  font-size: 1.8rem;
  line-height: 1;
  display: inline-block;
  animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.win-star.earned { color: var(--accent-400); animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both, starShimmer 1.5s ease-in-out 0.5s infinite; }
@keyframes starShimmer {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.3); }
}
.win-star.empty  { color: var(--neutral-200); }
@keyframes starPop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Zen Menu ── */
#zen-menu {
  background: var(--primary-50);
  padding: env(safe-area-inset-top, var(--sp-4)) var(--sp-4) env(safe-area-inset-bottom, var(--sp-4));
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
}
.zen-menu-subtitle {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--neutral-500);
  text-align: center;
  line-height: 1.5;
}
.btn-zen-back {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 12px);
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(180,90,60,0.12);
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 10;
  color: var(--primary-700);
}

/* ── Level Progress Grid ── */
.level-nav-btn {
  background: none; border: none;
  font-size: 1.6rem; cursor: pointer;
  color: var(--primary-500);
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.level-nav-btn.visible { opacity: 1; pointer-events: auto; }
.level-page-indicator {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.page-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--neutral-300);
  transition: background 0.2s;
}
.page-dot.active { background: var(--primary-500); }

.lvl-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--neutral-200);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
}
.lvl-dot.lvl-s1,
.lvl-dot.lvl-s2,
.lvl-dot.lvl-s3 {
  background: linear-gradient(180deg, #FFD15C, #FFB627);
  color: var(--accent-800);
  box-shadow: 0 6px 14px rgba(255,182,39,0.4), inset 0 1px 0 rgba(255,255,255,0.5);
  cursor: pointer;
  border: none;
  border-radius: 50%;
  clip-path: none;
}
.lvl-dot.lvl-cur {
  background: #fff;
  border: 3px solid var(--primary-500);
  color: var(--primary-500);
  box-shadow: 0 6px 16px rgba(242,84,45,0.3);
}
.lvl-dot.lvl-locked {
  background: var(--neutral-200);
  border: none;
  opacity: 1;
  font-size: 0.9rem;
  color: #C3B5AD;
  cursor: default;
}

/* ── Progress Screen ── */
#progress {
  background: var(--primary-50);
  padding: 0 var(--sp-4);
  padding-top: max(env(safe-area-inset-top, 0px), 16px);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 24px);
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--sp-2) 0;
  flex-shrink: 0;
}
.progress-back-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(180,90,60,0.12);
  border: none;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-700);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.progress-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--primary-700);
  line-height: 1.1;
}
.progress-subtitle {
  font-size: 0.8rem;
  color: var(--neutral-500);
  font-weight: 600;
  margin-top: 2px;
}

/* Stars progress bar */
.stars-progress-bar {
  width: 100%;
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 14px 18px;
  box-shadow: var(--shadow-md);
  margin: var(--sp-2) 0 var(--sp-3);
  flex-shrink: 0;
}
.stars-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stars-progress-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  color: var(--neutral-800);
}
.stars-progress-label .stars-count-secondary { color: var(--neutral-400); font-weight: 500; }
.stars-progress-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-400);
}
.stars-progress-track {
  height: 9px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  overflow: hidden;
}
.stars-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #FFD15C, #FFB300);
  transition: width 0.4s ease;
}

.progress-grid-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--sp-1) 0;
}
.progress-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px 12px;
  justify-items: center;
  width: 100%;
  max-width: 340px;
}
.progress-grid .lvl-dot {
  width: 50px;
  height: 50px;
  font-size: 1.15rem;
}

.lvl-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.lvl-star-label {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--accent-400);
  text-align: center;
  line-height: 1;
}
.lvl-now-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--primary-500);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1;
}

#progress .level-page-indicator {
  flex-shrink: 0;
  padding: 10px 0;
}

#btn-progress-start {
  flex-shrink: 0;
  width: 100%;
}

/* ── Placement Flash ── */
.rect-flash {
  position: absolute;
  pointer-events: none;
  background: rgba(255,255,255,0.55);
  animation: rectFlash 0.3s ease-out forwards;
}
@keyframes rectFlash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Replay Dialog ── */
.replay-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.25s ease;
}
.replay-overlay.visible { background: rgba(0,0,0,0.45); pointer-events: auto; }
.replay-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  max-width: 280px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  transform: translateY(40px) scale(0.95);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.3s ease;
}
.replay-overlay.visible .replay-card { transform: translateY(0) scale(1); opacity: 1; }
  box-shadow: var(--shadow-xl);
}
.replay-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--neutral-800);
  text-align: center;
}
.replay-stars { font-size: 1.4rem; letter-spacing: 0.05em; }
.replay-time {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--neutral-500);
  min-height: 1.2em;
}
.replay-buttons {
  display: flex;
  gap: var(--sp-2);
  width: 100%;
}

/* ════════════════════════════════════════
   GAME
════════════════════════════════════════ */
#game {
  background: var(--primary-50);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, var(--sp-2));
}

.game-header {
  display: flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-2);
  gap: 10px;
  flex-shrink: 0;
}

.btn-back, .btn-reset {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  background: white;
  border: none;
  border-radius: var(--radius-md);
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(180,90,60,0.12);
  color: var(--neutral-500);
  transition: background 0.1s;
}
.btn-back:active, .btn-reset:active { background: var(--neutral-50); }

.game-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-700);
  flex: 1;
}

/* ── Timer ── */
.timer {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  color: var(--primary-500);
  background: white;
  border: 2px solid var(--primary-500);
  border-radius: var(--radius-md);
  padding: 0 14px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 70px;
  box-shadow: 0 3px 10px rgba(242,84,45,0.16);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.timer.urgent {
  color: var(--error);
  border-color: var(--error);
  background: #fef2f2;
  animation: timerPulse 0.8s ease-in-out infinite;
}
.timer.stopped {
  color: var(--neutral-400);
  border-color: var(--neutral-200);
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2) var(--sp-3);
}

#board {
  position: relative;
  touch-action: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: white;
  border: 1px solid var(--primary-200);
  box-shadow: var(--shadow-xl);
  animation: boardSlideIn 0.4s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}
@keyframes boardSlideIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
#board canvas { display: block; }

.hint {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--neutral-500);
  text-align: center;
  padding: 0 var(--sp-3) var(--sp-0);
  flex-shrink: 0;
}

.live-stars {
  text-align: center;
  font-size: 1.8rem;
  letter-spacing: 4px;
  flex-shrink: 0;
  min-height: 1.4em;
  line-height: 1.4;
  color: var(--accent-400);
}
.live-star {
  color: var(--accent-400);
  display: inline-block;
  transition: opacity 0.4s, transform 0.4s;
}
.live-star.lost { opacity: 0.15; transform: scale(0.8); }
.live-star.pulsing {
  animation: starPulse 1s ease-in-out infinite;
}
@keyframes starPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(0.85); opacity: 0.5; }
}

.live-difficulty {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--neutral-500);
  text-align: center;
  margin: 0;
  flex-shrink: 0;
}

/* ── Difficulty/Progress pills ── */
.live-difficulty-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.diff-pill, .prog-pill {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}
.diff-pill {
  background: var(--success-light);
  color: var(--success);
}
.prog-pill {
  background: #fff;
  color: var(--neutral-600);
  box-shadow: var(--shadow-sm);
}
.prog-pill.prog-green {
  background: var(--success-light);
  color: var(--success);
}

/* ════════════════════════════════════════
   BANNERS (Win + Timeout)
════════════════════════════════════════ */
.banner-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3);
}
.banner-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.win-banner, .timeout-banner {
  z-index: 100;
  border-radius: var(--radius-xl);
  padding: var(--sp-4) var(--sp-4);
  text-align: center;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  box-shadow: var(--shadow-xl);
  max-width: 340px;
  width: 100%;
}
.win-banner.visible, .timeout-banner.visible {
  display: flex;
  animation: bannerSlideIn 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.timeout-banner.visible {
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.win-banner {
  background: white;
  border: 2px solid var(--success);
  overflow: visible;
}
.win-banner::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(242,96,60,0.3), rgba(124,58,237,0.3), rgba(255,209,92,0.3));
  z-index: -1;
  opacity: 0;
  animation: winGlow 1.2s ease-out 0.2s both;
  filter: blur(12px);
}
@keyframes winGlow {
  0%   { opacity: 0; transform: scale(0.9); }
  40%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05); }
}
.timeout-banner {
  background: white;
  border: 2px solid var(--error);
}

.win-icon { font-size: 1.8rem; line-height: 1; }

.win-banner h2, .timeout-banner h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--neutral-800);
}
.win-banner p, .timeout-banner p {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--neutral-500);
}

.btn-next, .btn-retry, .btn-extend-time, .btn-to-progress {
  border: none;
  border-radius: var(--radius-2xl);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 10px 22px rgba(232,67,31,0.34), inset 0 1px 0 rgba(255,255,255,0.25);
  margin-top: var(--sp-0);
  transition: filter 0.15s;
  color: white;
}
.btn-next        { background: linear-gradient(180deg, #F2603C, #E8431F); }
.btn-retry       { background: var(--error); box-shadow: var(--shadow-md); }
.btn-extend-time { background: linear-gradient(180deg, #F2603C, #E8431F); }
.btn-to-progress {
  background: white;
  color: var(--primary-700);
  border: 1.5px solid var(--primary-300);
  box-shadow: var(--shadow-sm);
}
.btn-next:active, .btn-retry:active, .btn-extend-time:active { filter: brightness(0.9); }
.btn-to-progress:active { background: var(--primary-50); }

/* ════════════════════════════════════════
   CONFIRMATION DIALOG
════════════════════════════════════════ */
.confirm-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.confirm-overlay.visible { opacity: 1; pointer-events: auto; }

.confirm-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--sp-5) var(--sp-4);
  max-width: 300px;
  width: 85%;
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3);
}
.confirm-msg {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--neutral-800);
  text-align: center;
  line-height: 1.4;
}
.confirm-buttons {
  display: flex;
  gap: var(--sp-2);
  width: 100%;
}
.btn-confirm-yes, .btn-confirm-no {
  flex: 1;
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--sp-2) 0;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-confirm-yes { background: var(--error); color: white; }
.btn-confirm-no  { background: var(--neutral-200); color: var(--neutral-700); }
.btn-confirm-yes:active, .btn-confirm-no:active { filter: brightness(0.9); }

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
@keyframes bannerSlideIn {
  from { transform: translateY(40px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}
@keyframes fadeSlideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Level Start Overlay (Countdown) ── */
.start-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(120% 80% at 50% 38%, #7C3AED 0%, #5B21B6 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow: hidden;
}
.start-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.start-overlay-info {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.2rem;
  color: rgba(255,255,255,0.92);
  text-align: center;
}
.start-overlay-ring-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.start-overlay-ring {
  position: absolute;
  transform: rotate(-90deg);
}
.ring-track { stroke: rgba(255,255,255,0.18); }
.ring-fill { stroke: #fff; transition: stroke-dashoffset 0.3s ease; }
.start-overlay-time {
  font-family: var(--font-heading);
  font-size: clamp(4rem, 22vw, 6rem);
  font-weight: 700;
  color: white;
  letter-spacing: -2px;
  line-height: 0.9;
  text-align: center;
}
.start-overlay-time .time-unit {
  font-size: 0.55em;
  font-weight: 600;
}
.start-overlay-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
}
.btn-start-skip {
  position: absolute;
  bottom: 58px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  padding: 11px 26px;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.9rem;
  color: #fff;
  cursor: pointer;
}

/* ── Demo Animation (inside instructions) ── */
.demo-board-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: visible;
  background: white;
  border: 2px solid var(--primary-200);
  box-shadow: var(--shadow-md);
}
.demo-board-wrap canvas {
  display: block;
  border-radius: calc(var(--radius-md) - 2px);
}
.demo-finger {
  position: absolute;
  font-size: 1.6rem;
  line-height: 1;
  pointer-events: none;
  z-index: 10;
  transform: translate(-50%, -10%);
  transition: none;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.demo-finger.visible { opacity: 1; }
.demo-finger.pressing { transform: translate(-50%, -10%) scale(0.85); }

/* ════════════════════════════════════════
   DARK MODE
════════════════════════════════════════ */
body.dark { background: #181320; color: #F3EEF7; }
body.dark .screen,
body.dark #menu,
body.dark #game,
body.dark #progress,
body.dark #zen-menu { background: #181320; }

/* Menu */
body.dark .menu-logo-icon { background: #0F0B16; box-shadow: 0 10px 24px rgba(0,0,0,0.4); }
body.dark .menu-logo-main { color: #F8F4FB; }
body.dark .menu-logo-sub { color: #E0A58C; }
body.dark .menu-level-hint { background: #3A2230; }
body.dark .level-pill-label { color: #FF8A66; }
body.dark .level-pill-stars { color: #E0A58C; }
body.dark .btn-theme { background: #2A2038; box-shadow: 0 3px 10px rgba(0,0,0,0.3); }
body.dark .btn-continue { background: linear-gradient(180deg, #FF6F45 0%, #F2542D 100%); box-shadow: 0 10px 24px rgba(242,84,45,0.4), inset 0 1px 0 rgba(255,255,255,0.25); }
body.dark .btn-zen-menu,
body.dark .btn-instructions { background: #251D31; box-shadow: 0 4px 12px rgba(0,0,0,0.22); color: #F3EEF7; }
body.dark .btn-zen-back { background: #2A2038; box-shadow: 0 3px 10px rgba(0,0,0,0.3); color: #FF8A66; }

/* Daily card */
body.dark .daily-card { background: #14241C; border-color: #2C4A3A; }
body.dark .daily-label { color: #5FDB99; }
body.dark .daily-date  { color: #4E9C72; }
body.dark .daily-diff  { color: #FF8A66; }
body.dark .daily-card.daily-solved { background: #14241C; border-color: #2C4A3A; }

/* Level dots */
body.dark .lvl-dot { background: #2A2038; color: #5A4D6C; }
body.dark .lvl-dot.lvl-s1,
body.dark .lvl-dot.lvl-s2,
body.dark .lvl-dot.lvl-s3 { box-shadow: 0 6px 14px rgba(255,182,39,0.32), inset 0 1px 0 rgba(255,255,255,0.5); }
body.dark .lvl-dot.lvl-cur { background: #251D31; border-color: #FF6F45; color: #FF8A66; box-shadow: 0 6px 16px rgba(242,84,45,0.4); }
body.dark .lvl-dot.lvl-locked { background: #2A2038; opacity: 1; }
body.dark .lvl-star-label { color: #FFC23C; }
body.dark .page-dot { background: #3A3048; }
body.dark .page-dot.active { background: #FF6F45; }
body.dark .level-nav-btn { color: #FF8A66; }

/* Progress header */
body.dark .progress-back-btn { background: #2A2038; box-shadow: 0 3px 10px rgba(0,0,0,0.3); color: #FF8A66; }
body.dark .progress-title { color: #FF8A66; }
body.dark .progress-subtitle { color: #7E7090; }
body.dark .lvl-now-label { color: #FF8A66; }

/* Stars progress bar */
body.dark .stars-progress-bar { background: #251D31; box-shadow: 0 4px 14px rgba(0,0,0,0.22); }
body.dark .stars-progress-label { color: #F3EEF7; }
body.dark .stars-progress-label .stars-count-secondary { color: #7E7090; }
body.dark .stars-progress-pct { color: #FFC23C; }
body.dark .stars-progress-track { background: #352940; }
body.dark .menu-stars { color: #7E7090; }

/* Game header */
body.dark .game-header { background: #181320; }
body.dark .btn-back,
body.dark .btn-reset { background: #2A2038; box-shadow: 0 3px 10px rgba(0,0,0,0.3); color: #7E7090; }
body.dark .game-title { color: #FF8A66; }
body.dark .timer { color: #FF8A66; background: #2A2038; border-color: #FF6F45; box-shadow: 0 3px 10px rgba(242,84,45,0.25); }
body.dark .timer.urgent { color: #fca5a5; border-color: #dc2626; background: #2a1414; }
body.dark .timer.stopped { color: #5A4D6C; border-color: #3A3048; }
body.dark .hint { color: #7E7090; }
body.dark .live-star { color: #FFC23C; }
body.dark .live-star.lost { opacity: 0.1; }
body.dark .live-difficulty { color: #7E7090; }
body.dark .diff-pill { background: #16291F; color: #5FDB99; }
body.dark .prog-pill { background: #251D31; color: #9D90AD; box-shadow: none; }
body.dark .prog-pill.prog-green { background: #16291F; color: #5FDB99; }

/* Board */
body.dark #board { background: #221A2D; border-color: #322642; box-shadow: 0 14px 34px rgba(0,0,0,0.4); }
body.dark .demo-board-wrap { background: #221A2D; border-color: #322642; }

/* Banners & dialogs */
body.dark .banner-backdrop { background: rgba(0,0,0,0.75); }
body.dark .win-banner,
body.dark .timeout-banner { background: #251D31; }
body.dark .win-banner h2,
body.dark .timeout-banner h2 { color: #F3EEF7; }
body.dark .timeout-banner p { color: #9D90AD; }
body.dark .win-star.empty { color: #3A3048; }
body.dark .btn-next { background: linear-gradient(180deg, #FF6F45, #F2542D); }
body.dark .btn-extend-time { background: linear-gradient(180deg, #FF6F45, #F2542D); }
body.dark .btn-to-progress { background: #251D31; color: #FF8A66; border-color: #3A3048; }
body.dark .btn-retry { background: #2A2038; color: #9D90AD; border-color: #3A3048; }
body.dark .replay-card { background: #251D31; }
body.dark .replay-title { color: #F3EEF7; }
body.dark .replay-time { color: #7E7090; }
body.dark .confirm-card,
body.dark .instructions-card { background: #251D31; }
body.dark .instructions-title { color: #F3EEF7; }
body.dark .instructions-rules li { color: #9D90AD; }
body.dark .btn-instructions-close { background: linear-gradient(180deg, #FF6F45, #F2542D); }
body.dark .confirm-msg { color: #F3EEF7; }
body.dark .zen-menu-subtitle { color: #7E7090; }

/* Countdown overlay dark */
body.dark .start-overlay { background: radial-gradient(120% 80% at 50% 38%, #3A1D6E 0%, #1A1028 100%); }
body.dark .ring-fill { stroke: #A985FF; }
body.dark .start-overlay-label { color: rgba(201,179,255,0.85); }
body.dark .start-overlay-info { color: rgba(255,255,255,0.92); }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .screen {
    transition: none;
    transform: none !important;
  }
  .timer.urgent {
    animation: none;
    opacity: 1;
  }
}

/* ── Register / Recover Overlay ──────────────────────────── */
.register-overlay {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.register-overlay.visible { opacity: 1; pointer-events: auto; }
.register-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 2rem 1.5rem; width: 90%; max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow-xl);
}
body.dark .register-card { background: var(--surface-1); }
.register-title { font-family: 'Fredoka', sans-serif; font-size: 1.4rem; font-weight: 600; margin: 0 0 0.3rem; }
.register-subtitle { font-size: 0.85rem; color: var(--text-secondary, #888); margin: 0 0 1.2rem; }
.register-input {
  width: 100%; box-sizing: border-box;
  padding: 0.7rem 1rem; border-radius: var(--radius-md);
  border: 2px solid #e0d5cf; background: var(--bg, #FCEFEA);
  font-family: 'Nunito', sans-serif; font-size: 1rem; font-weight: 600;
  text-align: center; outline: none;
  transition: border-color 0.2s;
}
.register-input:focus { border-color: var(--primary, #E8431F); }
body.dark .register-input { background: var(--surface-2, #2A2038); border-color: #3A2D52; color: #fff; }
.register-error { color: #E8431F; font-size: 0.8rem; min-height: 1.2em; margin: 0.5rem 0; }
.register-buttons { display: flex; gap: 0.8rem; margin-top: 0.8rem; }
.register-buttons .btn-confirm-no,
.register-buttons .btn-confirm-yes { flex: 1; }
/* ── Apple Sign In ── */
.btn-apple-signin {
  width: 100%;
  padding: 13px 20px;
  border-radius: var(--radius-xl);
  border: none;
  background: #000;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s;
}
.btn-apple-signin:active { transform: scale(0.97); }
body.dark .btn-apple-signin { background: #fff; color: #000; }

.register-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 6px;
  color: var(--neutral-400);
  font-size: 0.8rem;
}
.register-divider::before,
.register-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--neutral-200);
}
body.dark .register-divider { color: #7E7090; }
body.dark .register-divider::before,
body.dark .register-divider::after { background: #3A2D52; }

.btn-recover-toggle {
  background: none; border: none; color: var(--text-secondary, #888);
  font-size: 0.8rem; margin-top: 1rem; cursor: pointer;
  text-decoration: underline; font-family: 'Nunito', sans-serif;
}

/* ── Player Info (Menu) ──────────────────────────────────── */
.player-info {
  font-size: 0.75rem; color: var(--text-secondary, #999);
  text-align: center; margin-top: 0.5rem;
  font-family: 'Nunito', sans-serif;
}
.player-info .player-code {
  font-weight: 700; letter-spacing: 0.1em;
  color: var(--primary-400, #F2603C);
}

/* ── Win Ranking ─────────────────────────────────────────── */
.win-ranking {
  width: 100%; margin: 0.8rem 0;
}
.win-ranking:empty { display: none; }
.ranking-title {
  font-family: 'Fredoka', sans-serif; font-weight: 600;
  font-size: 0.85rem; color: var(--text-secondary, #888);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.ranking-list {
  display: flex; flex-direction: column; gap: 2px;
  font-family: 'Nunito', sans-serif; font-size: 0.82rem;
}
.ranking-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.6rem; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.03);
}
body.dark .ranking-row { background: rgba(255,255,255,0.05); }
.ranking-row.ranking-self {
  background: rgba(232,67,31,0.1); font-weight: 700;
}
body.dark .ranking-row.ranking-self { background: rgba(255,138,102,0.15); }
.ranking-pos { width: 1.5em; text-align: right; font-weight: 700; color: var(--primary, #E8431F); }
.ranking-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-stars { font-size: 0.75rem; color: var(--star-color, #FFB300); }
.ranking-time { font-variant-numeric: tabular-nums; color: var(--text-secondary, #888); }
.ranking-loader { text-align: center; padding: 0.8rem 0; }
.ranking-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2.5px solid rgba(124,58,237,0.2);
  border-top-color: #7C3AED;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Daily History Grid ──────────────────────────────────── */
.daily-history-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px 6px;
  width: 100%;
  padding: 0.5rem 0;
}
.daily-h-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.daily-h-dot {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  font-family: 'Nunito', sans-serif;
}
.daily-h-solved { background: rgba(34,197,122,0.18); color: #16874e; }
.daily-h-missed { background: rgba(239,68,68,0.12); color: #ef4444; }
.daily-h-today { background: rgba(124,58,237,0.15); color: #7C3AED; }
body.dark .daily-h-solved { background: rgba(34,197,122,0.25); color: #4ade80; }
body.dark .daily-h-missed { background: rgba(239,68,68,0.2); color: #f87171; }
body.dark .daily-h-today { background: rgba(124,58,237,0.25); color: #B68CFF; }
.daily-h-label {
  font-size: 0.6rem; color: var(--text-secondary, #888);
  font-family: 'Nunito', sans-serif;
}
.daily-h-time {
  font-size: 0.6rem; font-weight: 700;
  color: var(--text-secondary, #888);
  font-family: 'Nunito', sans-serif;
  font-variant-numeric: tabular-nums;
}
.daily-h-solved { cursor: pointer; transition: transform 0.1s; }
.daily-h-solved:active { transform: scale(0.9); }
.daily-history-detail {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.daily-history-detail:empty { display: none; }
.daily-detail-header {
  font-family: 'Nunito', sans-serif; font-size: 0.9rem;
  color: var(--neutral-800); margin-bottom: 8px;
}
body.dark .daily-history-detail { border-top-color: rgba(255,255,255,0.06); }
body.dark .daily-detail-header { color: #F3EEF7; }

/* ── Settings Overlay ──────────────────────────────────── */
.settings-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: var(--neutral-50, #FAF5F2);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.settings-overlay.visible { opacity: 1; pointer-events: auto; }
.settings-card {
  max-width: 420px; margin: 0 auto;
  padding: max(env(safe-area-inset-top, 16px), 16px) 20px 40px;
}
.settings-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px; padding-top: 8px;
}
.settings-back-btn {
  width: 44px; height: 44px; border-radius: var(--radius-xl);
  border: none; background: #fff; box-shadow: var(--shadow-md);
  font-size: 1.5rem; color: var(--primary, #E8431F);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.settings-title {
  font-family: var(--font-heading); font-size: 1.3rem;
  font-weight: 700; color: var(--neutral-800); margin: 0;
}
.settings-body { display: flex; flex-direction: column; gap: 0; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 4px;
}
.settings-label {
  font-family: var(--font-heading); font-size: 1.05rem;
  font-weight: 600; color: var(--neutral-800);
}
.settings-icon-col {
  display: inline-block; width: 1.6em; text-align: center;
}
.settings-toggle {
  width: 52px; height: 30px; border-radius: 15px;
  background: #ccc; cursor: pointer; position: relative;
  transition: background 0.2s;
}
.settings-toggle[aria-checked="true"] { background: #22c55e; }
.settings-toggle-knob {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; position: absolute; top: 2px; left: 2px;
  transition: transform 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.settings-toggle[aria-checked="true"] .settings-toggle-knob { transform: translateX(22px); }
.settings-divider { height: 1px; background: rgba(0,0,0,0.06); margin: 0 4px; }
.settings-link {
  font-family: var(--font-heading); font-size: 1.05rem;
  font-weight: 600; color: var(--neutral-800);
  background: none; border: none; text-align: left;
  padding: 16px 4px; cursor: pointer; width: 100%;
  transition: opacity 0.15s;
}
.settings-link:active { opacity: 0.6; }
.settings-link-danger { color: var(--error, #ef4444); }
.settings-text {
  gap: 0; font-family: 'Nunito', sans-serif;
  font-size: 0.92rem; line-height: 1.6; color: var(--neutral-600, #666);
}
.settings-text p { margin: 0 0 12px; }
.settings-text ul { margin: 0 0 12px; padding-left: 20px; }
.settings-text li { margin-bottom: 6px; }
.settings-text strong { color: var(--neutral-800); }

/* Settings dark */
body.dark .settings-overlay { background: #1A1028; }
body.dark .settings-back-btn { background: #2A2038; box-shadow: 0 3px 10px rgba(0,0,0,0.3); color: #FF8A66; }
body.dark .settings-title { color: #F3EEF7; }
body.dark .settings-label { color: #F3EEF7; }
body.dark .settings-toggle { background: #3A3048; }
body.dark .settings-toggle[aria-checked="true"] { background: #22c55e; }
body.dark .settings-divider { background: rgba(255,255,255,0.06); }
body.dark .settings-link { color: #F3EEF7; }
body.dark .settings-link-danger { color: #f87171; }
body.dark .settings-text { color: #9D90AD; }
body.dark .settings-text strong { color: #F3EEF7; }
body.dark .btn-settings { background: #251D31; box-shadow: 0 4px 12px rgba(0,0,0,0.22); color: #F3EEF7; }
