/* css/style.css - Giao diện game phố xá Việt Nam: HUD nổi trên cảnh, thanh công cụ phía dưới */
:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --outline: #2b2b3a;
  --primary: #f76707;
  --primary-dark: #c2410c;
  --accent: #fab005;
  --success: #2f9e44;
  --danger: #e03131;
  --blue: #1c7ed6;
  --blue-dark: #0b4f8a;
  --panel: #fffdf6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Be Vietnam Pro', 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 14px 12px 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.35) 0, transparent 40%),
    linear-gradient(180deg, #74c0fc 0%, #a5d8ff 45%, #d0ebff 100%);
}

.game-root { width: 100%; max-width: 1120px; }

/* ================= KHUNG GAME ================= */
.game-frame {
  border: 4px solid var(--outline);
  border-radius: 20px;
  overflow: hidden;
  background: #212529;
  box-shadow: 0 8px 0 var(--outline), 0 18px 40px rgba(0, 0, 0, 0.25);
}

.stage { position: relative; line-height: 0; }

#street-canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1000 / 520;
  touch-action: manipulation;
}

/* ================= HUD NỔI ================= */
.hud {
  position: absolute;
  top: 10px;
  line-height: normal;
  pointer-events: none;
  z-index: 2;
}
.hud > * { pointer-events: auto; }

.hud-left {
  left: 10px;
  display: flex;
  align-items: center;
  gap: 0;
}

