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

/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; touch-action: manipulation; }
html { height: 100%; -webkit-tap-highlight-color: transparent; }
body {
  min-height: 100%;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #FFF8F0;
  color: #4A3728;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
body.no-scroll { overflow: hidden; height: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ===== SCREENS ===== */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #FFF8F0;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.screen.active { opacity: 1; pointer-events: auto; }

/* ===== HUB SCREEN ===== */
#screen-home {
  position: static;
  opacity: 1;
  pointer-events: auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.hub-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 0.75rem 1rem 0.5rem;
}
.hub-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
}
.hub-avatar-btn {
  padding: 0;
  display: flex;
  align-items: center;
}
.hub-avatar-frame {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid #E8864C;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #FFF5E6;
  transition: border-color 0.3s;
}
.hub-avatar-frame svg { display: block; }
.hub-treats {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: white;
  padding: 0.35rem 0.9rem;
  border-radius: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.treats-icon { font-size: 1.1rem; }
.treats-count { font-size: 1.05rem; font-weight: 800; color: #4A3728; }
.hub-gear { color: #9B8B7E; }
.hub-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding-bottom: 0.5rem;
}
.hub-logo { text-align: center; }
.hub-hero-img { display: block; margin: 0 auto 0.25rem; }
.hub-title {
  font-size: 2.75rem; font-weight: 800;
  color: #E8864C;
  letter-spacing: -0.02em;
  margin-bottom: 0.15rem;
}
.hub-subtitle {
  font-size: 1rem; color: #9B8B7E;
}
.hub-play-btn {
  padding: 1rem 3rem;
  font-size: 1.2rem;
  min-width: 200px;
}
.hub-cards { width: 100%; max-width: 360px; }
.hub-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: white;
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s;
  font-family: inherit;
  text-align: left;
}
.hub-card:active { transform: scale(0.97); }
.hub-card-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.hub-card-emoji { font-size: 1.6rem; }
.hub-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #4A3728;
}
.hub-card-sub {
  font-size: 0.75rem;
  color: #B8A89E;
  font-weight: 600;
}
.hub-streak-badge {
  background: #F0943C;
  color: white;
  font-size: 1.1rem;
  font-weight: 800;
  min-width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.hub-features-row {
  display: flex;
  gap: 0.6rem;
}
.hub-feature {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: white;
  border-radius: 0.85rem;
  padding: 0.75rem 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s;
  font-family: inherit;
  position: relative;
}
.hub-feature:active { transform: scale(0.95); }
.hub-feature:disabled { opacity: 0.55; cursor: default; }
.hub-feature:disabled:active { transform: none; }
.hub-feature-emoji { font-size: 1.5rem; }
.hub-feature-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: #8B7B6E;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hub-feature-soon {
  position: absolute;
  top: 4px; right: 6px;
  font-size: 0.5rem;
  font-weight: 700;
  color: white;
  background: #D0C4BA;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-block;
  padding: 1rem 3.5rem;
  background: #F0943C;
  color: white;
  font-size: 1.25rem; font-weight: 700;
  border: none;
  border-radius: 2rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(240, 148, 60, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(240, 148, 60, 0.25); }
.btn-secondary {
  display: inline-block;
  padding: 1rem 3.5rem;
  background: #F0F0ED;
  color: #4A3728;
  font-size: 1.25rem; font-weight: 700;
  border-radius: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.btn-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #8B7B6E;
  transition: background 0.15s;
}
.btn-icon:active { background: rgba(0,0,0,0.05); }

/* ===== GAME HEADER ===== */
.game-header {
  display: flex; align-items: center;
  justify-content: space-between;
  width: 100%; max-width: 500px;
  padding: 0.5rem 0.75rem;
}
.header-center { display: flex; gap: 2rem; }
.header-stat { text-align: center; }
.header-label { display: block; font-size: 0.75rem; color: #B8A89E; font-weight: 600; text-transform: uppercase; }
.header-value { display: block; font-size: 1.5rem; font-weight: 800; color: #4A3728; }

/* ===== GAME INFO BAR ===== */
.game-info-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 1.5rem;
  padding: 0.4rem 0;
  width: 100%; max-width: 500px;
}
.progress-pill {
  display: flex; align-items: center; gap: 0.3rem;
  background: white;
  padding: 0.3rem 0.8rem;
  border-radius: 1rem;
  font-weight: 700; font-size: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.progress-pill .corgi-mini-icon { font-size: 1.1rem; }
.precise-timer {
  font-size: 0.85rem; font-weight: 800; color: #E8864C;
  font-variant-numeric: tabular-nums;
  background: white; padding: 0.25rem 0.6rem; border-radius: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.lives-display { display: flex; gap: 0.2rem; font-size: 1.3rem; }
.lives-display .bone { transition: all 0.3s ease; }
.lives-display .bone.lost { opacity: 0.25; filter: grayscale(1); transform: scale(0.85); }

/* ===== RULES BAR ===== */
.rules-bar {
  display: flex; gap: 0.4rem; justify-content: center;
  padding: 0.3rem 0.5rem;
  width: 100%; max-width: 500px;
}
.rule-chip {
  display: flex; align-items: center; gap: 0.2rem;
  background: white;
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.65rem; font-weight: 600;
  color: #8B7B6E;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  white-space: nowrap;
}
.rule-chip .rule-icon { font-size: 0.7rem; }

/* ===== SCORE POPUP ===== */
.score-popup {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem; font-weight: 800;
  color: #F0943C;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}
.score-popup.show {
  animation: scoreFloat 1s ease forwards;
}
@keyframes scoreFloat {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
  30% { opacity: 1; transform: translate(-50%, -80%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(0.9); }
}

/* ===== STATUS TEXT ===== */
.status-text {
  text-align: center;
  font-size: 1.4rem; font-weight: 800;
  min-height: 2rem;
  color: #4CAF7D;
  opacity: 0;
  transition: opacity 0.3s;
}
.status-text.show { opacity: 1; }

/* ===== BOARD ===== */
.board-container {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  padding: 0.5rem;
  width: 100%; max-width: 500px;
}
.board-grid {
  display: grid;
  gap: 3px;
  background: white;
  padding: 6px;
  border-radius: 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1;
  touch-action: manipulation;
}

/* ===== CELLS ===== */
.cell {
  position: relative;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
  overflow: hidden;
  aspect-ratio: 1;
}
.cell:active { transform: scale(0.93); }
.cell.excluded { }
.cell.placed { }
.cell.error { animation: cellShake 0.4s ease; }

@keyframes cellShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* X mark */
.cell .x-mark {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.cell.excluded .x-mark { opacity: 1; }
.cell .x-mark svg { width: 55%; height: 55%; }
.cell .x-mark path {
  stroke: rgba(255,255,255,0.7);
  stroke-width: 4;
  stroke-linecap: round;
}
.cell.error .x-mark path { stroke: #E05555; stroke-width: 5; }
.cell.error .x-mark { opacity: 1; }

/* Corgi in cell */
.cell .cell-corgi {
  width: 80%; height: 80%;
  object-fit: contain;
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.3s, transform 0.3s ease;
}
.cell.placed .cell-corgi {
  opacity: 1;
  transform: scale(1);
}
.cell.placed .cell-corgi.pop {
  animation: corgiPop 0.5s ease;
}
@keyframes corgiPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* Corgi idle animations */
.cell-corgi .corgi-eyes { transition: transform 0.15s; }
.cell-corgi.blink .corgi-eyes { transform: scaleY(0.1); }
.cell-corgi.look-left .corgi-eyes { transform: translateX(-2px); }
.cell-corgi.look-right .corgi-eyes { transform: translateX(2px); }

/* Sparkle effect */
.cell .sparkle {
  position: absolute; inset: -20%;
  pointer-events: none;
  opacity: 0;
}
.cell .sparkle.show {
  animation: sparkleAnim 0.8s ease forwards;
}
@keyframes sparkleAnim {
  0% { opacity: 1; transform: scale(0.3) rotate(0); }
  50% { opacity: 1; transform: scale(1.2) rotate(90deg); }
  100% { opacity: 0; transform: scale(1.5) rotate(180deg); }
}

/* Region border emphasis */
.cell.region-top { border-top: 2px solid rgba(255,255,255,0.5); }
.cell.region-bottom { border-bottom: 2px solid rgba(255,255,255,0.5); }
.cell.region-left { border-left: 2px solid rgba(255,255,255,0.5); }
.cell.region-right { border-right: 2px solid rgba(255,255,255,0.5); }

/* ===== POWERUPS ===== */
.powerups-bar {
  display: flex; gap: 2.5rem; justify-content: center;
  padding: 0.75rem 0;
}
.powerup-btn {
  position: relative;
  width: 64px; height: 64px;
  background: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: transform 0.15s;
}
.powerup-btn:active { transform: scale(0.92); }
.powerup-btn.disabled { opacity: 0.4; pointer-events: none; }
.powerup-icon { font-size: 2rem; }
.powerup-badge {
  position: absolute; top: -4px; right: -4px;
  background: #E05555;
  color: white;
  font-size: 0.7rem; font-weight: 700;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ===== AD SLOT ===== */
.ad-slot {
  width: 100%; max-width: 500px;
  height: 50px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 0.5rem;
  flex-shrink: 0;
}

/* ===== OVERLAYS ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
}
.overlay.active { opacity: 1; pointer-events: auto; }
.overlay-content {
  text-align: center;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

/* Completion */
#overlay-complete {
  background: rgba(74,55,40,0.85);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  padding: 2rem 0;
}
.completion-content {
  max-width: 360px;
  margin: auto;
}
.completion-title {
  font-size: 2rem; font-weight: 900;
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  margin-bottom: 0.25rem;
}
.completion-corgi {
  width: 180px;
  margin: 0 auto 0.5rem;
}
.completion-corgi img {
  width: 100%;
  height: auto;
  display: block;
}
.completion-msg {
  color: rgba(255,255,255,0.9);
  font-size: 1rem; font-weight: 600;
  margin-bottom: 0.75rem;
}
.completion-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}
.completion-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}
.completion-stat-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: white;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.completion-stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.completion-treats {
  font-size: 0.95rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  margin-bottom: 1.25rem;
}
.btn-next-level {
  min-width: 200px;
}

/* Game Over */
.gameover-title {
  font-size: 2.5rem; font-weight: 900;
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  margin-bottom: 0.5rem;
}
.gameover-corgi {
  width: 200px; height: 200px;
  margin: 0 auto 1rem;
}
.gameover-remaining {
  color: rgba(255,255,255,0.9);
  font-size: 1.1rem; font-weight: 600;
  margin-bottom: 1.5rem;
}

/* Settings overlay */
.settings-content { max-width: 380px; padding: 1rem; }
.settings-panel {
  background: #FFF8F0;
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.settings-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #4A3728;
}
.settings-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #9B8B7E;
  border-radius: 50%;
}
.settings-close:active { background: rgba(0,0,0,0.05); }
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px; height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #D0C4BA;
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider { background: #4CAF7D; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
}
.settings-row-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4A3728;
}
.settings-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.settings-actions .settings-btn {
  flex: 1;
  margin-bottom: 0;
}
.settings-btn {
  display: block;
  width: 100%;
  padding: 0.65rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 0.5rem;
}
.settings-btn-sm {
  padding: 0.5rem;
  font-size: 0.85rem;
}
.settings-btn-outline {
  background: transparent;
  border: 2px solid #E8864C;
  color: #E8864C;
}
.settings-btn-outline:active { background: rgba(232,134,76,0.08); }
.settings-btn-primary {
  background: #F0943C;
  color: white;
  border: none;
  box-shadow: 0 3px 10px rgba(240,148,60,0.3);
}
.settings-btn-primary:active { transform: scale(0.98); }
.settings-btn-link {
  background: none;
  border: none;
  color: #B8A89E;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0.3rem 0;
  display: block;
  width: 100%;
  text-align: center;
}
.settings-btn-link:active { color: #E05555; }
.settings-login-toggle { color: #C8B8A8; margin-top: 0.25rem; }
.settings-login-toggle:active { color: #E8864C; }
.settings-divider {
  height: 1px;
  background: #F0E8E0;
  margin: 0.5rem 0;
}
.settings-login-fields {
  margin-top: 0.5rem;
}
.settings-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.4rem;
  border: 1.5px solid #E0D6CC;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  color: #4A3728;
  background: #fff;
  outline: none;
}
.settings-input:focus { border-color: #E8864C; }
.login-error {
  color: #E05555;
  font-size: 0.82rem;
  min-height: 1.2em;
  margin-top: 0.25rem;
}

/* Pattern mode SVG overlays */
.cell .pattern-overlay {
  position: absolute; inset: 0;
  opacity: 0.18;
  pointer-events: none;
  z-index: 1;
}

/* Hint overlay */
.overlay-hint { background: rgba(0,0,0,0.8); }
.hint-content { max-width: 360px; }
.hint-message {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #6B5B4E;
  margin-bottom: 1rem;
  line-height: 1.4;
}
.hint-board {
  margin-bottom: 1rem;
  max-width: 300px;
  margin-left: auto; margin-right: auto;
}
.hint-board .cell { filter: brightness(0.7); }
.hint-board .cell.hint-highlight { filter: brightness(1); box-shadow: 0 0 0 3px #4CAF7D, 0 0 12px rgba(76,175,125,0.5); }
.hint-board .cell.hint-exclude { filter: brightness(0.9); animation: hintPulse 1.2s ease-in-out infinite; }
.hint-board .cell.hint-exclude .x-mark { opacity: 1; }
.hint-board .cell.hint-exclude .x-mark path { stroke: white; stroke-width: 5; }
@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(224,85,85,0.6); }
  50% { box-shadow: 0 0 0 3px rgba(224,85,85,0.9), 0 0 8px rgba(224,85,85,0.4); }
}

/* Milestone Toast */
.milestone-toast {
  position: fixed;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: #FFF8F0;
  border: 2px solid #F0943C;
  border-radius: 1rem;
  padding: 0.7rem 1.25rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 6px 24px rgba(74,55,40,0.25), 0 0 0 4px rgba(240,148,60,0.1);
  transition: top 0.4s ease;
  max-width: 340px;
  width: max-content;
}
.milestone-toast.active {
  top: env(safe-area-inset-top, 12px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
}
.milestone-toast-icon { font-size: 1.75rem; flex-shrink: 0; }
.milestone-toast-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #F0943C;
}
.milestone-toast-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4A3728;
}

/* Confetti */
.confetti-container {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 101;
}
.confetti-piece {
  position: absolute;
  width: 10px; height: 10px;
  top: -20px;
  animation: confettiFall 3s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ===== TUTORIAL ===== */
.tutorial-content {
  text-align: center;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
}
.tutorial-message {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #6B5B4E;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  line-height: 1.4;
}
.tutorial-message .highlight { color: #E05555; font-weight: 700; }
.tutorial-board-wrap {
  max-width: 280px;
  margin: 0 auto 1.5rem;
}
.tutorial-hint {
  font-size: 0.9rem;
  color: #9B8B7E;
  margin-bottom: 1rem;
}
.tut-tools {
  display: flex;
  gap: 1.25rem;
  justify-content: center;
  margin: 1rem 0;
}
.tut-tool {
  background: white;
  border-radius: 1rem;
  padding: 1.25rem 1rem;
  flex: 1;
  max-width: 160px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  text-align: center;
}
.tut-tool-icon {
  font-size: 2.5rem;
  margin-bottom: 0.4rem;
}
.tut-tool-label {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.tut-tool-desc {
  font-size: 0.78rem;
  color: #9B8B7E;
  line-height: 1.3;
}
.tut-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 0.75rem 0;
}
.tut-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  border-radius: 0.75rem;
  padding: 0.6rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.tut-control-icon {
  font-size: 1.3rem;
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF4ED;
  border-radius: 0.4rem;
  flex-shrink: 0;
}
.tut-control-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #6B5B4E;
  white-space: nowrap;
}
.tutorial-skip {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.15);
  border: none;
  color: white;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tutorial-skip:hover { background: rgba(0,0,0,0.25); }
.tutorial-redo-btn {
  display: block;
  margin: 0.5rem auto 0;
  background: none;
  border: none;
  color: #9B8B7E;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
}
.tutorial-redo-btn:hover { color: #6B5B4E; }

/* Shake animation for rejected input */
@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-6px); }
  30%, 60%, 90% { transform: translateX(6px); }
}
.input-shake {
  animation: inputShake 0.5s ease;
  border-color: #E05555 !important;
}

.tutorial-step-num {
  font-size: 0.7rem;
  color: #B8A89E;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.cell.tutorial-highlight {
  animation: tutorialPulse 1.5s ease-in-out infinite;
}
@keyframes tutorialPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(224, 85, 85, 0.3); }
  50% { box-shadow: inset 0 0 0 3px rgba(224, 85, 85, 0.8); }
}

/* ===== GAME SCREEN LAYOUT ===== */
#screen-game {
  justify-content: flex-start;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-y: auto;
  background: #FFF8F0;
  touch-action: none;
}
#screen-game * { touch-action: none; }
#screen-game.active { display: flex; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .completion-title { font-size: 1.75rem; margin-bottom: 0.15rem; }
  .completion-corgi { width: 150px; margin-bottom: 0.3rem; }
  .completion-msg { font-size: 0.9rem; margin-bottom: 0.5rem; }
  .completion-stat-value { font-size: 1.3rem; }
  .completion-stat-label { font-size: 0.6rem; }
  .completion-stats { gap: 1rem; margin-bottom: 0.4rem; }
  .completion-treats { font-size: 0.85rem; margin-bottom: 0.6rem; }
  .overlay-content { padding: 1.25rem; }
  .rules-bar { gap: 0.3rem; }
  .rule-chip { font-size: 0.6rem; padding: 0.2rem 0.45rem; }
}
@media (max-width: 380px) {
  .rules-bar { gap: 0.2rem; }
  .rule-chip { font-size: 0.55rem; padding: 0.2rem 0.4rem; }
  .header-value { font-size: 1.25rem; }
  .powerup-btn { width: 56px; height: 56px; }
  .board-grid { padding: 4px; gap: 2px; border-radius: 12px; }
  .cell { border-radius: 6px; }
  .completion-corgi { width: 130px; }
  .completion-title { font-size: 1.5rem; }
}
@media (min-width: 768px) {
  .board-container { max-width: 480px; }
  .hub-title { font-size: 3.5rem; }
  .game-footer { display: block; }
}

