:root {
  --sky: #5ec8ff; --sun: #ffd23f; --suit: #29b6f6; --accent: #ffca28; --ink: #17324d; --ok: #5bd16b;
  font-family: "Baloo 2", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd6ff; color: var(--ink); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 5; }

/* ---------- tiêu đề ---------- */
#title { justify-content: space-between; padding: max(3vh, env(safe-area-inset-top)) 4vw max(4vh, env(safe-area-inset-bottom)); pointer-events: none; }
#title > * { pointer-events: auto; }
.logo { display: flex; align-items: center; gap: 2vw; margin-top: 2vh; }
.logo h1 { margin: 0; font-size: min(11vw, 13vh); line-height: 1; color: #fff; letter-spacing: 1px;
  text-shadow: 0 0.06em 0 #1f7fc4, 0 0.12em 0 #155c91, 0 0.2em 0.3em rgba(0,0,0,.25); -webkit-text-stroke: 0.02em #0e4c7d; }
.logo-badge { width: min(14vw, 17vh); height: min(14vw, 17vh); background: url(../assets/icon.svg) center/contain no-repeat; filter: drop-shadow(0 6px 8px rgba(0,0,0,.25)); }
.title-btns { display: flex; gap: 3vw; align-self: flex-end; margin-right: 4vw; }
.big-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; width: min(22vw, 30vh); height: min(22vw, 30vh); border-radius: 30%;
  color: #fff; font-size: min(10vw, 14vh); box-shadow: 0 1.2vh 0 rgba(0,0,0,.18), inset 0 -1vh 0 rgba(0,0,0,.12); transition: transform .12s; }
.big-btn small { font-size: min(2.6vw, 3.6vh); font-weight: 700; opacity: .9; }
.big-btn:active { transform: translateY(0.8vh) scale(.97); }
.big-btn.play { background: linear-gradient(#5be36b, #23b33f); animation: pulse 1.6s ease-in-out infinite; }
.big-btn.pad { background: linear-gradient(#ffb74d, #f57c00); font-size: min(8vw, 11vh); }
@keyframes pulse { 50% { transform: scale(1.06); } }
.gear { position: fixed; right: max(2vw, env(safe-area-inset-right)); top: max(2vh, env(safe-area-inset-top)); width: 7vh; height: 7vh; border-radius: 50%;
  background: rgba(255,255,255,.55); font-size: 4.4vh; color: #335; }
.gear.holding { background: #ffe082; transition: background 1.2s; }
#loadBar { position: fixed; left: 30vw; right: 30vw; bottom: 2vh; height: 1.2vh; border-radius: 1vh; background: rgba(255,255,255,.5); overflow: hidden; }
#loadBar i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .2s; }

/* ---------- hướng dẫn đặt máy ---------- */
#setup { background: linear-gradient(#bfe8ff, #e9f7ff); gap: 3vh; }
.setup-wrap { display: flex; gap: 4vw; align-items: center; }
.guide-svg { width: 42vw; max-height: 55vh; background: #fff; border-radius: 3vh; box-shadow: 0 1vh 2vh rgba(0,0,0,.12); }
.setup-cam { position: relative; }
#camView { width: 38vw; aspect-ratio: 4/3; height: auto; max-height: 60vh; background: #234; border-radius: 3vh; box-shadow: 0 1vh 2vh rgba(0,0,0,.2); }
.cam-status { position: absolute; left: 0; right: 0; bottom: -5.5vh; text-align: center; font-size: 3.4vh; font-weight: 700; }
.setup-btns { display: flex; gap: 3vw; margin-top: 4vh; }
.small-btn { padding: 1.6vh 3vw; border-radius: 3vh; font-size: 3.2vh; font-weight: 700; background: #fff; color: var(--ink); box-shadow: 0 .6vh 0 rgba(0,0,0,.15); }
.small-btn.go { background: var(--ok); color: #fff; }
.small-btn.warn { background: #ff8a80; color: #fff; }

/* ---------- chọn nhân vật ---------- */
#pick { pointer-events: none; }
#pick > * { pointer-events: auto; }
.arrow { position: fixed; top: 44vh; width: 12vh; height: 12vh; border-radius: 50%; font-size: 6vh; color: #fff; background: rgba(23,50,77,.35); }
.arrow.left { left: 3vw; } .arrow.right { right: 3vw; }
.ok-btn { position: fixed; bottom: 20vh; left: 50%; transform: translateX(-50%); width: 13vh; height: 13vh; border-radius: 50%; font-size: 7vh; color: #fff; background: var(--ok); box-shadow: 0 1vh 0 rgba(0,0,0,.18); }
#pickDots { position: fixed; top: 4vh; left: 0; right: 0; display: flex; justify-content: center; gap: 1.4vw; }
#pickDots i { width: 3vh; height: 3vh; border-radius: 50%; background: rgba(255,255,255,.6); border: .4vh solid #fff; }
#pickDots i.on { background: var(--sun); transform: scale(1.3); }
#pickDots i.lock { background: rgba(60,60,80,.5); }

/* ---------- chọn màn ---------- */
#hub { pointer-events: none; }
.cards { display: flex; gap: 3vw; pointer-events: auto; margin-top: 18vh; }
.card { position: relative; width: 26vw; height: 26vw; max-height: 52vh; max-width: 52vh; border-radius: 6vh; background: rgba(255,255,255,.88); box-shadow: 0 1.4vh 0 rgba(0,0,0,.16); transition: transform .2s, box-shadow .2s; padding: 2vh; }
.card.sel { transform: scale(1.12) translateY(-2vh); box-shadow: 0 0 0 1.2vh var(--sun), 0 2vh 2vh rgba(0,0,0,.2); }
.card.done::after { content: "★"; position: absolute; right: 1vh; top: 0; font-size: 6vh; color: var(--sun); text-shadow: 0 .4vh 0 #b78400; }
.card-ico { width: 100%; height: 100%; background: center/contain no-repeat; }
.ico-swing { background-image: url(../assets/icons/card-swing.svg); }
.ico-climb { background-image: url(../assets/icons/card-climb.svg); }
.ico-villain { background-image: url(../assets/icons/card-villain.svg); }
.hub-hero { position: fixed; left: 2vw; bottom: 3vh; width: 14vh; height: 14vh; border-radius: 50%; background: rgba(255,255,255,.7) url(../assets/icon.svg) center/80% no-repeat; pointer-events: auto; box-shadow: 0 .8vh 0 rgba(0,0,0,.15); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#stars { position: fixed; left: max(2vw, env(safe-area-inset-left)); top: 2vh; background: rgba(255,255,255,.8); border-radius: 4vh; padding: .6vh 2.4vh; font-size: 5vh; font-weight: 800; display: flex; align-items: center; gap: 1vh; }
.star-ico { color: var(--sun); text-shadow: 0 .3vh 0 #c08c00; }
#stars.bump { animation: bump .35s; }
@keyframes bump { 50% { transform: scale(1.25); } }
#bigNum { position: fixed; left: 24%; top: 10vh; transform: translateX(-50%); font-size: 26vh; font-weight: 900; color: #fff; line-height: 1;
  text-shadow: 0 1.2vh 0 #1e88e5, 0 2vh 3vh rgba(0,0,0,.3); -webkit-text-stroke: .6vh #0d47a1; }
#bigNum.pop { animation: numpop .45s ease-out; }
@keyframes numpop { 0% { transform: translateX(-50%) scale(.4); } 60% { transform: translateX(-50%) scale(1.2); } 100% { transform: translateX(-50%) scale(1); } }
#hint { position: fixed; right: max(3vw, env(safe-area-inset-right)); top: 3vh; width: 22vh; height: 22vh; border-radius: 50%; background: rgba(255,255,255,.88); box-shadow: 0 1vh 2vh rgba(0,0,0,.18); }
#hint.wiggle { animation: wiggle 1s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-6deg) scale(1.04); } 75% { transform: rotate(6deg) scale(1.04); } }
#hintIco { position: absolute; inset: 8%; background: center/contain no-repeat; }
#hintRing { position: absolute; inset: -1vh; border-radius: 50%; border: 1vh solid var(--sun); clip-path: inset(0 0 0 0); opacity: 0; }
#hint.progress #hintRing { opacity: 1; }
#timerDot { position: fixed; right: 1.4vw; bottom: 1.4vh; width: 2vh; height: 2vh; border-radius: 50%; background: rgba(255,255,255,.6); }
#subs { position: fixed; left: 15vw; right: 15vw; bottom: 16vh; text-align: center; font-size: 3.2vh; font-weight: 700; color: #fff; text-shadow: 0 .3vh .5vh rgba(0,0,0,.7); z-index: 6; pointer-events: none; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 7; transition: opacity .5s; }

/* ---------- bảng nút ---------- */
#pad { position: fixed; left: 50%; bottom: max(1.5vh, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 1vw; z-index: 8; background: rgba(255,255,255,.45); padding: 1vh 1.4vw; border-radius: 3vh; }
#pad button { width: 10.5vh; height: 10.5vh; border-radius: 2.4vh; background: rgba(255,255,255,.92); box-shadow: 0 .6vh 0 rgba(0,0,0,.18); padding: 1vh; font-size: 5vh; }
#pad button img { width: 100%; height: 100%; pointer-events: none; }
#pad button.on { transform: translateY(.5vh); background: #fff3c4; box-shadow: 0 .1vh 0 rgba(0,0,0,.18); }
#pad button.assist { background: #fff3c4; }
#padToggle { position: fixed; right: 1vw; bottom: 1vh; width: 7vh; height: 7vh; border-radius: 50%; background: rgba(255,255,255,.4); font-size: 4vh; z-index: 8; opacity: .5; }
#mini { position: fixed; left: 1vw; bottom: 1vh; width: 18vh; height: 13.5vh; border-radius: 1.5vh; z-index: 8; opacity: .85; background: #123; }

/* ---------- cài đặt ---------- */
#settings { position: fixed; inset: 0; background: rgba(10,30,50,.55); display: flex; align-items: center; justify-content: center; z-index: 20; }
#settings .panel { background: #fff; border-radius: 3vh; padding: 3vh 4vw; width: min(90vw, 760px); max-height: 92vh; overflow: auto; font-size: 2.8vh; }
#settings h2 { margin: 0 0 2vh; }
#settings label { display: flex; justify-content: space-between; align-items: center; gap: 2vw; padding: 1vh 0; border-bottom: 1px solid #eef; }
#settings input, #settings select { font: inherit; font-size: 2.6vh; }
#settings input[type=checkbox] { width: 3.5vh; height: 3.5vh; }
#settings .row { display: flex; justify-content: space-between; margin-top: 2vh; }
.fine { font-size: 2.1vh; color: #567; }

/* ---------- tạm biệt ---------- */
#bye { background: linear-gradient(#0d1b3d 0%, #263e78 60%, #4a5fa3 100%); color: #fff; z-index: 15; justify-content: flex-end; padding-bottom: 6vh; background: transparent; }
.bye-moon { position: fixed; top: 6vh; right: 8vw; font-size: 14vh; }
#bye .small-btn { opacity: .55; font-size: 2.4vh; }

/* ---------- xoay dọc ---------- */
@media (orientation: portrait) {
  body::after { content: "↻"; position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30vw; color: #fff; background: rgba(30,120,200,.92); z-index: 100; }
}
