/* Tròn Sinh Tồn — nền tối, màu neon */
:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --panel2: #20263d;
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef1fb;
  --muted: #9aa3c4;
  --gold: #ffcf33;
  --accent: #3ec6ff;
  --pink: #ff5d8f;
  --green: #4dff88;
  --red: #ff4d5e;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}
html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}
#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- nút chung ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 14px;
  padding: 11px 18px;
  font-weight: 800;
  font-size: 15px;
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover {
  filter: brightness(1.15);
}
.btn:active {
  transform: scale(0.96);
}
.btn.primary {
  background: linear-gradient(180deg, #4fd2ff, #2b8fe0);
  border-color: transparent;
  color: #06142a;
  box-shadow: 0 6px 22px rgba(62, 198, 255, 0.35);
}
.btn.big {
  font-size: 20px;
  padding: 14px 40px;
  border-radius: 18px;
}
.btn.danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(255, 77, 94, 0.4);
  font-size: 13px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  filter: none;
  transform: none;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(23, 27, 46, 0.75);
  font-size: 16px;
  flex: none;
}
.back {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.gold {
  color: var(--gold);
}

/* ---------- màn hình phủ ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
}
.sheet-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(8, 10, 20, 0.55);
  backdrop-filter: blur(3px);
}
.sheet-wrap.dim {
  background: rgba(8, 10, 20, 0.62);
}
.sheet {
  position: relative;
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: pop 0.22s ease-out;
}
.sheet.wide {
  width: min(760px, 100%);
}
@keyframes pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
}
.sheet h2 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 900;
}
.sub {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 14px;
}
.close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  font-size: 22px;
  line-height: 1;
}
.btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ---------- sảnh ---------- */
.home {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 60% 45% at 50% 38%, rgba(62, 198, 255, 0.16), transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 85%, rgba(255, 93, 143, 0.12), transparent 70%),
    rgba(10, 12, 24, 0.72);
  overflow: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.home-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.wallet {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 207, 51, 0.12);
  border: 1px solid rgba(255, 207, 51, 0.35);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 900;
  color: var(--gold);
}
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 16px 24px;
  text-align: center;
}
.logo {
  margin: 0;
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 4px 30px rgba(62, 198, 255, 0.45);
}
.logo span {
  color: var(--pink);
  text-shadow: 0 4px 30px rgba(255, 93, 143, 0.5);
}
.tag {
  margin: 0;
  color: var(--muted);
  max-width: 460px;
  font-size: 15px;
}
.chars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(640px, 100%);
}
.char {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  transition: transform 0.1s, border-color 0.15s;
}
.char:hover {
  transform: translateY(-2px);
}
.char.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(62, 198, 255, 0.2);
}
.char .dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.char b {
  font-size: 15px;
}
.char small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}
.char .price {
  margin-top: 2px;
  font-weight: 900;
  color: var(--gold);
  font-size: 13px;
}
.char.locked .dot {
  filter: grayscale(1) brightness(0.6);
}
.home-btns {
  display: flex;
  gap: 10px;
}
.records {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.help-list {
  text-align: left;
  padding-left: 18px;
  margin: 8px 0 16px;
  font-size: 14px;
  line-height: 1.55;
}
.help-list li {
  margin-bottom: 4px;
}

/* ---------- cửa hàng ---------- */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  text-align: left;
}
.shop-item {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 2px 10px;
  align-items: center;
}
.shop-item .ic {
  grid-row: span 3;
  font-size: 26px;
  text-align: center;
}
.shop-item b {
  font-size: 15px;
}
.shop-item small {
  color: var(--muted);
  font-size: 12px;
}
.pips {
  display: flex;
  gap: 3px;
}
.pips i {
  width: 14px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
}
.pips i.on {
  background: var(--accent);
}
.shop-item .btn {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 8px;
  font-size: 14px;
}

