@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700;900&family=Inter:wght@400;500;600;700&family=IM+Fell+English+SC&display=swap');

:root{
  --bg:#ffffff;
  --text:#121212;
  --card:#ffffff;
  --muted:#6b6b6b;
  --rule:#e5e5e5;
  --accent:#00b0a9;
  --accent-dark:#008f8a;
  --danger:#d04a3b;
  --dark:#121212;
  --gold:#f5c531;
}

*{ box-sizing:border-box; }

html, body{ margin:0; padding:0; height:100%; }
body{
  font-family:'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.4;
  -webkit-font-smoothing:antialiased;
}

#mainContainer{
  max-width:560px;
  margin:0 auto;
  padding:18px 20px max(18px, env(safe-area-inset-bottom));
}

/* Wordmark — clean Merriweather, matches lobby */
h1{
  margin:4px 0 8px;
  text-align:center;
  font-family:'Merriweather', Georgia, serif;
  font-weight:900;
  font-size: clamp(36px, 9vw, 48px);
  letter-spacing:-1px;
  color:var(--text);
  text-transform:lowercase;
}

/* Top bar (streak + how + score) */
#topBar{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  width:100%; max-width:520px;
  margin:0 auto 12px;
  gap:8px;
  padding: 10px 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.topbar-label{
  font-family:'Inter', sans-serif;
  font-size:.7rem;
  font-weight:600;
  letter-spacing:1.5px;
  text-transform:uppercase;
  color:var(--muted);
  margin-right:6px;
}
#streakWrap{ display:flex; align-items:center; justify-content:flex-start; min-width:0; }
#scoreWrap{
  display:flex; align-items:center; justify-content:flex-end;
  min-width:0;
  font-family:'Merriweather', Georgia, serif;
  font-weight:900;
  font-size:1rem;
  color:var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
#highScore{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.streak-dots{ display:inline-flex; gap:6px; }
.streak-dots .dot{
  width:12px; height:12px; border-radius:50%;
  background:transparent;
  border:1.5px solid var(--text);
  transition: background-color .3s ease, transform .3s ease;
}
.streak-dots .dot.lit{
  background:var(--accent);
  border-color: var(--accent);
  transform: scale(1.08);
}
#howBtn{
  width:28px; height:28px; border-radius:50%;
  border:1.5px solid var(--text);
  background:#fff;
  color:var(--text);
  font-family:'Merriweather', Georgia, serif;
  font-size:.95rem;
  font-weight:900;
  cursor:pointer;
  line-height:1;
  padding:0;
}
#howBtn:hover{ background:var(--text); color:#fff; }

#challengeBanner{
  text-align:center;
  font-family:'Inter', sans-serif;
  font-weight:700;
  letter-spacing:2px;
  text-transform:uppercase;
  background:var(--text);
  color:#fff;
  padding:8px 10px;
  border-radius:2px;
  margin: 0 auto 12px;
  max-width:520px;
  font-size:.8rem;
}

/* Question / image */
#questionArea{
  display:flex;
  flex-direction:column;
  align-items:center;
}
.question-prompt{
  text-align:center;
  margin:28px 0 8px;
  font-family:'Merriweather', Georgia, serif;
  font-weight:700;
  font-size:1.15rem;
  line-height:1.3;
  max-width:520px;
  color:var(--text);
}
#playerName{ color:var(--text); }

.image-frame{
  width:200px; height:200px;
  margin:2px auto 2px;
  background-image:url('../assets/circularframeformookie.png');
  background-size:cover;
  display:flex; align-items:center; justify-content:center;
  position:relative; flex-shrink:0;
}
.player-image{
  width:62%; height:62%;
  object-fit:cover; object-position:center 20%;
  border-radius:50%;
}

#result{
  text-align:center;
  font-family:'Inter', sans-serif;
  font-size:.95rem;
  font-weight:500;
  min-height:1.4em;
  margin:6px 0 0;
  color:var(--text);
}
#result.correct{ color:#15803d; }
#result.incorrect{ color:#b91c1c; }
.kaboom{
  font-family:'Merriweather', Georgia, serif;
  font-weight:900;
  font-size:1.4rem;
  color:var(--accent-dark);
  letter-spacing:.5px;
}

