:root {
  --sea-light: #B8D9D2;
  --sea-deep: #7DC4C9;
  --sunset-soft: #F4C9A8;
  --sunset-deep: #E89B72;
  --coral: #E76F51;
  --coral-glow: rgba(231, 111, 81, 0.4);
  --light-warm: rgba(255, 200, 140, 0.75);
  --text-deep: #0A2A3F;
  --text-mid: #1F4A60;
  --text-soft: #2E5670;
  --modal-bg: rgba(255, 250, 245, 0.97);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: linear-gradient(160deg, var(--sea-deep) 0%, var(--sea-light) 35%, var(--sunset-soft) 70%, var(--sunset-deep) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 120%, rgba(255, 180, 130, 0.5) 0%, rgba(255, 180, 130, 0) 60%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% -20%, rgba(150, 200, 210, 0.3) 0%, rgba(150, 200, 210, 0) 50%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.5rem 1.5rem;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
  justify-content: space-between;
}

.top-bar {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.icon-button {
  background: rgba(255, 255, 255, 0.4);
  border: 0.5px solid rgba(20, 60, 80, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-deep);
  padding: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.6);
  transform: scale(1.05);
  outline: none;
}

.icon-button:active {
  transform: scale(0.95);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
}

.logo-text {
  font-size: 15px;
  color: var(--text-deep);
  letter-spacing: 0.08em;
  font-style: italic;
  font-weight: 500;
}

.counter-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.world-count {
  font-size: clamp(40px, 11vw, 64px);
  font-weight: 500;
  color: var(--text-deep);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.3s ease;
}

.counter-label {
  font-size: 14px;
  color: var(--text-mid);
  font-style: italic;
  letter-spacing: 0.02em;
}

.streak-display {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.streak-display[hidden] {
  display: none;
}

.streak-line {
  font-size: 14px;
  color: var(--text-mid);
  font-style: italic;
  letter-spacing: 0.02em;
}

.streak-icon {
  display: inline-block;
  color: var(--coral);
  font-style: normal;
  margin-right: 4px;
}

.best-streak-text {
  font-size: 12px;
  color: var(--text-soft);
  font-style: italic;
  opacity: 0.85;
}

.best-streak-text:empty {
  display: none;
}

.button-area {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.blessing-light {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--light-warm) 0%, rgba(255, 150, 100, 0.35) 40%, rgba(255, 150, 100, 0) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.tap-button {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--coral);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: all 0.4s ease;
  z-index: 2;
  color: white;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.05em;
  font-style: italic;
  box-shadow: 0 4px 24px var(--coral-glow);
}

.tap-button:hover,
.tap-button:focus-visible {
  transform: scale(1.03);
  outline: none;
}

.tap-button:active {
  transform: scale(0.97);
}

.tap-button.tapped {
  background: rgba(180, 180, 180, 0.4);
  color: rgba(255, 255, 255, 0.85);
  cursor: default;
  box-shadow: none;
  font-size: 15px;
}

.tap-button.tapped:hover {
  transform: none;
}

.sparkles {
  position: absolute;
  width: 300px;
  height: 300px;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.footer {
  font-size: 12px;
  color: var(--text-mid);
  font-style: italic;
  opacity: 0.85;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.footer-join-link {
  color: var(--coral);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-style: italic;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.footer-join-link:hover {
  opacity: 0.7;
}

.footer-join-link[hidden] {
  display: none;
}

/* ---------- MODALS ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 60, 80, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 1;
  animation: modal-fade-in 0.4s ease;
}

.modal[hidden] {
  display: none;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--modal-bg);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(20, 60, 80, 0.25);
  position: relative;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  animation: modal-slide-up 0.4s ease;
}

@keyframes modal-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-mid);
  font-size: 26px;
  padding: 4px 10px;
  opacity: 0.6;
  font-family: var(--serif);
  line-height: 1;
  transition: opacity 0.2s ease;
}

.modal-close:hover { opacity: 1; }

.modal-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 1.25rem;
}

.modal-logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
}

.modal-logo-text {
  font-size: 14px;
  color: var(--text-deep);
  letter-spacing: 0.08em;
  font-style: italic;
  font-weight: 500;
}

.modal-title {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--text-deep);
  font-style: italic;
  margin: 0 0 12px;
  font-weight: 400;
  line-height: 1.2;
}

.modal-text {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-mid);
  line-height: 1.6;
  font-style: italic;
  margin: 0 0 8px;
}

.modal-text:last-of-type {
  margin-bottom: 1.25rem;
}

.modal-subtle {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text-soft);
  font-style: italic;
  margin: 0 0 1.25rem;
  opacity: 0.85;
}

.modal-quote {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text-deep);
  font-style: italic;
  margin: 12px 0 0;
  line-height: 1.5;
}

.modal-primary-button {
  background: var(--coral);
  color: white;
  border: none;
  border-radius: 24px;
  padding: 12px 28px;
  font-family: var(--serif);
  font-size: 15px;
  font-style: italic;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 3px 14px var(--coral-glow);
  transition: transform 0.2s ease;
}

.modal-primary-button--small {
  padding: 9px 20px;
  font-size: 13px;
  margin-top: 6px;
}

.modal-primary-button:hover,
.modal-primary-button:focus-visible {
  transform: scale(1.03);
  outline: none;
}

.modal-primary-button:active {
  transform: scale(0.97);
}

.modal-secondary-button {
  background: transparent;
  border: 0.5px solid rgba(231, 111, 81, 0.5);
  color: var(--coral);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease;
}

.modal-secondary-button:hover {
  background: rgba(231, 111, 81, 0.08);
}

.modal-divider {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 0.5px solid rgba(20, 60, 80, 0.15);
}

.modal-member-prompt {
  font-size: 12px;
  color: var(--text-mid);
  font-style: italic;
  margin: 0 0 8px;
  opacity: 0.85;
}

.modal-restore-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.modal-restore-input {
  background: rgba(255, 255, 255, 0.7);
  border: 0.5px solid rgba(20, 60, 80, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text-deep);
  width: 160px;
  text-align: center;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.modal-restore-input:focus {
  outline: none;
  border-color: var(--coral);
  background: rgba(255, 255, 255, 0.9);
}

.modal-error {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--coral);
  font-style: italic;
  margin-top: 8px;
  text-align: center;
}

/* After-tap modal extras */
.aftertap-streak {
  margin-bottom: 14px;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text-deep);
  font-style: italic;
}

.aftertap-streak[hidden] { display: none; }

.streak-icon-modal {
  display: inline-block;
  color: var(--coral);
  font-style: normal;
  margin-right: 6px;
  font-size: 16px;
}

.aftertap-milestone {
  margin-bottom: 12px;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--coral);
  font-style: italic;
}

.aftertap-milestone[hidden] { display: none; }

.aftertap-upgrade {
  margin-top: 1.25rem;
  padding: 1rem 0.75rem;
  background: rgba(20, 60, 80, 0.05);
  border-radius: 12px;
}

.aftertap-upgrade[hidden] { display: none; }

.aftertap-upgrade-text {
  font-size: 12px;
  color: var(--text-mid);
  font-style: italic;
  margin: 0 0 8px;
  opacity: 0.9;
  line-height: 1.5;
}

/* Mobile adjustments */
@media (max-width: 380px) {
  #app { padding: 1rem; }
  .button-area { width: 170px; height: 170px; }
  .tap-button { width: 140px; height: 140px; font-size: 19px; }
  .blessing-light { width: 360px; height: 360px; }
  .sparkles { width: 260px; height: 260px; }
  .world-count { font-size: 44px; }
  .modal-content { padding: 1.5rem 1.25rem; }
  .modal-title { font-size: 22px; }
  .modal-text { font-size: 14px; }
}

@media (max-height: 700px) {
  .button-area { width: 170px; height: 170px; }
  .tap-button { width: 140px; height: 140px; font-size: 19px; }
  .blessing-light { width: 360px; height: 360px; }
  .world-count { font-size: 44px; }
}

@media (max-height: 600px) {
  .button-area { width: 140px; height: 140px; }
  .tap-button { width: 110px; height: 110px; font-size: 16px; }
  .blessing-light { width: 280px; height: 280px; }
  .world-count { font-size: 36px; }
  .brand { transform: scale(0.9); }
}