/* ---------- trong trận ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.xpbar {
  position: relative;
  height: 16px;
  background: rgba(0, 0, 0, 0.55);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.xpbar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #2b8fe0, #4fd2ff);
  box-shadow: 0 0 12px rgba(79, 210, 255, 0.6);
  transition: width 0.12s;
}
.xpbar span {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  line-height: 16px;
  text-shadow: 0 1px 2px #000;
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 18, 32, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 900;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.stat:first-child {
  font-size: 17px;
}
.hud-row .icon-btn {
  margin-left: auto;
  pointer-events: auto;
}
.bossbar {
  margin: 2px auto 0;
  width: min(520px, calc(100% - 24px));
  text-align: center;
}
.bossbar b {
  font-size: 13px;
  font-weight: 900;
  color: var(--pink);
  text-shadow: 0 1px 3px #000;
}
.bb {
  height: 12px;
  margin-top: 3px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 93, 143, 0.5);
  overflow: hidden;
}
.bb i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff3d7f, #ff8fb5);
  transition: width 0.15s;
}
.combo {
  position: absolute;
  right: 14px;
  top: 74px;
  text-align: right;
  font-weight: 900;
  font-size: 26px;
  color: #ffd43b;
  text-shadow: 0 2px 0 #7a4b00, 0 0 16px rgba(255, 212, 59, 0.45);
  opacity: 0;
  transition: opacity 0.2s;
}
.combo.on {
  opacity: 1;
}
.combo small {
  display: block;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}
.combo.bump {
  animation: bump 0.18s;
}
@keyframes bump {
  50% {
    transform: scale(1.25);
  }
}
.loadout {
  position: absolute;
  left: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 60%;
}
.slot {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(15, 18, 32, 0.78);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 900;
}
.slot.p {
  width: 32px;
  height: 32px;
  font-size: 15px;
}
.slot sub {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 10px;
  color: var(--gold);
}

/* cần điều khiển */
.joy {
  position: absolute;
  z-index: 5;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.joy i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.55);
}

/* ---------- thẻ lên cấp ---------- */
.lv-box {
  width: min(820px, 100%);
  max-height: 100%;
  overflow: auto;
  text-align: center;
}
.lv-title {
  margin: 0 0 14px;
  font-size: 34px;
  font-weight: 900;
  color: #7fe7ff;
  text-shadow: 0 0 24px rgba(127, 231, 255, 0.6);
  animation: pop 0.25s ease-out;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.card {
  position: relative;
  background: linear-gradient(180deg, #232a46, #181d33);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 18px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  animation: cardIn 0.3s ease-out backwards;
  transition: transform 0.1s, border-color 0.15s;
}
.card:nth-child(2) {
  animation-delay: 0.05s;
}
.card:nth-child(3) {
  animation-delay: 0.1s;
}
@keyframes cardIn {
  from {
    transform: translateY(24px) scale(0.9);
    opacity: 0;
  }
}
.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent);
  outline: none;
}
.card .ic {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.07);
}
.card b {
  font-size: 17px;
}
.card .lvl {
  font-size: 12px;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.card .lvl.new {
  background: var(--pink);
  color: #fff;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.card kbd {
  position: absolute;
  left: 10px;
  top: 8px;
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- tạm dừng / kết thúc ---------- */
.build {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.build .slot {
  position: relative;
}
.res-title {
  font-size: 34px !important;
}
.res-title.win {
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 207, 51, 0.5);
}
.res-title.lose {
  color: var(--red);
}
.res-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 6px 0 12px;
}
.res-stats div {
  background: var(--panel2);
  border-radius: 12px;
  padding: 8px;
}
.res-stats small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.res-stats b {
  font-size: 18px;
}
.res-stats .rec {
  display: block;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
}
.res-gold {
  font-size: 28px;
  font-weight: 900;
  color: var(--gold);
}
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  z-index: 30;
  background: rgba(15, 18, 32, 0.92);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- điện thoại ---------- */
@media (max-width: 640px) {
  .chars {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .card {
    flex-direction: row;
    text-align: left;
    padding: 12px;
    gap: 12px;
  }
  .card .ic {
    flex: none;
    width: 50px;
    height: 50px;
    font-size: 26px;
  }
  .card .txt {
    flex: 1;
  }
  .card kbd {
    display: none;
  }
  .lv-title {
    font-size: 28px;
  }
  .stat {
    font-size: 13px;
    padding: 3px 9px;
  }
  .stat:first-child {
    font-size: 15px;
  }
  .combo {
    top: 66px;
    font-size: 22px;
  }
  .slot {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }
  .slot.p {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
}
@media (max-height: 500px) {
  .home-body {
    gap: 8px;
    padding-bottom: 12px;
  }
  .logo {
    font-size: 40px;
  }
  .tag {
    display: none;
  }
  .char {
    padding: 8px 6px;
  }
  .char .dot {
    width: 28px;
    height: 28px;
  }
  .char small {
    display: none;
  }
  .btn.big {
    padding: 10px 34px;
    font-size: 18px;
  }
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .card {
    flex-direction: column;
    text-align: center;
    padding: 10px 8px;
  }
  .lv-title {
    font-size: 24px;
    margin-bottom: 8px;
  }
  .card .ic {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }
  .card p {
    font-size: 12px;
  }
}
