@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;700&family=Inter:wght@400;600;800&display=swap');

:root{
  --ink:#0b1020;
  --paper:#ffffff;
  --shadow:rgba(0,0,0,.25);
  --accent:#22c55e;
  --accent2:#06b6d4;
  --hot:#f59e0b;
  --pink:#fb7185;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  color:var(--ink);
  background: linear-gradient(135deg, #7c3aed 0%, #2563eb 40%, #06b6d4 100%);
  display:flex;
  justify-content:center;
  padding:16px;
}

#bg-bubbles{
  position:fixed;
  inset:0;
  pointer-events:none;
  background: #206be8;
}

#app{ width:100%; max-width:980px; position:relative; }

.topbar{ text-align:center; color:#fff; padding:8px 6px 14px; }
.logo{
  font-family:'Fredoka',system-ui,sans-serif;
  font-size:2.1rem;
  letter-spacing:.5px;
  text-shadow:0 6px 18px rgba(0,0,0,.25);
}
.subtitle{ opacity:.9; font-size:.95rem; }

.screen{ display:none; }
.screen.active{ display:block; }

.card{
  background:var(--paper);
  border-radius:28px;
  padding:18px;
  box-shadow:0 18px 40px var(--shadow);
  border:2px solid rgba(255,255,255,.55);
}
.card-pop{ animation: pop .18s ease-out; }
@keyframes pop { from{ transform:scale(.98); opacity:.7;} to{ transform:scale(1); opacity:1;} }

h2{ margin:6px 0 14px; font-family:'Fredoka',system-ui,sans-serif; font-size:1.8rem; text-align:center; }
.section-title{ font-family:'Fredoka',system-ui,sans-serif; margin:16px 0 10px; font-size:1.3rem; }

.field span{ display:block; font-weight:700; margin-bottom:6px; }
.field input[type=text], input[type=file]{
  width:100%;
  padding:12px 12px;
  border-radius:16px;
  border:2px solid rgba(15,23,42,.15);
  background:#fff;
  font-size:1rem;
}
.field input[type=text]:focus{ outline:none; border-color:rgba(34,197,94,.7); box-shadow:0 0 0 4px rgba(34,197,94,.15); }

.avatar-row{ display:flex; gap:12px; align-items:flex-end; }
.avatar-preview{
  width:84px; height:84px; border-radius:999px;
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  border:3px solid rgba(124,58,237,.25);
  display:flex; align-items:center; justify-content:center;
  overflow:hidden;
  font-size:2rem;
}
.avatar-preview img{ width:100%; height:100%; object-fit:cover; }

.actions{ margin-top:14px; }

.btn{
  border:none;
  border-radius:999px;
  padding:14px 18px;
  font-weight:800;
  font-size:1.05rem;
  cursor:pointer;
  width:100%;
  box-shadow:0 10px 18px rgba(0,0,0,.12);
  transform: translateY(0);
  transition: transform .06s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover{ transform: translateY(-1px); filter: brightness(1.02); }
.btn:active{ transform: translateY(1px); box-shadow:0 6px 10px rgba(0,0,0,.12); }
.btn-primary{ background: linear-gradient(135deg, var(--accent), #16a34a); color:#fff; }
.btn-secondary{ background: linear-gradient(135deg, #111827, #334155); color:#fff; }
.btn-chip{
  width:auto;
  padding:10px 12px;
  font-size:.95rem;
  border-radius:14px;
  background: rgba(17,24,39,.06);
  box-shadow:none;
}
.active-chip{
  background: rgba(34,197,94,.18);
  border:2px solid rgba(34,197,94,.25);
}

.divider{ display:flex; align-items:center; gap:10px; margin:14px 0; }
.divider:before,.divider:after{ content:""; height:2px; flex:1; background:rgba(15,23,42,.12); border-radius:99px; }
.divider span{ font-weight:900; color:rgba(15,23,42,.55); }

.hint{ margin-top:10px; font-size:.95rem; color:rgba(15,23,42,.70); text-align:center; }

.code-wrap{ text-align:center; margin-top:8px; }
.code-label{ font-weight:900; letter-spacing:.12em; color:rgba(15,23,42,.55); font-size:.85rem; }
.room-code-display{
  margin:10px auto 8px;
  display:inline-block;
  padding:10px 16px;
  border-radius:999px;
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  border:3px dashed rgba(245,158,11,.65);
  font-family:'Fredoka',system-ui,sans-serif;
  font-size:2.2rem;
  letter-spacing:.25em;
}


/* Range slider (round selector) */
.range-row{ display:flex; align-items:center; gap:12px; width:100%; }
input[type="range"]{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:12px;
  border-radius:999px;
  background: rgba(15,23,42,.10);
  outline:none;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:28px; height:28px;
  border-radius:999px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  box-shadow:0 10px 18px rgba(0,0,0,.12);
  border:3px solid rgba(255,255,255,.85);
  cursor:pointer;
}
input[type="range"]::-moz-range-thumb{
  width:28px; height:28px;
  border-radius:999px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  box-shadow:0 10px 18px rgba(0,0,0,.12);
  border:3px solid rgba(255,255,255,.85);
  cursor:pointer;
}
.range-value{
  min-width:38px;
  text-align:center;
  font-family:'Fredoka',system-ui,sans-serif;
  font-weight:900;
  padding:8px 10px;
  border-radius:999px;
  background: rgba(255,255,255,.55);
  border:2px solid rgba(255,255,255,.75);
  color:rgba(15,23,42,.75);
}

/* Kick button shown to host in lobby */
.kick-btn{
  width:auto;
  padding:8px 10px;
  font-size:.85rem;
  border-radius:14px;
  border:none;
  cursor:pointer;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color:#fff;
  box-shadow:0 10px 18px rgba(0,0,0,.12);
}
.kick-btn:active{ transform: translateY(1px); box-shadow:0 6px 10px rgba(0,0,0,.12); }

.player-grid{
  list-style:none;
  padding:0;
  margin:8px 0 0;
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:center;
}
.player-grid li{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:18px;
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  border:2px solid rgba(124,58,237,.12);
  min-width:180px;
  justify-content:space-between;
}
.player-left{ display:flex; align-items:center; gap:10px; }
.player-right{ display:flex; align-items:center; gap:8px; }
.player-grid img{
  width:34px; height:34px; border-radius:999px; object-fit:cover;
  border:2px solid rgba(34,197,94,.25);
}
.ready-pill{
  font-family:'Fredoka',system-ui,sans-serif;
  font-weight:900;
  padding:6px 10px;
  border-radius:999px;
  font-size:.95rem;
  transition: transform .18s ease;
}
.ready-yes{ background: rgba(34,197,94,.18); border:2px solid rgba(34,197,94,.25); }
.ready-no{ background: rgba(245,158,11,.14); border:2px solid rgba(245,158,11,.25); }

.ready-pill.pop {
  animation: popReady .25s ease-out;
}
@keyframes popReady {
  0% { transform: scale(0.85); }
  80% { transform: scale(1.10); }
  100% { transform: scale(1); }
}

.host-pill{
  margin:12px auto 10px;
  width:max-content;
  max-width:100%;
  padding:10px 14px;
  border-radius:999px;
  background: rgba(255,255,255,.55);
  border:2px solid rgba(255,255,255,.75);
  color:rgba(15,23,42,.75);
  font-weight:800;
  text-align:center;
}

.ready-panel{ margin-top:14px; }
.ready-hint{ text-align:center; margin-top:8px; opacity:.75; font-weight:700; }
.ready-results-note{ text-align:center; margin:12px 0 4px; font-weight:800; opacity:.7; }

.ready-counter{
  text-align:center;
  font-weight:900;
  margin:10px 0 0;
  opacity:.75;
}

.round-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
  flex-wrap:wrap;

  /* Keep the timer/header visible while scrolling during rounds */
  position: sticky;
  top: 0;
  z-index: 2000;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 12px;
  border-radius: 18px;
  box-shadow: 0 10px 22px rgba(0,0,0,.10);
}
.badge{
  font-family:'Fredoka',system-ui,sans-serif;
  background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,247,237,.95));
  border:2px solid rgba(251,113,133,.25);
  padding:8px 12px;
  border-radius:999px;
  font-weight:800;
}
.timer{
  font-family:'Fredoka',system-ui,sans-serif;
  font-size:1.35rem;
  color:var(--hot);
  font-weight:900;
  text-shadow:0 10px 24px rgba(245,158,11,.20);
  animation: pulse 1s infinite;
}
@keyframes pulse{ 0%,100%{ transform:scale(1);} 50%{ transform:scale(1.05);} }

.prompt{
  background: linear-gradient(135deg, #ffffff, #fff7ed);
  border:3px solid rgba(6,182,212,.22);
  border-radius:24px;
  padding:16px 14px;
  font-family:'Fredoka',system-ui,sans-serif;
  font-size:1.7rem;
  line-height:1.2;
  text-align:center;
}
.prompt.small{ font-size:1.2rem; padding:12px 12px; }

.host-only{
  margin-top:14px;
  padding:14px;
  border-radius:22px;
  background: rgba(124,58,237,.08);
  border:2px dashed rgba(124,58,237,.25);
}
.submissions{ display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.sub-label{ font-weight:900; opacity:.7; }
.sub-count{
  font-family:'Fredoka',system-ui,sans-serif;
  font-size:1.4rem;
  padding:6px 12px;
  border-radius:999px;
  background: rgba(255,255,255,.8);
  border:2px solid rgba(34,197,94,.22);
}

#edit-canvas{
  width:100%;
  max-width:560px;
  height:auto;
  border-radius:22px;
  border:3px solid rgba(15,23,42,.10);
  background:#0b1020;
  margin-top:10px;
  touch-action:none;
  display:block;
  margin-left:auto;
  margin-right:auto;
}

.tool-row{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top:10px; }

.colors-row{
  display:flex;
  gap:10px;
  justify-content:center;
  flex-wrap:wrap;
  margin:10px 0 0;
}
.color-swatch{
  width:34px;
  height:34px;
  border-radius:999px;
  border:3px solid rgba(15,23,42,.10);
  box-shadow:0 10px 18px rgba(0,0,0,.08);
  cursor:pointer;
}
.color-swatch.active{
  border-color: rgba(34,197,94,.75);
  box-shadow:0 0 0 5px rgba(34,197,94,.18), 0 10px 18px rgba(0,0,0,.10);
}

.slider-row{ display:flex; align-items:center; gap:10px; justify-content:center; margin-top:10px; }
.slider-label{ font-weight:900; opacity:.7; }
#brush-size{ width:min(420px, 70vw); }
.slider-val{
  font-family:'Fredoka',system-ui,sans-serif;
  font-weight:900;
  padding:6px 10px;
  border-radius:999px;
  background: rgba(255,255,255,.75);
  border:2px solid rgba(6,182,212,.20);
}

.edit-controls{ display:flex; flex-wrap:wrap; gap:10px; margin:12px 0; justify-content:center; }

.voting-grid{ margin-top:12px; display:flex; flex-wrap:wrap; gap:14px; justify-content:center; }
.voting-card{
  width:200px;
  background: linear-gradient(135deg, #ffffff, #fff7ed);
  border-radius:22px;
  overflow:hidden;
  border:3px solid rgba(15,23,42,.08);
  box-shadow:0 14px 26px rgba(0,0,0,.10);
  cursor:pointer;
  transition: transform .08s ease, box-shadow .12s ease;
}
.voting-card:hover{ transform: translateY(-2px) rotate(-.2deg); box-shadow:0 18px 32px rgba(0,0,0,.14); }
.voting-card.selected{ border-color: rgba(34,197,94,.75); box-shadow:0 0 0 5px rgba(34,197,94,.15), 0 18px 32px rgba(0,0,0,.14); }
.voting-card img{ width:100%; display:block; aspect-ratio:4/3; object-fit:cover; }
.voter-name{ padding:10px 10px; font-weight:900; text-align:center; opacity:.75; }

.winner{ margin:10px 0 6px; font-family:'Fredoka',system-ui,sans-serif; font-size:1.45rem; text-align:center; }
.scoreboard{ list-style:none; padding:0; margin:6px 0 0; }
.scoreboard li{
  display:flex;
  justify-content:space-between;
  padding:10px 12px;
  border-radius:18px;
  background: rgba(255,255,255,.65);
  border:2px dashed rgba(15,23,42,.10);
  margin-bottom:8px;
  font-weight:800;
}

.gallery-grid{ margin-top:14px; display:flex; flex-wrap:wrap; gap:14px; justify-content:center; }
.gallery-card{
  width:260px;
  border-radius:24px;
  overflow:hidden;
  background: linear-gradient(135deg, #ffffff, #fff7ed);
  border:3px solid rgba(6,182,212,.18);
  box-shadow:0 14px 26px rgba(0,0,0,.10);
}
.gallery-prompt{
  padding:12px 12px 10px;
  font-family:'Fredoka',system-ui,sans-serif;
  font-size:1.05rem;
  line-height:1.15;
  color:rgba(11,16,32,.95);
  border-bottom:2px dashed rgba(15,23,42,.10);
}
.gallery-card img{ width:100%; display:block; aspect-ratio:4/3; object-fit:cover; }
.gallery-caption{ padding:10px 12px 12px; font-weight:900; color:rgba(15,23,42,.70); }

.toast{
  position:fixed;
  left:50%;
  bottom:16px;
  transform:translateX(-50%);
  background: rgba(239,68,68,.95);
  color:#fff;
  padding:10px 14px;
  border-radius:999px;
  font-weight:900;
  opacity:0;
  pointer-events:none;
  transition: opacity .15s ease, transform .15s ease;
  box-shadow:0 14px 26px rgba(0,0,0,.22);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-4px); }

@media (min-width: 860px){
  body{ padding:24px; }
  .card{ padding:22px 26px; }
  .logo{ font-size:2.4rem; }
  .prompt{ font-size:2.05rem; padding:18px 16px; }
  .timer{ font-size:1.5rem; }
  .voting-card{ width:240px; }
  .gallery-card{ width:300px; }
}

/* =========================
   v2 ADAPTED ADDITIONS
   Restores GOLD vibe for new v2 screens (Prepare/Hand/Bonus)
   ========================= */

.hand-grid{
  margin-top:14px;
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  justify-content:center;
}

.card-thumb{
  width:220px;
  background: linear-gradient(135deg, #ffffff, #fff7ed);
  border-radius:22px;
  overflow:hidden;
  border:3px solid rgba(15,23,42,.08);
  box-shadow:0 14px 26px rgba(0,0,0,.10);
  cursor:pointer;
  transition: transform .08s ease, box-shadow .12s ease, filter .12s ease;
}
.card-thumb:hover{
  transform: translateY(-2px) rotate(-.2deg);
  box-shadow:0 18px 32px rgba(0,0,0,.14);
}
.card-thumb img{
  width:100%;
  display:block;
  aspect-ratio:4/3;
  object-fit:cover;
}
.card-thumb.selected{
  border-color: rgba(34,197,94,.75);
  box-shadow:0 0 0 5px rgba(34,197,94,.15), 0 18px 32px rgba(0,0,0,.14);
}
.card-thumb.used{
  opacity:.45;
  filter: grayscale(0.8);
  cursor:not-allowed;
}
.card-thumb.used:hover{
  transform:none;
  box-shadow:0 14px 26px rgba(0,0,0,.10);
}

/* Host rounds selector */
.host-only .rounds-row{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:12px;
  margin:12px 0 8px;
}
.rounds-label{
  font-weight:900;
  opacity:.75;
}
#roundSelect{
  padding:12px 14px;
  border-radius:14px;
  border:2px solid rgba(15,23,42,.15);
  background:#fff;
  font-weight:900;
}

/* Prepare progress pill */
#prepareProgress{
  font-family:'Fredoka',system-ui,sans-serif;
  font-weight:900;
  padding:8px 12px;
  border-radius:999px;
  background: rgba(255,255,255,.75);
  border:2px solid rgba(6,182,212,.20);
}


.check{display:flex;gap:10px;align-items:center;justify-content:center;margin-top:10px;font-weight:800;opacity:.9}
.check input{width:18px;height:18px}


/* ===== Header Logo Fix ===== */
.app-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}

.logo-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
}

.app-logo {
  max-width: 480px;
  width: 90%;
  height: auto;
}


/* Help / How-to modal */
.help-btn{
  position: fixed;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  font-weight: 800;
  font-size: 20px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3500;
  padding: 18px;
}

.modal.hidden{ display:none; }

.modal-content{
  width: min(520px, 100%);
  background: rgba(255,255,255,.96);
  border-radius: 16px;
  padding: 22px 18px;
  position: relative;
  box-shadow: 0 16px 60px rgba(0,0,0,.35);
}

/* Meme library modal */
.modal-content.meme-modal{
  width: min(900px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
}

.meme-search-row{
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  flex-wrap: wrap;
}

.meme-search{
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.95);
  font-size: 14px;
}

.meme-grid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 680px){
  .meme-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.meme-thumb{
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,.05);
  border: 1px solid rgba(0,0,0,.08);
  cursor: pointer;
  position: relative;
}

.meme-thumb img{
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}

.meme-thumb:hover{
  transform: translateY(-1px);
}

.meme-tag{
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: white;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.close-btn{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  background: rgba(0,0,0,.08);
}

.howto-list{ padding-left: 18px; }
.howto-list li{ margin: 8px 0; }

button.submitted{
  opacity: .75;
  cursor: not-allowed;
}

#cardGrid.locked .card-thumb{
  opacity: .55;
  filter: grayscale(1);
}

/* Shared photo source tile */
.photo-source-tile {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  text-align: center;
}
.photo-source-tile:hover {
  background: rgba(0,0,0,0.05);
}

/* Prepare-layered modals */
.prepare-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
}
.prepare-modal {
  position: fixed;
  inset: 10%;
  background: white;
  border-radius: 16px;
  z-index: 51;
  overflow: auto;
}

/* Photo source grid (upload / meme library) */
.photo-source-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0 8px;
}
@media (max-width: 520px){
  .photo-source-grid{ grid-template-columns: 1fr; }
}
.hidden-input{
  display:none;
}
.photo-source-tile{
  display:flex;
  flex-direction:column;
  gap:6px;
  align-items:center;
  justify-content:center;
  min-height: 110px;
  background: rgba(255,255,255,0.65);
}
.photo-source-tile .tile-icon{ font-size: 28px; line-height: 1; }
.photo-source-tile .tile-title{ font-weight: 800; }
.photo-source-tile .tile-sub{ font-size: .9rem; opacity: .75; }

/* Lobby settings */
.settings-box{
  margin: 12px 0 10px;
  padding: 12px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.55);
}
.settings-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.settings-label{
  font-weight: 800;
}
.radio-group{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.radio-pill{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.6);
}
.radio-pill input{ accent-color: auto; }
.radio-pill.disabled{
  opacity:.55;
}


.settings-box.locked{ opacity: .65; pointer-events: none; }
