/* =========================================================
   Dungeon Mayhem Online — stylesheet
   ========================================================= */

:root {
  --bg0: #110c22;
  --bg1: #1b1436;
  --bg2: #2a1f50;
  --panel: rgba(30, 22, 58, 0.86);
  --panel-solid: #221a44;
  --panel-border: rgba(255, 214, 140, 0.16);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5eeff;
  --muted: #b3a6d4;
  --faint: #7f73a3;
  --gold: #ffd06a;
  --gold-deep: #f0a32a;
  --parchment: #fbf1dc;
  --parchment-deep: #efdcb4;
  --ink: #2c1d10;

  --c-attack: #e2373d;
  --c-shield: #2f7fe8;
  --c-heal: #1fb866;
  --c-play: #f5b021;
  --c-draw: #8d5bdc;
  --c-power: #ff7b2e;

  --good: #3ddc84;
  --bad: #ff5d63;
  --info: #67b7ff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  --font-display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 310px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 600; }

#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(140, 80, 255, 0.28), transparent 60%),
    radial-gradient(900px 600px at 110% 20%, rgba(255, 110, 60, 0.16), transparent 60%),
    radial-gradient(1000px 800px at 50% 120%, rgba(40, 180, 160, 0.16), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 70%);
}
#bg::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 200, 120, 0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(200, 160, 255, 0.45) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.35) 0 1px, transparent 2px);
  background-size: 260px 260px, 340px 340px, 420px 420px;
  animation: drift 60s linear infinite;
}
@keyframes drift { to { background-position: 260px -520px, -340px 680px, 420px -840px; } }

/* ---------- generic UI ---------- */

.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

