/* --- Base reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  width: 100%;
}

body {
  height: 100%;
  width: 100%;
  position: fixed;
  overflow: hidden;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #fdfdfd;
  background-color: #040915;
  background: radial-gradient(circle at top, #202b46 0, #040915 55%, #02040a 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  /* Prevent mobile address bar issues */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* --- Layout --- */

.sky-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

#stars {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.content {
  position: relative;
  z-index: 1;
  min-height: 100%;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1rem, 3vh, 1.75rem) clamp(1rem, 4vw, 1.25rem) clamp(1.5rem, 4vh, 2.5rem);
}

/* --- Brand --- */

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  opacity: 0.9;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.brand .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd6a3, #ffe8c7, #fef9e7);
  box-shadow: 0 0 10px rgba(255, 230, 180, 0.8);
}

.brand-text {
  color: #f5f5ff;
}

/* --- Scene --- */

.scene {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  width: 100%;
  max-width: 480px;
}

.character-wrapper {
  width: clamp(120px, 35vw, 150px);
  max-width: 50vw;
  aspect-ratio: 3 / 4;
  position: relative;
}

.character-wrapper::before {
  content: "";
  position: absolute;
  inset: auto 12% -10%;
  height: 16%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.6), transparent 70%);
  -webkit-filter: blur(4px);
  filter: blur(4px);
}

.character {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.15));
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.15));
}

/* --- Message panel --- */

.message-panel {
  width: 100%;
  max-width: 480px;
  padding: clamp(2.5rem, 5vw, 3rem) clamp(1.4rem, 4.5vw, 1.8rem) clamp(1.2rem, 3vw, 1.5rem);
  border-radius: 999px; /* pill instead of card */
  background: radial-gradient(circle at 10% 0%, rgba(255, 255, 255, 0.03), transparent 60%),
    radial-gradient(circle at 90% 100%, rgba(97, 140, 255, 0.12), transparent 60%),
    rgba(7, 13, 32, 0.65);
  border: 1px solid rgba(164, 187, 255, 0.22);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(0.8rem, 2.5vw, 1.2rem);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.6),
    0 0 35px rgba(123, 162, 255, 0.15);
  position: relative;
  overflow: hidden;
  -webkit-animation: floatPanel 6s ease-in-out infinite;
  animation: floatPanel 6s ease-in-out infinite;
  will-change: transform;
  transition: padding 0.3s ease, min-height 0.3s ease;
}

.message-panel.has-share-button {
  min-height: clamp(180px, 25vh, 220px);
  padding: clamp(3rem, 6vw, 3.5rem) clamp(1.4rem, 4.5vw, 1.8rem) clamp(1.6rem, 4vw, 2rem);
}

.message-panel::before {
  /* faint inner glow on edges */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.message {
  text-align: center;
  font-size: clamp(0.95rem, 3.5vw, 1.1rem);
  line-height: 1.65;
  margin-top: 0;
  margin-bottom: clamp(0.3rem, 1vw, 0.5rem);
  color: #f7f6ff;
  max-width: 100%;
  opacity: 0.96;
  word-wrap: break-word;
  overflow-wrap: break-word;
  padding: 0 0.5rem;
}

.message-panel.has-share-button .message {
  min-height: 3.5em;
}

/* Tiny label above the button so it reads like a whisper, not a CTA */
.message-panel::after {
  content: "whisper for today";
  position: absolute;
  top: clamp(0.75rem, 2.5vw, 1.1rem);
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(0.65rem, 2.2vw, 0.85rem);
  letter-spacing: clamp(0.08em, 0.3vw, 0.14em);
  text-transform: uppercase;
  color: rgba(211, 221, 255, 0.7);
  white-space: nowrap;
  width: max-content;
  font-weight: 500;
}

/* subtle float with smooth easing */
@-webkit-keyframes floatPanel {
  0%, 100% {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
  50% {
    -webkit-transform: translate3d(0, -6px, 0);
    transform: translate3d(0, -6px, 0);
  }
}

@keyframes floatPanel {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -6px, 0);
  }
}


