@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;
  --tile-blue:#34afe6;
}

*{ 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;
  min-height:100vh;
}

/* Wordmark — clean Merriweather */
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;
}

/* Cards (setup / join / waiting) */
.card{
  background:var(--card);
  border:1px solid var(--rule);
  border-radius:8px;
  padding:18px 16px;
  margin:12px 0;
}

.lbl{
  font-family:'Inter', sans-serif;
  font-weight:600;
  font-size:.75rem;
  letter-spacing:1.2px;
  text-transform:uppercase;
  color:var(--muted);
  margin: 14px 0 6px;
  display:block;
  text-align:center;
}

.txt{
  width:100%;
  max-width:360px;
  margin:0 auto;
  display:block;
  padding:12px 16px;
  border:1.5px solid var(--text);
  border-radius:6px;
  font-size:1rem;
  text-align:center;
  font-family:'Inter', sans-serif;
  background-color:#fff;
  transition:border-color .2s ease;
}
.txt:focus{
  outline:none;
  border-color:var(--accent);
}

/* 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, .btn.secondary{ background:var(--text); color:#fff; }
.btn.dark:hover, .btn.secondary:hover{ background:#333; }
.btn.green{ background:var(--text); }   /* copy-link button — now black */
.btn.green:hover{ background:#333; }
.btn.start{ background:var(--accent); }
.btn.start:hover{ background:var(--accent-dark); }
.btn:disabled{
  opacity:.4;
  cursor:not-allowed;
}
.btn.wide{
  width:100%;
  max-width:360px;
  margin:10px auto;
  display:block;
}

/* Lobby helpers */
.muted{ color:var(--muted); font-size:.85rem; }

.section-title{
  font-family:'Merriweather', Georgia, serif;
  font-weight:900;
  font-size:1.1rem;
  margin:4px 0 14px;
  text-align:center;
  color:var(--text);
}

.divider{ border:0; border-top:1px solid var(--rule); margin:14px 0; }
.lobby-help{
  margin-top:4px;
  text-align:center;
  font-family:'Inter', sans-serif;
  font-size:.9rem;
  color:var(--muted);
}

/* Join + waiting heroes */
.join-hero, .waiting-hero{ text-align:center; padding:8px 12px 8px; }
.join-icon{ width:56px; height:56px; color:var(--text); margin:0 auto 12px; stroke-width:1.5; }
.join-title, .waiting-title{
  font-family:'Merriweather', Georgia, serif;
  font-size:1.3rem; font-weight:900;
  margin:0 0 6px;
  color:var(--text);
}
.join-subtitle, .waiting-subtitle{
  font-family:'Inter', sans-serif;
  font-size:.95rem;
  color:var(--muted);
  margin:0 0 18px;
}

.waiting-icon{
  width:56px; height:56px; color:var(--text); margin:0 auto 12px; stroke-width:1.5;
  animation: spin 3s linear infinite;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.text-link{ color:var(--accent); text-decoration:none; font-weight:600; }
.text-link:hover{ text-decoration:underline; }

/* Share / lobby */
.share-row{
  display:flex; gap:8px; margin:8px auto 0;
  width:100%; max-width:360px;
  justify-content:center; align-items:stretch;
}
.share-row .txt{ flex:1 1 auto; margin:0; }
.share-row .btn{ flex:0 0 auto; margin:0; padding: 12px 14px; font-size: 13px; }

.lobby-status{
  margin:10px auto 0;
  padding:8px;
  background:#fafafa;
  border:1px solid var(--rule);
  border-radius:6px;
  text-align:center;
  width:100%; max-width:360px;
  font-family:'Inter', sans-serif;
  font-weight:600;
  font-size:.85rem;
  color:var(--text);
}

.lobby-list{
  display:flex; gap:6px; flex-wrap:wrap;
  justify-content:center;
  margin-top:8px; margin-bottom:12px;
}
.lobby-pill{
  background:#fafafa;
  border:1px solid var(--rule);
  color:var(--text);
  border-radius:999px;
  padding:6px 12px;
  font-family:'Inter', sans-serif;
  font-weight:600;
  font-size:.85rem;
}
.pill-host{
  margin-left:6px; padding:2px 6px;
  border-radius:999px;
  background:var(--text); color:#fff;
  font-size:.65rem;
  text-transform:uppercase;
  letter-spacing:.06em;
  font-weight:700;
}

/* Question / image */
.question{
  text-align:center;
  margin:14px 0 6px;
  font-family:'Merriweather', Georgia, serif;
  font-size:1.25rem;
  font-weight:700;
  color:var(--text);
}

.image-frame{
  width:200px; height:200px; margin:4px auto 6px;
  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%;
}

/* Traffic light */
.traffic-light{
  width:60px; height:24px; margin:6px auto 10px;
  background:var(--text);
  border-radius:999px;
  display:flex; justify-content:space-around; align-items:center;
  padding:4px 6px;
}
.light{
  width:14px; height:14px; border-radius:50%;
  opacity:0.2;
  transition:opacity .2s ease, transform .2s ease, box-shadow .2s ease;
}
.light.red{ background:#ef4444; }
.light.yellow{ background:#facc15; }
.light.green{ background:#22c55e; }
.light.active{ opacity:1; }
@keyframes breatheRed{
  0%,100%{ transform:scale(1); box-shadow:0 0 0 0 rgba(239,68,68,0.6); }
  50%{ transform:scale(1.25); box-shadow:0 0 18px 4px rgba(239,68,68,0.9); }
}
.light.red.active{ animation:breatheRed 1s ease-in-out infinite; }
.light.yellow.active{ box-shadow:0 0 14px 3px rgba(250,204,21,0.7); }
.light.green.active{ box-shadow:0 0 14px 3px rgba(34,197,94,0.7); }

/* Scoreboard */
.scoreboard-grid{
  display:flex;
  flex-direction:column;
  gap:10px;
  max-width:520px;
  margin:10px auto 12px;
}
.player-card{
  background:transparent;
  border:0;
  padding:0;
  text-align:center;
}
.player-card.correct-answer{ animation:none !important; }
.player-card .wheel::before{ content:none !important; display:none !important; }

.player-card.correct-answer .player-name{
  text-shadow:
    0 0 8px rgba(34,197,94,.55),
    0 0 14px rgba(34,197,94,.35);
}

.player-name{
  font-family:'Inter', sans-serif;
  font-weight:700;
  margin:0 0 8px;
  font-size:.95rem;
  color:var(--text);
}
.player-name.eliminated{ color:var(--muted); text-decoration:line-through; }

/* Tiles row */
.wheel{
  display:flex;
  justify-content:center;
  gap:8px;
  flex-wrap:nowrap;
  width:100%;
}
.tile{
  width:34px;
  height:34px;
  background:var(--tile-blue);
  color:transparent;
  border-radius:4px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:900;
  font-size:1.6rem;
  font-family:'Merriweather', Georgia, serif;
  transform-style:preserve-3d;
  transition:transform .6s;
  position:relative;
  flex-shrink:0;
}
.tile.earned{ transform:rotateY(180deg); }
.tile::after{
  content:attr(data-letter);
  position:absolute;
  inset:0;
  background:#ffffff;
  color:#111;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:4px;
  border:1.5px solid var(--text);
  backface-visibility:hidden;
  transform:rotateY(180deg);
  font-size:1.5rem;
  font-family:'IM Fell English SC', Georgia, serif;
  font-weight:700;
}

/* Bottom CTA */
.bottom-guess-cta{ max-width:520px; margin:6px auto 10px; padding:0 8px; }

/* Input / suggestions (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:border-color .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;
  font-family:'Inter', sans-serif;
}
.suggestion-item{
  padding:14px 14px;
  min-height:48px;
  cursor:pointer;
  font-size:1rem;
  display:flex; align-items:center; gap:10px;
  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; }

/* Toast */
#feedbackMessage{
  position:fixed; left:50%; top:12px; transform:translateX(-50%);
  background:var(--text); color:#fff;
  padding:10px 14px; border-radius:6px;
  opacity:0; transition:opacity .25s; pointer-events:none;
  z-index:20;
  font-family:'Inter', sans-serif;
  font-size:.9rem;
}
#feedbackMessage.show{ opacity:1; }

/* Game Over */
#gameOverScreen{
  position:fixed; inset:0;
  background:rgba(15,15,15,0.85);
  display:none; flex-direction:column; align-items:center; justify-content:center;
  z-index:9999; padding:20px;
}
#gameOverScreen.show{ display:flex; }

#eliminatedMessage{
  position:fixed; bottom:20px; left:50%; transform:translateX(-50%);
  background:var(--text); color:#fff;
  padding:14px 22px; border-radius:8px;
  z-index:100; text-align:center; max-width:90%;
  width:auto; display:none;
}
#eliminatedMessage.show{ display:block; animation:slideUpFade 0.4s ease-out; }
@keyframes slideUpFade{
  from{ opacity:0; transform:translateX(-50%) translateY(20px); }
  to{ opacity:1; transform:translateX(-50%) translateY(0); }
}
.eliminated-title{
  font-family:'Merriweather', Georgia, serif;
  font-size:1.2rem; font-weight:900;
  color:#fff;
  margin:0 0 6px;
}
.eliminated-subtitle{
  font-family:'Inter', sans-serif;
  font-size:.95rem;
  color:#d1d5db;
  margin:0; line-height:1.4;
}

.winner-text{
  font-family:'Merriweather', Georgia, serif;
  font-size:clamp(60px, 12vw, 120px);
  font-weight:900;
  line-height:1;
  color:#fff;
  margin-bottom:24px;
  text-align:center;
}
.loser-text{
  font-family:'Merriweather', Georgia, serif;
  font-size:clamp(48px, 10vw, 96px);
  font-weight:900;
  line-height:1;
  color:#fff;
  opacity:.8;
  margin-bottom:24px;
  text-align:center;
}

.play-again-section{
  background:#fff;
  border:1px solid var(--rule);
  border-radius:8px;
  padding:20px 24px;
  text-align:center;
  max-width:400px;
}
.play-again-title{
  font-family:'Merriweather', Georgia, serif;
  font-weight:900;
  font-size:1.2rem;
  margin:0 0 12px;
  color:var(--text);
}
.play-again-status{
  font-family:'Inter', sans-serif;
  font-size:.9rem; color:var(--muted);
  margin-bottom:12px;
}
.ready-pills{ display:flex; gap:6px; flex-wrap:wrap; justify-content:center; margin-bottom:14px; }
.ready-pill{
  background:#fafafa;
  border:1px solid var(--rule);
  color:var(--text);
  border-radius:999px;
  padding:6px 10px;
  font-family:'Inter', sans-serif;
  font-weight:600;
  font-size:.8rem;
}
.ready-pill.ready{ background:var(--accent); color:#fff; border-color:var(--accent); }
#playAgainBtn{ margin:0; }

/* 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:1px solid var(--rule);
  border-radius:8px;
  padding:20px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow:0 12px 30px rgba(0,0,0,0.25);
  position:relative;
}
.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); }

/* Larger screens */
@media (min-width:768px){
  h1{ font-size:3rem; }
  .question{ font-size:1.5rem; }
  .image-frame{ width:230px; height:230px; }
  .tile{ width:38px; height:38px; font-size:1.8rem; }
  .tile::after{ font-size:1.7rem; }
}

/* Mobile */
@media (max-width:767px){
  html, body{ height:100%; overflow:hidden; position:fixed; width:100%; }
  #mainContainer{ padding:8px 14px max(8px, env(safe-area-inset-bottom)); height:100%; display:flex; flex-direction:column; overflow:hidden; }
  h1{ font-size:1.9rem; margin:4px 0 6px; flex-shrink:0; }

  #gameArea{ display:flex; flex-direction:column; height:100%; overflow:hidden; }

  .question{
    text-align:center; font-size:clamp(1.05rem, 4.2vw, 1.3rem);
    margin:6px 0 4px; flex-shrink:0;
  }
  .image-frame{ width:140px; height:140px; margin:4px auto; flex-shrink:0; }
  .traffic-light{ margin:4px auto 6px; width:54px; height:20px; flex-shrink:0; }
  .light{ width:12px; height:12px; }

  .scoreboard-grid{ gap:6px; margin:6px auto 4px; padding:0 4px; flex-shrink:0; }

  .player-name{
    font-size:.85rem; margin-bottom:4px;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .wheel{ gap:4px; }
  .tile{ width:28px; height:28px; font-size:1.15rem; }
  .tile::after{ font-size:1.1rem; }

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