:root {
  --bg: #f4e9d8;
  --bg-soft: #ece0cc;
  --fg: #5a3620;
  --fg-dim: #8a6a4d;
  --accent: #c98a52;
  --bubble-hi: #bfe3f5;
  --bubble-lo: #3d7ea6;
  --lip-red: #c81e3c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, 'Times New Roman', serif;
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  color: var(--fg);
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.2rem;
  line-height: 1.6;
  padding: 2rem;
}

@media (orientation: landscape) {
  #rotate-overlay { display: flex; }
  #app { display: none; }
}

/* ---------- Intro ---------- */

.screen-intro {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.intro-stack {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 0 1.75rem;
  transition: transform 0.5s ease;
  will-change: transform;
}

.intro-line {
  padding: 0.5rem 0;
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.5;
  opacity: 0.35;
  transition: opacity 0.5s ease;
}

.intro-line.current {
  opacity: 1;
}

.fade-text {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 0 2rem;
}

.fade-text.ready-text {
  top: 75%;
  transform: translateY(-50%);
  font-size: 1.15rem;
  line-height: 1.5;
}

.fade-text.mid-text {
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.05rem;
  line-height: 1.5;
  transition: opacity 0.8s ease;
}

.fade-text.mid-text.fading {
  opacity: 0;
}

.fade-text .word {
  display: inline-block;
  white-space: nowrap;
  opacity: 0;
}

.fade-text.visible .word {
  animation: wordFadeIn 0.3s ease forwards;
  animation-delay: var(--word-delay, 0s);
}

@keyframes wordFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-text .letter {
  display: inline-block;
}

.fade-text.dissolving .letter {
  animation-name: dissolve;
  animation-duration: 0.8s;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  animation-delay: var(--delay);
}

@keyframes dissolve {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
  }
}

/* ---------- Bubble screen ---------- */

.screen-bubbles {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 2.5rem 1.5rem 4rem;
  -webkit-overflow-scrolling: touch;
}

.screen-bubbles--single {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.section-label {
  text-align: center;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  margin: 2.5rem 0 1.25rem;
}

.section-label--home {
  margin-top: 5rem;
}

.bubble-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.25rem;
}

.bubble {
  position: relative;
  width: var(--size, 72px);
  height: var(--size, 72px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.4) 9%, rgba(255, 255, 255, 0) 20%),
    radial-gradient(circle at 62% 18%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 11%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.02) 55%, rgba(255, 255, 255, 0.1) 88%, rgba(255, 255, 255, 0.22) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.75),
    inset 4px -4px 7px hsl(var(--hue, 0deg) 55% 80% / 0.55),
    inset -4px 4px 7px hsl(calc(var(--hue, 0deg) + 90deg) 55% 80% / 0.5),
    inset -4px -4px 7px hsl(calc(var(--hue, 0deg) + 180deg) 55% 80% / 0.5),
    inset 4px 4px 7px hsl(calc(var(--hue, 0deg) + 270deg) 55% 80% / 0.5),
    inset -6px -6px 14px rgba(255, 255, 255, 0.12),
    inset 4px 6px 10px rgba(120, 150, 180, 0.07),
    0 4px 12px rgba(30, 40, 60, 0.14);
  opacity: 0;
  overflow: hidden;
  animation: bubbleIn 0.6s ease forwards, bubbleWobble 6s ease-in-out infinite, blobFloat 7s ease-in-out infinite;
  animation-delay: var(--in-delay, 0s), var(--phase, 0s), var(--phase, 0s);
  cursor: pointer;
}

.bubble-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.bubble-icon-img {
  width: 56%;
  height: 56%;
  background-color: var(--lip-red);
  -webkit-mask-image: var(--icon-url);
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-image: var(--icon-url);
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  opacity: 0.8;
  filter: drop-shadow(0 1px 2px rgba(60, 10, 20, 0.25));
}

@keyframes bubbleIn {
  to { opacity: 1; }
}

@keyframes bubbleWobble {
  0%, 100% { border-radius: 50%; }
  50%      { border-radius: 48% 52% 51% 49% / 51% 49% 52% 48%; }
}

@keyframes blobFloat {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1, 1); }
  50%  { transform: translate(var(--float-x, 4px), var(--float-y, -6px)) rotate(var(--float-rot, 3deg)) scale(var(--float-sx, 1.03), var(--float-sy, 0.97)); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1, 1); }
}

/* ---------- Split reveal ---------- */

.split-panel {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  z-index: 50;
  transition: transform 0.75s cubic-bezier(0.65, 0, 0.35, 1);
}

.split-top {
  top: 0;
  height: 50%;
  border-bottom: 2px solid var(--accent);
}

.split-bottom {
  bottom: 0;
  height: 50%;
  border-top: 2px solid var(--accent);
}

.split-panel.open.split-top {
  transform: translateY(-100%);
}

.split-panel.open.split-bottom {
  transform: translateY(100%);
}

/* ---------- Challenge screen ---------- */

.screen-challenge {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.75rem;
  text-align: center;
  overflow-y: hidden;
}

.screen-challenge.scrollable {
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.challenge-day {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 0 1.75rem;
  text-align: center;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  z-index: 10;
  pointer-events: none;
}

.challenge-title {
  font-size: 1.4rem;
  font-weight: bold;
  opacity: 0;
  margin-bottom: 1.5rem;
}

.challenge-title.visible {
  animation: fadeIn 0.8s ease forwards;
}

.challenge-body {
  font-size: 1.15rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.challenge-body .token-word {
  display: inline-block;
  white-space: nowrap;
}

.challenge-body .token {
  display: inline-block;
  opacity: 0;
}

.screen-challenge.instant .challenge-title,
.screen-challenge.instant .challenge-body .token {
  opacity: 1;
  animation: none;
  transform: none;
}

.challenge-body.visible .token {
  animation: tokenFadeIn 0.35s ease forwards;
  animation-delay: var(--token-delay, 0s);
}

@keyframes tokenFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Wheel of fortune ---------- */

.wheel-section {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity 0.9s ease 0.3s;
}

.wheel-section.instant {
  transition: none;
}

.wheel-section.visible {
  opacity: 1;
}

.wheel-stage {
  position: relative;
  width: min(72vw, 260px);
  height: min(72vw, 260px);
  touch-action: none;
}

.wheel-dial {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow:
    0 6px 18px rgba(60, 30, 10, 0.25),
    inset 0 0 0 3px var(--accent);
  cursor: grab;
}

.wheel-svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.wheel-slice-a {
  fill: var(--accent);
}

.wheel-slice-b {
  fill: #e7c9a0;
}

.wheel-number {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  font-weight: bold;
  fill: var(--fg);
  text-anchor: middle;
  dominant-baseline: middle;
}

.wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18%;
  height: 18%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--bg);
  box-shadow:
    0 0 0 3px var(--accent),
    0 2px 6px rgba(60, 30, 10, 0.3);
  pointer-events: none;
}

.wheel-marker {
  position: absolute;
  top: -0.6rem;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 0.7rem solid transparent;
  border-right: 0.7rem solid transparent;
  border-top: 1.1rem solid var(--lip-red);
  filter: drop-shadow(0 2px 2px rgba(60, 10, 20, 0.3));
  pointer-events: none;
}

.wheel-label {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  text-align: center;
  max-width: 22rem;
}

.wheel-section.locked .wheel-dial {
  cursor: default;
}
