/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
:root {
  --bg-deep: #07010a;
  --bg-mid: #1a0616;
  --bg-glow: #3a1130;
  --ink: #ffd6e7;
  --accent: #ff5fa2;
  --accent-soft: #ffb3d1;
  --chip-bg: rgba(255, 95, 162, 0.10);
  --chip-bg-hover: rgba(255, 95, 162, 0.22);
  --chip-border: rgba(255, 179, 209, 0.35);
  --chip-border-hover: rgba(255, 179, 209, 0.7);
  --caption-font: 'Great Vibes', cursive;
  --caption-name-size: 26px;
  --ui-font: 'Cormorant Garamond', 'Garamond', 'Georgia', serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

body {
  position: relative;
  background: radial-gradient(120% 90% at 50% 42%, var(--bg-glow) 0%, var(--bg-mid) 42%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  transition: background 0.9s ease, color 0.6s ease;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  z-index: 1;
}

/* Activity and character layer above the particles. */
#overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 2;
}

/* ---------------------------------------------------------------------------
   Page link (top left)
   --------------------------------------------------------------------------- */
.page-nav {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--ink);
  font: 400 14px/1 var(--ui-font);
  letter-spacing: 0.06em;
  text-decoration: none;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.page-nav:hover { background: var(--chip-bg-hover); border-color: var(--chip-border-hover); }
.page-nav:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.page-nav-emoji { font-size: 17px; }

/* On narrow screens the link collapses to its emoji so the top row fits. */
@media (max-width: 760px) {
  .page-nav { width: 40px; padding: 0; justify-content: center; }
  .page-nav-label { display: none; }
}

/* ---------------------------------------------------------------------------
   Mode switch (top centre)
   --------------------------------------------------------------------------- */
.modes {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.6s ease, border-color 0.6s ease;
}

.mode {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 14px/1 var(--ui-font);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 9px 16px 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0.7;
  transition: background 0.3s ease, opacity 0.3s ease, transform 0.2s ease;
}

.mode:hover { opacity: 1; }
.mode:focus-visible { opacity: 1; outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.mode.active { background: var(--chip-bg-hover); opacity: 1; }
.mode:active { transform: scale(0.97); }
.mode-emoji { letter-spacing: 0; margin-left: 2px; }

/* ---------------------------------------------------------------------------
   Bottom caption, next button, hint
   --------------------------------------------------------------------------- */
.ui {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 0 16px calc(22px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}

.ui p { margin: 0; }

.caption {
  font-size: 13px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.78;
  padding-left: 0.42em;
}

.caption .name {
  font-family: var(--caption-font);
  font-size: var(--caption-name-size);
  letter-spacing: 0;
  text-transform: none;
  vertical-align: -3px;
  margin: 0 0.15em;
  color: var(--accent-soft);
}

.caption .emoji {
  color: var(--accent);
  letter-spacing: 0;
  display: inline-block;
  animation: beat 1.1s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  10% { transform: scale(1.22); }
  24% { transform: scale(1); }
  34% { transform: scale(1.12); }
  48% { transform: scale(1); }
}

.next {
  pointer-events: auto;
  appearance: none;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--ink);
  font: 300 15px/1 var(--ui-font);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 11px 24px 10px 28px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.next:hover, .next:focus-visible {
  background: var(--chip-bg-hover);
  border-color: var(--chip-border-hover);
  outline: none;
  transform: translateY(-1px);
}

.next:active { transform: translateY(0) scale(0.98); }

.hint {
  font-size: 13px;
  font-style: italic;
  opacity: 0.55;
  transition: opacity 1.5s ease;
}

.hint.faded { opacity: 0; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  font-size: 20px;
}

/* ---------------------------------------------------------------------------
   Aubrey: Bikini Bottom. Sunlit water, flower clouds, sandy floor.
   --------------------------------------------------------------------------- */
body.theme-aubrey {
  --bg-deep: #0a3f7d;
  --bg-mid: #0e5aa8;
  --bg-glow: #2a9be0;
  --ink: #fff7c2;
  --accent: #ffd93b;
  --accent-soft: #fff1a1;
  --chip-bg: rgba(255, 224, 80, 0.14);
  --chip-bg-hover: rgba(255, 224, 80, 0.30);
  --chip-border: rgba(255, 240, 160, 0.45);
  --chip-border-hover: rgba(255, 240, 160, 0.85);
  --caption-font: 'Luckiest Guy', 'Arial Black', Impact, sans-serif;
  --caption-name-size: 22px;
  --ui-font: 'Fredoka', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(70% 45% at 50% -8%, rgba(160, 225, 255, 0.35) 0%, rgba(160, 225, 255, 0) 65%),
    linear-gradient(180deg, #1d7fc9 0%, #115ab0 30%, #0b3f8c 62%, #062a63 100%);
}

/* Flower clouds drift in the sky; a sandy floor sits under the water. */
body.theme-aubrey::before,
body.theme-aubrey::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 0;
}

body.theme-aubrey::before {
  top: 0;
  height: max(42%, 300px);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 120'%3E%3Cg fill='%23d9a7f2' fill-opacity='0.55'%3E%3Ccircle cx='60' cy='40' r='14'/%3E%3Ccircle cx='47' cy='31' r='11'/%3E%3Ccircle cx='73' cy='31' r='11'/%3E%3Ccircle cx='45' cy='48' r='11'/%3E%3Ccircle cx='75' cy='48' r='11'/%3E%3Ccircle cx='60' cy='25' r='10'/%3E%3Ccircle cx='60' cy='55' r='10'/%3E%3C/g%3E%3Cg fill='%23ff9fd0' fill-opacity='0.5'%3E%3Ccircle cx='150' cy='70' r='11'/%3E%3Ccircle cx='140' cy='63' r='8'/%3E%3Ccircle cx='160' cy='63' r='8'/%3E%3Ccircle cx='139' cy='77' r='8'/%3E%3Ccircle cx='161' cy='77' r='8'/%3E%3Ccircle cx='150' cy='58' r='7'/%3E%3Ccircle cx='150' cy='82' r='7'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 120'%3E%3Cg fill='%239fe4ff' fill-opacity='0.5'%3E%3Ccircle cx='100' cy='60' r='12'/%3E%3Ccircle cx='89' cy='52' r='9'/%3E%3Ccircle cx='111' cy='52' r='9'/%3E%3Ccircle cx='88' cy='68' r='9'/%3E%3Ccircle cx='112' cy='68' r='9'/%3E%3Ccircle cx='100' cy='47' r='8'/%3E%3Ccircle cx='100' cy='73' r='8'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat-x, repeat-x;
  background-size: 520px 312px, 700px 420px;
  background-position: 0 -40px, 260px 10px;
  opacity: 0.6;
  animation: clouds 90s linear infinite;
}

@keyframes clouds {
  from { background-position: 0 -40px, 260px 10px; }
  to { background-position: 520px -40px, 960px 10px; }
}

body.theme-aubrey::after {
  bottom: 0;
  height: 16%;
  background:
    radial-gradient(60% 100% at 30% 100%, rgba(255, 226, 150, 0.22) 0%, rgba(255, 226, 150, 0) 70%),
    radial-gradient(50% 100% at 75% 100%, rgba(255, 226, 150, 0.18) 0%, rgba(255, 226, 150, 0) 70%),
    linear-gradient(180deg, rgba(240, 205, 120, 0) 0%, rgba(240, 205, 120, 0.22) 100%);
}

body.theme-aubrey .caption {
  letter-spacing: 0.34em;
  opacity: 0.95;
  text-shadow: 0 2px 8px rgba(0, 40, 90, 0.45);
}

body.theme-aubrey .caption .name {
  color: var(--accent);
  vertical-align: -2px;
  text-shadow: 0 2px 0 rgba(120, 60, 0, 0.35), 0 4px 12px rgba(0, 40, 90, 0.4);
}

body.theme-aubrey .caption .emoji { animation: bob 1.8s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-3px) rotate(6deg); }
}

body.theme-aubrey .mode,
body.theme-aubrey .next,
body.theme-aubrey .hint {
  text-shadow: 0 1px 4px rgba(0, 40, 90, 0.4);
}

/* Keep the toggle and hint readable over the bright water and clouds. */
body.theme-aubrey .modes { background: rgba(6, 42, 99, 0.55); }
body.theme-aubrey .mode { opacity: 0.85; }
body.theme-aubrey .mode:hover,
body.theme-aubrey .mode:focus-visible { opacity: 1; }
body.theme-aubrey .mode.active {
  background: rgba(255, 217, 59, 0.9);
  color: #062a63;
  opacity: 1;
  text-shadow: none;
}
body.theme-aubrey .hint { opacity: 0.85; }

/* ---------------------------------------------------------------------------
   Responsive and motion preferences
   --------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .caption { font-size: 11px; letter-spacing: 0.32em; }
  :root { --caption-name-size: 22px; }
  body.theme-aubrey { --caption-name-size: 19px; }
  .hint { font-size: 12px; }
  .mode { font-size: 12px; padding: 8px 12px 7px 14px; letter-spacing: 0.12em; }
}

/* Phones: keep the hint text clear of the bottom-left Play button. */
@media (max-width: 480px) {
  .ui .hint { max-width: calc(100vw - 150px); margin-inline: auto; }
}

/* Very narrow phones: tighten the top row so link, toggle and sound fit. */
@media (max-width: 380px) {
  .page-nav {
    top: calc(17px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    width: 34px;
    height: 34px;
  }
  .mode { font-size: 11px; padding: 8px 8px 7px 9px; letter-spacing: 0.05em; }
}

@media (prefers-reduced-motion: reduce) {
  .caption .emoji { animation: none !important; }
  body.theme-aubrey::before { animation: none; }
}
