/* ====== RESET & BASE ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: #05070c;
  color: #e2e8f0;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}
button { font-family: inherit; }

/* ====== BACKGROUND GLOW ====== */
.bg-glow {
  position: fixed; inset: -20%;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(600px 400px at 85% 90%, rgba(236,72,153,.14), transparent 60%),
    radial-gradient(500px 400px at 50% 50%, rgba(34,211,238,.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ====== HUD ====== */
.hud {
  position: relative; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(9, 12, 22, .78);
  border-bottom: 1px solid rgba(148, 163, 184, .12);
  backdrop-filter: blur(10px);
  position: sticky; top: 0;
  z-index: 200;
}
.hud__brand { display: flex; align-items: center; gap: 10px; }
.hud__brand strong { display: block; font-size: 15px; letter-spacing: .2px; }
.hud__brand small { display: block; font-size: 11px; color: #94a3b8; }
.hud__logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #05070c; font-weight: 900; font-size: 18px;
}

.hud__stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  background: rgba(30, 41, 59, .7);
  border: 1px solid rgba(148, 163, 184, .15);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex; flex-direction: column; align-items: center;
  min-width: 62px;
}
.stat__label { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: #94a3b8; }
.stat__value { font-size: 15px; font-weight: 800; color: #f1f5f9; }
.stat--danger .stat__value { color: #f87171; animation: pulseRed .7s infinite alternate; }
@keyframes pulseRed { from { transform: scale(1); } to { transform: scale(1.15); } }

.btn-hint {
  background: rgba(30, 41, 59, .85);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.btn-hint b { color: #22d3ee; }
.btn-hint:hover:not(:disabled) { background: rgba(51, 65, 85, .9); transform: translateY(-1px); }
.btn-hint:disabled { opacity: .4; cursor: not-allowed; }

/* ====== STAGE ====== */
.stage {
  position: relative; z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

.rulebar {
  display: flex; align-items: center; gap: 10px;
  background: rgba(30, 41, 59, .5);
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #cbd5e1;
}
.rulebar__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #22d3ee; box-shadow: 0 0 10px #22d3ee; flex: 0 0 auto;
}
.rulebar p { margin: 0; }
.rulebar code {
  background: #0f172a; padding: 1px 5px; border-radius: 4px;
  font-size: 11px; color: #f87171;
}

/* ====== BROWSER ====== */
.browser {
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.7);
}
.browser__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: #0f172a;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot--r { background: #ef4444; }
.dot--y { background: #f59e0b; }
.dot--g { background: #22c55e; }
.browser__url {
  flex: 1;
  background: #05070c;
  border: 1px solid rgba(148, 163, 184, .15);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browser__lock { color: #64748b; font-size: 13px; }

.browser__page {
  position: relative;
  height: 540px;
  overflow: hidden;
  padding: 0;
  transition: background .4s ease;
}
@media (max-width: 640px) {
  .browser__page { height: 460px; }
}

/* ====== BUTTONS ====== */
.dl-btn {
  position: absolute;
  border: 0;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .2px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  transition: transform .12s ease, filter .12s ease;
  z-index: 2;
  white-space: nowrap;
}
.dl-btn:hover { filter: brightness(1.1); transform: translateY(-1px) scale(1.02); }
.dl-btn:active { transform: scale(.97); }
.dl-btn:disabled { cursor: not-allowed; }

.dl-btn--blink { animation: blink .7s steps(2, end) infinite; }
@keyframes blink { 50% { opacity: .3; } }

.dl-btn--glow { animation: glowPulse 1.1s ease-in-out infinite; }
@keyframes glowPulse {
  50% { box-shadow: 0 0 0 5px rgba(255,255,255,.12), 0 0 22px rgba(255,255,255,.35); }
}

.dl-btn--badge::after {
  content: "AD";
  position: absolute; top: -7px; right: -7px;
  background: #ef4444; color: #fff;
  font-size: 9px; font-weight: 900;
  padding: 2px 5px; border-radius: 4px;
  letter-spacing: .5px;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

.dl-btn--hint {
  outline: 3px solid #22d3ee;
  outline-offset: 3px;
  box-shadow: 0 0 0 8px rgba(34,211,238,.18), 0 0 32px rgba(34,211,238,.55);
  z-index: 6;
  animation: hintPulse .45s ease-in-out infinite alternate;
}
@keyframes hintPulse { from { transform: scale(1); } to { transform: scale(1.05); } }

.dl-btn--wrong {
  animation: shake .35s ease;
  filter: grayscale(.6) brightness(.7);
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ====== FAKE BANNERS ====== */
.fake-banner {
  position: absolute;
  pointer-events: none;
  border-radius: 6px;
  opacity: .13;
  display: grid; place-items: center;
  font-weight: 900;
  letter-spacing: 5px;
  color: #fff;
  z-index: 1;
  user-select: none;
}

/* ====== POPUP QUẢNG CÁO ====== */
.popup-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 50;
}
.ad-popup {
  position: fixed;
  pointer-events: auto;
  width: 250px;
  background: linear-gradient(160deg, #1e293b, #0f172a);
  border: 1px solid rgba(148, 163, 184, .3);
  border-radius: 12px;
  padding: 14px 14px 10px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.8), 0 0 0 1px rgba(239,68,68,.35);
  animation: popIn .25s cubic-bezier(.2,1.3,.5,1);
  font-size: 13px;
}
@keyframes popIn {
  from { transform: scale(.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.ad-popup strong { display: block; font-size: 14px; margin-bottom: 6px; color: #fbbf24; }
.ad-popup p { margin: 0 0 10px; color: #cbd5e1; font-size: 12px; line-height: 1.4; }
.ad-popup__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ad-popup__row button {
  background: #ef4444; color: #fff; border: 0;
  padding: 6px 14px; border-radius: 7px;
  font-weight: 800; font-size: 12px; cursor: pointer;
}
.ad-popup__row span { font-size: 10px; color: #64748b; }
.ad-popup__row span b { color: #f87171; }

/* ====== TOAST ====== */
.toast-layer {
  position: fixed;
  top: 82px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, .95);
  border: 1px solid rgba(148, 163, 184, .25);
  border-left: 4px solid #22d3ee;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 300px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.7);
  animation: toastIn .25s ease;
  transition: opacity .3s, transform .3s;
}
.toast--ok { border-left-color: #22c55e; }
.toast--bad { border-left-color: #ef4444; }
.toast--out { opacity: 0; transform: translateX(20px); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ====== OVERLAY / MODAL ====== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(3, 6, 12, .82);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.overlay.is-open { display: flex; }

.modal {
  width: 100%; max-width: 480px;
  background: linear-gradient(165deg, #101827, #0a0f1c);
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 18px;
  padding: 26px 26px 22px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(34,211,238,.08);
  text-align: center;
}
.modal h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: -.3px; }
.modal__sub { margin: 0 0 16px; color: #94a3b8; font-size: 14px; line-height: 1.5; }
.modal__list {
  text-align: left;
  margin: 0 0 20px;
  padding: 12px 14px 12px 34px;
  background: rgba(15, 23, 42, .7);
  border: 1px solid rgba(148, 163, 184, .12);
  border-radius: 12px;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.55;
}
.modal__list li { margin: 4px 0; }
.modal__list code {
  background: #0f172a; padding: 1px 5px; border-radius: 4px;
  font-size: 11px; color: #f87171;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #05070c;
  border: 0;
  padding: 13px 18px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  transition: transform .12s, filter .12s;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.end-stats {
  display: flex; gap: 12px;
  margin: 0 0 20px;
}
.end-stats > div {
  flex: 1;
  background: rgba(15, 23, 42, .7);
  border: 1px solid rgba(148, 163, 184, .15);
  border-radius: 12px;
  padding: 14px 10px;
}
.end-stats span { display: block; font-size: 26px; font-weight: 900; color: #22d3ee; }
.end-stats small { display: block; font-size: 11px; color: #94a3b8; margin-top: 4px; }

/* ====== SHARE TROLL ====== */
.end-share {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed rgba(148, 163, 184, .18);
}
.end-share__label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  margin-bottom: 10px;
}
.end-share__row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.end-share__row button {
  background: rgba(30, 41, 59, .7);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
}
.end-share__row button:hover {
  background: rgba(51, 65, 85, .9);
  color: #e2e8f0;
  transform: translateY(-1px);
}
.end-share__row button:active {
  transform: scale(.95);
}
.end-share__row button.is-pwned {
  opacity: .35;
  text-decoration: line-through;
  cursor: not-allowed;
}

.end-share__response {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .25);
  border-left: 3px solid #ef4444;
  border-radius: 8px;
  font-size: 13px;
  color: #fca5a5;
  line-height: 1.5;
  text-align: left;
  animation: trollIn .3s cubic-bezier(.2, 1.3, .5, 1);
}
.end-share__response[hidden] { display: none; }
@keyframes trollIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lang-select {
  background: rgba(30, 41, 59, .85);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
}
.lang-select:hover { background: rgba(51, 65, 85, .9); }