.avatar-badge {
  padding: 0;
  cursor: pointer;
  overflow: visible;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff9db, #ffd43b 70%);
  border: 3px solid var(--outline);
  box-shadow: 0 3px 0 var(--outline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  position: relative;
  z-index: 2;
  animation: avatar-bob 2.6s ease-in-out infinite;
}

#hud-avatar { width: 100%; height: 100%; border-radius: 50%; display: block; }
.avatar-edit {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--outline);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.avatar-badge:hover .avatar-edit { transform: scale(1.25) rotate(-15deg); }

.account-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 800;
}
.acc-name { color: #1864ab; white-space: nowrap; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.save-status { color: var(--muted); white-space: nowrap; }
.save-status.saved { color: #2b8a3e; }
.save-status.saving, .save-status.pending { color: #e67700; }
.save-status.error { color: #c92a2a; }
.save-status.local { color: #6741d9; }

@keyframes avatar-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-2px) rotate(-4deg); }
}

.profile-box {
  margin-left: -14px;
  padding: 6px 12px 7px 22px;
  background: rgba(255, 253, 246, 0.95);
  border: 2.5px solid var(--outline);
  border-radius: 0 14px 14px 0;
  box-shadow: 0 3px 0 var(--outline);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
}

.profile-name-row { display: flex; align-items: center; gap: 6px; }
.profile-name { font-weight: 900; font-size: 14px; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

.level-pill {
  background: linear-gradient(180deg, #ff922b, #e8590c);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 99px;
  border: 1.5px solid var(--outline);
  white-space: nowrap;
}

.bar {
  position: relative;
  height: 13px;
  background: #343a40;
  border: 1.5px solid var(--outline);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s cubic-bezier(.2,.8,.2,1);
  position: relative;
}
.bar-fill::after {
  content: '';
  position: absolute;
  inset: 0 0 50% 0;
  background: rgba(255,255,255,0.35);
  border-radius: 99px;
}
.bar-fill.exp { background: linear-gradient(90deg, #4dabf7, #15aabf); }
.bar-fill.energy { background: linear-gradient(90deg, #40c057, #94d82d); }

.bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 0 #000, 0 0 2px #000;
}

.hud-right {
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.curr-row { display: flex; gap: 6px; }

.curr-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 4px;
  background: rgba(33, 37, 41, 0.85);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 99px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
  white-space: nowrap;
}
.curr-pill i {
  font-style: normal;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.curr-pill.vnd span { color: #ffe066; }
.curr-pill.xu span { color: #ffc078; }
.curr-pill.rep span { color: #d0bfff; }
.curr-pill.bump { animation: bump 0.35s ease; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px 3px 10px;
  background: rgba(255, 253, 246, 0.95);
  border: 2px solid var(--outline);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}
.stat-row b { margin-left: 2px; }

.icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--outline);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
}
.icon-btn:hover { transform: rotate(-12deg) scale(1.1); }
.icon-btn:active { transform: scale(0.92); }

.buff-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 40%;
  line-height: normal;
  pointer-events: none;
  z-index: 2;
}
.buff-pill {
  background: rgba(33, 37, 41, 0.85);
  color: #ffe066;
  border: 1.5px solid #ffe066;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
  animation: buff-glow 1.6s ease-in-out infinite;
}
@keyframes buff-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(255,224,102,0); }
  50% { box-shadow: 0 0 10px rgba(255,224,102,0.7); }
}

/* ================= THANH CÔNG CỤ DƯỚI ================= */
.toolbar {
  background: linear-gradient(180deg, #1864ab 0%, #0b4f8a 100%);
  border-top: 3px solid var(--outline);
  padding: 6px 8px 8px;
}

.toolbar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.district-bar { display: flex; gap: 4px; flex-shrink: 0; }

.dist-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-weight: 800;
  font-size: 11.5px;
  color: #fff;
  background: linear-gradient(180deg, #4dabf7, #1971c2);
  border: 2px solid var(--outline);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 2px 0 var(--outline);
  transition: transform 0.1s, filter 0.15s;
}
.dist-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.dist-btn:active { transform: translateY(1px); box-shadow: none; }
.dist-btn.active {
  background: linear-gradient(180deg, #ffe066, #f59f00);
  color: var(--ink);
}
.dist-btn.locked {
  background: linear-gradient(180deg, #868e96, #495057);
  color: #dee2e6;
}
.dist-btn small { font-weight: 600; opacity: 0.85; font-size: 10px; }

.loa-ticker {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 99px;
  padding: 3px 10px;
  overflow: hidden;
}
.loa-icon { font-size: 14px; animation: loa-shake 1.2s ease-in-out infinite; }
@keyframes loa-shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg); }
  40% { transform: rotate(10deg); }
}
.ticker-track { flex: 1; overflow: hidden; white-space: nowrap; }
.ticker-track span {
  display: inline-block;
  padding-left: 100%;
  color: #ffe066;
  font-size: 12.5px;
  font-weight: 700;
  animation: marquee 18s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.dock-bar {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}

.dock-btn {
  --c1: #ffa94d;
  --c2: #e8590c;
  position: relative;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 4px 4px;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), 0 3px 0 var(--outline);
  transition: transform 0.12s, filter 0.15s;
}
.dock-btn:hover { transform: translateY(-3px); filter: brightness(1.08); }
.dock-btn:hover .dock-icon { animation: icon-wiggle 0.5s ease; }
.dock-btn:active { transform: translateY(1px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.45); }

.dock-icon { font-size: 24px; line-height: 1.1; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.3)); }
.dock-label {
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(0,0,0,0.55);
  white-space: nowrap;
}

@keyframes icon-wiggle {
  0% { transform: rotate(0) scale(1); }
  30% { transform: rotate(-14deg) scale(1.15); }
  60% { transform: rotate(10deg) scale(1.1); }
  100% { transform: rotate(0) scale(1); }
}

.c-orange { --c1: #ffa94d; --c2: #e8590c; }
.c-blue   { --c1: #74c0fc; --c2: #1971c2; }
.c-green  { --c1: #8ce99a; --c2: #2b8a3e; }
.c-brown  { --c1: #d4a373; --c2: #8b5a2b; }
.c-pink   { --c1: #faa2c1; --c2: #c2255c; }
.c-teal   { --c1: #63e6be; --c2: #0c8599; }
.c-purple { --c1: #b197fc; --c2: #6741d9; }
.c-red    { --c1: #ff8787; --c2: #c92a2a; }

.badge-count {
  position: absolute;
  top: -8px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  border: 2px solid #fff;
  font-size: 11px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-pulse 1s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.hint-line {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #0b4f8a;
}

/* ================= NÚT CHUNG ================= */
.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  border: 2px solid var(--outline);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
  color: #fff;
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.4), 0 2px 0 var(--outline);
  transition: transform 0.1s, filter 0.15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(180deg, #ffa94d, #e8590c); }
.btn-accent { background: linear-gradient(180deg, #ffe066, #f59f00); color: var(--ink); }
.btn-success { background: linear-gradient(180deg, #69db7c, #2b8a3e); }
.btn-danger { background: linear-gradient(180deg, #ff8787, #c92a2a); }
.btn-secondary { background: linear-gradient(180deg, #f1f3f5, #ced4da); color: var(--ink); }

/* ================= MODAL ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 30, 60, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 860px;
  max-height: 86vh;
  background: var(--panel);
  border: 4px solid var(--outline);
  border-radius: 22px;
  box-shadow: 0 10px 0 var(--outline), 0 24px 50px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop-in 0.28s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop-in {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  background: linear-gradient(180deg, #4dabf7, #1864ab);
  border-bottom: 3px solid var(--outline);
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-header h2 {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.modal-close {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff8787, #c92a2a);
  color: #fff;
  border: 2.5px solid var(--outline);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--outline);
  transition: transform 0.15s;
}
.modal-close:hover { transform: rotate(90deg); }

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  background:
    repeating-linear-gradient(45deg, rgba(250,176,5,0.04) 0 12px, transparent 12px 24px),
    var(--panel);
}

.hidden { display: none !important; }

/* ================= NỘI DUNG MODAL ================= */
.info-banner {
  background: #fff3bf;
  border: 2px dashed #f08c00;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.section-heading {
  font-size: 15px;
  font-weight: 900;
  margin: 14px 0 10px;
  color: #c2410c;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 10px;
}

.item-card {
  background: #fff;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  box-shadow: 0 3px 0 rgba(43,43,58,0.85);
  transition: transform 0.12s;
}
.item-card:hover { transform: translateY(-2px); }
.item-card.is-locked { opacity: 0.65; background: #f1f3f5; }
.item-card.is-sale { border-color: #e03131; background: #fff5f5; }
.item-card.is-equipped { border-color: #2f9e44; background: #ebfbee; }

.item-head { display: flex; align-items: center; gap: 10px; }
.item-icon {
  font-size: 28px;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  background: #fff9db;
  border: 2px solid var(--outline);
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-name { font-weight: 800; font-size: 14px; }
.item-meta { font-size: 12px; color: var(--muted); }
.item-desc { font-size: 12.5px; color: #374151; line-height: 1.4; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.tag-sale { background: #e03131; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 6px; }
.tag-plus { background: #f59f00; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.tag-count { background: #e9ecef; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.tag-ok, .tag-max { color: #2f9e44; font-weight: 800; font-size: 12px; }
.lock-label { color: #c92a2a; font-weight: 700; font-size: 12px; }

.stall-summary {
  background: #fff9db;
  border: 2.5px solid var(--outline);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.stall-tier-title { font-size: 17px; font-weight: 900; }

.empty-box {
  background: #f8f9fa;
  border: 2px dashed #adb5bd;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

.tab-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  background: #e9ecef;
  border: 2px solid var(--outline);
  border-radius: 10px 10px 4px 4px;
  padding: 7px 14px;
  cursor: pointer;
}
.tab-btn.active {
  background: linear-gradient(180deg, #ffa94d, #e8590c);
  color: #fff;
}

.quest-list { display: flex; flex-direction: column; gap: 9px; }
.quest-row {
  background: #fff;
  border: 2.5px solid var(--outline);
  border-radius: 12px;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.quest-row.quest-ready { background: #ebfbee; border-color: #2f9e44; animation: ready-glow 1.4s ease-in-out infinite; }
.quest-row.quest-done { opacity: 0.6; background: #f1f3f5; }
@keyframes ready-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(47,158,68,0); }
  50% { box-shadow: 0 0 12px rgba(47,158,68,0.55); }
}
.quest-group {
  display: inline-block;
  background: #ffd8a8;
  color: #c2410c;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  margin-bottom: 3px;
}
.quest-title { font-weight: 800; font-size: 14px; }
.quest-desc { font-size: 12.5px; color: #4b5563; }
.quest-reward { font-size: 12px; font-weight: 700; color: #c2410c; margin-top: 3px; }
.quest-action { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.quest-prog { font-weight: 800; font-size: 13px; }

.boss-arena, .rps-box {
  background: #fff;
  border: 2.5px solid var(--outline);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
}
.boss-avatar { font-size: 64px; margin-bottom: 4px; display: inline-block; animation: boss-idle 1.4s ease-in-out infinite; }
@keyframes boss-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.04); }
}
.boss-quote { font-style: italic; color: #c92a2a; font-weight: 600; margin: 6px 0 12px; }

.hp-bar-wrap {
  max-width: 420px;
  height: 24px;
  margin: 0 auto;
  background: #343a40;
  border: 2px solid var(--outline);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.hp-bar-fill { height: 100%; background: linear-gradient(90deg, #fa5252, #ff922b); transition: width 0.25s; }
.hp-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 0 #000;
}

.rps-bet-row { margin: 12px 0; font-weight: 700; }
.rps-bet-row select { padding: 5px 10px; border-radius: 8px; border: 2px solid var(--outline); font-weight: 700; font-family: inherit; }
.rps-buttons { display: flex; justify-content: center; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.rps-result { background: #fff3bf; border-radius: 10px; padding: 10px; font-size: 14px; }

.chat-box { background: #fff; border: 2.5px solid var(--outline); border-radius: 14px; padding: 12px; }
.chat-messages {
  height: 230px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  padding-right: 4px;
}
.chat-line { background: #f1f3f5; padding: 7px 10px; border-radius: 12px 12px 12px 4px; font-size: 13px; max-width: 90%; }
.chat-line.chat-self { background: #d0ebff; align-self: flex-end; border-radius: 12px 12px 4px 12px; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input {
  flex: 1;
  border: 2px solid var(--outline);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: inherit;
}

/* ================= ĐĂNG NHẬP ================= */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(11, 30, 60, 0.45);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 4px solid var(--outline);
  border-radius: 24px;
  box-shadow: 0 10px 0 var(--outline), 0 26px 50px rgba(0,0,0,0.35);
  padding: 22px 22px 18px;
  animation: pop-in 0.35s cubic-bezier(.2,1.4,.4,1);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: -52px auto 14px;
  width: max-content;
  padding: 10px 22px 10px 14px;
  background: linear-gradient(180deg, #ff8787, #c92a2a);
  border: 3.5px solid var(--outline);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--outline);
  color: #fff;
}
.logo-icon {
  font-size: 34px;
  display: inline-block;
  animation: logo-swing 2.4s ease-in-out infinite;
  transform-origin: 50% 0;
}
@keyframes logo-swing {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
.logo-title { font-weight: 900; font-size: 26px; letter-spacing: 1px; line-height: 1; text-shadow: 0 3px 0 rgba(0,0,0,0.3); }
.logo-sub { font-weight: 700; font-size: 12px; color: #ffe066; }

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e9ecef;
  border: 2.5px solid var(--outline);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 14px;
}
.login-tab {
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  border: none;
  border-radius: 9px;
  padding: 7px 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.login-tab.active {
  background: linear-gradient(180deg, #4dabf7, #1971c2);
  color: #fff;
  box-shadow: 0 2px 0 var(--outline);
}

.login-form { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: 13px; }
.field small { font-weight: 600; color: var(--muted); }
.field input, .opt-row input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 12px;
  border: 2.5px solid var(--outline);
  border-radius: 11px;
  background: #fff;
  outline: none;
  transition: box-shadow 0.15s;
}
.field input:focus, .opt-row input[type="text"]:focus { box-shadow: 0 0 0 4px rgba(77,171,247,0.35); }
.field input:disabled { background: #f1f3f5; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 42px; }
.pass-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
}
.remember { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: #495057; cursor: pointer; }

.login-msg {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  background: #fff5f5;
  border: 2px solid #ffa8a8;
  color: #c92a2a;
  animation: shake 0.35s ease;
}
.login-msg.ok { background: #e7f5ff; border-color: #74c0fc; color: #1864ab; animation: none; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 2px; background: #dee2e6; }

.login-foot { margin-top: 12px; text-align: center; }
.server-status { font-size: 11.5px; font-weight: 800; }
.server-status.on { color: #2b8a3e; }
.server-status.off { color: #c92a2a; }
.server-help {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  background: #fff9db;
  border: 2px dashed #f08c00;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
}
.server-help code {
  display: block;
  margin: 6px 0;
  padding: 6px 10px;
  background: #212529;
  color: #69db7c;
  border-radius: 8px;
  font-size: 12.5px;
}
.server-help .btn { margin-top: 8px; }

/* ================= TẠO NHÂN VẬT ================= */
.creator-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 30, 60, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 30px 16px 16px;
  overflow-y: auto;
}
.creator-card {
  position: relative;
  background: var(--panel);
  border: 4px solid var(--outline);
  border-radius: 24px;
  box-shadow: 0 10px 0 var(--outline);
  max-width: 760px;
  width: 100%;
  padding: 34px 22px 18px;
  margin: auto;
  animation: pop-in 0.35s cubic-bezier(.2,1.4,.4,1);
}
.creator-ribbon {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: linear-gradient(180deg, #ff8787, #c92a2a);
  color: #fff;
  font-weight: 900;
  font-size: 19px;
  padding: 8px 24px;
  border: 3px solid var(--outline);
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--outline);
  text-shadow: 0 2px 0 rgba(0,0,0,0.3);
}
.creator-intro { font-size: 13px; color: #4b5563; text-align: center; margin-bottom: 12px; }

.creator-body { display: grid; grid-template-columns: 230px 1fr; gap: 18px; }

.preview-col { display: flex; flex-direction: column; gap: 8px; }
.preview-stage {
  height: 270px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #a5d8ff 0 62%, transparent 62%),
    repeating-linear-gradient(60deg, #d2c0a0 0 14px, #e3d5bd 14px 28px);
  box-shadow: inset 0 -12px 0 rgba(0,0,0,0.06);
  position: relative;
}
.preview-stage::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 0;
  height: 28px;
  background: repeating-linear-gradient(90deg, #fa5252 0 18px, #fff5f5 18px 36px);
  border-bottom: 3px solid var(--outline);
}
#cr-preview { width: 100%; height: 100%; display: block; position: relative; }

.anim-row { display: flex; gap: 5px; justify-content: center; }
.anim-btn {
  width: 38px;
  height: 34px;
  border: 2px solid var(--outline);
  border-radius: 10px;
  background: #fff;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--outline);
  transition: transform 0.1s;
}
.anim-btn:hover { transform: translateY(-2px); }
.anim-btn.active { background: #ffe066; }

.options-col { display: flex; flex-direction: column; gap: 9px; }
.opt-row { display: flex; flex-direction: column; gap: 4px; }
.opt-row.inline { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.opt-row > label:first-child { font-weight: 900; font-size: 12.5px; color: #c2410c; min-width: 62px; }
.gender-opt { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13.5px; cursor: pointer; }

.swatch-row, .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--outline);
  background: var(--sw);
  cursor: pointer;
  transition: transform 0.12s;
  position: relative;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px #1c7ed6; transform: scale(1.08); }
.swatch.custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: conic-gradient(#fa5252, #fab005, #40c057, #15aabf, #7950f2, #e64980, #fa5252);
  overflow: hidden;
}
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.chip {
  font-family: inherit;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 11px;
  border: 2px solid var(--outline);
  border-radius: 99px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.chip:hover { transform: translateY(-1px); }
.chip.active { background: linear-gradient(180deg, #ffa94d, #e8590c); color: #fff; }

.creator-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ================= TOAST ================= */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: #212529;
  color: #fff;
  padding: 10px 15px;
  border-radius: 12px;
  border: 2.5px solid var(--outline);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--outline), 0 6px 14px rgba(0,0,0,0.25);
  animation: toast-in 0.3s cubic-bezier(.2,1.4,.4,1);
  transition: opacity 0.3s, transform 0.3s;
}
@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast-success { background: linear-gradient(180deg, #40c057, #2b8a3e); }
.toast-error { background: linear-gradient(180deg, #fa5252, #c92a2a); }
.toast-info { background: linear-gradient(180deg, #339af0, #1864ab); }
.toast.fade-out { opacity: 0; transform: translateX(30px); }

/* ================= RESPONSIVE ================= */
@media (max-width: 900px) {
  .dock-bar { grid-template-columns: repeat(4, 1fr); }
  .toolbar-top { flex-direction: column; align-items: stretch; }
  .district-bar { overflow-x: auto; }
  .buff-bar { display: none; }
}

@media (max-width: 680px) {
  .creator-body { grid-template-columns: 1fr; }
  .preview-stage { height: 210px; }
  body { padding: 6px 4px 16px; }
  .hud { top: 6px; }
  .hud-left { left: 6px; transform: scale(0.8); transform-origin: top left; }
  .hud-right { right: 6px; transform: scale(0.8); transform-origin: top right; }
  .stat-row span { display: none; }
  .curr-pill.rep { display: none; }
  .dock-label { font-size: 10px; }
}

/* ================= TOÀN MÀN HÌNH ================= */
html, body { height: 100%; }
body {
  padding: 0;
  display: block;
  overflow: hidden;
  background: #1b2a3a;
}
.game-root {
  max-width: none;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.game-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #343a40;
}
#street-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}
.hint-line { display: none; }
.toolbar { flex-shrink: 0; }
.dock-bar { grid-template-columns: repeat(10, 1fr); }
.c-indigo { --c1: #91a7ff; --c2: #3b5bdb; }
.c-gold   { --c1: #ffe066; --c2: #f08c00; }
.hud-left { left: 12px; }
.hud-right { right: 12px; }
@media (min-height: 820px) {
  .dock-icon { font-size: 28px; }
  .dock-label { font-size: 12.5px; }
  .dock-btn { padding: 7px 4px 6px; }
}
@media (max-width: 1100px) {
  .dock-bar { grid-template-columns: repeat(5, 1fr); }
}

/* Thanh map phụ */
.map-bar {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(720px, 60vw);
  padding: 6px 12px 6px 6px;
  background: rgba(255, 253, 246, 0.95);
  border: 3px solid var(--outline);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--outline);
  line-height: 1.25;
  animation: pop-in 0.3s cubic-bezier(.2,1.4,.4,1);
}
.map-info { display: flex; flex-direction: column; min-width: 0; }
.map-info b { font-size: 14px; }
.map-info span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
body.in-map #district-bar { opacity: 0.6; }

/* Thẻ bản đồ */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.map-card {
  display: flex;
  flex-direction: column;
  border: 3px solid var(--outline);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 0 var(--outline);
}
.map-art {
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 54px;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.25));
}
.map-cong_vien .map-art { background: linear-gradient(180deg, #74c0fc 0 45%, #4dabf7 45% 60%, #8ce99a 60%); }
.map-ben_cang .map-art { background: linear-gradient(180deg, #ffa94d 0 40%, #339af0 40% 70%, #c98b55 70%); }
.map-hem_nho .map-art { background: linear-gradient(90deg, #ffd8a8 0 33%, #b2f2bb 33% 66%, #a5d8ff 66%); }
.map-card.locked .map-art { filter: grayscale(0.7) brightness(0.9); }
.map-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.map-body .btn { margin-top: auto; }
.map-reqs .ok { color: var(--success); font-weight: 800; }
.map-reqs .no { color: var(--danger); font-weight: 800; }

/* Nhiệm vụ ngày */
.daily-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 10px; }
.daily-card, .ach-card {
  border: 2px solid #dee2e6;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.daily-card.quest-ready, .ach-card.quest-ready { background: #ebfbee; border-color: #2f9e44; animation: ready-glow 1.4s ease-in-out infinite; }
.daily-card.quest-done, .ach-card.quest-done { opacity: 0.6; background: #f1f3f5; }
.daily-bonus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 2px dashed #f08c00;
  border-radius: 12px;
  background: #fff9db;
  font-size: 13px;
}
.daily-bonus.quest-done { opacity: 0.65; }
.mini-bar {
  position: relative;
  height: 16px;
  border-radius: 99px;
  background: #e9ecef;
  border: 1.5px solid var(--outline);
  overflow: hidden;
}
.mini-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #69db7c, #2f9e44); transition: width 0.4s; }
.mini-bar span { position: relative; display: block; text-align: center; font-size: 10.5px; font-weight: 800; line-height: 13px; }
.muted { color: var(--muted); font-weight: 600; }

/* Đăng nhập 7 ngày */
.login-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.login-day {
  position: relative;
  text-align: center;
  padding: 8px 4px;
  border: 2.5px solid var(--outline);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f1f3f5);
  font-size: 11px;
  line-height: 1.3;
}
.login-day small { font-weight: 800; color: var(--muted); }
.ld-icon { font-size: 30px; margin: 4px 0; }
.login-day.today { background: linear-gradient(180deg, #fff3bf, #ffd43b); animation: ready-glow 1.2s ease-in-out infinite; transform: translateY(-3px); }
.login-day.got { opacity: 0.55; }
.login-day.big .ld-icon { font-size: 36px; }
.ld-check {
  position: absolute; top: -8px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--success); color: #fff; font-style: normal; font-weight: 900; font-size: 12px; line-height: 20px;
  border: 2px solid #fff;
}
@media (max-width: 680px) { .login-grid { grid-template-columns: repeat(4, 1fr); } }

/* Vòng quay */
.wheel-wrap { position: relative; width: min(340px, 80vw); aspect-ratio: 1; margin: 8px auto 0; }
.wheel {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 6px solid var(--outline);
  box-shadow: 0 6px 0 var(--outline), inset 0 0 0 6px rgba(255,255,255,0.6);
}
.wheel-label {
  position: absolute; left: 50%; top: 0; bottom: 50%;
  width: 70px; margin-left: -35px;
  transform-origin: 50% 100%;
  display: flex; justify-content: center;
}
.wheel-label span {
  margin-top: 12px;
  font-size: 11px; font-weight: 900; line-height: 1.2; text-align: center;
  color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}
.wheel-hub {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: #fff; border: 4px solid var(--outline);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.wheel-pointer {
  position: absolute; left: 50%; top: -18px; transform: translateX(-50%);
  z-index: 2; font-size: 34px; color: #e03131;
  text-shadow: 0 2px 0 var(--outline), 2px 0 0 var(--outline), -2px 0 0 var(--outline);
}

/* Thành tựu */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.ach-card { flex-direction: row; align-items: center; }
.ach-icon { font-size: 30px; }
.ach-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ach-xu { font-weight: 800; font-size: 12px; color: var(--muted); }
.ach-ok { font-size: 18px; }

/* ================= ONLINE: MÁY CHỦ, XẾP HẠNG, VÕ ĐÀI, ADMIN ================= */
.dock-bar { grid-template-columns: repeat(12, 1fr); gap: 6px; }
.dock-label { font-size: 10.5px; }
@media (max-width: 1300px) { .dock-bar { grid-template-columns: repeat(6, 1fr); } }
.c-crimson { --c1: #ff6b6b; --c2: #a61e4d; }
.c-amber   { --c1: #ffd43b; --c2: #e67700; }

/* Chọn máy chủ ở màn đăng nhập */
.server-picker { margin-bottom: 10px; }
.sp-label { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 5px; }
.sp-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sp-item {
  font-family: inherit; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 4px; border: 2px solid #dee2e6; border-radius: 12px; background: #fff;
  transition: transform 0.1s, border-color 0.15s;
}
.sp-item:hover { transform: translateY(-2px); }
.sp-item.active { border-color: var(--primary); background: #fff4e6; box-shadow: 0 3px 0 var(--primary-dark); }
.sp-icon { font-size: 22px; }
.sp-name { font-size: 11.5px; font-weight: 900; }
.sp-meta { font-size: 10px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 3px; }
.sp-dot { width: 7px; height: 7px; border-radius: 50%; background: #40c057; display: inline-block; }
.sp-dot.busy { background: #fa5252; }
.sp-dot.new { background: #339af0; }
.server-chip {
  font-family: inherit; font-size: 10px; font-weight: 800; cursor: pointer;
  padding: 0 6px; margin-left: 4px; border-radius: 99px; border: 1.5px solid var(--outline);
  background: #e7f5ff; color: var(--blue-dark);
}
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.server-card {
  border: 3px solid var(--outline); border-radius: 14px; background: #fff; padding: 12px;
  display: flex; flex-direction: column; gap: 5px; box-shadow: 0 3px 0 var(--outline);
}
.server-card.active { background: #fff9db; }
.sv-icon { font-size: 34px; }

/* Hòm thư */
.mail-list { display: flex; flex-direction: column; gap: 8px; }
.mail-row { display: flex; align-items: center; gap: 12px; padding: 10px; background: #fff; border: 2px solid #dee2e6; border-radius: 12px; }
.mail-icon { font-size: 30px; }
.mail-body { flex: 1; min-width: 0; }

/* Xếp hạng */
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: #fff; border: 2px solid #dee2e6; border-radius: 12px;
}
.rank-row.top1 { background: linear-gradient(90deg, #fff3bf, #fff); border-color: #fab005; }
.rank-row.top2 { background: linear-gradient(90deg, #f1f3f5, #fff); border-color: #adb5bd; }
.rank-row.top3 { background: linear-gradient(90deg, #ffe8cc, #fff); border-color: #e8590c; }
.rank-row.me { outline: 3px solid #339af0; }
.rank-no { width: 40px; text-align: center; font-weight: 900; font-size: 18px; }
canvas.portrait { width: 44px; height: 44px; border-radius: 50%; background: #e7f5ff; border: 2px solid var(--outline); flex-shrink: 0; }
.rank-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rank-name small { color: var(--muted); font-weight: 600; font-size: 11px; }
.rank-val { font-weight: 900; color: var(--primary-dark); white-space: nowrap; }

/* Vinh danh: bục podium */
.fame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.fame-block { background: linear-gradient(180deg, #e7f5ff, #fff); border: 3px solid var(--outline); border-radius: 16px; padding: 8px 8px 0; overflow: hidden; }
.fame-block h4 { text-align: center; font-size: 13.5px; margin-bottom: 4px; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 4px; }
.pod-slot { display: flex; flex-direction: column; align-items: center; text-align: center; }
.pod-char { width: 72px; height: 96px; }
.pod-slot.p1 .pod-char { width: 86px; height: 112px; }
.pod-name { font-size: 11px; font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-val { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.pod-base {
  width: 100%; margin-top: 3px; color: #fff; font-weight: 900; font-size: 18px;
  border: 2px solid var(--outline); border-bottom: none; border-radius: 8px 8px 0 0;
}
.pod-slot.p1 .pod-base { height: 46px; background: linear-gradient(180deg, #ffd43b, #f08c00); }
.pod-slot.p2 .pod-base { height: 32px; background: linear-gradient(180deg, #ced4da, #868e96); }
.pod-slot.p3 .pod-base { height: 22px; background: linear-gradient(180deg, #ffa94d, #c2410c); }
.legend-row { display: flex; flex-wrap: wrap; gap: 10px; }
.legend { display: flex; flex-direction: column; align-items: center; font-size: 11px; }
.legend canvas.portrait { width: 56px; height: 56px; border-color: #fab005; box-shadow: 0 0 0 3px #fff3bf; }

/* Võ đài */
.pvp-me {
  display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 12px; margin-bottom: 10px; border-radius: 14px; color: #fff;
  background: linear-gradient(90deg, #a61e4d, #e8590c); border: 3px solid var(--outline);
}
.pvp-me div { display: flex; flex-direction: column; }
.pvp-me small { opacity: 0.85; font-size: 11px; }
.opp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.opp-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px;
  padding: 10px; background: #fff; border: 3px solid var(--outline); border-radius: 14px; box-shadow: 0 3px 0 var(--outline);
}
.opp-char { width: 96px; height: 130px; background: radial-gradient(ellipse at 50% 90%, rgba(0,0,0,0.12) 0 30%, transparent 31%); }
.diff { font-size: 10px; font-weight: 900; padding: 1px 6px; border-radius: 99px; color: #fff; }
.diff.easy { background: #40c057; }
.diff.even { background: #fab005; }
.diff.hard { background: #e03131; }
.pvp-hist { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.pvp-hist > div { padding: 6px 10px; border-radius: 8px; background: #f8f9fa; }
.pvp-hist .won { background: #ebfbee; }
.pvp-hist .lost { background: #fff5f5; }

.arena {
  position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px;
  padding: 16px; border-radius: 16px; border: 3px solid var(--outline);
  background: linear-gradient(180deg, #ffd8a8 0 55%, #c98b55 55%);
}
.fighter { display: flex; flex-direction: column; align-items: center; text-align: center; }
.fighter canvas { width: 150px; height: 200px; }
.fighter small { font-weight: 700; }
.fighter.lunge.left { animation: lunge-r 0.35s ease; }
.fighter.lunge.right { animation: lunge-l 0.35s ease; }
.fighter.hit canvas { animation: hit-shake 0.35s ease; }
@keyframes lunge-r { 50% { transform: translateX(40px); } }
@keyframes lunge-l { 50% { transform: translateX(-40px); } }
@keyframes hit-shake { 25% { transform: translateX(-6px); filter: brightness(1.8) saturate(0.3); } 75% { transform: translateX(6px); } }
.vs { font-size: 40px; font-weight: 900; color: #e03131; text-shadow: 0 3px 0 var(--outline); align-self: center; }
.hp { position: relative; width: 160px; height: 16px; border: 2px solid var(--outline); border-radius: 99px; background: #495057; overflow: hidden; margin-bottom: 6px; }
.hp i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #fa5252, #40c057); transition: width 0.3s; }
.hp span { position: relative; display: block; font-size: 10px; font-weight: 900; color: #fff; line-height: 12px; text-shadow: 0 1px 0 #000; }
.arena-fx { position: absolute; inset: 0; pointer-events: none; }
.dmg { position: absolute; top: 30%; font-size: 22px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 #c92a2a, 0 0 6px #000; animation: dmg-up 0.9s ease forwards; }
.dmg.l { left: 18%; }
.dmg.r { right: 18%; }
.dmg.crit { font-size: 30px; color: #ffe066; }
@keyframes dmg-up { from { transform: translateY(0) scale(1.3); opacity: 1; } to { transform: translateY(-50px) scale(1); opacity: 0; } }
.arena-log { max-height: 110px; overflow-y: auto; margin-top: 8px; font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; }
.arena-result { margin-top: 10px; text-align: center; padding: 14px; border-radius: 14px; border: 3px solid var(--outline); display: flex; flex-direction: column; gap: 6px; align-items: center; animation: pop-in 0.3s; }
.arena-result.win { background: linear-gradient(180deg, #fff3bf, #ffd43b); }
.arena-result.lose { background: linear-gradient(180deg, #f1f3f5, #ced4da); }
.ar-title { font-size: 26px; font-weight: 900; }

/* Quản trị */
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.admin-stats div { background: #fff; border: 3px solid var(--outline); border-radius: 14px; padding: 12px; text-align: center; display: flex; flex-direction: column; }
.admin-stats b { font-size: 26px; color: var(--blue-dark); }
.admin-stats small { font-weight: 700; color: var(--muted); }
.admin-filter, .admin-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.admin-form .section-heading { width: 100%; margin: 4px 0 0; }
.admin-filter input, .admin-form input, .admin-filter select, .admin-form select {
  font-family: inherit; font-size: 13px; padding: 6px 10px; border: 2px solid var(--outline); border-radius: 10px; min-width: 120px;
}
.admin-filter input#adm-q, .admin-form input#an-text { flex: 1; min-width: 220px; }
.admin-form.floating { background: #fff9db; border: 2px dashed #f08c00; border-radius: 12px; padding: 10px; }
.admin-table { display: flex; flex-direction: column; gap: 8px; }
.adm-row { display: flex; gap: 10px; justify-content: space-between; padding: 10px; background: #fff; border: 2px solid #dee2e6; border-radius: 12px; }
.adm-row.banned { background: #fff5f5; border-color: #ffa8a8; }
.adm-user { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.adm-user small { color: var(--muted); font-size: 11px; }
.adm-saves { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; }
.adm-saves span { background: #f1f3f5; border-radius: 8px; padding: 2px 8px; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; justify-content: flex-end; max-width: 50%; }
.role { font-size: 10px; font-weight: 900; padding: 1px 6px; border-radius: 6px; color: #fff; }
.role.admin { background: #f08c00; }
.role.mod { background: #1c7ed6; }
.role.ban { background: #e03131; }
.admin-pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 10px; font-weight: 700; }
@media (max-width: 760px) {
  .pvp-me, .admin-stats { grid-template-columns: 1fr 1fr; }
  .adm-row { flex-direction: column; }
  .adm-actions { max-width: none; justify-content: flex-start; }
  .fighter canvas { width: 100px; height: 140px; }
}
.adm-user > .role { align-self: flex-start; }