.message--intro {
  opacity: 0.9;
}

/* --- Light button --- */

.light-button {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  outline: none;
}

.light-button:focus-visible {
  outline: 2px solid rgba(255, 230, 173, 0.6);
  outline-offset: 8px;
}

.light-button__core {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe3 0, #ffe3a8 45%, #f4b55a 85%);
  box-shadow:
    0 0 25px rgba(255, 230, 173, 0.95),
    0 0 55px rgba(252, 203, 119, 0.75);
  -webkit-animation: candlePulse 2.8s ease-in-out infinite;
  animation: candlePulse 2.8s ease-in-out infinite;
}

.light-button__glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 244, 209, 0.35), transparent 60%);
  -webkit-filter: blur(4px);
  filter: blur(4px);
  opacity: 0.7;
  pointer-events: none;
}

.light-button__label {
  font-size: 0.82rem;
  color: rgba(229, 237, 255, 0.9);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.04em;
}

.light-button:hover .light-button__core {
  transform: scale(1.08);
  box-shadow:
    0 0 32px rgba(255, 240, 195, 1),
    0 0 70px rgba(255, 223, 164, 0.95);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.light-button:active .light-button__core {
  transform: scale(0.93) translateY(1px);
}

/* --- Share button --- */

.share-button {
  font-size: 0.75rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 230, 173, 0.3);
  background: rgba(255, 244, 209, 0.05);
  color: rgba(255, 237, 195, 0.85);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  margin-top: 0.3rem;
  display: none;
}

.share-button.visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
  animation: fadeInButton 0.3s ease forwards;
}

.share-button:hover {
  background: rgba(255, 244, 209, 0.12);
  border-color: rgba(255, 230, 173, 0.5);
  transform: translateY(-1px);
}

.share-button:active {
  transform: scale(0.95);
}