/* ===== MILESTONES OVERLAY ===== */
.milestones-content { max-width: 560px; padding: 0.75rem; }
.milestones-panel {
  background: #FFF8F0;
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.milestones-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.milestones-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #4A3728;
}
.milestones-list {
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: #E0D6CC transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.milestones-list::-webkit-scrollbar { width: 6px; }
.milestones-list::-webkit-scrollbar-track { background: transparent; }
.milestones-list::-webkit-scrollbar-thumb { background: #E0D6CC; border-radius: 3px; }
.milestones-list::-webkit-scrollbar-thumb:hover { background: #C8B8A8; }
.ms-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.5rem;
  border-radius: 0.75rem;
  border-bottom: 1px solid #F0E8E0;
}
.ms-entry:last-child { border-bottom: none; }
.ms-entry.ms-unlocked { background: rgba(76, 175, 125, 0.06); }
.ms-icon {
  font-size: 1.5rem;
  min-width: 32px;
  text-align: center;
}
.ms-info { flex: 1; min-width: 0; text-align: left; }
.ms-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4A3728;
}
.ms-desc {
  font-size: 0.7rem;
  color: #B8A89E;
  font-weight: 600;
}
.ms-progress-bar {
  height: 6px;
  background: #F0E8E0;
  border-radius: 3px;
  margin-top: 0.3rem;
  overflow: hidden;
}
.ms-progress-fill {
  height: 100%;
  background: #F0943C;
  border-radius: 3px;
  transition: width 0.3s;
}
.ms-progress-fill.complete { background: #4CAF7D; }
.ms-right {
  text-align: right;
  flex-shrink: 0;
}
.ms-reward {
  font-size: 0.7rem;
  font-weight: 700;
  color: #E8864C;
}
.ms-claim-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 0.5rem;
  background: #4CAF7D;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s;
}
.ms-claim-btn:active { transform: scale(0.95); }
.ms-claimed {
  font-size: 0.65rem;
  font-weight: 700;
  color: #4CAF7D;
}

/* ===== WARDROBE OVERLAY ===== */
/* ===== DRESSUP SCREEN ===== */
#screen-dressup {
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.dressup-topbar {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: white;
  border-bottom: 1px solid #F0E8E0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.dressup-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #9B8B7E;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.dressup-back:active { background: rgba(0,0,0,0.05); }
.dressup-title {
  flex: 1;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #4A3728;
}
.dressup-treats {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: #4A3728;
  background: #FFF0DC;
  padding: 0.3rem 0.65rem;
  border-radius: 1rem;
}
.dressup-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  max-width: 440px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  justify-content: center;
}
.dressup-coming-soon {
  text-align: center;
  padding: 1rem 1.5rem 0;
}
.dressup-coming-msg {
  font-size: 0.85rem;
  color: #9B8B7E;
  font-weight: 600;
  line-height: 1.5;
}
.dressup-preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1rem;
}
.dressup-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 220px;
  height: 220px;
  background: white;
  border-radius: 1.25rem;
  border: 2px solid #F0E8E0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  margin-bottom: 0.75rem;
}
.dressup-preview svg { width: 180px; height: 180px; }
.dressup-actions {
  display: flex;
  gap: 0.5rem;
}
.dressup-action-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 2px solid #F0E8E0;
  background: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, transform 0.15s;
  font-family: inherit;
  color: #9B8B7E;
}
.dressup-action-btn:active { transform: scale(0.9); border-color: #E8864C; }
.dressup-picker {
  width: 100%;
}
.dressup-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.dressup-tab {
  flex: 1;
  padding: 0.55rem 0.25rem;
  border-radius: 0.6rem;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: #9B8B7E;
  background: #F0E8E0;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.dressup-tab.active {
  background: #E8864C;
  color: white;
}
.dressup-items {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.dressup-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.25rem;
  border-radius: 0.75rem;
  border: 2px solid #F0E8E0;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  font-family: inherit;
}
.dressup-item:active { transform: scale(0.95); }
.dressup-item.equipped { border-color: #4CAF7D; background: #F5FFF8; }
.dressup-item.locked { opacity: 0.6; }
.dressup-item-preview {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.3rem;
}
.dressup-item-preview svg { display: block; }
.dressup-item-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: #4A3728;
  text-align: center;
  line-height: 1.2;
}
.dressup-item-price {
  font-size: 0.6rem;
  font-weight: 700;
  color: #E8864C;
  margin-top: 0.15rem;
}
.dressup-item-owned {
  font-size: 0.55rem;
  font-weight: 700;
  color: #4CAF7D;
  margin-top: 0.15rem;
}

/* ===== PROFILE OVERLAY ===== */
/* Welcome name prompt */
.welcome-content { max-width: 340px; padding: 1rem; }
.welcome-panel {
  background: #FFF8F0;
  border-radius: 1.25rem;
  padding: 2rem 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  text-align: center;
}
.welcome-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #4A3728;
  margin-bottom: 0.3rem;
}
.welcome-subtitle {
  font-size: 0.85rem;
  color: #9B8B7E;
  margin-bottom: 1.25rem;
}
.welcome-name-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #F0E8E0;
  border-radius: 0.75rem;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  color: #4A3728;
  background: white;
  outline: none;
  text-align: center;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}
