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

:root {
  --bg: #dd2d4a;
  --step: #fce8ec;
  --click: #e599a6;
}

html {
  height: 100%;
  background: var(--bg);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  z-index: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
}

/* ── SHARED SCREEN SHELL ── */
.screen {
  flex: 1;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  padding: max(40px, env(safe-area-inset-top)) 28px
    max(36px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.screen.hidden {
  display: none;
}

/* ── PRIMARY BUTTON ── */
.btn-primary {
  width: 100%;
  padding: 18px 20px;
  background: #fff;
  color: #333;
  border: 1px #333 solid;
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-size: 19px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.08s,
    background 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
  background: #f0f0f0;
}

.btn-primary:active {
  transform: translateY(2px);
  background: #e8e8e8;
}

/* ── SCREEN 1: Names ── */
#screen-names {
  justify-content: space-between;
}

.logo {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.3px;
  text-align: center;
  padding-top: 8px;
}

.names-middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 24px 0;
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-field {
  width: 100%;
  padding: 26px 20px;
  background: #fff;
  border: 1px solid #1a1a1a;
  border-radius: 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  text-align: center;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  -webkit-appearance: none;
}

.input-field::placeholder {
  color: #bbb;
  font-weight: 700;
}

.input-field:focus {
  border-color: var(--bg);
  box-shadow: 0 0 0 3px rgba(221, 45, 74, 0.25);
}

/* ── SCREEN 2: Rules ── */
#screen-rules {
  justify-content: space-between;
}

.rules-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(38px, 10vw, 52px);
  letter-spacing: 2px;
  text-align: center;
  line-height: 1;
  padding-top: 8px;
}

.rules-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 20px 0;
}

.rules-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rule-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.rule-step-num {
  font-family: 'Bangers', cursive;
  font-size: clamp(60px, 14vw, 65px);
  line-height: 1;
  letter-spacing: 1px;
  color: var(--step);
}

.rule-step-text {
  font-size: clamp(20px, 5.5vw, 24px);
  font-weight: 800;
  line-height: 1.35;
  color: #fff;
  margin-top: 4px;
  margin-bottom: 30px;
}

.rule-step-text strong {
  font-weight: 900;
}

/* ── SCREEN 3: Game ── */
.game {
  flex: 1;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  padding: max(48px, env(safe-area-inset-top)) 20px
    max(20px, env(safe-area-inset-bottom));
  gap: 14px;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.game.hidden {
  display: none;
}

.game.hidden-during-countdown {
  opacity: 0;
  pointer-events: none;
}

.top {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.question-text {
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}

#result-indicator {
  flex: 0 0 auto;
}

.result-text {
  width: 100%;
  text-align: center;
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 800;
  line-height: 1.6;
}

.result-text span {
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  padding: 0 6px;
  border-radius: 4px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.answers {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
}

.answer-btn {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #1a1a1a;
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(19px, 4.5vw, 16px);
  font-weight: 700;
  color: #1a1a1a;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color 0.12s,
    border-width 0.12s;
}

@media (hover: hover) {
  .answer-btn:hover:not(:disabled) {
    background: #f5f5f5;
  }
}

.answer-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.answer-btn:disabled {
  cursor: default;
}

.answer-text {
  flex: 1;
  line-height: 1.25;
  text-align: center;
}

.answer-badges {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.badge {
  display: none;
  height: 22px;
  border-radius: 100px;
  padding: 0 8px;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  background: var(--bg);
  color: #fff;
}

.badge.visible {
  display: flex;
}

.answer-btn.sel-p1::before,
.answer-btn.sel-p2::before,
.answer-btn.sel-both::before {
  content: '▸';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 40px;
  color: var(--bg);
  line-height: 1;
}

.answer-btn.flash-p1,
.answer-btn.flash-p2 {
  background: var(--click);
  border-color: #333;
  color: #fff;
}

.bottom {
  flex: 0 0 auto;
  display: grid;
  overflow: hidden;
}

#player-indicator {
  grid-area: 1/1;
  display: flex;
  align-items: center;
  min-height: 62px;
}

#player-indicator.hidden {
  opacity: 0;
  pointer-events: none;
}

.player-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.p-item {
  margin-bottom: -20px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity 0.2s;
}

.p-item.waiting {
  opacity: 0.38;
}

.p-num {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  font-weight: 400;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.p-item.active .p-num {
  background: rgba(0, 0, 0, 0.1);
}

.p-item.active:first-child .p-label {
  transform-origin: left center;
  animation: player-attention 0.9s ease forwards;
}

.p-item.active:last-child .p-label {
  transform-origin: right center;
  animation: player-attention 0.9s ease forwards;
}

@keyframes player-attention {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.7);
  }
  100% {
    transform: scale(1);
  }
}

.p-label {
  font-size: clamp(18px, 4.8vw, 21px);
  font-weight: 900;
  line-height: 1.2;
}

.p-sublabel {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.7;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  6% {
    transform: scale(1.05);
  }
  12% {
    transform: scale(1);
  }
}

.next-btn {
  grid-area: 1/1;
  width: 100%;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 100px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: clamp(16px, 4.5vw, 19px);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.08s,
    background 0.08s;
  -webkit-tap-highlight-color: transparent;
}

.next-btn.visible {
  opacity: 1;
  pointer-events: auto;
  animation: pulse 8s ease-in-out infinite;
  animation-delay: 7s;
}

.next-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.next-btn:active {
  animation: none;
  transform: translateY(2px);
  background: rgba(255, 255, 255, 0.14);
}

/* ── COUNTDOWN ── */
.countdown-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}