/* Guess CTA */
.bottom-guess-cta{
  width:100%; max-width:520px;
  margin: 10px auto 6px;
  padding:0 4px;
}

/* Buttons */
.btn{
  padding:14px 16px;
  border:0;
  border-radius:6px;
  background:var(--accent);
  color:#fff;
  font-weight:700;
  cursor:pointer;
  font-family:'Inter', sans-serif;
  font-size:15px;
  letter-spacing:.3px;
  text-transform:uppercase;
  transition: background-color .2s ease, transform .1s ease;
  line-height:1.2;
}
.btn:hover{ background:var(--accent-dark); }
.btn:active{ transform: translateY(1px); }
.btn.primary{ background:var(--accent); }
.btn.primary:hover{ background:var(--accent-dark); }
.btn.dark{ background:var(--text); color:#fff; }
.btn.dark:hover{ background:#333; }
.btn.danger{ background:var(--danger); }
.btn.danger:hover{ background:#b03b2e; }
.btn.wide{
  width:100%;
  max-width:360px;
  margin:8px auto;
  display:block;
}
.btn:disabled{
  opacity:.5;
  cursor:not-allowed;
}

/* Input / suggestions (inside modal) */
.input-area{
  display:flex; flex-direction:column; align-items:center;
  gap:6px; margin:8px 0 16px;
}
.input-area input{
  width:100%; max-width:360px;
  padding:14px 18px;
  border:1.5px solid var(--text);
  border-radius:6px;
  font-size:16px;
  text-align:center;
  font-family:'Inter', sans-serif;
  background-color:#fff;
  transition:all .2s ease;
}
.input-area input:focus{
  outline:none;
  border-color:var(--accent);
}
.suggestions{
  width:100%; max-width:360px;
  max-height:40dvh;
  overflow:auto;
  background:#fff;
  border:1px solid var(--rule);
  border-top:none;
  border-radius:0 0 6px 6px;
  display:none;
  z-index:5;
}
.suggestions.show{ display:block; }
.suggestion-item{
  padding:14px 14px;
  min-height:48px;
  cursor:pointer;
  font-size:1rem;
  display:flex; align-items:center; gap:10px;
  font-family:'Inter', sans-serif;
  border-bottom: 1px solid var(--rule);
}
.suggestion-item:last-child{ border-bottom: 0; }
.suggestion-item:hover{ background:#fafafa; }
.suggestion-item:active{ background:#f0f0f0; }
.suggestion-logo{
  width:20px; height:20px; object-fit:contain; flex:0 0 auto;
}
.guess-field{ position:relative; display:block; width:100%; max-width:360px; }
.guess-field .field-logo{
  position:absolute; left:14px; top:50%; transform:translateY(-50%);
  width:26px; height:26px; object-fit:contain; display:none; pointer-events:none;
}
.guess-field.has-logo .field-logo{ display:block; }
.guess-field.has-logo input{ padding-left:52px; }

/* Guess Modal */
.guess-modal{
  position:fixed; inset:0; height:100dvh;
  display:none; align-items:flex-start; justify-content:center;
  padding:clamp(10px, 10dvh, 80px) 18px 18px;
  background:rgba(15,15,15,0.6);
  z-index:10000;
}
.guess-modal.show{ display:flex; }
.guess-modal-inner{
  width:100%; max-width:520px;
  max-height:calc(100dvh - 32px);
  overflow:auto;
  background:#fff;
  border-radius:8px;
  padding:20px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow:0 12px 30px rgba(0,0,0,.25);
  position:relative;
  border:1px solid var(--rule);
}
.guess-modal-title{
  margin:2px 0 6px;
  font-family:'Merriweather', Georgia, serif;
  font-size:1.25rem; font-weight:900;
  text-align:center;
  color:var(--text);
}
.guess-modal-subtitle{
  margin:0 0 12px;
  font-family:'Inter', sans-serif;
  font-size:.95rem;
  color:var(--muted);
  text-align:center;
}
.guess-modal-close{
  position:absolute; right:12px; top:10px;
  border:0; background:none; font-size:24px; line-height:1;
  cursor:pointer; color:var(--muted);
}
.guess-modal-close:hover{ color:var(--text); }
.modal-cancel{
  margin-top:6px;
  border:0; background:none;
  color:var(--muted);
  font-family:'Inter', sans-serif;
  font-size:.9rem;
  cursor:pointer;
  text-decoration:underline;
}
.modal-cancel:hover{ color:var(--text); }

.how-list{
  list-style:disc; padding-left:22px; margin:8px 0 16px;
  font-family:'Inter', sans-serif;
  font-size:.95rem;
  line-height:1.5;
  color:var(--text);
}
.how-list li{ margin:8px 0; }

/* Win/Lose popups */
.popup{
  display:none;
  position:fixed; inset:0;
  background:rgba(15,15,15,0.6);
  z-index:10001;
  align-items:flex-start; justify-content:center;
  padding:clamp(10px, 10dvh, 80px) 18px 18px;
}
.popup.show{ display:flex; }
.popup-content{
  width:100%; max-width:520px;
  background:#fff;
  border-radius:8px;
  padding:24px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow:0 12px 30px rgba(0,0,0,.25);
  position:relative;
  text-align:center;
  border:1px solid var(--rule);
}
.popup-logo{
  max-width:70%; height:auto;
  margin:0 auto 14px;
  display:block;
}
.popup-message{
  margin:0 0 16px;
  font-family:'Inter', sans-serif;
  font-size:1rem;
  color:var(--text);
}
.popup-buttons{
  display:flex; flex-direction:column; align-items:center; gap:6px;
}
.popup .close{
  position:absolute; right:12px; top:8px;
  font-size:26px; line-height:1;
  cursor:pointer; color:var(--muted);
}
.popup .close:hover{ color:var(--text); }

/* MOOKIE celebration — editorial, not garish */
#mookiePopup .popup-content{
  border-top:4px solid var(--gold);
  animation:popCardIn .42s cubic-bezier(.2,.9,.3,1.25) both;
}
.popup-headline{
  font-family:'Merriweather', Georgia, serif;
  font-weight:900;
  font-size:1.7rem;
  line-height:1.1;
  letter-spacing:-.01em;
  margin:2px 0 8px;
  color:var(--text);
}
.popup-headline .accent{ color:var(--accent-dark); }
#nopePopup .popup-headline{ display:none; }

#fireworksCanvas{
  position:fixed; inset:0;
  width:100%; height:100%;
  pointer-events:none;
  z-index:10050;
}

/* YES/NO pow animation */
@keyframes mookiePopIn{
  0%{ transform:scale(.2) rotate(-10deg); opacity:0; }
  60%{ transform:scale(1.2) rotate(6deg); opacity:1; }
  100%{ transform:scale(1) rotate(0); opacity:1; }
}
@keyframes popCardIn{
  0%{ transform:translateY(10px) scale(.96); opacity:0; }
  100%{ transform:translateY(0) scale(1); opacity:1; }
}
@media (prefers-reduced-motion: reduce){
  #mookiePopup .popup-content{ animation:none; }
}

/* Larger screens */
@media (min-width:768px){
  h1{ font-size:3rem; }
  .question-prompt{ font-size:1.35rem; }
  .image-frame{ width:240px; height:240px; }
}

/* Mobile - tight stack, no wasted vertical space */
@media (max-width:767px){
  html, body{ height:100%; overflow:hidden; }
  #mainContainer{
    padding:8px 14px max(10px, env(safe-area-inset-bottom));
  }
  h1{ font-size:2rem; margin:4px 0 6px; }
  #topBar{
    margin:2px auto 8px;
    gap:4px;
    padding:8px;
  }
  .topbar-label{ font-size:.6rem; letter-spacing:1px; margin-right:4px; }
  #scoreWrap{ font-size:.9rem; }
  .streak-dots{ gap:4px; }
  .streak-dots .dot{ width:11px; height:11px; }

  #questionArea{ gap:0; }
  .question-prompt{ font-size:clamp(1rem, 4vw, 1.2rem); margin:14px 0 6px; }
  .image-frame{ width:160px; height:160px; margin:4px auto; }
  #result{ font-size:.9rem; min-height:1.2em; margin:4px 0 0; }

  .bottom-guess-cta{
    margin:10px auto 0;
    padding:0 4px;
  }
  .btn.wide{ padding:14px; font-size:15px; margin:0 auto; }
  .suggestions{ max-height:40dvh; }
}
