/* ============================================================
   Krabbelster — stijl
   Gebaseerd op de aangeleverde huisstijl: crème achtergrond, inkt-
   zwarte lijnen, harde "sticker" schaduwen, ronde koppen (Fredoka),
   Nunito voor tekst, Material Symbols Rounded voor iconen.
   ============================================================ */

:root{
  color-scheme: light;
  --heading-font: 'Fredoka', sans-serif;
  --body-font: 'Nunito', sans-serif;

  --cream:      #FDF7E4;
  --cream-deep: #F5EAC7;
  --ink:        #2B2115;
  --ink-soft:   #6B5F4E;

  --coral:      #FF7134;
  --coral-deep: #E85920;
  --yellow:     #FFD200;
  --green:      #31AD54;
  --blue:       #346BC8;
  --sage:       #B6CBA9;
  --pink:       #E85B8A;
  --purple:     #8B6BC7;
  --teal:       #2E9E8F;
  --red:        #D9503F;
  --sky:        #3FA9E8;

  --coral-tint: #FFE3D3;
  --yellow-tint:#FFF2BE;
  --green-tint: #DCF2E2;
  --blue-tint:  #DCE7FA;
  --pink-tint:  #FCE0E9;
  --purple-tint:#EAE2F8;
  --teal-tint:  #DBF0EC;

  --radius-lg: 26px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--body-font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a{ color: inherit; }

/* subtiele stippen-textuur achter alles, zoals het voorbeeld */
.bg-dots{
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(43,33,21,.06) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  pointer-events: none;
}

h1,h2,h3{ font-family: var(--heading-font); font-weight: 600; margin: 0; color: var(--ink); }
p{ line-height: 1.6; color: var(--ink-soft); margin: 0; }

button{ font-family: inherit; cursor: pointer; }
input{ font-family: inherit; }

.material-symbols-rounded{
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}

/* ---------- Buttons ---------- */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: 1rem;
  border: 2.3px solid var(--ink);
  border-radius: 999px;
  padding: 14px 26px;
  background: #FFFDF6;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.btn:hover{ transform: translate(-2px,-3px); box-shadow: 6px 7px 0 var(--ink); }
.btn:active{ transform: translate(0,0); box-shadow: var(--shadow-sm); }
.btn:disabled{ opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }

.btn-primary{ background: var(--coral); color: #FFFDF6; }
.btn-yellow{ background: var(--yellow); color: var(--ink); }
.btn-green{ background: var(--green); color: #FFFDF6; }
.btn-block{ width: 100%; }
.btn-lg{ padding: 18px 32px; font-size: 1.15rem; }
.btn-sm{ padding: 9px 16px; font-size: .88rem; box-shadow: var(--shadow-sm); }
.btn-sm:hover{ box-shadow: 4px 4px 0 var(--ink); }
.btn-ghost{ background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover{ background: var(--cream-deep); box-shadow: none; transform: none; }

/* ---------- Cards ---------- */
.card{
  background: #FFFDF6;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(24px, 4vw, 40px);
}

/* ---------- Layout shells ---------- */
.screen{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.screen-center{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.container-narrow{ width: 100%; max-width: 460px; }
.container-wide{ width: 100%; max-width: 1100px; }

.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 40px);
}
.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: 1.3rem;
}
.brand .brand-icon{
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--coral);
  color: #FFFDF6;
  display: flex; align-items: center; justify-content: center;
  border: 2.3px solid var(--ink);
  box-shadow: var(--shadow-sm);
}
.brand .tag{ color: var(--coral); font-size: .78rem; font-weight: 800; }

/* ---------- Start screen ---------- */
.start-title{
  text-align: center;
  font-size: clamp(2rem, 6vw, 2.9rem);
  line-height: 1.1;
}
.start-title .accent{ color: var(--coral); }
.start-sub{
  text-align: center;
  margin: 14px 0 32px;
  font-size: 1.05rem;
}
.role-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 640px){
  .role-grid{ grid-template-columns: 1fr 1fr; }
}
.role-card{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 28px 20px;
  cursor: pointer;
}
.role-card .role-icon{
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid var(--ink);
  box-shadow: var(--shadow-sm);
  color: #FFFDF6;
}
.role-card.host .role-icon{ background: var(--coral); }
.role-card.player .role-icon{ background: var(--teal); }
.role-card .role-icon .material-symbols-rounded{ font-size: 30px; }
.role-card h3{ font-size: 1.2rem; }
.role-card p{ font-size: .92rem; }

/* ---------- Form fields ---------- */
.field{ display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field label{
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: .92rem;
  color: var(--ink-soft);
}
.field input, .field select{
  font-size: 1.1rem;
  padding: 13px 18px;
  border: 2.3px solid var(--ink);
  border-radius: 999px;
  background: #FFFDF6;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus{ border-color: var(--coral); box-shadow: 0 0 0 3px var(--coral-tint); }
.field input.code-input{
  text-align: center;
  letter-spacing: .35em;
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: 1.6rem;
  text-transform: uppercase;
}

.emoji-grid{
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.emoji-pick{
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border: 2.3px solid transparent;
  border-radius: 14px;
  background: var(--cream-deep);
  transition: transform .12s ease, border-color .12s ease, background-color .12s ease;
}
.emoji-pick:hover{ transform: scale(1.08); }
.emoji-pick.is-selected{
  border-color: var(--ink);
  background: var(--yellow-tint);
  box-shadow: var(--shadow-sm);
}

.error-msg{
  color: var(--red);
  font-weight: 700;
  font-size: .9rem;
  margin-top: 10px;
  text-align: center;
}

/* ---------- Room code hero (host lobby) ---------- */
.room-code-hero{
  text-align: center;
  padding: 40px 20px;
}
.room-code-label{
  font-family: var(--heading-font);
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 1.1rem;
  margin-bottom: 10px;
}
.room-code{
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: clamp(3.4rem, 12vw, 6.2rem);
  letter-spacing: .1em;
  color: var(--coral);
  line-height: 1;
}
.room-join-hint{
  margin-top: 14px;
  font-size: 1.05rem;
}
.room-join-hint strong{ color: var(--ink); }

/* ---------- Player pills / lobby grid ---------- */
.player-grid{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 8px 0;
}
.player-pill{
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cream-deep);
  border: 2.3px solid var(--ink);
  border-radius: 999px;
  padding: 9px 16px 9px 10px;
  font-family: var(--heading-font);
  font-weight: 500;
  font-size: 1rem;
  animation: popIn .3s cubic-bezier(.34,1.56,.64,1) both;
}
.player-pill .emoji{ font-size: 1.3rem; }
@keyframes popIn{ from{ transform: scale(.5); opacity: 0; } to{ transform: scale(1); opacity: 1; } }

.player-count-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-tint);
  color: var(--green);
  border: 2px solid var(--green);
  border-radius: 999px;
  padding: 6px 16px;
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: .95rem;
  margin: 0 auto 22px;
}

/* ---------- Countdown ---------- */
.countdown-screen{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}
.countdown-number{
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: clamp(6rem, 30vw, 12rem);
  color: var(--coral);
  line-height: 1;
  animation: countPulse .55s cubic-bezier(.34,1.56,.64,1);
}
.countdown-number.is-go{ color: var(--green); font-size: clamp(4.5rem, 22vw, 9rem); }
@keyframes countPulse{
  0%{ transform: scale(.4); opacity: 0; }
  60%{ transform: scale(1.15); opacity: 1; }
  100%{ transform: scale(1); }
}
.countdown-label{ font-family: var(--heading-font); font-weight: 600; font-size: 1.3rem; color: var(--ink-soft); }

/* ---------- Prompt card (host) ---------- */
.prompt-card{
  text-align: center;
  padding: clamp(30px, 6vw, 56px);
  background: linear-gradient(160deg, var(--yellow-tint) 0%, #fff 100%);
}
.prompt-eyebrow{
  font-family: var(--heading-font);
  font-weight: 600;
  color: var(--coral);
  font-size: 1rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.prompt-text{
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 1.25;
}

/* ---------- Timer bar ---------- */
.timer-wrap{
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}
.timer-bar-track{
  width: min(520px, 90vw);
  height: 18px;
  border-radius: 999px;
  background: var(--cream-deep);
  border: 2px solid var(--ink);
  overflow: hidden;
}
.timer-bar-fill{
  height: 100%;
  background: var(--coral);
  border-radius: 999px 0 0 999px;
  transition: width 1s linear, background-color .3s ease;
}
.timer-bar-fill.is-low{ background: var(--red); }
.timer-clock{
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: 1.3rem;
  min-width: 52px;
  text-align: right;
}

/* ---------- Drawing canvas ---------- */
.draw-screen{ flex: 1; display: flex; flex-direction: column; }
.draw-header{
  padding: 14px clamp(14px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.draw-prompt-pill{
  font-family: var(--heading-font);
  font-weight: 600;
  background: var(--coral-tint);
  color: var(--coral-deep);
  border: 2px solid var(--coral);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: .98rem;
}
.canvas-wrap{
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(10px, 3vw, 24px) 12px;
}
.canvas-frame{
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  touch-action: none;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 4/3;
  display: block;
  cursor: crosshair;
}
.tool-dock{
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 14px 22px;
}
.color-swatch{
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2.3px solid var(--ink);
  transition: transform .12s ease;
  flex: 0 0 auto;
}
.color-swatch.is-selected{ transform: scale(1.18); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.tool-sep{ width: 2px; height: 28px; background: var(--cream-deep); border-radius: 2px; }
.tool-btn{
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #FFFDF6;
  border: 2.3px solid var(--ink);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.tool-btn:hover{ transform: translateY(-2px); }
.tool-btn:active{ transform: translateY(0); }
.tool-btn.is-selected{ background: var(--ink); color: var(--cream); }
.brush-size-input{
  width: 100px;
  accent-color: var(--coral);
}

.submit-dock{ padding: 0 16px 24px; text-align: center; }

.waiting-note{
  text-align: center;
  font-family: var(--heading-font);
  font-weight: 500;
  color: var(--ink-soft);
  padding: 30px;
}

/* ---------- Gallery / voting (host) ---------- */
.gallery-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  padding: 10px 0;
}
.gallery-card{
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1) both;
}
.gallery-card img{ display: block; width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; }
.gallery-card-meta{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 2px solid var(--cream-deep);
}
.gallery-card-name{ font-family: var(--heading-font); font-weight: 600; }
.gallery-stars{ display: flex; align-items: center; gap: 3px; color: var(--yellow); }
.gallery-stars .material-symbols-rounded{ font-size: 20px; }

/* ---------- Player voting screen ---------- */
.vote-card{
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 18px;
}
.vote-card img{ display: block; width: 100%; aspect-ratio: 4/3; object-fit: contain; background: #fff; }
.vote-stars{
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 16px;
}
.star-btn{
  background: none; border: none; padding: 4px;
  color: var(--cream-deep);
  transition: transform .12s ease, color .12s ease;
}
.star-btn .material-symbols-rounded{ font-size: 34px; }
.star-btn.is-filled{ color: var(--yellow); }
.star-btn:hover{ transform: scale(1.15); }
.vote-own-note{
  text-align: center;
  font-family: var(--heading-font);
  color: var(--ink-soft);
  padding: 18px;
}

/* ---------- Leaderboard ---------- */
.leader-list{ display: flex; flex-direction: column; gap: 12px; }
.leader-row{
  display: flex;
  align-items: center;
  gap: 14px;
  background: #FFFDF6;
  border: 2.3px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-sm);
}
.leader-rank{
  font-family: var(--heading-font);
  font-weight: 600;
  font-size: 1.2rem;
  width: 34px;
  text-align: center;
  color: var(--ink-soft);
}
.leader-row.is-first .leader-rank{ color: var(--yellow); font-size: 1.5rem; }
.leader-row.is-first{ background: var(--yellow-tint); border-color: var(--yellow); }
.leader-emoji{ font-size: 1.5rem; }
.leader-name{ font-family: var(--heading-font); font-weight: 600; flex: 1; }
.leader-score{
  font-family: var(--heading-font);
  font-weight: 700;
  color: var(--coral);
  display: flex; align-items: center; gap: 4px;
}

/* ---------- Winner banner ---------- */
.winner-banner{
  text-align: center;
  padding: 30px;
  background: linear-gradient(160deg, var(--green-tint), #fff);
  border-radius: var(--radius-lg);
  border: 2.5px solid var(--green);
  margin-bottom: 24px;
}
.winner-banner .material-symbols-rounded{ font-size: 42px; color: var(--yellow); }
.winner-banner h2{ font-size: 1.6rem; margin: 8px 0 4px; }

/* ---------- Utility ---------- */
.stack-gap-sm > * + *{ margin-top: 10px; }
.text-center{ text-align: center; }
.muted{ color: var(--ink-soft); }
.qr-box{
  display: inline-flex;
  padding: 10px;
  background: #fff;
  border: 2.3px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  margin-top: 18px;
}
.round-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--heading-font);
  font-weight: 600;
  background: var(--purple-tint);
  color: var(--purple);
  border: 2px solid var(--purple);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: .92rem;
}
.center-col{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.music-toggle{
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
}

@media (max-width: 560px){
  .topbar{ padding: 14px 16px; }
  .card{ padding: 22px; }
}