.welcome-name-input:focus { border-color: #E8864C; }
.welcome-name-input::placeholder { color: #D0C4BA; }
.welcome-start-btn {
  width: 100%;
  margin-bottom: 0.5rem;
}
.welcome-skip {
  background: none;
  border: none;
  color: #9B8B7E;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem;
}
.welcome-skip:hover { color: #6B5B4E; }

/* Feedback form */
.feedback-content { max-width: 380px; padding: 1rem; }
.feedback-panel {
  background: #FFF8F0;
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.feedback-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #4A3728;
}
.feedback-subtitle {
  font-size: 0.85rem;
  color: #9B8B7E;
  margin-bottom: 1rem;
}
.feedback-field {
  margin-bottom: 0.75rem;
}

.profile-content { max-width: 380px; padding: 1rem; }
.profile-panel {
  background: #FFF8F0;
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.profile-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #4A3728;
}
.profile-avatar-section {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.profile-avatar-ring {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 4px solid #E8864C;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #FFF5E6;
  transition: border-color 0.3s;
}
.profile-avatar-ring svg { display: block; }
.profile-field {
  margin-bottom: 1rem;
}
.profile-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #9B8B7E;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.profile-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 2px solid #F0E8E0;
  border-radius: 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #4A3728;
  background: white;
  outline: none;
  transition: border-color 0.2s;
}
.profile-input:focus { border-color: #E8864C; }
.profile-input::placeholder { color: #D0C4BA; }
.colour-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.colour-swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s;
  padding: 0;
  font-family: inherit;
}
.colour-swatch:active { transform: scale(0.9); }
.colour-swatch.selected { border-color: #4A3728; transform: scale(1.1); }

/* ===== STREAK OVERLAY ===== */
.streak-content { max-width: 380px; padding: 0.75rem; }
.streak-panel {
  background: #FFF8F0;
  border-radius: 1.5rem;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 12px 48px rgba(74,55,40,0.25);
  text-align: center;
}
.streak-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.streak-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #4A3728;
}
.streak-display { margin-bottom: 1.25rem; }
.streak-fire { font-size: 2.5rem; margin-bottom: 0.1rem; }
.streak-count {
  font-size: 3.5rem;
  font-weight: 900;
  color: #E8864C;
  line-height: 1;
}
.streak-label-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: #9B8B7E;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.15rem;
}
.streak-calendar {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  background: white;
  border-radius: 1rem;
  padding: 0.75rem 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.streak-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
}
.streak-day-future { opacity: 0.35; }
.streak-day-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #9B8B7E;
  text-transform: uppercase;
}
.streak-day-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #F0E8E0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all 0.3s;
}
.streak-day-dot.checked {
  background: linear-gradient(135deg, #F0943C, #E8864C);
  box-shadow: 0 2px 8px rgba(240,148,60,0.3);
}
.streak-day-dot.today {
  border: 2.5px solid #E8864C;
  background: #FFF5EB;
}
.streak-day-dot.checked.today {
  border-color: transparent;
  background: linear-gradient(135deg, #F0943C, #E8864C);
}
.streak-best {
  font-size: 0.8rem;
  font-weight: 600;
  color: #B8A89E;
  margin-bottom: 0.5rem;
}
.streak-best span { font-weight: 800; color: #4A3728; }
.streak-reward {
  font-size: 0.95rem;
  font-weight: 700;
  color: #4CAF7D;
  margin-bottom: 0.75rem;
  min-height: 1.2rem;
}
.streak-checkin-btn {
  min-width: 200px;
  font-size: 1.05rem;
}
.streak-checkin-btn:disabled {
  background: #D0C4BA;
  box-shadow: none;
  cursor: default;
}

/* ===== LEADERBOARD OVERLAY ===== */
.leaderboard-content { max-width: 560px; padding: 0.75rem; }
.leaderboard-panel {
  background: #FFF8F0;
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.leaderboard-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #4A3728;
}
.leaderboard-list {
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: #E0D6CC transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.leaderboard-list::-webkit-scrollbar { width: 6px; }
.leaderboard-list::-webkit-scrollbar-track { background: transparent; }
.leaderboard-list::-webkit-scrollbar-thumb { background: #E0D6CC; border-radius: 3px; }
.leaderboard-list::-webkit-scrollbar-thumb:hover { background: #C8B8A8; }
.leaderboard-loading {
  text-align: center;
  color: #B8A89E;
  font-weight: 600;
  padding: 2rem;
}
.leaderboard-empty {
  text-align: center;
  color: #B8A89E;
  font-weight: 600;
  padding: 2rem;
}
.lb-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
  border-radius: 0.75rem;
  transition: background 0.2s;
}
.lb-entry.lb-self { background: rgba(240, 148, 60, 0.08); }
.lb-rank {
  font-size: 1rem;
  font-weight: 800;
  color: #B8A89E;
  min-width: 28px;
  text-align: center;
}
.lb-rank-1 { color: #E8C860; }
.lb-rank-2 { color: #C0C0C0; }
.lb-rank-3 { color: #CD7F32; }
.lb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #FFF5E6;
  flex-shrink: 0;
}
.lb-avatar svg { display: block; }
.lb-info { flex: 1; min-width: 0; text-align: left; }
.lb-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #4A3728;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-puzzles {
  font-size: 0.7rem;
  font-weight: 600;
  color: #B8A89E;
}
.lb-score {
  font-size: 1rem;
  font-weight: 800;
  color: #E8864C;
  white-space: nowrap;
}

/* ===== SITE FOOTER ===== */
.site-footer {
  display: block;
  text-align: center;
}
#screen-home .site-footer {
  padding: 0.5rem 0 0.75rem;
  width: 100%;
}
.game-footer {
  margin-top: auto;
  padding: 0.5rem 0 0.75rem;
  width: 100%;
  max-width: 500px;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}
.footer-links a {
  color: #C4B5A8;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
  transition: color 0.2s, background 0.2s;
}
.footer-links a:hover {
  color: #E8864C;
  background: rgba(232, 134, 76, 0.08);
}
.footer-sep {
  color: #E0D6CC;
  font-size: 0.6rem;
  line-height: 1.8;
}
.footer-copy {
  font-size: 0.65rem;
  color: #D0C4BA;
  letter-spacing: 0.02em;
}
