:root {
  --bg-0: #0d0b16;
  --bg-1: #17132a;
  --surface: #1f1a35;
  --surface-2: #291f47;
  --surface-border: #362a58;
  --text: #f5f2ff;
  --text-dim: #a99fd1;
  --accent: #ffd23f;
  --accent-dark: #e8a920;
  --accent-2: #ff5d7a;
  --accent-3: #7c5cff;
  --success: #4ade80;
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at 20% -10%, #2a1f52 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1,
h2,
h3,
.display {
  font-family: "Fredoka", "Manrope", system-ui, sans-serif;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

input {
  font-family: inherit;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(20px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Screens ---------- */

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.screen.active {
  display: flex;
  animation: screen-in 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}

.brand .logo-emoji {
  font-size: 2.1rem;
  animation: sway 3.2s ease-in-out infinite;
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-8deg);
  }
  50% {
    transform: rotate(8deg);
  }
}

.brand h1 {
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: 0.5px;
}

.subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  margin: -12px 0 20px;
}

/* ---------- Cards / sections ---------- */

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.card .hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 0 0 14px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  font-size: 1.08rem;
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #241a02;
  box-shadow: 0 8px 24px -8px rgba(255, 210, 63, 0.55);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--surface-border);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-2), #c93a58);
  color: #2a0410;
  box-shadow: 0 8px 24px -8px rgba(255, 93, 122, 0.55);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  padding: 10px;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- Stepper ---------- */

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.stepper-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--surface-border);
  color: var(--text);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.stepper-btn:active {
  transform: scale(0.9);
  background: var(--accent);
  color: #241a02;
}

.stepper-value {
  min-width: 64px;
  text-align: center;
  font-size: 1.7rem;
  font-weight: 700;
  font-family: "Fredoka", sans-serif;
}

.stepper-value small {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Player name inputs ---------- */

.player-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: row-in 0.25s ease;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.player-row .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.player-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-0);
  border: 1px solid var(--surface-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.player-row input:focus {
  border-color: var(--accent);
}

/* ---------- Segmented control ---------- */

.segmented {
  display: flex;
  background: var(--bg-0);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.segmented button {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.segmented button.active {
  background: var(--accent);
  color: #241a02;
}

/* ---------- Category grid ---------- */

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.category-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-0);
  border: 1.5px solid var(--surface-border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  font-size: 0.86rem;
  font-weight: 700;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.category-chip .emoji {
  font-size: 1.15rem;
}

.category-chip.selected {
  border-color: var(--accent);
  background: rgba(255, 210, 63, 0.12);
  color: var(--text);
}

.category-chip:active {
  transform: scale(0.97);
}

/* ---------- Setup footer / errors ---------- */

.setup-error {
  color: var(--accent-2);
  font-size: 0.85rem;
  text-align: center;
  min-height: 1.2em;
  margin-bottom: 10px;
}

/* ---------- Pass / Reveal screen ---------- */

.pass-progress {
  text-align: center;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.reveal-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reveal-card {
  width: 100%;
  min-height: 320px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  gap: 18px;
  position: relative;
  overflow: hidden;
}

.reveal-card .hand-emoji {
  font-size: 3rem;
  animation: bounce 1.6s ease-in-out infinite;
}

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

.reveal-card .player-name {
  font-family: "Fredoka", sans-serif;
  font-size: 1.7rem;
  margin: 0;
}

.reveal-card .tap-hint {
  color: var(--text-dim);
  margin: 0;
  font-size: 0.95rem;
}

.reveal-content {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: reveal-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reveal-content.show {
  display: flex;
}

@keyframes reveal-pop {
  0% {
    opacity: 0;
    transform: scale(0.6) rotate(-6deg);
  }
  60% {
    transform: scale(1.06) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.reveal-content .category-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.reveal-content .secret-word {
  font-family: "Fredoka", sans-serif;
  font-size: 2rem;
  margin: 0;
  line-height: 1.15;
}

.word-hint {
  display: block;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 0.4em;
  font-weight: 500;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 8px;
}

.reveal-content.is-banana .secret-word {
  font-size: 2.6rem;
  color: var(--accent);
  animation: banana-wiggle 0.6s ease-in-out infinite alternate;
}

@keyframes banana-wiggle {
  from {
    transform: rotate(-4deg) scale(1);
  }
  to {
    transform: rotate(4deg) scale(1.05);
  }
}

.reveal-actions {
  margin-top: 22px;
  width: 100%;
}

/* ---------- Final screen ---------- */

.final-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}

.final-stage .big-emoji {
  font-size: 3.4rem;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.final-stage p {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--text);
  max-width: 380px;
  margin: 0;
}

/* ---------- Banana reveal screen ---------- */

.bananas-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bananas-stage h2 {
  text-align: center;
  font-size: 1.4rem;
  margin: 0;
}

.banana-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.banana-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(255, 210, 63, 0.16), rgba(255, 93, 122, 0.1));
  border: 1px solid rgba(255, 210, 63, 0.35);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-weight: 700;
  font-size: 1.05rem;
  opacity: 0;
  animation: banana-item-in 0.4s ease forwards;
}

@keyframes banana-item-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.banana-item .emoji {
  font-size: 1.3rem;
}

.no-bananas {
  text-align: center;
  color: var(--text-dim);
  padding: 18px;
  font-weight: 600;
}

.secret-reveal-card {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.secret-reveal-card .category-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}

.secret-reveal-card .secret-word {
  font-family: "Fredoka", sans-serif;
  font-size: 1.6rem;
  margin: 0;
}

.bananas-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
}

/* ---------- Utility ---------- */

.grow {
  flex: 1;
}

@media (max-width: 360px) {
  .brand h1 {
    font-size: 1.5rem;
  }
  .reveal-content .secret-word {
    font-size: 1.7rem;
  }
}
