/* ============================================================
   Bible Bowl Bonanza — "Sunday-morning carnival" theme
   ============================================================ */
:root {
  --ink: #22335f;
  --sun: #ffc93c;
  --coral: #ff6b6b;
  --teal: #06d6a0;
  --sky: #4cc9f0;
  --grape: #9b5de5;
  --tang: #ff9f1c;
  --paper: #fffdf5;
  --line: #22335f;
  --shadow: 0 6px 0 var(--line);
  --radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { height: 100%; }
body {
  min-height: 100%;
  font-family: "Baloo 2", "Comic Sans MS", cursive, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -10%, #fff4c2 0%, transparent 45%),
    linear-gradient(180deg, #aee7ff 0%, #d8f4ff 38%, #fff3d6 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ---------- decorated sky ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.cloud { position: absolute; font-size: 3.2rem; opacity: .8; animation: drift 40s linear infinite; }
.cloud-1 { top: 8%;  animation-duration: 55s; }
.cloud-2 { top: 22%; font-size: 2.2rem; animation-duration: 38s; animation-delay: -18s; }
.cloud-3 { top: 55%; font-size: 2.6rem; opacity: .5; animation-duration: 70s; animation-delay: -40s; }
@keyframes drift {
  from { left: -12%; }
  to   { left: 108%; }
}
.sun-spin {
  position: absolute; top: 4%; right: 5%;
  font-size: 4rem;
  animation: sunspin 24s linear infinite;
}
@keyframes sunspin { to { transform: rotate(360deg); } }

/* ---------- screens ---------- */
.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 24px 16px 60px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ---------- typography & logo ---------- */
.logo { font-family: "Lilita One", "Baloo 2", sans-serif; line-height: .95; text-align: center; }
.logo-line { display: block; }
.logo-line-1 {
  font-size: clamp(2rem, 7vw, 3.4rem);
  color: var(--ink);
  transform: rotate(-2deg);
}
.logo-line-2 {
  font-size: clamp(3rem, 11vw, 5.6rem);
  transform: rotate(-2deg);
  background: linear-gradient(180deg, var(--tang), var(--coral));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(3px 4px 0 var(--ink));
  letter-spacing: .02em;
}
.logo-emoji {
  font-size: clamp(3rem, 9vw, 4.6rem);
  text-align: center;
  animation: bob 2.4s ease-in-out infinite;
}
.logo-bounce { animation: pop-in .6s cubic-bezier(.2, 1.6, .4, 1) both; }
.tagline {
  margin: 14px 0 26px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  transform: rotate(-1deg);
  animation: pop-in .6s .15s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-12px) rotate(4deg); }
}

.title-stack { display: flex; flex-direction: column; align-items: center; }

/* ---------- cards ---------- */
.card {
  background: var(--paper);
  border: 4px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px;
  width: min(92vw, 520px);
}
.card-title { font-family: "Lilita One", sans-serif; font-size: 1.7rem; text-align: center; }
.card-sub { text-align: center; margin: 8px 0 18px; opacity: .85; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 800;
  color: var(--ink);
  border: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--line);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-big { display: block; width: 100%; padding: 14px 22px; font-size: 1.35rem; }
.btn-small { padding: 6px 14px; font-size: .95rem; }
.btn-coral { background: var(--coral); color: #fff; }
.btn-teal  { background: var(--teal); }
.btn-sky   { background: var(--sky); }
.btn-sun   { background: var(--sun); }
.btn-grape { background: var(--grape); color: #fff; }
.btn-plain { background: #fff; }
.btn-ghosted { opacity: .4; }

/* ---------- inputs ---------- */
.field-label { display: block; font-size: 1.1rem; margin-bottom: 10px; text-align: center; }
.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  padding: 12px;
  margin-bottom: 16px;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 14px;
  outline: none;
}
.text-input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(76, 201, 240, .35); }
.code-input { text-transform: uppercase; letter-spacing: .18em; }
.error-msg { color: var(--coral); font-weight: 700; min-height: 1.4em; margin-bottom: 8px; text-align: center; }

/* ---------- mode select ---------- */
.mode-btns { display: grid; gap: 16px; }
.btn-mode { padding: 18px; font-size: 1.3rem; text-align: center; }
.btn-mode small { display: block; font-size: .85rem; font-weight: 600; opacity: .85; margin-top: 2px; }
.mode-emoji { font-size: 1.6rem; margin-right: 4px; }

/* ---------- lobby ---------- */
.lobby-card { text-align: center; }
.code-badge {
  display: inline-block;
  background: var(--sun);
  border: 3px solid var(--line);
  border-radius: 10px;
  padding: 2px 12px;
  letter-spacing: .15em;
}
.player-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0; }
.player-chip {
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--line);
  padding: 6px 16px;
  font-weight: 800;
}
.lobby-spinner { font-size: 2.6rem; animation: spin-slow 3s linear infinite; margin: 6px 0 14px; }
@keyframes spin-slow { to { transform: rotate(360deg); } }
#btn-lobby-back { margin-top: 18px; }
#btn-begin { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 5px 0 var(--line); filter: brightness(1); }
  50%      { box-shadow: 0 5px 0 var(--line), 0 0 22px 6px rgba(255, 201, 60, .8); filter: brightness(1.08); }
}