.countdown-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.countdown-num {
  font-size: 144px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  letter-spacing: -8px;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

.countdown-label {
  font-size: clamp(19px, 5.2vw, 24px);
  font-weight: 800;
  text-align: center;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
}

.countdown-hint {
  font-size: clamp(12px, 3.2vw, 14px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

/* ── GAME OVER ── */
.game-over {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  z-index: 60;
  background: var(--bg);
}

.game-over::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}

.game-over.visible {
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  padding: max(40px, env(safe-area-inset-top)) 28px
    max(36px, env(safe-area-inset-bottom));
}

.game-over-header {
  display: flex;
  flex-direction: column;
  align-self: start;
  gap: 15px;
  text-align: center;
}

.game-over-title {
  font-size: clamp(28px, 8vw, 42px);
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.game-over-subtitle {
  font-size: clamp(19px, 5.5vw, 23px);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}

.game-over-middle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 30px;
}

.game-over-score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

#game-over-score-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.game-over-score-big {
  font-size: clamp(140px, 38vw, 200px);
  font-weight: 900;
  color: #fff;
  letter-spacing: -8px;
  line-height: 1;
}

.game-over-score-of {
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.game-over-score-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 4px;
}

.game-over-bottom {
  display: flex;
  align-items: flex-end;
  align-self: end;
}

/* ── Spinner ── */
.game-over-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: go-spin 0.8s linear infinite;
}

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

/* ── Game over entrance animations ── */
@keyframes go-fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.go-anim {
  opacity: 0;
}

.game-over.visible .go-anim--header {
  animation: go-fade-up 0.5s ease forwards;
  animation-delay: 0.1s;
}

.game-over.visible .go-anim--score {
  animation: go-fade-up 0.5s ease forwards;
  animation-delay: 0.7s;
}

.game-over.visible .go-anim--btn {
  animation: go-fade-up 0.5s ease forwards;
}

.font-preload {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  font-family: 'Bangers', cursive;
  font-size: 48px;
  line-height: 1;
  white-space: nowrap;
}

/* ── Settings gear ── */
.settings-btn {
  position: fixed;
  top: max(4px, env(safe-area-inset-top));
  right: 12px;
  z-index: 100;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.55);
  transition: color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.settings-btn:hover {
  color: #fff;
}

.settings-menu {
  position: fixed;
  top: max(60px, calc(env(safe-area-inset-top) + 44px));
  right: 16px;
  z-index: 100;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  min-width: 220px;
}

.settings-menu.hidden {
  display: none;
}

.settings-item {
  padding: 12px 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: #1a1a1a;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  display: block;
  -webkit-tap-highlight-color: transparent;
}

.settings-item:hover {
  background: #f5f5f5;
}

.settings-item--danger {
  color: #dd2d4a;
  border-top: 1px solid #eee;
  margin-top: 4px;
}

/* ── Rule steps stagger animation ── */
@keyframes rule-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rule-step--anim {
  opacity: 0;
}

#screen-rules.animated .rule-step--anim {
  animation: rule-fade-up 0.4s ease forwards;
}

#screen-rules.animated .rule-step--1 {
  animation-delay: 0s;
}
#screen-rules.animated .rule-step--2 {
  animation-delay: 0.7s;
}
#screen-rules.animated .rule-step--3 {
  animation-delay: 1.4s;
}
#screen-rules.animated .rule-step--4 {
  animation-delay: 2s;
}

#screen-rules:not(.animated) .rule-step--anim {
  opacity: 1;
}

/* ── Paywall screen ── */
#screen-paywall {
  justify-content: space-between;
  text-align: center;
}

@keyframes pw-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pw-anim {
  opacity: 0;
  animation: pw-fade-up 0.6s ease forwards;
}
.pw-anim--1 {
  animation-delay: 0.1s;
}
.pw-anim--2 {
  animation-delay: 0.5s;
}
.pw-anim--3 {
  animation-delay: 1s;
}
.pw-anim--4 {
  animation-delay: 1.6s;
}

.paywall-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.paywall-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.paywall-emoji {
  font-size: 72px;
  line-height: 1;
}

.paywall-kicker {
  font-size: clamp(21px, 7vw, 29px);
  font-weight: 900;
  line-height: 1.3;
}

.paywall-kicker-box {
  background: #fff;
  color: #dd2d4a;
  padding: 22px 24px;
  border-radius: 14px;
  display: inline-block;
}

.paywall-headline {
  font-size: clamp(36px, 11vw, 48px);
  font-weight: 900;
  color: #fff;
  line-height: 1.05;
  letter-spacing: -1.5px;
}

.paywall-hook {
  font-size: clamp(21px, 6vw, 26px);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.35;
}

.paywall-highlight {
  background: #fff;
  color: #dd2d4a;
  padding: 2px 10px;
  border-radius: 6px;
  font-weight: 900;
}

.paywall-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.paywall-cta {
  width: 100%;
  background: #fff;
  color: #dd2d4a;
  border: none;
  border-radius: 100px;
  padding: 20px 24px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: -0.3px;
  transition:
    transform 0.15s,
    opacity 0.15s;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.cta-main {
  font-size: clamp(16px, 4.5vw, 18px);
}

.cta-price {
  font-size: clamp(20px, 6vw, 23px);
}

.cta-original {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.4;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.paywall-cta:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.paywall-fine {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.8;
}

.paywall-tc {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 14px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 800;
  white-space: normal;
  max-width: calc(100vw - 48px);
  width: max-content;
  text-align: center;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.toast.hidden {
  display: none;
}
