:root {
  --bg: #fbf7f2;
  --panel: #ffffff;
  --ink: #2b2530;
  --muted: #7a7082;
  --line: #e9e1d8;
  --accent: #ff6b5b;
  --accent-ink: #ffffff;
  --free: #3fb68b;
  --rounds: #6c7cff;
  --assisted: #f2a93b;
  --shadow: 0 2px 10px rgba(60, 40, 30, .08);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a21;
    --panel: #29252f;
    --ink: #f3eef7;
    --muted: #a79eb0;
    --line: #3a3441;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Nunito, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 800; }
button.active { outline: 3px solid var(--accent); outline-offset: 1px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 20px; text-decoration: none; }
.me { display: flex; gap: 10px; align-items: center; }
.me a { text-decoration: none; display: flex; gap: 8px; align-items: center; font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 16px; }

.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; flex: none; background: var(--line); font-weight: 800; color: #fff;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.login {
  max-width: 420px; margin: 12vh auto; text-align: center; background: var(--panel);
  padding: 32px 24px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 8px; }
.login p { color: var(--muted); }
.google-btn { display: inline-flex; gap: 10px; align-items: center; padding: 12px 18px; font-weight: 800; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; text-decoration: none; display: flex; flex-direction: column; gap: 10px;
  border: 2px solid transparent; transition: transform .1s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line); }
.card h3 { margin: 0; font-size: 20px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.badge { align-self: flex-start; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 99px; color: #fff; }
.badge.free { background: var(--free); }
.badge.rounds { background: var(--rounds); }
.badge.assisted { background: var(--assisted); }
.faces { display: flex; gap: 4px; min-height: 28px; align-items: center; color: var(--muted); font-size: 13px; }

.profile { max-width: 560px; margin: 0 auto; background: var(--panel); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }
.profile label { display: block; font-weight: 800; margin: 16px 0 8px; }
.profile input[type=text], .login input[type=text] { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.preview { display: flex; gap: 14px; align-items: center; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-grid button { font-size: 24px; width: 48px; height: 48px; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; padding: 0; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.error { color: var(--accent); font-weight: 600; }

.room { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
@media (max-width: 900px) { .room { grid-template-columns: 1fr; } }
.room-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.room-head h2 { margin: 0; }
.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; touch-action: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage canvas.top { cursor: crosshair; }
.stage.locked canvas.top { cursor: not-allowed; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.toolbar input[type=range] { width: 120px; }
.toolbar .swatch { width: 28px; height: 28px; }
.side { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel h4 { margin: 0 0 10px; }
.people { display: flex; flex-direction: column; gap: 8px; }
.person { display: flex; gap: 8px; align-items: center; }
.person.drawing { font-weight: 800; }
.hint { font-size: 18px; font-weight: 600; margin: 8px 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.timer { font-size: 32px; font-weight: 800; }
.banner { background: var(--accent); color: #fff; font-weight: 800; padding: 8px 12px; border-radius: 12px; text-align: center; }
.steps { display: flex; gap: 4px; margin: 8px 0; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps span.done { background: var(--assisted); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 10;
}
.login input[type=text] { width: auto; flex: 1; min-width: 160px; }
.keybox { margin-top: 8px; }
.key { font-size: 20px; font-weight: 800; padding: 8px 12px; border-radius: 12px; background: var(--bg); border: 2px dashed var(--assisted); }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.person-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; font-weight: 600; }
.pic-box { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 8px 0; }
.pic-slots { display: flex; gap: 10px; }
.pic-slot { width: 56px; height: 56px; border-radius: 14px; border: 2px dashed var(--assisted); display: flex; align-items: center; justify-content: center; font-size: 32px; }
.pic-pad { display: grid; grid-template-columns: repeat(4, 64px); gap: 8px; }
.pic-pad button { width: 64px; height: 64px; font-size: 34px; padding: 0; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.login p.error { color: var(--accent); }
select.lang { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 8px; font-weight: 800; }
@media (max-width: 520px) { .me .nick, #brand { display: none; } }
.invite-hint {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  margin: 12px 0; padding: 14px 16px; border-radius: 14px;
  background: #fff4dc; color: #6b4a00; border: 2px dashed var(--assisted); font-size: 18px;
}
.invite-hint b { font-size: 26px; letter-spacing: 1px; }
.stats-link { margin-left: auto; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.stat { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 44px; line-height: 1; }
.stat span { color: var(--muted); }
.stat.online b { color: var(--free); }
.badge.guess { background: #ff7eb6; }
.stamp-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.stamp-btn { font-size: 24px; width: 44px; height: 44px; padding: 0; }
.react-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.react-bar button { font-size: 22px; padding: 4px 10px; border-radius: 99px; }
.fly-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.fly { position: absolute; bottom: 0; display: flex; flex-direction: column; align-items: center; animation: fly-up 2.5s ease-out forwards; }
.fly span { font-size: 44px; line-height: 1; }
.fly small { font-size: 12px; font-weight: 800; color: #6b5f73; background: rgba(255,255,255,.85); padding: 1px 6px; border-radius: 99px; }
@keyframes fly-up {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { transform: translateY(-15%) scale(1.1); opacity: 1; }
  100% { transform: translateY(-420%) scale(1); opacity: 0; }
}
.secret { font-size: 28px; margin-top: 4px; letter-spacing: 1px; }
.mask { font-size: 26px; font-weight: 800; letter-spacing: 6px; margin: 8px 0; font-family: ui-monospace, monospace; }
.scores { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.chat { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 14px; margin-bottom: 8px; }
.chat-ok { color: var(--free); font-weight: 800; }
.chat-form input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.pic { margin: 0; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pic img { width: 100%; aspect-ratio: 4 / 3; display: block; background: #fff; }
.pic figcaption { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.heart { border-radius: 99px; padding: 4px 12px; font-weight: 800; }
.heart.on { border-color: #ff7eb6; }
.room-head a + a { font-weight: 600; }
