/* ===================== Vẽ Vui – giao diện ===================== */
:root {
  --bg: #FFF3DC;
  --bg-dot: #F5D9A8;
  --ink: #1F1A3D;
  --muted: #6E6790;
  --card: #FFFFFF;
  --soft: #FFF8EC;
  --red: #FF4D5E;
  --red-d: #E23447;
  --yellow: #FFC83D;
  --yellow-soft: #FFF1C2;
  --green: #1FBF85;
  --green-soft: #D9F7EA;
  --blue: #3D7BFF;
  --blue-soft: #E1EAFF;
  --purple: #8C5CFF;
  --purple-soft: #EFE7FF;
  --pink: #FF7EB6;
  --radius: 18px;
  --radius-sm: 12px;
  --border: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --font-head: 'Baloo 2', 'Be Vietnam Pro', system-ui, sans-serif;
  --font-body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1.6px, transparent 1.6px);
  background-size: 22px 22px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.15; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: 500; }

/* ---------- Screens ---------- */
.screen { display: none; }
.screen.active { display: block; }
#screen-room.active { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- Card / Button / Field ---------- */
.card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn {
  --btn-bg: var(--card);
  --btn-fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font-family: var(--font-head); font-weight: 700; font-size: 1.05rem;
  padding: .55em 1.1em .45em;
  border: var(--border); border-radius: 14px;
  background: var(--btn-bg); color: var(--btn-fg);
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--ink); filter: grayscale(.4); }
.btn-red { --btn-bg: var(--red); --btn-fg: #fff; }
.btn-blue { --btn-bg: var(--blue); --btn-fg: #fff; }
.btn-yellow { --btn-bg: var(--yellow); }
.btn-green { --btn-bg: var(--green); --btn-fg: #fff; }
.btn-ghost { --btn-bg: var(--card); }
.btn-lg { font-size: 1.3rem; padding: .55em 1.2em .45em; }
.btn-sm { font-size: .95rem; padding: .35em .8em .25em; border-radius: 11px; box-shadow: 0 3px 0 var(--ink); }
.btn-block { width: 100%; }
.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: inline-grid; place-items: center;
  border: var(--border); border-radius: 12px; background: var(--card);
  box-shadow: 0 3px 0 var(--ink); font-size: 1.15rem;
  transition: transform .08s;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
input[type=text], input:not([type]), select, textarea {
  width: 100%;
  border: var(--border); border-radius: var(--radius-sm);
  background: var(--soft);
  padding: .65em .85em; font-size: 1rem; font-weight: 500;
  outline: none; transition: box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus { background: #fff; box-shadow: 0 0 0 4px rgba(61, 123, 255, .3); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2em; cursor: pointer; }
select:disabled, input:disabled, textarea:disabled { opacity: .75; cursor: not-allowed; }
textarea { resize: vertical; min-height: 56px; }

.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; border: 2px solid var(--ink); background: #eee; }
.chip-green { background: var(--green-soft); }
.chip-yellow { background: var(--yellow-soft); }
.chip-blue { background: var(--blue-soft); }

/* ---------- Avatar ---------- */
.avatar {
  --c: #FFD43B;
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; border: 3px solid var(--ink);
  background: var(--c); font-size: 1.3rem; line-height: 1;
}
.avatar-sm { width: 30px; height: 30px; font-size: 1rem; border-width: 2px; }
.avatar-xl { width: 108px; height: 108px; font-size: 3.6rem; box-shadow: var(--shadow-sm); animation: bob 3s ease-in-out infinite; }

/* ---------- Top nav ---------- */
.topnav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1160px; margin: 0 auto; padding: 18px 16px;
}
.logo { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-family: var(--font-head); font-weight: 800; font-size: 2rem; color: var(--ink); }
.logo-icon { display: inline-block; animation: wiggle 2.8s ease-in-out infinite; margin-right: 4px; }
.logo-ve { color: var(--red); -webkit-text-stroke: 1.5px var(--ink); text-shadow: 2px 2px 0 var(--ink); }
.logo-vui { color: var(--yellow); -webkit-text-stroke: 1.5px var(--ink); text-shadow: 2px 2px 0 var(--ink); transform: rotate(-4deg); display: inline-block; }
.topnav-right { display: flex; align-items: center; gap: 10px; }
.online-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .85rem; background: var(--card); border: 2px solid var(--ink); border-radius: 99px; padding: 6px 12px; }
.online-pill i { width: 9px; height: 9px; border-radius: 50%; background: #bbb; }
.online-pill.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(31, 191, 133, .25); }

/* ---------- Home ---------- */
.home { max-width: 1160px; margin: 0 auto; padding: 0 16px 40px; }
.hero { text-align: center; padding: 18px 0 30px; }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 800; letter-spacing: -.5px; }
.hero mark { background: linear-gradient(transparent 55%, var(--yellow) 55%); color: var(--ink); padding: 0 .1em; }
.hero p { max-width: 560px; margin: 14px auto 0; font-size: 1.05rem; color: var(--muted); }
.invite-banner { margin: 18px auto 0; max-width: 520px; padding: 12px 16px; background: var(--blue-soft); border: var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); font-weight: 500; animation: pop .35s ease; }

.home-grid { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.profile-card { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.avatar-picker { display: flex; align-items: center; justify-content: center; gap: 18px; }
.arrow-btn { width: 40px; height: 40px; border-radius: 50%; border: var(--border); background: var(--card); font-size: 1.6rem; line-height: 1; font-weight: 800; box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; padding-bottom: 4px; }
.arrow-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.color-dots { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink); padding: 0; transition: transform .12s; }
.color-dot.active { transform: scale(1.25); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.name-row { display: flex; gap: 8px; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; font-family: var(--font-head); font-size: 1.15rem; text-align: center; }
.join-row input::placeholder { letter-spacing: 1px; font-size: .95rem; }
.join-row.glow .btn { animation: glow 1.2s ease-in-out infinite; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.divider::before, .divider::after { content: ''; flex: 1; height: 2px; background: #E8DCC6; border-radius: 2px; }

.rooms-card { padding: 20px; min-height: 100%; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.card-head h2 { font-size: 1.5rem; }
.room-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: 440px; padding: 2px 4px 6px 2px; }
.room-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 14px; background: var(--soft); transition: transform .12s, background .12s; }
.room-item:hover { transform: translateX(3px); background: #fff; }
.room-emoji { font-size: 1.8rem; width: 46px; height: 46px; display: grid; place-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 12px; flex: none; }
.room-meta { flex: 1; min-width: 0; }
.room-meta b { display: block; font-family: var(--font-head); font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta small { color: var(--muted); font-weight: 500; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.room-count { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.empty .big { font-size: 3rem; }

.section-title { font-size: 2rem; text-align: center; margin: 48px 0 20px; }
.howto-grid, .games-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.games-grid { grid-template-columns: repeat(4, 1fr); }
.howto-item { padding: 22px 20px; position: relative; text-align: center; }
.howto-item:nth-child(1) { background: var(--yellow-soft); transform: rotate(-1deg); }
.howto-item:nth-child(2) { background: var(--blue-soft); transform: rotate(.8deg); }
.howto-item:nth-child(3) { background: var(--green-soft); transform: rotate(-.6deg); }
.howto-item h3 { font-size: 1.3rem; margin: 8px 0 6px; }
.howto-item p { margin: 0; color: var(--muted); }
.howto-emoji { font-size: 2.6rem; }
.step { position: absolute; top: -14px; left: -10px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; border: var(--border); font-family: var(--font-head); font-size: 1.2rem; }
.game-card { background: var(--card); border: var(--border); border-radius: var(--radius); padding: 20px 16px; text-align: center; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.game-card.active { background: linear-gradient(160deg, #FFE3E6, #FFF1C2); box-shadow: var(--shadow); }
.game-card.soon { opacity: .7; }
.game-card.soon .game-emoji { filter: grayscale(.6); }
.game-emoji { font-size: 2.6rem; }
.game-card h3 { font-size: 1.25rem; }
.game-card p { margin: 0 0 6px; color: var(--muted); font-size: .9rem; }
.footer { text-align: center; padding: 24px 16px 32px; color: var(--muted); font-size: .9rem; }

/* ---------- Stats & Leaderboard ---------- */
.my-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { background: var(--soft); border: 2px solid var(--ink); border-radius: 12px; padding: 6px 4px; text-align: center; display: flex; flex-direction: column; }
.stat b { font-family: var(--font-head); font-size: 1rem; white-space: nowrap; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 600; }
.lb-card { padding: 18px; max-width: 760px; margin: 0 auto; }
.lb-tabs { display: flex; gap: 8px; margin-bottom: 14px; background: var(--soft); border: 2px solid var(--ink); border-radius: 14px; padding: 4px; }
.lb-tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 10px; font-family: var(--font-head); font-weight: 700; font-size: 1rem; color: var(--muted); }
.lb-tab.active { background: var(--yellow); color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; border: 2px solid transparent; animation: slide-up .25s ease both; }
.lb-row:nth-child(odd) { background: var(--soft); }
.lb-row.top1 { background: #FFF1C2; border-color: var(--ink); }
.lb-row.top2 { background: #EEF0F5; border-color: var(--ink); }
.lb-row.top3 { background: #FBE3D0; border-color: var(--ink); }
.lb-rank { width: 30px; text-align: center; font-family: var(--font-head); font-weight: 800; font-size: 1.1rem; color: var(--muted); }
.lb-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-meta { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.lb-score { font-family: var(--font-head); font-weight: 800; font-size: 1.1rem; min-width: 64px; text-align: right; }
@media (max-width: 600px) { .lb-meta { display: none; } .lb-card { padding: 12px; } }

/* ---------- Room ---------- */
.room-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: var(--card);
  border-bottom: var(--border); flex: none;
}
.round-info { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; background: var(--yellow); border: 2px solid var(--ink); border-radius: 99px; padding: 3px 14px 1px; white-space: nowrap; }
.word-box { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; text-align: center; }
.word-box .label { color: var(--muted); font-size: 1rem; font-weight: 600; }
.word-box .the-word { font-size: 1.6rem; color: var(--red); letter-spacing: .5px; }
.word-box .the-word.ok { color: var(--green); }
.mask { display: inline-flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.mask-word { display: inline-flex; gap: 4px; }
.mask-ch { width: 22px; height: 32px; display: grid; place-items: end center; border-bottom: 4px solid var(--ink); font-size: 1.45rem; line-height: 1; padding-bottom: 2px; }
.mask-ch.shown { color: var(--blue); animation: pop .4s ease; }
.mask-ch.sym { border-bottom-color: transparent; }
.mask-len { font-size: .85rem; color: var(--muted); font-weight: 600; font-family: var(--font-body); }
.room-bar-right { display: flex; align-items: center; gap: 10px; }
.timer { position: relative; width: 50px; height: 50px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 5; }
.timer .ring-bg { stroke: #EFE5D3; }
.timer .ring { stroke: var(--green); stroke-linecap: round; stroke-dasharray: 119.4; transition: stroke-dashoffset .25s linear, stroke .3s; }
.timer.warn .ring { stroke: var(--yellow); }
.timer.danger .ring { stroke: var(--red); }
.timer.danger { animation: pulse 1s ease-in-out infinite; }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; padding-top: 2px; }

.room-layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px;
  gap: 16px; padding: 16px;
  max-width: 1500px; width: 100%; margin: 0 auto;
}
.panel-title { font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.count-pill { font-size: .85rem; background: var(--blue-soft); border: 2px solid var(--ink); border-radius: 99px; padding: 0 10px; }

.players-panel { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.player-list { list-style: none; margin: 0; padding: 2px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.player {
  display: flex; align-items: center; gap: 8px; position: relative;
  padding: 7px 8px; border: 2px solid var(--ink); border-radius: 14px; background: var(--soft);
  transition: background .2s, transform .2s;
}
.player.me { box-shadow: inset 0 0 0 2px var(--blue); }
.player.drawing { background: var(--yellow-soft); }
.player.guessed { background: var(--green-soft); }
.player .rank { font-family: var(--font-head); font-weight: 800; width: 22px; text-align: center; color: var(--muted); font-size: .95rem; }
.player .pinfo { flex: 1; min-width: 0; }
.player .pname { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .pname em { font-style: normal; color: var(--blue); font-weight: 600; font-size: .8rem; }
.player .pscore { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 3px; }
.player .pscore span { font-size: .9rem; }
.player .badges { font-size: 1.05rem; display: flex; gap: 2px; }
.player .pmenu { flex: none; border: none; background: transparent; font-size: 1.1rem; padding: 2px 4px; border-radius: 8px; color: var(--muted); }
.player .pmenu:hover { background: #fff; color: var(--ink); }
.player.bump { animation: bump .5s ease; }
.player.offline { opacity: .5; filter: grayscale(.7); }

.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* Lobby */
.lobby-view { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding: 2px 6px 8px 2px; }
.invite-card { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: linear-gradient(120deg, #E1EAFF, #FFE3E6); }
.invite-card .label { font-weight: 600; color: var(--muted); font-size: .9rem; }
.room-code { font-family: var(--font-head); font-weight: 800; font-size: 2.4rem; letter-spacing: 6px; line-height: 1; margin-top: 4px; }
.invite-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-opt {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--soft);
  font-weight: 600; font-size: .9rem; text-align: left; transition: transform .1s, background .15s;
}
.theme-opt .te { font-size: 1.4rem; }
.theme-opt small { display: block; color: var(--muted); font-weight: 500; font-size: .75rem; }
.theme-opt.active { background: var(--yellow); box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.theme-opt:disabled { cursor: default; }
.theme-opt:disabled:not(.active) { opacity: .6; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.switch-row { display: flex; gap: 20px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 46px; height: 26px; border: 2px solid var(--ink); border-radius: 99px; background: #E9DFCC; position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); transition: transform .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:disabled + i { opacity: .6; }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(61, 123, 255, .4); }
.start-hint { margin: 0; text-align: center; color: var(--muted); font-weight: 500; font-size: .92rem; }

/* Game */
.game-view { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; align-items: center; }
.board-wrap {
  position: relative; width: 100%; max-width: calc((100dvh - 250px) * 4 / 3); min-width: 0;
  aspect-ratio: 4 / 3; flex: none;
  border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; background: #fff;
}
#board { width: 100%; height: 100%; display: block; touch-action: none; cursor: default; }
#board.can-draw { cursor: crosshair; }
#board.tool-fill { cursor: cell; }
.overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px; text-align: center;
  background: rgba(255, 248, 236, .9); backdrop-filter: blur(3px);
  animation: fade .25s ease;
}
.overlay h2 { font-size: clamp(1.3rem, 3.4vw, 2.1rem); }
.overlay p { margin: 0; color: var(--muted); font-weight: 500; }
.overlay .big-word { font-family: var(--font-head); font-weight: 800; font-size: clamp(2rem, 6vw, 3.4rem); color: var(--red); text-shadow: 3px 3px 0 var(--ink); animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
.choices { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.choices .btn { font-size: 1.25rem; animation: pop .35s cubic-bezier(.2, 1.6, .4, 1) both; }
.choices .btn:nth-child(2) { animation-delay: .07s; --btn-bg: var(--yellow); }
.choices .btn:nth-child(3) { animation-delay: .14s; --btn-bg: var(--green-soft); }
.choices .btn:nth-child(1) { --btn-bg: var(--blue-soft); }
.gain-list { display: flex; flex-direction: column; gap: 6px; width: min(340px, 100%); max-height: 45%; overflow-y: auto; }
.gain-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 5px 10px; font-weight: 600; animation: slide-up .3s ease both; }
.gain-row .g { margin-left: auto; color: var(--green); font-family: var(--font-head); font-weight: 800; }
.gain-row.drawer { background: var(--yellow-soft); }
.waiting-avatar { font-size: 3rem; width: 84px; height: 84px; animation: bob 1.4s ease-in-out infinite; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin-top: 6px; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 110px; }
.podium-col .pn { font-weight: 700; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-col .ps { font-size: .8rem; color: var(--muted); font-weight: 600; }
.podium-block { width: 100%; border: var(--border); border-radius: 12px 12px 0 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; font-size: 1.8rem; animation: grow .6s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: bottom; }
.podium-col.p1 .podium-block { height: 110px; background: var(--yellow); animation-delay: .4s; }
.podium-col.p2 .podium-block { height: 80px; background: #D9DDE6; animation-delay: .2s; }
.podium-col.p3 .podium-block { height: 60px; background: #F2B98A; }
.podium-col.p1 .avatar { width: 60px; height: 60px; font-size: 2rem; }
.crown { font-size: 1.6rem; margin-bottom: -10px; animation: wiggle 1.5s ease-in-out infinite; }

.float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.floaty { position: absolute; bottom: 10px; font-size: 2.2rem; animation: float-up 2.2s ease-out forwards; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; padding: 10px 12px; width: 100%; max-width: 900px; box-shadow: var(--shadow-sm); }
.tool-group { display: flex; gap: 6px; align-items: center; }
.tool {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--soft); font-size: 1.2rem;
  transition: transform .1s, background .15s;
}
.tool:hover { background: #fff; }
.tool.active { background: var(--yellow); box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }
.tool.danger:hover { background: #FFE3E6; }
.size-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--soft); }
.size-btn i { display: block; border-radius: 50%; background: var(--ink); }
.size-btn.active { background: var(--yellow); }
.palette { display: grid; grid-template-columns: repeat(11, 24px); gap: 4px; }
.swatch { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--ink); padding: 0; transition: transform .1s; }
.swatch:hover { transform: scale(1.15); }
.swatch.active { transform: scale(1.2); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); z-index: 1; }

.react-bar { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); }
.react-btn { width: 46px; height: 46px; border: var(--border); border-radius: 50%; background: var(--card); font-size: 1.4rem; box-shadow: 0 3px 0 var(--ink); transition: transform .1s; }
.react-btn:hover { transform: scale(1.08); }
.react-btn:disabled { opacity: .45; transform: none; cursor: default; }

/* Chat */
.chat-panel { display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 10px; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; overscroll-behavior: contain; }
.msg { display: flex; gap: 8px; align-items: flex-start; padding: 4px 6px; border-radius: 10px; font-size: .93rem; line-height: 1.4; word-break: break-word; animation: slide-up .2s ease; }
.msg .avatar { margin-top: 1px; }
.msg b { font-weight: 700; margin-right: 4px; }
.msg.mine { background: var(--blue-soft); }
.msg.secret { background: var(--purple-soft); }
.msg.secret::after { content: '🔒'; font-size: .7rem; margin-left: auto; opacity: .6; }
.note { align-self: center; text-align: center; font-size: .85rem; font-weight: 600; padding: 4px 12px; border-radius: 99px; margin: 2px 0; animation: slide-up .2s ease; max-width: 100%; }
.note.sys, .note.join, .note.leave { color: var(--muted); }
.note.join { color: var(--blue); }
.note.info { background: var(--blue-soft); }
.note.good { background: var(--green-soft); color: #0E7A54; border: 2px solid var(--green); }
.note.close { background: var(--yellow-soft); color: #8A5A00; border: 2px dashed #E0A800; }
.note.warn { background: #FFE3E6; color: var(--red-d); }
.note.answer { background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { padding: .6em .8em; }
.chat-form .btn { flex: none; width: 48px; padding: 0; font-size: 1.15rem; }
.chat-form.guessing input { border-color: var(--red); }

/* ---------- Toast & Modal ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); animation: toast-in .25s ease; max-width: 480px; text-align: center; }
.toast.error { background: var(--red-d); }
.toast.ok { background: #0E7A54; }
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(31, 26, 61, .45); display: grid; place-items: center; padding: 16px; animation: fade .2s ease; }
.modal-box { width: min(380px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 12px; text-align: center; animation: pop .3s cubic-bezier(.2, 1.5, .4, 1); }
.modal-box .avatar { margin: 0 auto; width: 70px; height: 70px; font-size: 2.4rem; }
.modal-box h3 { font-size: 1.4rem; }
.modal-box p { margin: 0; color: var(--muted); }

/* ---------- Animations ---------- */
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes glow { 0%, 100% { box-shadow: 0 4px 0 var(--ink); } 50% { box-shadow: 0 4px 0 var(--ink), 0 0 0 6px rgba(61, 123, 255, .35); } }
@keyframes float-up { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-20px) scale(1.1); } 100% { transform: translateY(-320px) scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .room-layout { grid-template-columns: 200px minmax(0, 1fr) 280px; gap: 12px; padding: 12px; }
  .palette { grid-template-columns: repeat(11, 22px); }
  .swatch { width: 22px; height: 22px; }
}
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .games-grid { grid-template-columns: repeat(2, 1fr); }
  #screen-room.active { height: auto; min-height: 100dvh; }
  .room-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "stage" "players" "chat";
    padding: 10px; gap: 10px;
  }
  .stage { grid-area: stage; }
  .players-panel { grid-area: players; padding: 10px; }
  .chat-panel { grid-area: chat; height: 300px; padding: 10px; }
  .players-panel .panel-title { font-size: 1rem; }
  .player-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
  .player { flex: none; min-width: 150px; }
  .board-wrap { max-width: 100%; }
  .room-bar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; position: sticky; top: 0; z-index: 10; }
  .word-box { order: 5; flex-basis: 100%; }
  .room-bar-right { margin-left: auto; }
  .chat-title { display: none; }
}
@media (max-width: 600px) {
  .howto-grid { grid-template-columns: 1fr; gap: 24px; }
  .section-title { font-size: 1.6rem; margin-top: 36px; }
  .logo { font-size: 1.6rem; }
  .online-pill { display: none; }
  .profile-card { padding: 18px; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid .field:last-child { grid-column: span 2; }
  .theme-grid { grid-template-columns: 1fr 1fr; }
  .room-code { font-size: 2rem; }
  .invite-actions, .invite-actions .btn { width: 100%; }
  .toolbar { gap: 8px; padding: 8px; }
  .tool { width: 38px; height: 38px; font-size: 1.05rem; }
  .size-btn { width: 32px; height: 32px; }
  .palette { grid-template-columns: repeat(11, 1fr); width: 100%; }
  .swatch { width: 100%; height: 24px; }
  .mask-ch { width: 17px; height: 26px; font-size: 1.15rem; }
  .mask { gap: 10px; }
  .word-box .the-word { font-size: 1.35rem; }
  .podium-col { width: 84px; }
  .overlay { padding: 12px; gap: 10px; }
  .gain-list { max-height: 38%; }
}

/* ---------- PWA / màn hình có tai thỏ ---------- */
.topnav { padding-top: max(18px, env(safe-area-inset-top)); }
.room-bar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.footer { padding-bottom: max(32px, env(safe-area-inset-bottom)); }
.room-layout { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.toasts { bottom: max(24px, env(safe-area-inset-bottom)); }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; user-select: none; -webkit-user-select: none; }
  input, textarea { user-select: text; -webkit-user-select: text; }
}
.ios-steps { text-align: left; margin: 4px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-weight: 500; }
.ios-steps b { font-weight: 700; }