.btn {
  --b: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--b);
  background: rgba(255, 255, 255, 0.07);
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, background 0.15s, box-shadow 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible, .hero-tile:focus-visible, .card:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #ffd978, #f4a12a);
  color: #3a2205;
  border-color: #ffe7a6;
  box-shadow: 0 6px 18px rgba(245, 165, 40, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffe08e, #f7ac3c); }
.btn-secondary {
  background: linear-gradient(180deg, #6d4bd8, #4d2fb0);
  border-color: rgba(190, 160, 255, 0.5);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.btn-secondary:hover { background: linear-gradient(180deg, #7a59e2, #5838bf); }
.btn-danger { background: linear-gradient(180deg, #e65159, #b72e36); border-color: rgba(255, 160, 160, 0.4); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.btn-lg { padding: 14px 22px; font-size: 17px; border-radius: 14px; }
.btn-sm { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.icon-btn { padding: 6px 10px; font-size: 17px; position: relative; }

input[type='text'], input:not([type]), select {
  background: rgba(10, 6, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 208, 106, 0.18); }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; color: var(--muted); font-size: 13.5px; }
.field input { font-size: 16px; color: var(--text); }

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.topbar-right { display: flex; gap: 4px; }

/* ---------- toasts / connection ---------- */

.toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 460px);
}
.toast {
  background: rgba(24, 16, 48, 0.96);
  border: 1px solid var(--panel-border);
  border-left: 4px solid var(--info);
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-weight: 700;
  animation: toastIn 0.25s ease-out;
  pointer-events: auto;
}
.toast.error { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }
.toast.out { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(0.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

.conn {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #8a2a33;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 800;
  z-index: 300;
  box-shadow: var(--shadow);
}

/* =========================================================
   HOME
   ========================================================= */

.home-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 28px 16px 22px;
}
.logo { text-align: center; }
.logo-dragon { font-size: 64px; filter: drop-shadow(0 8px 20px rgba(255, 100, 40, 0.5)); animation: bob 3.5s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
.logo h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(44px, 10vw, 76px);
  line-height: 0.86;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff3c4 10%, #ffc24a 55%, #e0731e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #5a2a0b) drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}
.logo h1 span { font-size: 1.18em; }
.tagline { color: var(--muted); font-weight: 700; margin: 10px 0 0; }

.home-panel {
  width: min(100%, 420px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 13px; font-weight: 700; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-weight: 800;
  text-align: center;
  font-size: 18px;
}
.home-heroes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; }
.home-heroes .avatar { width: 44px; height: 44px; font-size: 24px; animation: pop 0.5s backwards; }
.fineprint { color: var(--faint); font-size: 12px; text-align: center; margin: 0; }

/* =========================================================
   AVATARS
   ========================================================= */

.avatar {
  --hero: #888;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--hero) 60%, white), var(--hero) 60%, color-mix(in srgb, var(--hero) 55%, black));
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45), inset 0 -3px 6px rgba(0, 0, 0, 0.25);
}
.avatar.empty { background: rgba(255, 255, 255, 0.06); border-style: dashed; border-color: rgba(255, 255, 255, 0.3); color: var(--faint); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

/* =========================================================
   LOBBY
   ========================================================= */

.room-code {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 6px 8px 6px 14px;
  border-radius: 14px;
}
.room-code .label { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.room-code strong { font-family: var(--font-display); font-size: 26px; letter-spacing: 0.18em; color: var(--gold); line-height: 1; }

.lobby-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr 290px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    'players heroes chat'
    'settings heroes chat';
  gap: 16px;
  padding: 4px 16px 16px;
  min-height: 0;
}
.lobby-grid > .panel { padding: 16px; min-height: 0; }
.lobby-players { grid-area: players; display: flex; flex-direction: column; gap: 12px; }
.lobby-heroes { grid-area: heroes; }
.lobby-settings { grid-area: settings; align-self: start; }
.lobby-chat { grid-area: chat; }

.seat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: pop 0.25s backwards;
}
.seat.me { border-color: rgba(255, 208, 106, 0.45); background: rgba(255, 208, 106, 0.07); }
.seat .avatar { width: 40px; height: 40px; font-size: 21px; }
.seat-info { flex: 1; min-width: 0; }
.seat-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-hero { font-size: 13px; color: var(--muted); }
.seat .tag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.seat .tag.host { background: rgba(255, 208, 106, 0.18); color: var(--gold); }
.seat .tag.off { background: rgba(255, 93, 99, 0.18); color: var(--bad); }
.seat .kick { padding: 4px 8px; }
.seat.spectators { flex-wrap: wrap; font-size: 13px; color: var(--muted); }

.lobby-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.lobby-actions .btn-primary { flex: 1; }
.hint { width: 100%; margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }

.settings { display: flex; flex-direction: column; gap: 10px; }
.settings h3 { margin: 0; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.toggle input { appearance: none; width: 40px; height: 22px; border-radius: 11px; background: rgba(255, 255, 255, 0.15); position: relative; transition: background 0.15s; cursor: pointer; flex: none; padding: 0; border: 0; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle input:checked { background: var(--c-heal); }
.toggle input:checked::after { transform: translateX(18px); }
.toggle input:disabled { opacity: 0.5; cursor: default; }
.toggle small { color: var(--faint); font-weight: 600; }
.settings select { padding: 7px 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 14px; }

.lobby-heroes { display: flex; flex-direction: column; min-height: 0; }
.heroes-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.heroes-head h2 { margin: 0; }
.hero-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.hero-tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
}
.hero-tab.active { background: rgba(255, 208, 106, 0.16); color: var(--gold); border-color: rgba(255, 208, 106, 0.4); }

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 2px;
  align-content: start;
}
.hero-tile {
  --hero: #888;
  position: relative;
  text-align: left;
  border-radius: 14px;
  padding: 12px;
  border: 2px solid transparent;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--hero) 32%, transparent), rgba(255, 255, 255, 0.03) 70%),
    rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: pop 0.3s backwards;
}
.hero-tile:hover:not(.taken) { transform: translateY(-3px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 10px 22px rgba(0, 0, 0, 0.35); }
.hero-tile.mine { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 208, 106, 0.2), 0 10px 22px rgba(0, 0, 0, 0.35); }
.hero-tile.taken { opacity: 0.55; cursor: not-allowed; }
.hero-tile.disabled { opacity: 0.35; filter: grayscale(0.7); cursor: not-allowed; }
/* The hero's portrait card, faded in behind the tile's text. */
.hero-tile.has-art { overflow: hidden; }
.hero-tile.has-art::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 55%;
  background: var(--art) center 78% / cover no-repeat;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 75%);
  mask-image: linear-gradient(to right, transparent, #000 75%);
  opacity: 0.28;
  pointer-events: none;
  transition: opacity 0.2s;
}
.hero-tile.has-art:hover::before, .hero-tile.has-art.mine::before { opacity: 0.45; }
.hero-tile > * { position: relative; }
.hero-tile .ht-top { display: flex; align-items: center; gap: 10px; }
.hero-tile .ht-name { font-family: var(--font-display); font-size: 17px; font-weight: 800; line-height: 1.05; }
.hero-tile .ht-class { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.hero-tile .ht-desc { font-size: 13px; color: #ddd3f5; line-height: 1.35; }
.hero-tile .ht-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; font-size: 12px; color: var(--muted); font-weight: 700; }
.hero-tile .ht-owner { font-size: 12px; font-weight: 800; color: var(--gold); }
.hero-tile .ht-owner.other { color: var(--muted); }
.stars { color: var(--gold); letter-spacing: 1px; }
.stars.off { color: rgba(255, 255, 255, 0.18); }
.link-btn { background: none; border: 0; color: var(--info); font-weight: 800; font-size: 12.5px; padding: 2px 0; }
.link-btn:hover { text-decoration: underline; }
.set-chip { font-size: 10.5px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.3); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.random-tile { --hero: #6b5ca5; justify-content: center; align-items: center; text-align: center; min-height: 120px; }
.random-tile .avatar { font-size: 24px; }

/* chat */
.chat-box { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 6px; font-size: 14px; min-height: 120px; padding-right: 4px; }
.chat-msg { word-wrap: break-word; }
.chat-msg b { color: var(--gold); }
.chat-msg.system { color: var(--faint); font-style: italic; font-size: 13px; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; padding: 8px 12px; }

/* =========================================================
   CARDS  (all sizes scale from --cs)
   ========================================================= */

.card {
  --hero: #777;
  --cs: 10px;
  font-size: var(--cs);
  width: 11.6em;
  height: 16.4em;
  flex: none;
  position: relative;
  border-radius: 1.15em;
  padding: 0.45em;
  background: linear-gradient(165deg, color-mix(in srgb, var(--hero) 75%, white 25%), var(--hero) 45%, color-mix(in srgb, var(--hero) 55%, black));
  box-shadow: 0 0.5em 1.4em rgba(0, 0, 0, 0.45), inset 0 0 0 0.18em rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1.2), box-shadow 0.18s, filter 0.18s;
}
.card .c-name {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-deep));
  border-radius: 0.7em;
  padding: 0.35em 0.5em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.22em;
  line-height: 1.02;
  text-align: center;
  min-height: 2.3em;
  display: grid;
  place-items: center;
  box-shadow: 0 0.15em 0 rgba(0, 0, 0, 0.2);
}
.card .c-body { flex: 1; position: relative; min-height: 0; }
.card .c-syms { position: relative; z-index: 1; display: flex; flex-direction: column; flex-wrap: wrap; gap: 0.28em; max-height: 100%; align-content: flex-start; }
.card .c-art {
  position: absolute;
  right: 0.1em;
  bottom: 0;
  font-size: 4.6em;
  line-height: 1;
  filter: drop-shadow(0 0.08em 0.12em rgba(0, 0, 0, 0.45));
  opacity: 0.95;
  pointer-events: none;
}
.card .c-text {
  background: linear-gradient(180deg, var(--parchment), var(--parchment-deep));
  border-radius: 0.7em;
  padding: 0.4em 0.55em;
  font-size: 0.98em;
  line-height: 1.2;
  font-weight: 700;
  box-shadow: 0 -0.12em 0 rgba(0, 0, 0, 0.12) inset;
  max-height: 7.4em;
  overflow: hidden;
}
.card .c-text .pw { color: #b33b0c; font-weight: 900; }
.card .c-foot {
  text-align: center;
  font-size: 0.78em;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
  margin-top: -0.1em;
}
.card.no-text .c-body { min-height: 7em; }

.sym {
  width: 2.75em;
  height: 2.75em;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 0.2em solid #fff;
  box-shadow: 0 0.15em 0.3em rgba(0, 0, 0, 0.45), inset 0 -0.25em 0 rgba(0, 0, 0, 0.18);
  flex: none;
}
.sym svg { width: 1.6em; height: 1.6em; fill: #fff; filter: drop-shadow(0 0.05em 0 rgba(0, 0, 0, 0.3)); }
.sym-attack { background: var(--c-attack); }
.sym-shield { background: var(--c-shield); }
.sym-heal { background: var(--c-heal); }
.sym-play { background: var(--c-play); }
.sym-draw { background: var(--c-draw); }
.sym-power { background: var(--c-power); }
.sym-paw { background: #8b5a2b; }

/* ---- cards with real art ---- */
.card.img-card {
  padding: 0;
  gap: 0;
  height: 17.4em;
  background: #0c0b10;
  border-radius: 0.75em;
  overflow: hidden;
  box-shadow: 0 0.5em 1.4em rgba(0, 0, 0, 0.5), 0 0 0 0.08em rgba(255, 255, 255, 0.12);
}
.card.img-card > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}
/* Vietnamese name + effect strip laid over the printed English text. */
.card.img-card .c-vi {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 19%;
  padding: 1.5em 0.6em 0.75em;
  background: linear-gradient(to top, rgba(12, 9, 14, 0.97) 0, rgba(12, 9, 14, 0.95) calc(100% - 1.4em), rgba(12, 9, 14, 0));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.25em;
  text-align: center;
  color: #f6efe2;
  pointer-events: none;
}
.card.img-card .c-vi.tall { min-height: 31%; }
.card.img-card .vi-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.22em;
  line-height: 1.02;
  color: #fff3dc;
  text-shadow: 0 0.08em 0 rgba(0, 0, 0, 0.7);
}
.card.img-card .c-vi.pw .vi-name { color: #ffd36e; }
.card.img-card .vi-text { font-size: 0.86em; line-height: 1.2; font-weight: 700; color: #e9e1f5; }
/* Pure mode: the printed paw icon is crossed out. */
.paw-off {
  position: absolute;
  left: 13.8%;
  width: 3.4em;
  height: 3.4em;
  margin: -1.7em 0 0 -1.7em;
  border-radius: 50%;
  border: 0.32em solid #ff4d57;
  background: linear-gradient(45deg, transparent 44%, #ff4d57 44% 56%, transparent 56%), rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0.4em rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.card.img-card .c-vi.off-rule .vi-text { color: #ffd0d3; }
/* Too small to read: show the printed card instead. */
.card.mini .c-vi, .field-card .c-vi, .card.no-vi .c-vi { display: none; }

.card-back.img {
  background-size: cover;
  background-position: center;
  border: 0;
  border-radius: 0.75em;
}
.card-back.img::after { content: none; }

/* Damage tokens on the printed shield icons of a card in play. */
.dmg-token {
  position: absolute;
  left: 13.8%;
  width: 3.3em;
  height: 3.3em;
  margin: -1.65em 0 0 -1.65em;
  border-radius: 50%;
  z-index: 2;
  background: radial-gradient(circle at 35% 30%, #ff9a8f, #d32f2f 55%, #7a0b0b);
  border: 0.22em solid #2a0505;
  box-shadow: 0 0.2em 0.35em rgba(0, 0, 0, 0.6), inset 0 -0.3em 0.4em rgba(0, 0, 0, 0.35);
  animation: tokenDrop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.dmg-token::after {
  content: '';
  position: absolute;
  inset: 22%;
  background:
    linear-gradient(45deg, transparent 42%, #fff 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, #fff 42% 58%, transparent 58%);
  opacity: 0.9;
}
.dmg-token.img {
  background-color: transparent;
  background-size: cover;
  border: 0;
  box-shadow: none;
  filter: drop-shadow(0 0.15em 0.25em rgba(0, 0, 0, 0.7));
}
.dmg-token.img::after { content: none; }
@keyframes tokenDrop { from { transform: translateY(-1.5em) scale(1.6); opacity: 0; } }

/* Hit point tracker card with the hero's face token on the current HP. */
.hp-card {
  position: relative;
  flex: none;
  width: 64px;
  aspect-ratio: 372 / 580;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.hp-card:hover { transform: translateY(-2px); }
.hp-token {
  position: absolute;
  width: 40%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.7), 0 0 0 1.5px rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
.pp.dead .hp-token { filter: grayscale(1); }

.portrait-card { display: block; border-radius: 12px; box-shadow: var(--shadow); }
.portrait-card.winner { width: 170px; margin: 6px auto 12px; animation: pop 0.5s; }
.hero-sheet { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin: 6px 0 16px; }
.hero-sheet figure { margin: 0; text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.hero-sheet img { width: 150px; border-radius: 10px; display: block; margin-bottom: 4px; box-shadow: var(--shadow); }

/* little stacks for hand / deck / discard in player panels */
.piles { display: flex; align-items: flex-end; gap: 12px; }
.pile {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-weight: 800;
  font-size: 12.5px;
}
.pile b { min-width: 14px; text-align: left; }
button.pile:hover b { color: var(--text); }
button.pile:hover .card { transform: translateY(-2px); }
.card.mini, .card-back.mini { --cs: 2.55px; flex: none; }
.card.mini { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.card.mini:not(.img-card) > * { visibility: hidden; }
.card-back.mini { height: 17.4em; border-width: 0.6em; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.card-back.mini::after { font-size: 2.6em; }
.card-back.stacked { box-shadow: 1.5px 1.5px 0 #1b1530, 3px 3px 0 rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.6); }
.pile-fan { display: flex; }
.pile-fan .card-back + .card-back { margin-left: -20px; }
.pile-fan .card-back:nth-child(1) { transform: rotate(-8deg); }
.pile-fan .card-back:nth-child(3) { transform: rotate(8deg); }
.pile-empty { width: 30px; height: 44px; border: 1.5px dashed rgba(255, 255, 255, 0.2); border-radius: 5px; }
.pile-deck { font-size: 15px; align-self: center; }

.avatar.art {
  background-size: cover;
  background-position: center;
  background-color: var(--hero);
}

.card-back {
  --cs: 10px;
  font-size: var(--cs);
  width: 11.6em;
  height: 16.4em;
  border-radius: 1.15em;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 0.6em, transparent 0.6em 1.2em),
    radial-gradient(circle at 50% 45%, #6a43c8, #2d1a63 70%);
  border: 0.35em solid #f3dfb2;
  box-shadow: 0 0.5em 1.2em rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  font-size: var(--cs);
}
.card-back::after { content: '🐉'; font-size: 4.2em; filter: drop-shadow(0 0.1em 0.2em rgba(0, 0, 0, 0.5)); }

/* field (in-play) mini cards */
.field-card { position: relative; }
.field-card .card { --cs: 5.6px; }
.field-card .shield-left {
  position: absolute;
  bottom: -6px;
  right: -6px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--c-shield);
  border: 2px solid #fff;
  color: #fff;
  border-radius: 12px;
  padding: 1px 7px 1px 4px;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.field-card .shield-left svg { width: 14px; height: 14px; fill: #fff; }
.field-card .shield-left.hurt { background: #c46a1b; }
.field-card.targetable .card { outline: 3px solid var(--gold); outline-offset: 2px; animation: pulseGlow 1.1s ease-in-out infinite; cursor: pointer; }
.field-card.targetable:hover .card { transform: translateY(-3px) scale(1.06); }
.field-card .owner-dot { position: absolute; top: -5px; left: -5px; font-size: 13px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.field-card .copy-dot { left: auto; right: -5px; }

/* =========================================================
   GAME TABLE
   ========================================================= */

.game-topbar { padding-bottom: 4px; }
.turn-banner {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.turn-banner .you { color: var(--gold); }
.turn-banner .timer {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}
.turn-banner .timer.low { background: rgba(255, 93, 99, 0.25); color: #ffb3b6; }
.mode-chip {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 10px;
  background: rgba(255, 123, 46, 0.18);
  color: #ffc49b;
  border: 1px solid rgba(255, 123, 46, 0.35);
}
.mode-desc { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hi-mode { font-size: 12.5px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 123, 46, 0.12); border-left: 3px solid var(--c-power); color: #ffd9bf; }

#screen-game.active { height: 100vh; height: 100dvh; overflow: hidden; }
.table { flex: 1; display: flex; min-height: 0; position: relative; }
.table-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 6px 14px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  position: relative;
}

.opponents { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 12px; }

/* player panel */
.pp {
  --hero: #888;
  position: relative;
  width: 232px;
  padding: 10px 12px 12px;
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--hero) 30%, transparent), transparent 60%),
    var(--panel);
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s, opacity 0.3s;
}
.pp.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 208, 106, 0.16), 0 0 30px rgba(255, 190, 80, 0.3), var(--shadow);
}
.pp.active::before {
  content: 'Đang đánh';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #ffd978, #f4a12a);
  color: #3a2205;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.pp.choosing::before { content: 'Đang chọn…'; background: linear-gradient(180deg, #b39cff, #7a57e6); color: #fff; }
.pp.dead { opacity: 0.5; filter: grayscale(0.85); }
.pp.dead::after {
  content: '💀';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 54px;
  pointer-events: none;
  opacity: 0.85;
}
.pp.targetable { cursor: pointer; border-color: var(--bad); animation: pulseRed 1s ease-in-out infinite; }
.pp.targetable.friendly { border-color: var(--good); animation: pulseGreen 1s ease-in-out infinite; }
.pp.targetable:hover { transform: translateY(-3px) scale(1.02); }
@keyframes pulseRed { 50% { box-shadow: 0 0 0 5px rgba(255, 93, 99, 0.35), 0 0 26px rgba(255, 93, 99, 0.4); } }
@keyframes pulseGreen { 50% { box-shadow: 0 0 0 5px rgba(61, 220, 132, 0.35), 0 0 26px rgba(61, 220, 132, 0.4); } }
@keyframes pulseGlow { 50% { box-shadow: 0 0 0 4px rgba(255, 208, 106, 0.4), 0 0 22px rgba(255, 208, 106, 0.6); } }
.pp.hit { animation: shake 0.45s; }
.pp.healed { animation: healGlow 0.8s; }
@keyframes shake {
  20% { transform: translateX(-7px) rotate(-1deg); }
  40% { transform: translateX(6px) rotate(1deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes healGlow { 40% { box-shadow: 0 0 0 5px rgba(61, 220, 132, 0.45), 0 0 34px rgba(61, 220, 132, 0.55); } }

.pp-main { display: flex; gap: 10px; align-items: stretch; }
.pp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pp-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.pp-hero { font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-hp { display: flex; align-items: center; gap: 2px; font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1; margin-top: 2px; }
.pp-hp svg { width: 22px; height: 22px; fill: var(--c-attack); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4)); }
.pp-hp.low span { color: #ff8b8f; }
.pp > .piles { margin-top: 8px; }

.pp-status { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.status-chip { font-size: 11.5px; font-weight: 800; padding: 2px 7px; border-radius: 8px; background: rgba(160, 107, 255, 0.25); color: #e2d2ff; }
.status-chip.warn { background: rgba(255, 93, 99, 0.22); color: #ffc2c4; }
.status-chip.off { background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.pp-field { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; min-height: 0; }
.pp-field:empty { display: none; }

.emote-pop {
  position: fixed;
  font-size: 44px;
  z-index: 60;
  pointer-events: none;
  animation: emotePop 2.2s ease-out forwards;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
@keyframes emotePop {
  0% { transform: translate(-50%, 0) scale(0.3); opacity: 0; }
  15% { transform: translate(-50%, -20px) scale(1.25); opacity: 1; }
  30% { transform: translate(-50%, -26px) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -70px) scale(1); opacity: 0; }
}

/* center */
.center-stage { display: grid; place-items: center; min-height: 0; overflow: hidden; position: relative; }
.stage { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.stage .card { --cs: clamp(6.5px, 1.15vh, 11.5px); cursor: zoom-in; }
.stage-card.old { opacity: 0.72; }
.stage-card { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: stageIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.25); }
.stage-card .by { font-weight: 800; font-size: 14px; color: var(--muted); background: rgba(0, 0, 0, 0.3); padding: 3px 12px; border-radius: 12px; }
@keyframes stageIn { from { transform: translateY(40px) scale(0.6) rotate(-6deg); opacity: 0; } }
.stage-empty { color: var(--faint); font-weight: 700; text-align: center; font-size: 14px; }
.stage-empty .big { font-size: 40px; display: block; opacity: 0.6; }

/* prompt */
.prompt {
  justify-self: center;
  width: min(100%, 760px);
  background: linear-gradient(180deg, rgba(60, 40, 120, 0.96), rgba(36, 24, 74, 0.96));
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 0 0 4px rgba(255, 208, 106, 0.12), var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: promptIn 0.3s ease-out;
  z-index: 5;
}
.prompt.waiting { border-color: rgba(255, 255, 255, 0.15); background: rgba(30, 22, 58, 0.9); box-shadow: var(--shadow); }
.prompt .dots i { font-style: normal; animation: dotBlink 1.2s infinite; }
.prompt .dots i:nth-child(2) { animation-delay: 0.2s; }
.prompt .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBlink { 0%, 60%, 100% { opacity: 0.2; } 30% { opacity: 1; } }
@keyframes promptIn { from { transform: translateY(12px); opacity: 0; } }
.prompt-title { font-family: var(--font-display); font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.prompt-sub { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: -6px; }
.prompt-options { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-options .btn { padding: 8px 14px; }
.prompt-options .btn .avatar { width: 24px; height: 24px; font-size: 13px; border-width: 1px; }
.prompt-cards { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 10px; }
.prompt-cards .card { --cs: 8.5px; cursor: pointer; }
.prompt-cards .card:hover { transform: translateY(-6px); }

/* me + hand */
.bottom-row { display: flex; align-items: flex-end; gap: 14px; min-width: 0; }
.me-area { flex: none; }
.me-area .pp { width: 250px; }
.me-area .stage-empty { width: 200px; }

.hand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  min-height: 222px;
  padding: 40px 12px 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
/* Auto margins centre the cards while still letting an overflowing hand scroll from its start. */
.hand::before, .hand::after { content: ''; margin: auto; }
.hand .card { --cs: 10.2px; margin: 0 4px; cursor: default; }
.hand.many .card { margin: 0 -22px; }
.hand .card:first-child { margin-left: 0; }
.hand .card:last-child { margin-right: 0; }
.hand .card.playable { cursor: pointer; }
.hand .card.playable::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 1.4em;
  border: 3px solid var(--gold);
  opacity: 0.85;
  animation: pulseGlow 1.4s ease-in-out infinite;
  pointer-events: none;
}
.hand .card:hover { transform: translateY(-14px) scale(1.06); z-index: 3; }
.hand .card.selected { transform: translateY(-26px) scale(1.12); z-index: 4; box-shadow: 0 0 0 3px #fff, 0 0 30px rgba(255, 208, 106, 0.7), 0 1em 2em rgba(0, 0, 0, 0.5); }
.hand .card.enter { animation: dealIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards; }
.hand .card.dim { filter: saturate(0.6) brightness(0.8); }
@keyframes dealIn { from { transform: translateY(80px) rotate(8deg) scale(0.7); opacity: 0; } }
.hand-empty { color: var(--faint); font-weight: 700; align-self: center; }

.emote-bar { position: relative; }
.emote-bar .toggle-emotes { font-size: 17px; padding: 6px 10px; background: transparent; border: 0; border-radius: 10px; }
.emote-bar .toggle-emotes:hover { background: rgba(255, 255, 255, 0.07); }
.emote-bar .emotes {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  display: flex;
  gap: 2px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
  animation: pop 0.15s;
}
.emote-bar .emotes button { font-size: 22px; background: none; border: 0; padding: 4px; border-radius: 8px; line-height: 1; }
.emote-bar .emotes button:hover { background: rgba(255, 255, 255, 0.1); transform: scale(1.15); }

/* sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--panel-border);
  min-height: 0;
}
.side-tabs { display: flex; align-items: center; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.side-tab { flex: 1; background: none; border: 0; padding: 8px 4px; border-radius: 10px; font-weight: 800; color: var(--muted); font-size: 13px; white-space: nowrap; }
.side-tab.active { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.side-close { display: none; }
.side-pane { display: none; flex: 1; min-height: 0; padding: 10px 12px 12px; }
.side-pane.active { display: flex; flex-direction: column; }
.game-log { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; padding-right: 4px; }
.log-line { padding: 3px 0 3px 8px; border-left: 3px solid transparent; animation: fadeIn 0.3s; }
.log-line.turn { margin-top: 8px; border-left-color: var(--gold); font-weight: 800; color: var(--gold); }
.log-line .lp { font-weight: 800; color: var(--pc, var(--text)); }
.log-line .lc { font-weight: 800; color: #ffe3a8; border-bottom: 1px dotted rgba(255, 227, 168, 0.5); cursor: help; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(6px); } }

/* "Nhân vật" tab and deck viewer: hero summary */
.hero-pane { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.hi-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.hi-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px 3px 3px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
}
.hi-pick:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.hi-pick.active { color: var(--gold); border-color: rgba(255, 208, 106, 0.55); background: rgba(255, 208, 106, 0.12); }
.hi-pick.dead { opacity: 0.5; }
.hi-pick .avatar { width: 26px; height: 26px; font-size: 14px; border-width: 1px; }
.hi-pick span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 108px; }

.hero-info { display: flex; flex-direction: column; gap: 10px; }
.hi-head { display: flex; gap: 12px; align-items: center; }
.hi-portrait { width: 84px; flex: none; border-radius: 8px; }
.hi-name { font-family: var(--font-display); font-size: 20px; font-weight: 800; line-height: 1.05; }
.hi-cls { font-size: 13px; font-weight: 800; color: color-mix(in srgb, var(--hero) 45%, white); }
.hi-set { font-size: 12px; font-weight: 700; color: var(--muted); }
.hi-desc { margin: 0; font-size: 13.5px; color: #e3daf7; }
.hi-sw { display: grid; gap: 6px; }
.hi-sw > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #ddd3f2;
  background: rgba(61, 220, 132, 0.08);
  border-left: 3px solid var(--good);
}
.hi-sw > .hi-bad { background: rgba(255, 93, 99, 0.08); border-left-color: var(--bad); }
.hi-h { margin: 4px 0 0; font-family: var(--font-display); font-size: 15px; color: var(--gold); }
.hi-powers { display: flex; flex-direction: column; gap: 8px; }
.hi-power {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 7px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  cursor: zoom-in;
}
.hi-power:hover { background: rgba(255, 255, 255, 0.08); }
.hi-power .card.mini { --cs: 4.6px; }
.hi-pw-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12.5px; line-height: 1.3; color: #e3daf7; }
.hi-pw-text b { color: #ffd36e; font-size: 13.5px; }
.hi-pw-text small { color: var(--faint); font-size: 11px; font-weight: 700; }
.hi-cnt { font-size: 11px; font-weight: 900; color: var(--muted); }
.hi-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.hi-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  line-height: 1.1;
}
.hi-stat .sym { font-size: 9px; }
.hi-stat b { font-family: var(--font-display); font-size: 17px; line-height: 1; color: var(--text); }
.hi-tip { margin: 0; font-size: 12.5px; color: var(--muted); }
.hi-deck { align-self: flex-start; }
.hi-live { padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.hi-live-title { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.hi-live-row { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.hi-live-row span { display: inline-flex; align-items: center; gap: 3px; }
.hi-live-row svg { width: 15px; height: 15px; fill: currentColor; }
.hi-live-row b { font-size: 15px; color: var(--text); }

.deck-view { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.deck-view-info { position: sticky; top: 0; }
.deck-view-info .hero-sheet img { width: 130px; }
.deck-view .card-grid { justify-content: flex-start; }
@media (max-width: 860px) {
  .deck-view { grid-template-columns: 1fr; }
  .deck-view-info { position: static; }
}

.lang-btn { font-size: 12.5px; padding: 6px 8px; }

/* fx */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.fx-float {
  position: fixed;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 34px;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55), 0 0 18px rgba(0, 0, 0, 0.6);
  animation: floatUp 1.4s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.fx-float.bad { color: #ff6b70; }
.fx-float.good { color: #6cf0a6; }
.fx-float.info { color: #a8d4ff; font-size: 22px; }
.fx-float.shield { color: #8fc2ff; }
.fx-float.big { font-size: 46px; }
.fx-float.speech {
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 900;
  color: #2c1d10;
  background: var(--parchment);
  padding: 8px 14px;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  text-shadow: none;
  max-width: 260px;
  white-space: normal;
  text-align: center;
  animation-duration: 2.6s;
}
@keyframes floatUp {
  0% { transform: translate(-50%, -30%) scale(0.5); opacity: 0; }
  15% { transform: translate(-50%, -60%) scale(1.25); opacity: 1; }
  30% { transform: translate(-50%, -70%) scale(1); }
  100% { transform: translate(-50%, -190%) scale(1); opacity: 0; }
}
.fx-banner {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 6vw, 56px);
  color: var(--gold);
  text-shadow: 0 4px 0 #5a2a0b, 0 0 40px rgba(255, 180, 60, 0.6);
  animation: banner 1.6s ease-out forwards;
  white-space: nowrap;
}
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; }
  28% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}

/* =========================================================
   MODAL
   ========================================================= */

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 2, 15, 0.7); backdrop-filter: blur(3px); animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.modal-box {
  position: relative;
  width: min(100%, 860px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
  animation: modalIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes modalIn { from { transform: translateY(16px) scale(0.97); opacity: 0; } }
.modal-x { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.06); border: 0; width: 34px; height: 34px; border-radius: 50%; font-size: 15px; z-index: 2; }
.modal-x:hover { background: rgba(255, 255, 255, 0.14); }
.modal h2 { font-family: var(--font-display); margin: 0 0 6px; font-size: 26px; padding-right: 30px; }
.modal h3 { font-family: var(--font-display); font-size: 19px; margin: 18px 0 6px; color: var(--gold); }
.modal p, .modal li { color: #e3daf7; }
.modal ul { padding-left: 20px; margin: 6px 0; }
.modal li { margin: 3px 0; }
.card-grid { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 12px; }
.card-grid .card { --cs: 10px; }
.card-grid .cell { position: relative; }
.card-grid .count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--gold);
  color: #3a2205;
  font-weight: 900;
  border-radius: 12px;
  padding: 0 8px;
  font-size: 14px;
  border: 2px solid #fff;
  z-index: 2;
}
.card-grid.pick .card { cursor: pointer; }
.card-grid.pick .card:hover { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--gold), 0 1em 2em rgba(0, 0, 0, 0.5); }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 10px 0; }
.legend-item { display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 8px 10px; }
.legend-item .sym { --cs: 11px; font-size: 11px; }
.legend-item b { display: block; }
.legend-item span { font-size: 13px; color: var(--muted); }
.zoom-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.zoom-wrap .card { --cs: 16px; }

.gameover { text-align: center; }
.gameover .crown { font-size: 60px; animation: bob 2.5s ease-in-out infinite; }
.gameover .avatar { width: 96px; height: 96px; font-size: 52px; margin: 6px auto 10px; }
.gameover h2 { font-size: 34px; padding: 0; }
.ranking { list-style: none; padding: 0; margin: 16px auto; max-width: 380px; text-align: left; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); margin: 6px 0; font-weight: 700; }
.ranking li .pos { width: 26px; font-family: var(--font-display); font-size: 20px; color: var(--gold); }
.ranking li .avatar { width: 32px; height: 32px; font-size: 17px; margin: 0; border-width: 1px; }
.go-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }

.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 120; pointer-events: none; animation: confetti linear forwards; }
@keyframes confetti { to { transform: translateY(110vh) rotate(720deg); } }

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1280px) {
  .lobby-grid {
    grid-template-columns: 300px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      'players heroes'
      'settings heroes'
      'chat chat';
  }
  .lobby-chat { max-height: 300px; }
}

@media (max-width: 1180px) {
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    transform: translateX(105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
    width: min(88vw, var(--sidebar-w));
  }
  .sidebar.open { transform: none; }
  .side-close { display: inline-flex; flex: none; }
}
@media (min-width: 1181px) {
  #btn-log { display: none; }
}

@media (max-width: 860px) {
  .lobby-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas: 'players' 'heroes' 'settings' 'chat';
    padding: 4px 10px 12px;
    gap: 12px;
  }
  .hero-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: none; }
  .hero-tile .ht-desc { display: none; }
  .room-code .label { display: none; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .hide-sm { display: none; }
  .room-code { padding: 4px 6px 4px 10px; gap: 6px; }
  .room-code strong { font-size: 22px; }
  .topbar-right { gap: 0; }
  .topbar-right .icon-btn, .emote-bar .toggle-emotes { padding: 6px 7px; }
  .topbar { padding: 8px 10px; }
  .turn-banner { font-size: 15px; }
  .table-main { padding: 4px 8px 8px; gap: 6px; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .opponents { gap: 8px; }
  .opponents .pp { width: calc(50% - 4px); padding: 8px 9px 9px; }
  .opponents .pp-main, .me-area .pp-main { gap: 7px; }
  .opponents .hp-card, .me-area .hp-card { width: 46px; }
  .opponents .pp-hp, .me-area .pp-hp { font-size: 20px; }
  .opponents .pp-hp svg { width: 16px; height: 16px; }
  .opponents .pp-name { font-size: 13.5px; }
  .opponents .pp-hero { display: none; }
  .opponents .pp-field .card { --cs: 4.6px; }
  .opponents .pile-deck { display: none; }
  .piles { gap: 6px; }
  .stage .card { --cs: clamp(5.5px, 1vh, 8.4px); }
  .bottom-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .me-area .pp { width: 100%; padding: 8px 10px; display: flex; gap: 10px; align-items: center; }
  .me-area .pp .pp-main { flex: 1; min-width: 0; }
  .me-area .pp .pp-field { margin-top: 0; }
  .me-area .pp-field .card { --cs: 4.6px; }
  .hand { min-height: 150px; padding-top: 24px; }
  .hand .card { --cs: 8.6px; margin: 0 -8px; }
  .hand.many .card { margin: 0 -18px; }
  .hand .card:hover { transform: none; }
  .hand .card.selected { transform: translateY(-16px) scale(1.06); }
  .prompt { padding: 10px 12px; }
  .prompt-title { font-size: 16px; }
  .modal-box { padding: 18px 14px; }
  .card-grid .card { --cs: 8px; }
  .zoom-wrap .card { --cs: 13px; }
  .pp.active::before { font-size: 10px; }
}

@media (max-width: 720px) {
  .opponents.count-1 .pp { width: min(100%, 320px); }
}

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