:root {
  --ink: #172033;
  --muted: #697087;
  --paper: #fffdf8;
  --paper-2: #f8f5ee;
  --violet: #7157ff;
  --violet-dark: #5136df;
  --coral: #ff6f61;
  --yellow: #ffd75e;
  --mint: #70dfbd;
  --blue: #5cb8ff;
  --pink: #ff91c8;
  --green: #41c986;
  --red: #f05252;
  --shadow: 0 20px 60px rgba(28, 33, 57, .14);
  --rough-shadow: 7px 8px 0 rgba(23, 32, 51, .13);
  --radius: 26px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --hand: "Segoe Print", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #efeaff; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 215, 94, .35), transparent 28%),
    radial-gradient(circle at 90% 14%, rgba(112, 223, 189, .3), transparent 25%),
    radial-gradient(circle at 80% 85%, rgba(255, 145, 200, .26), transparent 29%),
    linear-gradient(135deg, #f5f0ff 0%, #fffaf0 47%, #f3fbff 100%);
}
button, input, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
input, select { color: var(--ink); }
::selection { background: var(--yellow); color: var(--ink); }

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.doodle-field { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.doodle {
  position: absolute;
  font-family: var(--hand);
  font-size: clamp(28px, 4vw, 70px);
  font-weight: 700;
  opacity: .14;
  animation: floatDoodle 8s ease-in-out infinite alternate;
}
.doodle-a { left: 4%; top: 18%; color: var(--coral); transform: rotate(-14deg); }
.doodle-b { left: 42%; top: 7%; color: var(--violet); animation-delay: -3s; }
.doodle-c { right: 7%; top: 28%; color: var(--mint); animation-delay: -5s; }
.doodle-d { left: 7%; bottom: 12%; color: var(--blue); animation-delay: -2s; }
.doodle-e { right: 35%; bottom: 6%; color: var(--pink); animation-delay: -6s; }
.doodle-f { right: 4%; bottom: 20%; color: var(--yellow); animation-delay: -1s; }
.scribble { position: absolute; fill: none; stroke-width: 6; stroke-linecap: round; opacity: .13; }
.scribble-1 { width: 280px; left: 28%; bottom: 7%; stroke: var(--violet); animation: drift 12s ease-in-out infinite alternate; }
.scribble-2 { width: 220px; right: 11%; top: 12%; stroke: var(--coral); animation: drift 10s ease-in-out infinite alternate-reverse; }

@keyframes floatDoodle {
  to { transform: translate3d(8px, -16px, 0) rotate(7deg) scale(1.04); }
}
@keyframes drift { to { transform: translate(20px, -10px) rotate(4deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(-1deg); } 50% { transform: rotate(1.2deg); } }
@keyframes pulseDot { 50% { transform: scale(1.8); opacity: .35; } }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.94) rotate(-1deg); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px) rotate(-1deg); } 75% { transform: translateX(5px) rotate(1deg); } }
@keyframes reactionFly {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(.3) rotate(-20deg); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.25) rotate(8deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), -240px) scale(.85) rotate(var(--rot)); }
}
@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(-20vh) rotate(0deg); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translateY(110vh) rotate(720deg); }
}

.top-shell {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1500px;
  margin: 0 auto;
  min-height: 76px;
  padding: 14px 28px;
}
.mini-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -.8px;
}
.mini-brand > span:last-child span { color: var(--violet); margin-left: 2px; }
.mini-brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  border-radius: 13px 16px 12px 17px;
  background: var(--yellow);
  font-family: var(--hand);
  font-weight: 700;
  font-size: 24px;
  box-shadow: 3px 4px 0 var(--ink);
  transform: rotate(-4deg);
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(23, 32, 51, .16);
  border-radius: 14px;
  background: rgba(255,255,255,.68);
  backdrop-filter: blur(14px);
  box-shadow: 0 5px 15px rgba(40,44,70,.08);
}
.icon-btn:hover { transform: translateY(-2px) rotate(-2deg); }
.install-hidden { display: none; }
.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 92px;
  height: 42px;
  padding: 0 13px;
  border: 2px solid rgba(23, 32, 51, .12);
  border-radius: 999px;
  background: rgba(255,255,255,.66);
  backdrop-filter: blur(14px);
  font-size: 12px;
}
.connection-pill span { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(240,82,82,.12); }
.connection-pill.is-online span { background: var(--green); box-shadow: 0 0 0 4px rgba(65,201,134,.14); animation: pulseDot 1.8s infinite; }
.connection-pill.is-connecting span { background: var(--yellow); box-shadow: 0 0 0 4px rgba(255,215,94,.18); }