@keyframes fadeInButton {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* flame-y pulse */
@-webkit-keyframes candlePulse {
  0%, 100% {
    -webkit-transform: translateY(0) scale(1);
    transform: translateY(0) scale(1);
    box-shadow:
      0 0 22px rgba(255, 230, 173, 0.9),
      0 0 48px rgba(252, 203, 119, 0.75);
  }
  50% {
    -webkit-transform: translateY(-1px) scale(1.06);
    transform: translateY(-1px) scale(1.06);
    box-shadow:
      0 0 32px rgba(255, 240, 195, 1),
      0 0 70px rgba(255, 223, 164, 0.95);
  }
}

@keyframes candlePulse {
  0%, 100% {
    transform: translateY(0) scale(1);
    box-shadow:
      0 0 22px rgba(255, 230, 173, 0.9),
      0 0 48px rgba(252, 203, 119, 0.75);
  }
  50% {
    transform: translateY(-1px) scale(1.06);
    box-shadow:
      0 0 32px rgba(255, 240, 195, 1),
      0 0 70px rgba(255, 223, 164, 0.95);
  }
}


/* --- Controls --- */

.controls {
  margin-top: 2rem;
}

.sound-toggle {
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(174, 195, 255, 0.55);
  background: rgba(6, 12, 32, 0.85);
  color: #dbe3ff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 0.2s ease, transform 0.1s ease;
}

.sound-toggle:hover {
  background: rgba(10, 18, 46, 0.95);
}

.sound-toggle:active {
  transform: scale(0.96);
  background: rgba(15, 25, 56, 1);
}

/* --- Animations --- */

@-webkit-keyframes pulse {
  0%,
  100% {
    -webkit-transform: scale(1);
    transform: scale(1);
    box-shadow: 0 0 22px rgba(255, 223, 145, 0.9),
      0 0 50px rgba(246, 197, 119, 0.7);
  }
  50% {
    -webkit-transform: scale(1.06);
    transform: scale(1.06);
    box-shadow: 0 0 32px rgba(255, 234, 184, 1),
      0 0 72px rgba(255, 221, 164, 0.9);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 22px rgba(255, 223, 145, 0.9),
      0 0 50px rgba(246, 197, 119, 0.7);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 32px rgba(255, 234, 184, 1),
      0 0 72px rgba(255, 221, 164, 0.9);
  }
}

.fade-out {
  -webkit-animation: fadeOut 250ms cubic-bezier(0.4, 0, 0.6, 1) forwards;
  animation: fadeOut 250ms cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

.fade-in {
  -webkit-animation: fadeIn 320ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation: fadeIn 320ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@-webkit-keyframes fadeOut {
  to {
    opacity: 0;
    -webkit-transform: translateY(4px);
    transform: translateY(4px);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(4px);
  }
}

@-webkit-keyframes fadeIn {
  from {
    opacity: 0;
    -webkit-transform: translateY(4px);
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive tweaks --- */

@media (max-width: 480px) {
  .content {
    padding: clamp(0.8rem, 2vh, 1.5rem) 1rem clamp(1.2rem, 3vh, 2rem);
  }

  .scene {
    gap: clamp(1.2rem, 3vh, 1.6rem);
  }

  .message-panel {
    padding: clamp(2rem, 5vw, 2.4rem) clamp(1.2rem, 3.5vw, 1.5rem) clamp(1.4rem, 3.5vw, 1.7rem);
    max-width: calc(100vw - 2rem);
  }

  .message-panel.has-share-button {
    min-height: clamp(170px, 24vh, 200px);
  }

  .message-panel::after {
    font-size: clamp(0.6rem, 2vw, 0.75rem);
    letter-spacing: clamp(0.06em, 0.25vw, 0.1em);
    top: clamp(0.7rem, 2.2vw, 0.95rem);
  }

  .message {
    font-size: clamp(0.88rem, 3.2vw, 1rem);
    margin-top: 0;
    padding: 0 0.3rem;
  }

  .message-panel.has-share-button .message {
    min-height: 3em;
  }

  .brand {
    margin-bottom: clamp(1rem, 2vh, 1.4rem);
    font-size: 0.85rem;
  }

  .character-wrapper {
    width: clamp(100px, 30vw, 130px);
  }

  .light-button__core {
    width: 1.7rem;
    height: 1.7rem;
  }

  .light-button__label {
    font-size: clamp(0.72rem, 2.2vw, 0.8rem);
  }
}

@media (max-width: 380px) {
  .message-panel {
    padding: clamp(1.8rem, 5.5vw, 2.2rem) clamp(1rem, 3vw, 1.3rem) clamp(1.3rem, 3.5vw, 1.6rem);
  }

  .message-panel.has-share-button {
    min-height: clamp(165px, 26vh, 195px);
  }

  .message-panel::after {
    font-size: clamp(0.65rem, 2.5vw, 0.78rem);
    top: clamp(0.65rem, 2.5vw, 0.85rem);
  }

  .message {
    font-size: clamp(0.85rem, 3.5vw, 0.95rem);
    line-height: 1.6;
  }
}

@media (max-height: 700px) {
  .scene {
    gap: 1.2rem;
  }

  .character-wrapper {
    width: clamp(100px, 25vw, 120px);
  }

  .content {
    padding: 1rem 1rem 1.5rem;
  }

  .message-panel.has-share-button {
    min-height: clamp(155px, 22vh, 180px);
  }
}

/* --- Fallback for browsers without backdrop-filter support --- */
@supports not (backdrop-filter: blur(10px)) {
  .message-panel {
    background: radial-gradient(circle at 10% 0%, rgba(255, 255, 255, 0.05), transparent 60%),
      radial-gradient(circle at 90% 100%, rgba(97, 140, 255, 0.15), transparent 60%),
      rgba(7, 13, 32, 0.85);
  }

  .sound-toggle {
    background: rgba(6, 12, 32, 0.95);
  }
}

/* --- iOS specific fixes --- */
@supports (-webkit-touch-callout: none) {
  .content {
    /* Use older viewport units for better iOS support */
    height: -webkit-fill-available;
  }

  /* Improve tap response on iOS */
  button {
    -webkit-tap-highlight-color: transparent;
  }
}
