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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
}

html {
  height: -webkit-fill-available;
}

/* Activity: stop page scroll / pinch-zoom fighting pad taps on touch screens */
body[data-page="activity"] {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body[data-page="activity"] .activity-page,
body[data-page="activity"] .activity-main,
body[data-page="activity"] .activity-pads {
  touch-action: none;
  overscroll-behavior: none;
}

body[data-page="activity"] .settings-modal,
body[data-page="activity"] .settings-dialog {
  touch-action: pan-y;
  -webkit-user-select: auto;
  user-select: auto;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
}

/* Dark layered background */
body::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(0, 169, 157, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 50% at 85% 20%, rgba(34, 118, 232, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 50% at 70% 90%, rgba(121, 73, 255, 0.1), transparent 55%),
    radial-gradient(circle at 50% 50%, var(--page-bg-secondary), var(--page-bg));
}

body::after {
  z-index: -1;
  opacity: 0.55;
  background-image:
    radial-gradient(circle at 12% 28%, var(--dot-texture) 0 1px, transparent 2px),
    radial-gradient(circle at 78% 18%, var(--dot-texture) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 72%, var(--dot-texture) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 64%, var(--dot-texture) 0 1px, transparent 2px),
    radial-gradient(circle at 24% 86%, var(--dot-texture) 0 1px, transparent 2px);
  background-size: 100% 100%;
  box-shadow: var(--vignette);
}

/* Light page background - pale blue-gray, calm */
html[data-theme="light"] body::before {
  background: #f7f1d4;
}

html[data-theme="light"] body::after {
  opacity: 0.5;
  box-shadow: var(--vignette);
}

.bg-waves {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.28;
}

html[data-theme="light"] .bg-waves {
  opacity: 0.38;
}

.bg-waves span {
  position: absolute;
  left: -10%;
  width: 120%;
  height: 180px;
  border: 1px solid var(--wave-line);
  border-radius: 50%;
  transform: rotate(-8deg);
}

.bg-waves span:nth-child(1) { top: 8%; }
.bg-waves span:nth-child(2) {
  top: 34%;
  transform: rotate(6deg);
  opacity: 0.85;
}
.bg-waves span:nth-child(3) {
  top: 62%;
  transform: rotate(-4deg);
  opacity: 0.7;
}
.bg-waves span:nth-child(4) {
  top: 84%;
  opacity: 0.55;
}

@media (prefers-reduced-motion: no-preference) {
  .bg-waves span {
    animation: waveDrift 28s ease-in-out infinite alternate;
  }
  .bg-waves span:nth-child(2) { animation-duration: 34s; animation-delay: -6s; }
  .bg-waves span:nth-child(3) { animation-duration: 40s; animation-delay: -12s; }
}

@keyframes waveDrift {
  from { transform: translateX(-1.5%) rotate(-8deg); }
  to { transform: translateX(1.5%) rotate(-5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-waves span,
  .pad,
  .start-btn {
    animation: none !important;
    transition: none !important;
  }
}

.page {
  width: min(var(--page-max), calc(100% - 40px));
  max-width: 100%;
  margin-inline: auto;
  padding: calc(var(--safe-top) + 12px) 0 calc(var(--safe-bottom) + 16px);
  display: flex;
  flex-direction: column;
  gap: var(--space-section);
  box-sizing: border-box;
  min-width: 0;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

a {
  color: var(--teal);
}

:focus-visible {
  outline: 3px solid var(--teal-bright);
  outline-offset: 3px;
}

.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;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero {
  position: relative;
}

.hero--menu {
  text-align: left;
  margin-bottom: 0;
}

.menu-choose {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero-title {
  margin: 10px 0 8px;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.hero-lead {
  margin: 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 1.6vw, 1.1875rem);
  font-weight: 500;
  max-width: 36rem;
}

@media (max-width: 599px) {
  .hero-lead {
    font-size: 1rem;
  }
}

/* Decorative fluid wave to the right of heading - light mode accent */
.hero::after {
  content: "";
  position: absolute;
  right: 0;
  top: 12%;
  width: min(46%, 380px);
  height: 78%;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse at 55% 45%, rgba(0, 190, 180, 0.1), transparent 62%),
    repeating-linear-gradient(
      100deg,
      transparent 0 10px,
      rgba(0, 190, 180, 0.1) 10px 11px,
      transparent 11px 22px
    );
  border-radius: 48% 52% 46% 54% / 42% 58% 40% 60%;
  mask-image: radial-gradient(ellipse at 50% 50%, #000 20%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 20%, transparent 72%);
}

html[data-theme="light"] .hero::after {
  /* Decorative wave removed for a flat, clean look */
  opacity: 0;
  background: none;
}

html[data-theme="light"] .panel-title {
  color: #2476b9;
  letter-spacing: 0.06em;
}

html[data-theme="light"] .brand-title {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #0b2e5c;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: clamp(12px, 1.6vh, 18px);
  box-shadow: var(--shadow-panel);
  color: var(--text-primary);
}

.panel-title {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 20px);
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(90vw, 420px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 14px;
  box-shadow: var(--shadow-soft);
}

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

/* Light: yellow letter/space pads readable on white panels (setup + activity) */
html[data-theme="light"] .pad[data-color="yellow"] {
  background: var(--yellow-pad);
  box-shadow:
    inset 0 0 0 2px var(--pad-border),
    0 4px 12px rgba(11, 46, 92, 0.12);
}
