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

:root {
  --red: #e91c24;
  --red-dark: #c70307;
  --red-glow: rgba(233, 28, 36, 0.35);
  --white: #f2f2f2;
  --gray: #a6a6a6;
  --black: #0d0d0d;
  --error: #ff6b6b;
  --star-size: 2.75rem;
  --font-heading: "Montserrat", system-ui, sans-serif;
  --font-body: "Work Sans", system-ui, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--white);
  background: var(--black);
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 85% 50%, var(--red-glow) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 90%, rgba(199, 3, 7, 0.2) 0%, transparent 60%),
    linear-gradient(135deg, #000 0%, #0d0d0d 40%, #1a0003 100%);
  pointer-events: none;
}

.bg-watermark {
  position: fixed;
  right: -5%;
  top: 50%;
  transform: translateY(-50%);
  width: min(55vw, 520px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem calc(5.5rem + env(safe-area-inset-bottom));
}

/* Progress */
.progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 2rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--red);
  border-radius: 2px;
  transition: width 0.35s ease;
  width: 0%;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--gray);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Screens */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: flex;
}

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

.brand-line {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--red);
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
}

.screen-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1.15;
  color: var(--white);
  margin-bottom: 0.75rem;
}

.screen-subtitle {
  font-size: 1rem;
  color: var(--gray);
  line-height: 1.5;
  margin-bottom: 2rem;
  max-width: 36rem;
}

.screen-content {
  flex: 1;
}

/* Welcome */
.welcome-number {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 4rem;
  color: var(--red);
  line-height: 1;
  margin-bottom: 0.25rem;
}

/* Form */
.text-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: var(--font-body);
  font-size: 1.125rem;
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.text-input::placeholder {
  color: rgba(166, 166, 166, 0.6);
}

.text-input:focus {
  border-color: var(--red);
}

.text-input.error {
  border-color: var(--error);
}

.text-area {
  resize: vertical;
  min-height: 9rem;
  line-height: 1.5;
}

.error-msg {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

.error-msg:empty {
  display: none;
}

/* Star rating */
.star-rating {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.star-rating.centered {
  justify-content: center;
  margin: 1rem 0;
}

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  min-width: var(--star-size);
  min-height: var(--star-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.star-btn:hover,
.star-btn:focus-visible {
  transform: scale(1.12);
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.star-btn svg {
  width: var(--star-size);
  height: var(--star-size);
}

.star-btn .star-fill {
  fill: transparent;
  stroke: var(--red);
  stroke-width: 1.5;
  transition: fill 0.15s, stroke 0.15s;
}

.star-btn.active .star-fill,
.star-btn.hover-preview .star-fill {
  fill: var(--red);
  stroke: var(--red);
}

.rating-label {
  font-size: 0.875rem;
  color: var(--gray);
  margin-top: 0.5rem;
  min-height: 1.25rem;
}

/* Multi-rating list */
.rating-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.rating-item {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rating-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.rating-item-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.35rem;
  color: var(--white);
}

.rating-item-summary {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--gray);
  margin-bottom: 0.75rem;
  max-width: 36rem;
}

.rating-item.error .rating-item-label {
  color: var(--error);
}

/* Buttons */
.nav-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
}

.btn {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.9rem 2rem;
  min-height: 48px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.btn-primary {
  background: var(--red);
  color: var(--white);
  flex: 1;
}

.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--gray);
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--white);
}

/* Footer logos */
.footer-logos {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: max(1.25rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 2;
  pointer-events: none;
}

.footer-logos img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

/* Thank you */
.thank-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.thank-icon svg {
  width: 32px;
  height: 32px;
  fill: var(--white);
}

.submit-status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--gray);
}

.submit-status.error {
  color: var(--error);
}

/* Loading */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Scrollable rating screens on small phones */
@media (max-height: 700px) {
  .rating-list-screen .screen-content {
    max-height: 62vh;
    overflow-y: auto;
    padding-right: 0.25rem;
  }
}

@media (max-width: 480px) {
  :root {
    --star-size: 2.35rem;
  }

  .app {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .screen-subtitle {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
  }

  .welcome-number {
    font-size: 3rem;
  }

  .footer-logos img {
    height: 28px;
  }

  .nav-buttons {
    flex-direction: column-reverse;
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin-top: auto;
    padding-top: 1.25rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--black) 65%, transparent);
  }

  .btn-secondary {
    text-align: center;
  }

  .rating-list-screen .screen-content {
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 0.5rem;
  }

  .rating-item {
    padding-bottom: 1.25rem;
  }

  .star-rating {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
