@font-face { font-family: 'Title'; src: url('assets/fonts/NotoSerif-Black.woff2') format('woff2'); font-weight: 900; }
:root {
  --gold: #ffd56b; --gold2: #f0a83a; --ink: #f3f0ff; --dim: #b9b2dd; --panel: rgba(16, 12, 44, .78); --line: rgba(255, 213, 107, .35);
  --cyan: #4ce6ff; --red: #ff4d6d; --green: #5dff9a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0820; color: var(--ink); font-family: 'Be Vietnam Pro', system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ---------- Màn hình phủ ---------- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; pointer-events: none; }
.screen.show { display: flex; }
.screen > * { pointer-events: auto; }
.go { padding: 14px 44px; border-radius: 999px; font-weight: 900; font-size: 20px; letter-spacing: .08em; color: #2a1600; background: linear-gradient(#ffe9a6, var(--gold) 45%, var(--gold2)); box-shadow: 0 0 0 2px #fff6d0 inset, 0 6px 0 #9a5a10, 0 10px 30px rgba(255, 190, 80, .45); transition: transform .08s; }
.go:active { transform: translateY(3px); box-shadow: 0 0 0 2px #fff6d0 inset, 0 3px 0 #9a5a10; }
.ghost { padding: 12px 26px; border-radius: 999px; font-weight: 700; border: 1px solid var(--line); background: rgba(0, 0, 0, .35); }

#menu { justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(8, 6, 30, .55), transparent 30%, transparent 55%, rgba(8, 6, 30, .8)); }
.logo { text-align: center; line-height: 1; font-family: 'Title', serif; text-shadow: 0 3px 0 #6a3a08, 0 0 30px rgba(255, 200, 90, .5); }
.logo small { display: block; font-size: clamp(16px, 3vw, 24px); letter-spacing: .4em; color: var(--gold); }
.logo h1 { margin: 4px 0 0; font-size: clamp(40px, 8vw, 76px); background: linear-gradient(#fff6d0, var(--gold) 50%, var(--gold2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pick { display: flex; align-items: center; gap: 10px; width: min(820px, 100%); }
.arrow { flex: none; width: 48px; height: 48px; border-radius: 50%; font-size: 34px; line-height: 1; background: var(--panel); border: 1px solid var(--line); color: var(--gold); }
.card { flex: 1; display: grid; grid-template-columns: 180px 1fr; gap: 18px; align-items: center; padding: 16px 20px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px); box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
.cimg { aspect-ratio: 1; border-radius: 16px; background: radial-gradient(circle, color-mix(in srgb, var(--c, #fff) 45%, transparent), transparent 70%); display: grid; place-items: center; }
.cimg img { width: 100%; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); }
.cno { font-size: 13px; color: var(--dim); font-weight: 700; letter-spacing: .12em; }
.card h2 { margin: 2px 0 4px; font-family: 'Title', serif; font-size: 32px; color: var(--c, var(--gold)); text-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.cult { font-weight: 900; color: var(--gold); font-size: 14px; letter-spacing: .05em; }
.card p { margin: 4px 0 10px; color: var(--dim); font-size: 15px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; font-size: 13px; font-weight: 700; }
.stats i { display: flex; gap: 3px; }
.stats i b { width: 22px; height: 8px; border-radius: 3px; background: rgba(255, 255, 255, .12); }
.stats i b.on { background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.crec { margin-top: 8px; font-size: 12px; color: var(--dim); }
.dots { display: flex; gap: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .25); cursor: pointer; }
.dots i.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.opts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.seg { display: flex; padding: 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.seg button { padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--dim); }
.seg button.on { background: var(--gold); color: #2a1600; }
.mbottom { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.keys { margin: 0; font-size: 12px; color: var(--dim); text-align: center; }

#launch { justify-content: flex-end; padding-bottom: max(30px, env(safe-area-inset-bottom)); }
.lbox { width: min(520px, 100%); text-align: center; padding: 18px 20px 20px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); }
.lbox h2 { margin: 0; font-family: 'Title', serif; font-size: 34px; color: var(--gold); }
.lbox p { margin: 4px 0 14px; color: var(--dim); font-size: 14px; }
.meter { position: relative; height: 26px; border-radius: 13px; margin-bottom: 16px; background: linear-gradient(90deg, #3a2a7a, #5a3aa8 60%, #ff4d6d); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2); overflow: hidden; }
.meter .zone { position: absolute; top: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255, 213, 107, .95) 30%, #fff6d0 50%, rgba(255, 213, 107, .95) 70%, transparent); }
.meter .needle { position: absolute; top: -2px; bottom: -2px; width: 6px; margin-left: -3px; border-radius: 3px; background: #fff; box-shadow: 0 0 10px #fff; }
.lres { min-height: 26px; margin-top: 10px; font-weight: 900; font-size: 20px; color: var(--gold); }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; display: none; pointer-events: none; }
.hud.show { display: block; }
.hud > * { pointer-events: auto; }
.me { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); display: flex; gap: 10px; align-items: center; padding: 8px 14px 8px 8px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); width: min(340px, 60vw); }
.me img { width: 54px; height: 54px; object-fit: contain; }
.mebars { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.mebars b { font-family: 'Title', serif; font-size: 17px; color: var(--c, var(--gold)); }
.bar { position: relative; height: 14px; border-radius: 7px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.bar i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #2fd67a, var(--green)); transition: transform .12s; }
.bar.hp.low i { background: linear-gradient(90deg, #c8102e, var(--red)); }
.bar.hp.mid i { background: linear-gradient(90deg, #e08a10, #ffd04d); }
.bar span { position: absolute; inset: 0; font-size: 11px; font-weight: 800; line-height: 14px; text-align: center; text-shadow: 0 1px 2px #000; }
.bar.en { height: 8px; }
.bar.en i { background: linear-gradient(90deg, #6a5cff, var(--cyan)); }
.bar.en.full i { background: linear-gradient(90deg, var(--gold2), #fff6d0); animation: glow .6s infinite alternate; }
@keyframes glow { to { filter: brightness(1.5); } }
.count { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; padding: 6px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); line-height: 1; }
.count b { display: block; font-size: 30px; font-weight: 900; color: var(--gold); }
.count small { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--dim); }
.count em { display: block; margin-top: 3px; font-style: normal; font-size: 12px; color: var(--dim); }
.sound { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); color: var(--gold); font-size: 20px; }
.sound.off { opacity: .45; text-decoration: line-through; }
.stick { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(24px, env(safe-area-inset-bottom)); width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .06), rgba(255, 255, 255, .14)); border: 2px solid rgba(255, 255, 255, .2); touch-action: none; display: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6d0, var(--gold) 60%, var(--gold2)); box-shadow: 0 4px 12px rgba(0, 0, 0, .5); }
.touch .stick { display: block; }
.acts { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); display: flex; gap: 14px; align-items: flex-end; }
.act { position: relative; width: 84px; height: 84px; border-radius: 50%; font-weight: 900; font-size: 13px; line-height: 1.1; border: 2px solid var(--line); background: var(--panel); overflow: hidden; touch-action: none; }
.act.ult { width: 100px; height: 100px; }
.act span { position: relative; z-index: 1; }
.act .cd { position: absolute; inset: 0; background: conic-gradient(rgba(0, 0, 0, .65) calc(var(--p, 0) * 1turn), transparent 0); }
.act.ready { border-color: var(--gold); box-shadow: 0 0 20px rgba(255, 213, 107, .6); color: var(--gold); }
.act.ult.ready { animation: pulse .7s infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 34px rgba(255, 213, 107, .95); transform: scale(1.05); } }
.act .key { position: absolute; bottom: 8px; left: 0; right: 0; font-size: 10px; color: var(--dim); }
.out { position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%); display: none; gap: 12px; align-items: center; padding: 10px 14px 10px 20px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; font-weight: 700; }
.out.show { display: flex; }
.out button { padding: 8px 16px; border-radius: 999px; background: var(--gold); color: #2a1600; font-weight: 900; }

/* Thẻ máu trên đầu con quay */
#tags { position: fixed; inset: 0; pointer-events: none; }
.tag { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 4px; padding: 2px 6px 2px 2px; border-radius: 10px; background: rgba(10, 8, 30, .75); border: 1px solid color-mix(in srgb, var(--c) 70%, transparent); font-size: 11px; font-weight: 800; will-change: transform; }
.tag i { font-style: normal; width: 16px; height: 16px; border-radius: 50%; background: var(--c); color: #111; text-align: center; line-height: 16px; font-size: 10px; }
.tag u { position: relative; display: block; width: 44px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .15); overflow: hidden; text-decoration: none; }
.tag u::after { content: ''; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--h, 1)); background: var(--green); }
.tag.mid u::after { background: #ffd04d; }
.tag.low u::after { background: var(--red); }
.tag.mine { border-color: var(--gold); box-shadow: 0 0 10px rgba(255, 213, 107, .6); }
.tag.mine i { background: var(--gold); }
.tag.hide { display: none; }

#big { position: fixed; left: 0; right: 0; top: 24%; text-align: center; pointer-events: none; font-family: 'Title', serif; font-size: clamp(30px, 6vw, 64px); color: #fff6d0; text-shadow: 0 3px 0 #7a3a00, 0 0 30px var(--gold); opacity: 0; padding: 0 16px; }
#big.pop { animation: big 1.1s ease-out; }
@keyframes big { 0% { opacity: 0; transform: scale(1.8); } 15% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(.96); } }

#result { background: radial-gradient(circle at 50% 40%, transparent 30%, rgba(8, 6, 30, .6)); justify-content: flex-end; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.rbox { text-align: center; padding: 18px 26px 22px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); width: min(480px, 100%); }
.rplace { font-weight: 900; letter-spacing: .2em; color: var(--dim); font-size: 13px; }
.rbox h2 { margin: 4px 0; font-family: 'Title', serif; font-size: clamp(30px, 6vw, 44px); color: var(--gold); }
.rbox p { margin: 0 0 16px; color: var(--dim); }
.rbtns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; align-items: center; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #0b0820; font-weight: 700; color: var(--dim); z-index: 9; }
#loading.done { display: none; }

@media (max-width: 640px) {
  .card { grid-template-columns: 1fr; text-align: center; padding: 12px; gap: 6px; }
  .cimg { display: none; }
  .card h2 { font-size: 26px; }
  .stats { justify-content: center; }
  .arrow { width: 38px; height: 38px; font-size: 26px; }
  .pick { gap: 6px; }
  .count { left: auto; right: 64px; transform: none; padding: 5px 12px; }
  .count b { font-size: 22px; }
  .tag u { width: 30px; }
  .tag { font-size: 10px; }
  .me { width: auto; max-width: 52vw; }
  .me img { width: 40px; height: 40px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .card { grid-template-columns: 120px 1fr; padding: 10px 14px; }
  .card p { display: none; }
  .logo h1 { font-size: 36px; }
}