/* ---------- quiz HUD ---------- */
.hud {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  width: min(94vw, 640px);
  margin-bottom: 12px;
}
.hud-pill {
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--line);
  padding: 7px 16px;
  font-size: 1.02rem;
}
.hud-score-pill { background: var(--sun); font-size: 1.1rem; }

.meter-box {
  display: flex; align-items: center; gap: 10px;
  width: min(94vw, 640px);
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--line);
  padding: 7px 16px;
  margin-bottom: 16px;
}
.meter-icon { font-size: 1.4rem; }
.meter-track {
  flex: 1; height: 16px;
  background: #e8e4d8;
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(45deg, var(--grape), var(--grape) 12px, #b07ff0 12px, #b07ff0 24px);
  border-radius: 999px;
  transition: width .5s cubic-bezier(.2, 1.2, .4, 1);
}
.meter-count { font-size: .85rem; font-weight: 800; white-space: nowrap; }
.meter-flash { animation: meterflash .3s ease 3; }
@keyframes meterflash {
  50% { background: var(--sun); transform: scale(1.02); }
}

/* ---------- quiz card ---------- */
.quiz-card { width: min(94vw, 640px); }
.quiz-question { font-size: 1.25rem; font-weight: 700; line-height: 1.45; margin-bottom: 20px; }
.quiz-answers { display: grid; gap: 12px; }
.answer-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--line);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.answer-btn:hover:not(:disabled) { background: #fff8e1; transform: translateY(-2px); box-shadow: 0 6px 0 var(--line); }
.answer-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--line); }
.answer-letter {
  flex: 0 0 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--sky);
  border: 2px solid var(--line);
  border-radius: 10px;
  font-weight: 800;
}
.answer-correct { background: var(--teal) !important; animation: correct-pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.answer-correct .answer-letter { background: var(--sun); }
.answer-wrong {
  background: #ffd9d9 !important;
  opacity: .6;
  text-decoration: line-through;
}
@keyframes correct-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- results ---------- */
.results-card { text-align: center; }
.final-stats { display: flex; gap: 14px; justify-content: center; margin: 18px 0 22px; flex-wrap: wrap; }
.final-stat {
  background: var(--sun);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--line);
  padding: 12px 26px;
  transform: rotate(-1.5deg);
}
.final-stat + .final-stat { background: var(--sky); transform: rotate(1.5deg); }
.final-label { font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.final-value { font-family: "Lilita One", sans-serif; font-size: 2.4rem; }
.final-value-small { font-size: 1.8rem; }
.board-title { font-family: "Lilita One", sans-serif; margin: 10px 0 12px; }
.board { display: grid; gap: 8px; margin-bottom: 22px; }
.board-row {
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 8px 14px;
  font-weight: 700;
}
.board-rank { flex: 0 0 2.2em; font-size: 1.15rem; }
.board-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-first { font-size: .9rem; opacity: .85; }
.board-score { font-family: "Lilita One", sans-serif; font-size: 1.15rem; }
.board-me { background: #fff3c4; border-color: var(--tang); }
.board-playing { opacity: .7; border-style: dashed; }

/* ---------- overlays (wheel & mini-games) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(34, 51, 95, .55);
  backdrop-filter: blur(3px);
  animation: fade-in .25s ease both;
  padding: 12px;
}
.overlay-out { animation: fade-out .25s ease both; }
@keyframes fade-in  { from { opacity: 0; } }
@keyframes fade-out { to   { opacity: 0; } }
.overlay-card {
  background: var(--paper);
  border: 4px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  width: min(92vw, 560px);
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  text-align: center;
}

/* wheel */
.wheel-title { font-family: "Lilita One", sans-serif; font-size: 1.4rem; margin-bottom: 14px; }
.wheel-wrap { position: relative; display: inline-block; margin-bottom: 16px; }
.wheel-pointer {
  position: absolute; top: -18px; left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  color: var(--coral);
  text-shadow: 0 2px 0 var(--line);
  z-index: 2;
}
.wheel-canvas { display: block; border-radius: 50%; box-shadow: 0 6px 0 rgba(34,51,95,.5); }
.wheel-result {
  margin-top: 14px;
  font-size: 1.35rem;
  font-weight: 800;
  background: var(--sun);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

/* mini-game host */
.mg-card { text-align: center; }
.mg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.mg-title { font-family: "Lilita One", sans-serif; font-size: 1.25rem; }
.mg-intro-emoji { font-size: 4rem; animation: bob 2s ease-in-out infinite; }
.mg-intro h2 { font-family: "Lilita One", sans-serif; margin: 6px 0; }
.mg-intro p { margin-bottom: 18px; }
.mg-banner {
  position: sticky; bottom: 0;
  margin-top: 14px;
  font-size: 1.3rem;
  font-weight: 800;
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 4px 0 var(--line);
}
.mg-banner-win  { background: var(--teal); }
.mg-banner-lose { background: var(--sky); }
.mg-banner-skip { background: #eee; }

/* ---------- floating points ---------- */
.fly-points {
  position: fixed; z-index: 60;
  transform: translateX(-50%);
  font-family: "Lilita One", sans-serif;
  font-size: 1.7rem;
  color: var(--teal);
  -webkit-text-stroke: 1.5px var(--line);
  pointer-events: none;
  animation: fly-up 1.3s ease-out both;
}
.fly-gold { color: var(--sun); font-size: 2rem; }
@keyframes fly-up {
  0%   { opacity: 0; transform: translate(-50%, 10px) scale(.6); }
  15%  { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(1); }
}

/* ---------- confetti ---------- */
.confetti-layer { position: fixed; inset: 0; z-index: 70; pointer-events: none; }

/* ---------- mute ---------- */
.mute-btn {
  position: fixed; top: 12px; left: 12px; z-index: 40;
  font-size: 1.3rem;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--line);
  padding: 6px 10px;
  cursor: pointer;
}

/* ---------- shared animations ---------- */
.pop-in { animation: pop-in .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop-in {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: scale(1); }
}
.bounce-in { animation: bounce-in .55s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes bounce-in {
  0%   { opacity: 0; transform: scale(.4) rotate(-6deg); }
  60%  { transform: scale(1.1) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.slide-in { animation: slide-in .4s ease both; }
@keyframes slide-in {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.shake { animation: shake .45s ease; }
@keyframes shake {
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ---------- small screens ---------- */
@media (max-width: 480px) {
  .card { padding: 20px 16px; }
  .quiz-question { font-size: 1.1rem; }
  .hud-pill { font-size: .9rem; padding: 6px 12px; }
}
