:root { --accent: #5ef0c0; --accent2: #6aa8ff; --gold: #ffd36b; --hot: #ff6b9a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0a0c18; color: #eef2ff;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }

/* canvas phủ toàn màn hình, mọi thứ khác nổi phía trên */
#game { position: fixed; inset: 0; display: block; z-index: 0; touch-action: none; width: 100%; height: 100%; }

header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top));
  padding-left: calc(10px + env(safe-area-inset-left)); padding-right: calc(10px + env(safe-area-inset-right));
  pointer-events: none;
}
header > * { pointer-events: auto; }
.brand { flex: 1; font-weight: 900; font-size: 17px; letter-spacing: .4px; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.brand span { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
header button {
  background: rgba(255, 255, 255, .08); color: #fff; border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px; padding: 7px 10px; font-size: 14px; line-height: 1;
}
header button:hover { background: rgba(255, 255, 255, .15); }

/* ---------- HUD ---------- */
#hud {
  position: fixed; z-index: 2; pointer-events: none;
  top: calc(44px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left));
  display: flex; gap: 6px;
}
.hstat {
  background: rgba(8, 10, 26, .55); border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px;
  padding: 3px 10px 4px; min-width: 58px; text-align: center;
}
.hstat .label { display: block; font-size: 9.5px; opacity: .65; text-transform: uppercase; letter-spacing: .5px; }
.hstat b { font-size: 16px; color: var(--accent); font-variant-numeric: tabular-nums; }

#lb {
  position: fixed; z-index: 2; pointer-events: none;
  top: calc(44px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  width: 178px; padding: 6px 8px 7px; border-radius: 12px;
  background: rgba(8, 10, 26, .5); border: 1px solid rgba(255, 255, 255, .08);
  font-size: 12.5px; line-height: 1.5; font-variant-numeric: tabular-nums;
}
.lb-title { font-weight: 800; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; opacity: .7; text-align: center; margin-bottom: 2px; }
#lb ol { list-style: none; margin: 0; padding: 0; }
#lb li, #lb-me { display: flex; gap: 5px; white-space: nowrap; opacity: .82; }
#lb .n { width: 20px; text-align: right; opacity: .6; flex: none; }
#lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#lb .v { flex: none; opacity: .9; }
#lb li.me, #lb-me { color: var(--gold); opacity: 1; font-weight: 800; }
#lb-me { border-top: 1px dashed rgba(255, 255, 255, .18); margin-top: 3px; padding-top: 2px; }

#feed {
  position: fixed; z-index: 2; pointer-events: none; left: 50%; transform: translateX(-50%);
  top: calc(96px + env(safe-area-inset-top)); width: min(90vw, 420px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.fd {
  background: rgba(10, 8, 30, .62); border: 1px solid rgba(255, 211, 107, .35); color: #fff;
  padding: 5px 14px; border-radius: 999px; font-weight: 800; font-size: 15px; white-space: nowrap;
  animation: fd 3s ease forwards;
}
.fd b { color: var(--gold); }
.fd.bad { border-color: rgba(255, 107, 154, .45); }
.fd.bad b { color: var(--hot); }
@keyframes fd {
  0% { opacity: 0; transform: translateY(-8px) scale(.9); }
  8% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

#btn-boost {
  position: fixed; z-index: 2;
  left: calc(16px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom));
  width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 220, 120, .35), rgba(255, 120, 60, .18));
  border: 2px solid rgba(255, 210, 120, .55); color: #fff; font-size: 28px; line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  touch-action: none; box-shadow: 0 6px 22px rgba(0, 0, 0, .45);
}
#btn-boost small { font-size: 10px; font-weight: 800; opacity: .85; }
#btn-boost.on { background: radial-gradient(circle at 40% 35%, rgba(255, 230, 140, .75), rgba(255, 120, 60, .5)); transform: scale(.94); }

/* ---------- lớp phủ ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(4, 6, 20, .5); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.panel {
  background: linear-gradient(160deg, rgba(20, 34, 60, .95), rgba(10, 12, 34, .96));
  border: 1px solid rgba(120, 230, 200, .22); border-radius: 18px; padding: 20px 22px;
  max-width: 460px; width: 100%; max-height: 100%; overflow: auto; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 40px rgba(80, 230, 190, .14);
}
.panel h1 {
  margin: 0 0 6px; font-size: 28px;
  background: linear-gradient(90deg, #7ff5cf, #79b4ff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gnx-btn {
  display: inline-block; margin-top: 10px; background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px; padding: 8px 14px; font-size: 14px; font-weight: 700;
}
#ov-text { line-height: 1.5; opacity: .95; margin: 6px 0; font-size: 15px; }
#ov-text p { margin: 6px 0; }
.panel kbd {
  display: inline-block; min-width: 22px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .25);
  border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; line-height: 18px; font-family: inherit;
}
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; text-align: left; font-size: 13px; margin: 10px auto 2px; max-width: 330px; }
.keys > span:nth-child(odd) { text-align: right; white-space: nowrap; }
.keys > span:nth-child(even) { opacity: .85; }
.rec { color: var(--gold); font-weight: 800; }
.who { opacity: .8; font-size: 13px; }
.who b { color: var(--accent); }
#ov-stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
#ov-stats:empty { display: none; }
.stat { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; padding: 4px 12px; min-width: 72px; text-align: center; }
.stat .label { display: block; font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 16px; color: var(--accent); }
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #06172a; border: none; border-radius: 12px;
  padding: 12px 34px; font-size: 17px; font-weight: 800; margin-top: 6px; box-shadow: 0 6px 20px rgba(80, 200, 220, .35);
}
.primary:hover { filter: brightness(1.08); }

/* chọn skin */
.skins-title { font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; opacity: .7; margin: 12px 0 6px; }
.skins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-width: 360px; margin: 0 auto; }
.skin {
  position: relative; padding: 2px; border-radius: 10px; background: rgba(255, 255, 255, .05);
  border: 2px solid rgba(255, 255, 255, .1); aspect-ratio: 3 / 2; overflow: hidden;
}
.skin canvas { width: 100%; height: 100%; display: block; }
.skin.sel { border-color: var(--gold); background: rgba(255, 211, 107, .12); box-shadow: 0 0 12px rgba(255, 211, 107, .35); }
.skin-name { font-size: 13px; margin-top: 6px; opacity: .85; min-height: 1.2em; }
.skin-name b { color: var(--gold); }

.hidden { display: none !important; }

@media (max-width: 520px) {
  #lb { width: 140px; font-size: 11px; line-height: 1.42; padding: 5px 6px 6px; }
  #lb .n { width: 16px; }
  .hstat { min-width: 48px; padding: 2px 7px 3px; }
  .hstat b { font-size: 14px; }
  #feed { top: calc(92px + env(safe-area-inset-top)); }
  .fd { font-size: 13px; }
  .panel { padding: 16px 14px; }
  .panel h1 { font-size: 24px; }
}
@media (max-height: 520px) {
  #lb .lb-title { display: none; }
  #lb li:nth-child(n+6) { display: none; }
}
