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

:root {
  --bg-dark: #0a0000;
  --crimson: #8b0000;
  --crimson-bright: #dc143c;
  --gold-dim: #c9a84c;
  --text-primary: #e8e0d4;
  --text-dim: #8a7e72;
  --card-bg: rgba(10, 0, 0, 0.85);
  --serif: Georgia, 'Times New Roman', Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html {
  font-size: 16px;
}

body {
  font-family: var(--sans);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: linear-gradient(
    180deg,
    #0a0000 0%,
    #1a0005 25%,
    #3d0010 50%,
    #1a0005 75%,
    #0a0000 100%
  );
  background-size: 100% 300%;
  animation: gradientShift 12s ease-in-out infinite;
  z-index: 0;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 0% 100%; }
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  animation: grainAnim 0.5s steps(4) infinite;
}

@keyframes grainAnim {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 3px); }
  50% { transform: translate(3px, -1px); }
  75% { transform: translate(-1px, -3px); }
  100% { transform: translate(2px, 1px); }
}

.card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 560px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
}

@media (min-width: 600px) {
  .card {
    min-height: auto;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid rgba(139, 0, 0, 0.2);
    margin: 2rem auto;
  }
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.top-title {
  font-family: var(--serif);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sound-toggle {
  background: none;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.3s ease;
  min-height: 32px;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.sound-toggle.active {
  color: var(--crimson-bright);
  border-color: var(--crimson-bright);
}

.meter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.meter.visible {
  opacity: 1;
}

.meter-label {
  font-family: var(--sans);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
}

.meter-segments {
  display: flex;
  gap: 4px;
  flex: 1;
}

.seg {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.seg.filled {
  background: var(--crimson-bright);
}

.meter.glow .seg.filled {
  box-shadow: 0 0 8px var(--crimson-bright), 0 0 16px rgba(220, 20, 60, 0.4);
  animation: segJitter 0.15s infinite;
}

@keyframes segJitter {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

.screen-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 400px;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  animation: fadeIn 0.6s ease;
}

.screen.active {
  display: flex;
}

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

.headline {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--text-primary);
  transition: text-shadow 0.4s ease;
}

.body-text {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  max-width: 380px;
}

.prompt-text {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 2rem;
}

.choice-prompt {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 1rem;
  max-width: 420px;
  transition: text-shadow 0.4s ease, animation 0.4s ease;
}

.choice-step {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.glitch-text {
  text-shadow:
    2px 0 rgba(220, 20, 60, 0.5),
    -2px 0 rgba(60, 60, 220, 0.4);
}

.shake-text {
  animation: shakeAnim 0.12s infinite;
}

@keyframes shakeAnim {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, 2px); }
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 400px;
}

@media (min-width: 480px) {
  .btn-row {
    flex-direction: row;
  }
}

.phone-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
}

.phone-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-family: var(--sans);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.3s ease;
  min-height: 52px;
}

.phone-input:focus {
  border-color: var(--crimson-bright);
}

.phone-input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

.phone-error {
  font-size: 0.8rem;
  color: var(--crimson-bright);
  min-height: 1.2em;
}

.phone-legal {
  font-size: 0.6rem;
  color: var(--text-dim);
  opacity: 0.7;
  line-height: 1.4;
  margin-top: 0.25rem;
}

.phone-legal a {
  color: var(--text-dim);
  text-decoration: underline;
}

.btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-height: 52px;
  padding: 0.875rem 1.5rem;
  transition: all 0.25s ease;
  width: 100%;
}

.btn:focus-visible {
  outline: 2px solid var(--crimson-bright);
  outline-offset: 3px;
}

.btn-start {
  background: transparent;
  border: 1px solid var(--crimson-bright);
  color: var(--crimson-bright);
  max-width: 320px;
}

.btn-start:hover {
  background: rgba(220, 20, 60, 0.1);
}

.btn-heaven {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-heaven:hover,
.btn-heaven.focused {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-her {
  background: rgba(139, 0, 0, 0.25);
  color: var(--crimson-bright);
  border: 1px solid rgba(220, 20, 60, 0.4);
}

.btn-her:hover,
.btn-her.focused {
  background: rgba(139, 0, 0, 0.45);
  border-color: var(--crimson-bright);
  box-shadow: 0 0 20px rgba(220, 20, 60, 0.3);
}

.ending-heading {
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  transition: text-shadow 0.4s ease;
}

.ending-subline {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.ending-body {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  max-width: 380px;
}

.share-preview {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 1.5rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(139, 0, 0, 0.3);
}

.share-preview canvas {
  width: 100%;
  height: auto;
  display: block;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 320px;
}

.btn-action {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.75rem;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-spotify {
  background: rgba(30, 215, 96, 0.1);
  border-color: rgba(30, 215, 96, 0.3);
  color: #1ed760;
}

.btn-spotify:hover {
  background: rgba(30, 215, 96, 0.2);
}

.footer {
  text-align: center;
  padding-top: 1.5rem;
  margin-top: auto;
}

.footer small {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.copied-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--crimson);
  color: var(--text-primary);
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  z-index: 100;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.5s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

body.fall-high::before {
  background: linear-gradient(
    180deg,
    #0a0000 0%,
    #2a0008 20%,
    #5a001a 50%,
    #2a0008 80%,
    #0a0000 100%
  );
  background-size: 100% 300%;
  animation: gradientShift 8s ease-in-out infinite;
}

body.fall-max::before {
  background: linear-gradient(
    180deg,
    #0a0000 0%,
    #3d000f 15%,
    #7a0025 50%,
    #3d000f 85%,
    #0a0000 100%
  );
  background-size: 100% 300%;
  animation: gradientShift 5s ease-in-out infinite;
}