#app { position: relative; z-index: 2; }
.screen {
  display: none;
  width: min(1500px, calc(100% - 44px));
  margin: 0 auto;
  min-height: calc(100dvh - 96px);
  padding: 24px 0 42px;
}
.screen.is-active { display: block; animation: popIn .45s cubic-bezier(.2,.8,.2,1) both; }

.home-screen.is-active {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .78fr);
  gap: clamp(38px, 6vw, 105px);
  align-items: center;
  max-width: 1320px;
  padding-bottom: 70px;
}
.hero-copy { position: relative; padding: 25px 0 40px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--violet-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.8px;
}
.eyebrow > span { color: var(--coral); font-size: 9px; }
.hero-copy h1 {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 22px 0 20px;
  font-family: var(--hand);
  font-size: clamp(76px, 10vw, 150px);
  line-height: .68;
  letter-spacing: -9px;
}
.word-firka {
  position: relative;
  z-index: 2;
  color: var(--ink);
  text-shadow: 5px 7px 0 rgba(23,32,51,.11);
  transform: rotate(-2deg);
}
.word-party {
  position: relative;
  margin-left: clamp(80px, 10vw, 145px);
  color: var(--violet);
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 6px 7px 0 var(--yellow), 11px 12px 0 var(--ink);
  transform: rotate(1.5deg);
}
.hero-copy > p {
  max-width: 680px;
  margin: 32px 0 23px;
  color: #535b70;
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.65;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-chips span {
  padding: 9px 13px;
  border: 2px dashed rgba(23,32,51,.22);
  border-radius: 999px;
  background: rgba(255,255,255,.48);
  font-size: 12px;
  font-weight: 800;
}
.hero-sketch {
  position: absolute;
  right: -4%;
  bottom: -4%;
  width: 300px;
  height: 165px;
  pointer-events: none;
}
.hero-sketch svg { position: absolute; inset: 15px 10px auto auto; width: 230px; fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; opacity: .36; }
.sketch-card {
  position: absolute;
  display: grid;
  place-items: center;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 6px 0 var(--ink);
  font-family: var(--hand);
}
.sketch-card-one { right: 22px; bottom: 2px; width: 85px; height: 92px; border-radius: 18px 14px 20px 15px; transform: rotate(8deg); background: var(--yellow); font-size: 50px; }
.sketch-card-two { left: 8px; bottom: 0; width: 140px; height: 118px; border-radius: 18px 22px 16px 24px; transform: rotate(-6deg); }
.sketch-card-two span { font-size: 52px; }
.sketch-card-two b { font-size: 14px; }

.rough-card {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 28px 24px 31px 23px;
  background: rgba(255,253,248,.92);
  box-shadow: var(--rough-shadow), var(--shadow);
}
.entry-card { padding: 17px 26px 28px; backdrop-filter: blur(14px); transform: rotate(.25deg); }
.entry-card::before, .entry-card::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 16px;
  background: rgba(255, 215, 94, .72);
  border: 1px solid rgba(23,32,51,.15);
  top: -10px;
}
.entry-card::before { left: 46px; transform: rotate(-4deg); }
.entry-card::after { right: 42px; transform: rotate(5deg); background: rgba(112,223,189,.6); }
.tabs { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 25px; border-bottom: 2px solid rgba(23,32,51,.09); }
.tab {
  position: relative;
  z-index: 2;
  height: 52px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.tab.is-active { color: var(--ink); }
.tab-underline { position: absolute; left: 0; bottom: -2px; width: 50%; height: 4px; border-radius: 99px; background: var(--violet); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.tabs.join-active .tab-underline { transform: translateX(100%); background: var(--coral); }
.entry-pane { display: none; }
.entry-pane.is-active { display: block; animation: slideUp .28s ease both; }
.field-label { display: block; margin: 18px 0 8px; font-size: 12px; font-weight: 900; letter-spacing: .4px; }
.row-label { display: flex; justify-content: space-between; align-items: center; }
.row-label small { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.input-wrap, .code-input-wrap {
  display: flex;
  align-items: center;
  border: 2px solid rgba(23,32,51,.16);
  border-radius: 15px 18px 14px 17px;
  background: #fff;
  box-shadow: inset 0 2px 0 rgba(23,32,51,.03);
  transition: .2s ease;
}
.input-wrap:focus-within, .code-input-wrap:focus-within { border-color: var(--violet); box-shadow: 0 0 0 5px rgba(113,87,255,.11); transform: rotate(-.3deg); }
.input-wrap > span { padding-left: 14px; font-size: 20px; }
.input-wrap input, .code-input-wrap input {
  width: 100%;
  height: 51px;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 15px;
  font-weight: 700;
}
.code-input-wrap input { text-align: center; font-family: var(--hand); font-size: 26px; letter-spacing: 9px; text-transform: uppercase; }
.code-input-wrap > span { flex: 0 0 auto; margin-right: 12px; padding: 5px 8px; border-radius: 8px; background: var(--paper-2); color: var(--muted); font-size: 10px; font-weight: 800; }
.mode-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.mode-card {
  min-width: 0;
  padding: 13px 8px 12px;
  border: 2px solid rgba(23,32,51,.13);
  border-radius: 16px 13px 17px 14px;
  background: #fff;
  text-align: center;
  transition: .18s ease;
}
.mode-card:hover { transform: translateY(-2px) rotate(-.5deg); }
.mode-card.is-selected { border-color: var(--violet); background: rgba(113,87,255,.08); box-shadow: 3px 4px 0 rgba(113,87,255,.24); }
.mode-card > span { display: block; font-size: 25px; }
.mode-card b { display: block; margin: 4px 0 2px; font-size: 12px; }
.mode-card small { display: block; min-height: 28px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.inline-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.inline-settings label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
select {
  height: 44px;
  border: 2px solid rgba(23,32,51,.13);
  border-radius: 13px;
  background: #fff;
  padding: 0 11px;
  outline: none;
  font-weight: 800;
}
select:focus { border-color: var(--violet); }
.primary-btn {
  width: 100%;
  min-height: 56px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 3px solid var(--ink);
  border-radius: 17px 14px 19px 15px;
  color: #fff;
  font-weight: 900;
  box-shadow: 5px 6px 0 var(--ink);
  transition: .14s ease;
}
.primary-btn:hover:not(:disabled) { transform: translate(-1px, -2px) rotate(-.3deg); box-shadow: 7px 9px 0 var(--ink); }
.primary-btn:active:not(:disabled) { transform: translate(4px, 5px); box-shadow: 1px 1px 0 var(--ink); }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.splash-btn { background: linear-gradient(135deg, var(--violet), #8d6fff); }
.coral-btn { background: linear-gradient(135deg, var(--coral), #ff8b65); }
.primary-btn b { font-size: 22px; }
.join-note { display: flex; gap: 10px; margin-top: 18px; padding: 10px 12px; border-radius: 13px; background: rgba(255,215,94,.19); color: var(--muted); font-size: 11px; }
.join-note p { margin: 0; line-height: 1.5; }

/* Lobby */
.lobby-screen { max-width: 1320px; }
.lobby-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin: 10px 0 30px; }
.lobby-heading h2 { margin: 10px 0 4px; font-family: var(--hand); font-size: clamp(40px, 5vw, 70px); letter-spacing: -3px; }
.lobby-heading p { margin: 0; color: var(--muted); }
.room-code-card {
  min-width: 235px;
  padding: 13px 18px;
  border: 3px dashed var(--ink);
  border-radius: 18px;
  background: var(--yellow);
  text-align: center;
  box-shadow: 5px 6px 0 var(--ink);
  transform: rotate(1.5deg);
}
.room-code-card small { display: block; font-weight: 900; font-size: 10px; letter-spacing: 2px; }
.room-code-card strong { display: block; margin: 2px 0; font-family: var(--hand); font-size: 38px; letter-spacing: 7px; }
.room-code-card button { border: 0; background: transparent; text-decoration: underline; font-size: 11px; font-weight: 800; }
.lobby-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .62fr); gap: 28px; align-items: start; }
.player-lobby-card, .lobby-settings-card { padding: 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.section-heading h3 { margin: 0; font-family: var(--hand); font-size: 24px; }
.section-heading h3 span { padding: 4px 8px; border-radius: 10px; background: var(--paper-2); font-family: var(--font); font-size: 11px; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 10px; font-weight: 900; }
.live-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulseDot 1.6s infinite; }
.lobby-players { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; min-height: 290px; margin-top: 22px; align-content: start; }
.lobby-player {
  position: relative;
  min-height: 126px;
  padding: 15px 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 16px 20px 14px 18px;
  background: var(--player-bg, #fff3b4);
  text-align: center;
  box-shadow: 3px 4px 0 var(--ink);
  animation: popIn .3s both;
}
.lobby-player:nth-child(even) { transform: rotate(1deg); }
.lobby-player:nth-child(odd) { transform: rotate(-.7deg); }
.player-avatar { position: relative; display: grid; place-items: center; width: 55px; height: 55px; margin: 0 auto 8px; border: 2px solid var(--ink); border-radius: 50% 45% 52% 43%; background: var(--avatar-bg, var(--mint)); font-family: var(--hand); font-size: 23px; font-weight: 900; }
.player-avatar::after { content: ""; width: 19px; height: 6px; border-bottom: 3px solid var(--ink); border-radius: 50%; position: absolute; bottom: 12px; }
.lobby-player b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.lobby-player small { display: inline-block; margin-top: 5px; padding: 3px 7px; border-radius: 99px; background: rgba(255,255,255,.58); color: var(--muted); font-size: 8px; font-weight: 900; }
.lobby-player .kick-player { position: absolute; right: 6px; top: 5px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(255,255,255,.7); color: var(--red); font-weight: 900; }
.lobby-slot { display: grid; place-items: center; min-height: 126px; border: 2px dashed rgba(23,32,51,.18); border-radius: 18px; color: rgba(23,32,51,.28); font-size: 23px; }
.waiting-strip { display: flex; align-items: center; gap: 10px; margin-top: 20px; color: var(--muted); font-size: 11px; font-weight: 700; }
.waiting-strip i { flex: 1; height: 2px; background: repeating-linear-gradient(90deg, rgba(23,32,51,.16) 0 5px, transparent 5px 10px); }
.lobby-settings-card { position: sticky; top: 90px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 71px; border-bottom: 2px dashed rgba(23,32,51,.12); }
.setting-row > span { display: flex; flex-direction: column; }
.setting-row b { font-size: 12px; }
.setting-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.setting-row select { width: 125px; height: 38px; font-size: 11px; }
.setting-row.fixed strong { padding: 7px 10px; border: 2px solid var(--ink); border-radius: 10px; background: var(--yellow); font-family: var(--hand); }
.bank-meter { margin: 18px 0 2px; }
.bank-meter > span, .bank-meter > strong { font-size: 9px; font-weight: 900; }
.bank-meter > strong { float: right; }
.bank-meter > b { display: block; height: 9px; margin-top: 5px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; }
.bank-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--violet)); }
.host-waiting { display: none; margin-top: 18px; padding: 13px; border-radius: 13px; background: var(--paper-2); color: var(--muted); text-align: center; font-size: 11px; }
.text-btn { display: block; margin: 15px auto 0; border: 0; background: transparent; color: var(--muted); text-decoration: underline; font-weight: 700; font-size: 11px; }
.danger-text { color: var(--red); }

/* Game */
.game-screen { width: min(1680px, calc(100% - 28px)); padding-top: 4px; }
.game-topbar { display: grid; grid-template-columns: 105px 1fr 115px; align-items: center; min-height: 86px; padding: 10px 16px; margin-bottom: 15px; border-radius: 20px 17px 23px 18px; }
.round-badge { height: 60px; display: flex; flex-direction: column; justify-content: center; align-items: center; border-right: 2px dashed rgba(23,32,51,.18); }
.round-badge small, .prompt-area small { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: 1.3px; }
.round-badge strong { font-family: var(--hand); font-size: 22px; }
.prompt-area { min-width: 0; padding: 0 18px; text-align: center; }
.prompt-area strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--hand); font-size: clamp(24px, 3vw, 40px); letter-spacing: 5px; }
.prompt-area > span { display: inline-block; margin-top: 2px; padding: 3px 9px; border-radius: 99px; background: rgba(113,87,255,.1); color: var(--violet-dark); font-size: 9px; font-weight: 800; }
.timer-box { position: relative; width: 74px; height: 68px; justify-self: end; }
.timer-box svg { position: absolute; inset: 0; width: 68px; height: 68px; transform: rotate(-90deg); }
.timer-box circle { fill: none; stroke: rgba(23,32,51,.1); stroke-width: 6; }
.timer-box circle:last-child { stroke: var(--violet); stroke-linecap: round; stroke-dasharray: 157.08; stroke-dashoffset: 0; transition: stroke .2s; }
.timer-box > div { position: absolute; inset: 0 6px 0 0; display: grid; place-content: center; text-align: center; }
.timer-box strong { font-family: var(--hand); font-size: 15px; }
.timer-box small { color: var(--muted); font-size: 7px; font-weight: 900; }
.timer-box.is-urgent circle:last-child { stroke: var(--red); }
.timer-box.is-urgent { animation: shake .55s ease infinite; }
.game-layout { display: grid; grid-template-columns: 220px minmax(520px, 1fr) 300px; gap: 15px; align-items: stretch; }
.game-panel { height: calc(100dvh - 205px); min-height: 520px; padding: 17px; overflow: hidden; border-radius: 19px 23px 18px 21px; }
.players-panel { display: flex; flex-direction: column; }
.game-panel .section-heading h3 { font-size: 19px; }
.game-panel .section-heading > span { color: var(--muted); font-size: 9px; font-weight: 800; }
.score-list { flex: 1; min-height: 0; margin-top: 13px; overflow-y: auto; padding-right: 3px; }
.score-player { display: grid; grid-template-columns: 30px 37px minmax(0,1fr); align-items: center; gap: 8px; min-height: 58px; margin-bottom: 8px; padding: 7px 8px; border: 2px solid rgba(23,32,51,.12); border-radius: 13px 16px 12px 15px; background: #fff; transition: .2s; }
.score-player.is-drawer { border-color: var(--violet); background: rgba(113,87,255,.08); transform: rotate(-.5deg); }
.score-player.is-correct { border-color: var(--green); background: rgba(65,201,134,.1); }
.score-player.is-offline { opacity: .47; filter: grayscale(.6); }
.score-rank { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; background: var(--paper-2); font-family: var(--hand); font-weight: 900; }
.score-avatar { display: grid; place-items: center; width: 36px; height: 36px; border: 2px solid var(--ink); border-radius: 50%; background: var(--avatar-bg); font-size: 15px; font-weight: 900; }
.score-copy { min-width: 0; }
.score-copy b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.score-copy span { color: var(--muted); font-size: 9px; font-weight: 800; }
.reaction-tray { padding-top: 12px; border-top: 2px dashed rgba(23,32,51,.13); }
.reaction-tray small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 8px; font-weight: 900; }
.reaction-tray > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.reaction-tray button { height: 34px; border: 1px solid rgba(23,32,51,.12); border-radius: 10px; background: #fff; font-size: 16px; }
.reaction-tray button:hover { transform: translateY(-2px) rotate(-5deg); background: var(--yellow); }
.canvas-zone { position: relative; display: flex; flex-direction: column; min-width: 0; }
.drawer-ribbon { position: absolute; z-index: 5; top: -8px; left: 50%; transform: translateX(-50%) rotate(-.7deg); display: flex; align-items: center; gap: 7px; min-width: 170px; justify-content: center; padding: 6px 16px; border: 2px solid var(--ink); border-radius: 12px; background: var(--yellow); box-shadow: 3px 4px 0 var(--ink); font-size: 10px; }
.drawer-ribbon i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulseDot 1.5s infinite; }
.canvas-paper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: 22px 18px 26px 19px;
  background: #e9e5dd;
  box-shadow: 7px 8px 0 var(--ink), var(--shadow);
  overflow: hidden;
}
.canvas-paper::before, .canvas-paper::after { content: ""; position: absolute; z-index: 3; top: 7px; width: 54px; height: 16px; background: rgba(255,215,94,.62); border: 1px solid rgba(23,32,51,.17); }
.canvas-paper::before { left: 13%; transform: rotate(-5deg); }
.canvas-paper::after { right: 13%; transform: rotate(4deg); background: rgba(112,223,189,.55); }
#drawCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 315px);
  aspect-ratio: 8 / 5;
  border: 2px solid rgba(23,32,51,.15);
  border-radius: 6px 11px 7px 9px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(23,32,51,.12);
  touch-action: none;
  cursor: crosshair;
}
#drawCanvas.is-disabled { cursor: default; }
.canvas-watermark { position: absolute; right: 35px; bottom: 30px; color: rgba(23,32,51,.055); font-family: var(--hand); font-size: 36px; font-weight: 900; pointer-events: none; transform: rotate(-7deg); }
.spectator-cover { position: absolute; z-index: 4; inset: 18px; display: none; place-content: center; text-align: center; border-radius: 13px; background: rgba(255,253,248,.82); backdrop-filter: blur(8px); }
.spectator-cover.is-visible { display: grid; }
.spectator-cover span { font-size: 52px; }
.spectator-cover b { font-family: var(--hand); font-size: 26px; }
.spectator-cover small { color: var(--muted); }
.round-result-card { position: absolute; z-index: 6; left: 50%; top: 50%; width: min(430px, 82%); transform: translate(-50%, -50%) scale(.85) rotate(-1deg); padding: 24px; border: 3px solid var(--ink); border-radius: 22px 18px 25px 19px; background: var(--yellow); box-shadow: 7px 8px 0 var(--ink), 0 25px 60px rgba(23,32,51,.22); text-align: center; opacity: 0; pointer-events: none; transition: .3s cubic-bezier(.2,.9,.2,1.2); }
.round-result-card.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-1deg); }
.round-result-card small { font-size: 9px; font-weight: 900; letter-spacing: 2px; }
.round-result-card strong { display: block; margin: 8px 0; font-family: var(--hand); font-size: clamp(30px, 5vw, 52px); }
.round-result-card span { color: #555; font-size: 11px; font-weight: 700; }
.toolbar { display: grid; grid-template-columns: auto minmax(200px, 1fr) 175px auto; align-items: center; gap: 11px; min-height: 72px; margin-top: 13px; padding: 9px 12px; border-radius: 18px 15px 20px 16px; box-shadow: 5px 6px 0 var(--ink), 0 10px 30px rgba(23,32,51,.12); }
.toolbar.is-disabled { opacity: .58; filter: grayscale(.35); pointer-events: none; }
.tool-group, .history-tools { display: flex; gap: 5px; }
.tool-btn, .history-tools button { width: 42px; height: 42px; border: 2px solid rgba(23,32,51,.14); border-radius: 12px; background: #fff; font-family: var(--hand); font-size: 20px; font-weight: 900; }
.tool-btn.is-active { border-color: var(--ink); background: var(--yellow); box-shadow: 2px 3px 0 var(--ink); transform: translateY(-1px) rotate(-2deg); }
.palette { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.color-swatch { width: 24px; height: 24px; padding: 0; border: 2px solid rgba(23,32,51,.18); border-radius: 50% 44% 52% 46%; background: var(--swatch); }
.color-swatch.is-active { border-color: var(--ink); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); transform: scale(.9); }
.size-control { display: grid; grid-template-columns: 29px 1fr 26px; align-items: center; gap: 6px; }
.size-control > span { display: block; justify-self: center; width: var(--preview-size, 8px); height: var(--preview-size, 8px); max-width: 24px; max-height: 24px; min-width: 4px; min-height: 4px; border-radius: 50%; background: var(--ink); }
.size-control input { width: 100%; accent-color: var(--violet); }
.size-control b { font-size: 10px; }
.chat-panel { display: flex; flex-direction: column; }
#mobileCloseChat { display: none; border: 0; background: transparent; font-size: 24px; }
.chat-stream { flex: 1; min-height: 0; overflow-y: auto; margin: 12px -4px 10px 0; padding-right: 7px; scroll-behavior: smooth; }
.chat-message { margin-bottom: 8px; padding: 8px 10px; border-radius: 11px 14px 10px 13px; background: var(--paper-2); font-size: 11px; line-height: 1.35; animation: slideUp .2s both; overflow-wrap: anywhere; }
.chat-message b { color: var(--violet-dark); }
.chat-message.system { border: 1px dashed rgba(23,32,51,.18); background: rgba(255,215,94,.16); color: var(--muted); text-align: center; font-size: 9px; font-weight: 700; }
.chat-message.correct { border: 2px solid rgba(65,201,134,.35); background: rgba(65,201,134,.12); color: #16744a; font-weight: 900; }
.guess-form { display: grid; grid-template-columns: 1fr 43px; gap: 7px; }
.guess-form input { min-width: 0; height: 45px; border: 2px solid rgba(23,32,51,.15); border-radius: 13px; padding: 0 11px; outline: 0; }
.guess-form input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(113,87,255,.1); }
.guess-form input:disabled { background: var(--paper-2); color: var(--muted); }
.guess-form button { border: 2px solid var(--ink); border-radius: 12px; background: var(--violet); color: #fff; box-shadow: 2px 3px 0 var(--ink); }
.guess-form button:disabled { opacity: .45; }
.guess-hint { display: block; min-height: 26px; margin-top: 7px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.mobile-game-nav { display: none; }

/* Modals and feedback */
.modal-layer { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(23,32,51,.48); backdrop-filter: blur(9px); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.modal-layer.is-visible { opacity: 1; pointer-events: auto; }
.choice-modal, .game-over-modal { width: min(610px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 34px; text-align: center; transform: translateY(20px) scale(.94) rotate(-.5deg); transition: .3s cubic-bezier(.2,.9,.2,1.15); }
.modal-layer.is-visible > div { transform: translateY(0) scale(1) rotate(-.5deg); }
.modal-doodle { position: absolute; right: 25px; top: 12px; color: var(--violet); font-family: var(--hand); font-size: 48px; transform: rotate(13deg); }
.choice-modal > small, .game-over-modal > small { color: var(--violet-dark); font-size: 10px; font-weight: 900; letter-spacing: 2px; }
.choice-modal h2, .game-over-modal h2 { margin: 6px 0; font-family: var(--hand); font-size: clamp(32px, 5vw, 48px); }
.choice-modal > p { margin: 0 0 18px; color: var(--muted); }
.choice-countdown { position: relative; height: 9px; margin: 18px 0 22px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; }
.choice-countdown i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--violet)); transform-origin: left; }
.choice-countdown span { position: absolute; right: -10px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 33px; height: 33px; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-family: var(--hand); font-weight: 900; box-shadow: 2px 3px 0 var(--ink); }
.word-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.word-choice { min-height: 128px; padding: 15px 9px; border: 3px solid var(--ink); border-radius: 17px 14px 20px 15px; background: #fff; box-shadow: 4px 5px 0 var(--ink); transition: .15s; }
.word-choice:nth-child(1) { background: #fff3b4; transform: rotate(-1.5deg); }
.word-choice:nth-child(2) { background: #dff9ef; transform: rotate(1deg); }
.word-choice:nth-child(3) { background: #eee8ff; transform: rotate(-.5deg); }
.word-choice:hover { transform: translateY(-5px) rotate(0); box-shadow: 7px 9px 0 var(--ink); }
.word-choice span { display: block; color: var(--muted); font-size: 8px; font-weight: 900; text-transform: uppercase; }
.word-choice b { display: block; margin-top: 15px; font-family: var(--hand); font-size: clamp(18px, 2vw, 25px); }
.custom-answer-form { display: none; text-align: left; }
.custom-answer-form.is-visible { display: block; }
.custom-answer-form label { display: block; margin-top: 13px; font-size: 11px; font-weight: 900; }
.custom-answer-form input { width: 100%; height: 49px; margin-top: 6px; border: 2px solid rgba(23,32,51,.16); border-radius: 13px; padding: 0 13px; outline: 0; }
.custom-answer-form input:focus { border-color: var(--coral); box-shadow: 0 0 0 4px rgba(255,111,97,.1); }
.game-over-modal { width: min(680px, 100%); }
.winner-crown { margin: -12px auto 0; font-size: 62px; color: var(--yellow); -webkit-text-stroke: 3px var(--ink); filter: drop-shadow(4px 5px 0 var(--ink)); animation: wobble 2s infinite; }
#podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; min-height: 185px; margin: 20px 0; }
.podium-place { width: 30%; max-width: 150px; text-align: center; }
.podium-avatar { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 6px; border: 3px solid var(--ink); border-radius: 50%; background: var(--avatar-bg); font-family: var(--hand); font-size: 25px; font-weight: 900; box-shadow: 3px 4px 0 var(--ink); }
.podium-block { display: grid; align-content: center; min-height: var(--height); padding: 8px; border: 3px solid var(--ink); border-radius: 13px 13px 5px 5px; background: var(--podium-bg); box-shadow: 4px 0 0 var(--ink); }
.podium-block b { font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.podium-block strong { font-family: var(--hand); font-size: 18px; }
.final-ranking { display: grid; gap: 7px; margin-top: 15px; }
.final-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 12px; background: var(--paper-2); text-align: left; font-size: 11px; }
.final-row span:first-child { font-family: var(--hand); font-weight: 900; }

.toast-stack { position: fixed; z-index: 150; right: 18px; top: 80px; display: grid; gap: 9px; width: min(350px, calc(100% - 36px)); pointer-events: none; }
.toast { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 13px 16px 12px 15px; background: var(--paper); box-shadow: 4px 5px 0 var(--ink), 0 16px 35px rgba(23,32,51,.16); animation: popIn .25s both; font-size: 11px; font-weight: 800; }
.toast.is-error { background: #ffe1de; }
.toast.is-success { background: #dff8eb; }
.toast-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,.7); }
.reaction-layer { position: fixed; z-index: 140; inset: 0; pointer-events: none; overflow: hidden; }
.flying-reaction { position: absolute; left: var(--x); bottom: 10%; font-size: 48px; filter: drop-shadow(0 8px 9px rgba(23,32,51,.2)); animation: reactionFly 2.3s ease-out forwards; }
.confetti-piece { position: fixed; z-index: 160; top: -40px; left: var(--x); width: 11px; height: 19px; border: 2px solid var(--ink); background: var(--c); animation: confettiFall var(--duration) linear forwards; animation-delay: var(--delay); pointer-events: none; }
.mobile-scrim { display: none; }

@media (min-width: 921px) {
  html { height: 100%; }
  body { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
  .top-shell { flex: 0 0 auto; width: 100%; }
  #app { flex: 1 1 auto; min-height: 0; }
  .screen.is-active { height: 100%; max-height: 100%; overflow-y: auto; box-sizing: border-box; }
  .game-screen.is-active { display: flex; flex-direction: column; }
  .game-topbar { flex: 0 0 auto; }
  .game-layout { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .game-panel { height: 100%; min-height: 0; }
  .canvas-zone { height: 100%; min-height: 0; }
  #drawCanvas { max-height: 100%; }
}

@media (max-width: 1180px) {
  .home-screen.is-active { grid-template-columns: minmax(0, 1fr) minmax(390px, .9fr); gap: 38px; }
  .hero-sketch { opacity: .6; }
  .game-layout { grid-template-columns: 185px minmax(450px, 1fr) 260px; }
  .toolbar { grid-template-columns: auto 1fr 145px auto; }
  .color-swatch { width: 21px; height: 21px; }
}

@media (max-width: 920px) {
  .top-shell { padding: 10px 16px; min-height: 64px; }
  .screen { width: min(100% - 24px, 760px); min-height: calc(100dvh - 75px); }
  .home-screen.is-active { display: block; }
  .hero-copy { text-align: center; padding-top: 10px; }
  .hero-copy h1 { align-items: center; }
  .word-party { margin-left: 0; }
  .hero-copy > p { margin-left: auto; margin-right: auto; }
  .hero-chips { justify-content: center; }
  .hero-sketch { display: none; }
  .entry-card { max-width: 620px; margin: 40px auto 0; }
  .lobby-heading { align-items: center; }
  .lobby-layout { grid-template-columns: 1fr; }
  .lobby-settings-card { position: static; }
  .lobby-players { grid-template-columns: repeat(4, 1fr); min-height: auto; }

  .game-screen { width: calc(100% - 18px); padding-bottom: 82px; }
  .game-topbar { grid-template-columns: 80px 1fr 78px; min-height: 76px; }
  .game-layout { grid-template-columns: 1fr; }
  .canvas-zone { min-height: calc(100dvh - 245px); }
  #drawCanvas { max-height: calc(100dvh - 360px); }
  .game-panel { position: fixed; z-index: 80; top: 75px; bottom: 75px; height: auto; min-height: 0; width: min(330px, calc(100% - 38px)); transform: translateX(-120%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .players-panel { left: 12px; }
  .chat-panel { right: 12px; transform: translateX(120%); }
  .game-panel.is-mobile-open { transform: translateX(0); }
  #mobileCloseChat { display: block; }
  .mobile-scrim { position: fixed; z-index: 70; inset: 0; background: rgba(23,32,51,.55); }
  .mobile-scrim.is-visible { display: block; }
  .mobile-game-nav { position: fixed; z-index: 50; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; grid-template-columns: 1fr 1fr; gap: 7px; width: min(420px, calc(100% - 24px)); padding: 7px; border: 2px solid var(--ink); border-radius: 16px; background: rgba(255,253,248,.92); box-shadow: 4px 5px 0 var(--ink); backdrop-filter: blur(12px); }
  .mobile-game-nav button { height: 43px; border: 0; border-radius: 11px; background: var(--paper-2); font-weight: 900; font-size: 11px; }
  .mobile-game-nav span { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; border-radius: 99px; background: var(--coral); color: #fff; font-size: 8px; }
  .toolbar { grid-template-columns: auto 1fr auto; }
  .size-control { grid-column: 1 / -1; grid-row: 2; }
  .history-tools { grid-column: 3; grid-row: 1; }
}

@media (max-width: 620px) {
  .connection-pill { min-width: 42px; width: 42px; justify-content: center; padding: 0; }
  .connection-pill b { display: none; }
  .screen { width: calc(100% - 16px); padding-top: 10px; }
  .hero-copy h1 { margin-top: 17px; }
  .hero-copy > p { margin-top: 26px; }
  .entry-card { margin-top: 28px; padding: 14px 15px 22px; border-radius: 21px 18px 24px 19px; }
  .mode-picker { grid-template-columns: 1fr; }
  .mode-card { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; text-align: left; padding: 10px 12px; }
  .mode-card > span { grid-row: 1 / 3; align-self: center; }
  .mode-card b, .mode-card small { margin: 0; min-height: 0; }
  .inline-settings { grid-template-columns: 1fr; }
  .lobby-heading { display: block; text-align: center; }
  .room-code-card { width: 230px; margin: 22px auto 0; }
  .player-lobby-card, .lobby-settings-card { padding: 17px; }
  .lobby-players { grid-template-columns: repeat(2, 1fr); }
  .lobby-slot:nth-of-type(n+5) { display: none; }
  .game-topbar { grid-template-columns: 58px 1fr 58px; min-height: 70px; padding: 7px; }
  .round-badge { height: 52px; }
  .prompt-area { padding: 0 7px; }
  .prompt-area > span { max-width: 130px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .timer-box, .timer-box svg { width: 56px; height: 56px; }
  .canvas-zone { min-height: calc(100dvh - 225px); }
  .canvas-paper { padding: 8px; border-radius: 17px; }
  .canvas-paper::before, .canvas-paper::after { display: none; }
  #drawCanvas { max-height: calc(100dvh - 350px); }
  .toolbar { gap: 7px; min-height: 65px; padding: 8px; margin-top: 9px; }
  .tool-btn, .history-tools button { width: 36px; height: 36px; }
  .palette { gap: 4px; max-height: 58px; overflow-y: auto; }
  .color-swatch { width: 19px; height: 19px; }
  .drawer-ribbon { min-width: 145px; }
  .choice-modal, .game-over-modal { padding: 25px 16px; }
  .word-choices { grid-template-columns: 1fr; }
  .word-choice { min-height: 78px; display: grid; place-content: center; }
  .word-choice b { margin-top: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
