* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #0b0420; }
:root { --font: "Arial Black", "Trebuchet MS", sans-serif; --ol: #1a0636; --cyan: #5ff4ff; --mag: #ff3fd0; --gold: #ffd54a; }
#app { position: fixed; inset: 0; overflow: hidden; font-family: var(--font); color: #fff; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.otext, .num, .tag, #cardTitle, #bannerMain, #bannerSub, .gbtn, #startPrompt, #toast {
  font-weight: 900;
  text-shadow: 0 3px 0 var(--ol), 2px 0 0 var(--ol), -2px 0 0 var(--ol), 0 2px 0 var(--ol), 0 -2px 0 var(--ol), 2px 2px 0 var(--ol), -2px 2px 0 var(--ol), 2px -2px 0 var(--ol), -2px -2px 0 var(--ol);
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hudLeft { position: absolute; left: calc(10px + env(safe-area-inset-left)); top: 10px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.chip { display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 14px; background: rgba(20, 6, 48, 0.62); border: 2px solid rgba(95, 244, 255, 0.55); box-shadow: 0 3px 0 rgba(0,0,0,0.35); }
.num { font-size: 19px; letter-spacing: 0.5px; min-width: 18px; }
.ico { width: 22px; height: 22px; display: inline-block; background-size: contain; background-repeat: no-repeat; background-position: center; }
.ico.heart { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 21 2.5 11.5a5.5 5.5 0 0 1 9.5-6 5.5 5.5 0 0 1 9.5 6Z' fill='%23ff3f7a' stroke='%231a0636' stroke-width='2.2' stroke-linejoin='round'/><path d='M7 8.5l2-2' stroke='%23ffc2d6' stroke-width='2' stroke-linecap='round'/></svg>"); }
.ico.gem { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2 21 12 12 22 3 12Z' fill='%23ffd54a' stroke='%231a0636' stroke-width='2.2' stroke-linejoin='round'/><path d='M12 2v20M3 12h18' stroke='%23fff3a8' stroke-width='1.2'/></svg>"); }
.chip.combo { border-color: rgba(255, 63, 208, 0.7); padding: 2px 10px; font-size: 16px; font-weight: 900; color: #ffd0f4; }
.chip.combo.pulse { animation: pop 0.35s ease-out; }
#powers { display: flex; gap: 6px; margin-top: 2px; }
.pw { position: relative; width: 40px; height: 40px; border-radius: 50%; background: rgba(20, 6, 48, 0.7); border: 2px solid var(--cyan); overflow: hidden; }
.pw img { position: absolute; inset: 5px; width: 26px; height: 26px; }
.pw .cd { position: absolute; inset: 0; background: conic-gradient(rgba(10, 0, 30, 0.75) var(--p, 0%), transparent 0); }
.pw.ready { box-shadow: 0 0 10px var(--cyan); }
#pwBurst { border-color: var(--mag); }
#pwBurst.ready { box-shadow: 0 0 14px var(--mag); animation: glow 0.8s infinite alternate; }

#hudTop { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 44%; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tag { display: inline-block; padding: 2px 12px; border-radius: 8px; font-size: 14px; letter-spacing: 1px; background: linear-gradient(90deg, #ff3fd0, #7a3cff); border: 2px solid #fff; transform: skewX(-10deg); white-space: nowrap; }
.tag.big { font-size: 17px; padding: 4px 16px; }
.bar { width: 100%; height: 10px; border-radius: 6px; background: rgba(20, 6, 48, 0.75); border: 2px solid rgba(255,255,255,0.8); overflow: hidden; position: relative; }
#progFill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), #a0ffb0); }
.bar.boss { height: 18px; width: 150%; border-color: var(--mag); }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff2a6a, #ff3fd0, #b23cff); transition: width 0.15s; }
#bossName { position: absolute; inset: 0; font-size: 12px; line-height: 14px; text-align: center; font-weight: 900; letter-spacing: 1px; white-space: nowrap; text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000; }
#phaseTimer { font-size: 14px; font-weight: 900; color: #ffe; text-shadow: 0 2px 0 var(--ol), 1px 0 0 var(--ol), -1px 0 0 var(--ol); white-space: nowrap; }

/* ---------- overlays ---------- */
#popLayer { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.pop { position: absolute; font-weight: 900; font-size: 16px; transform: translate(-50%, -50%); animation: popUp 0.8s ease-out forwards; white-space: nowrap;
  text-shadow: 0 2px 0 var(--ol), 1px 0 0 var(--ol), -1px 0 0 var(--ol), 0 -1px 0 var(--ol); }
#redFlash { position: absolute; inset: 0; pointer-events: none; z-index: 7; opacity: 0; box-shadow: inset 0 0 90px 30px rgba(255, 30, 80, 0.85); transition: opacity 0.25s; }
#redFlash.on { opacity: 1; transition: none; }

#glitch { position: absolute; inset: 0; pointer-events: none; z-index: 9; opacity: 0; }
#glitch.on { opacity: 1; }
#glitch .g1, #glitch .g2, #glitch .g3 { position: absolute; inset: 0; }
#glitch.on .g1 { background: repeating-linear-gradient(0deg, rgba(255,63,208,0.0) 0 6px, rgba(255,63,208,0.25) 6px 9px); animation: scan 0.18s steps(3) infinite; mix-blend-mode: screen; }
#glitch.on .g2 { background: linear-gradient(90deg, rgba(95,244,255,0.35), transparent 30%, transparent 70%, rgba(255,63,208,0.35)); animation: jit 0.12s steps(2) infinite; }
#glitch.on .g3 { background: #fff; animation: flash 0.5s ease-out forwards; }
#shiftFx { position: absolute; left: 50%; top: 45%; width: 120vmin; height: 120vmin; transform: translate(-50%, -50%); mix-blend-mode: screen; background-repeat: no-repeat; }

#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; z-index: 10; pointer-events: none; opacity: 0; }
#banner.on { animation: slam 1.6s cubic-bezier(.2,1.4,.4,1) forwards; }
#bannerMain { font-size: 44px; line-height: 1.05; color: #fff; background: linear-gradient(180deg, #fff 30%, #ffe36a 55%, #ff9a3c); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 4px 0 #1a0636) drop-shadow(3px 0 0 #1a0636) drop-shadow(-3px 0 0 #1a0636) drop-shadow(0 -3px 0 #1a0636); text-shadow: none; padding: 0 12px; }
#bannerSub { margin-top: 6px; font-size: 20px; color: var(--cyan); }
#banner.shift #bannerMain { background: linear-gradient(180deg, #fff 20%, #5ff4ff 50%, #ff3fd0); -webkit-background-clip: text; background-clip: text; animation: rgb 0.1s steps(2) infinite; }
#banner.bad #bannerMain { background: linear-gradient(180deg, #fff 20%, #ff6a8a 50%, #a01040); -webkit-background-clip: text; background-clip: text; }

#toast { position: absolute; left: 50%; top: 28%; transform: translateX(-50%); z-index: 10; font-size: 18px; color: #fff; padding: 6px 16px; border-radius: 12px; background: rgba(20, 6, 48, 0.75); border: 2px solid var(--mag); opacity: 0; pointer-events: none; white-space: nowrap; max-width: 92%; text-align: center; }
#toast.on { animation: toastIn 2s ease-out forwards; }

#subtitle { position: absolute; left: 6%; right: 6%; bottom: 16%; z-index: 30; text-align: center; font-size: 16px; font-weight: 700; line-height: 1.4; color: #fff; pointer-events: none; opacity: 0; transition: opacity 0.25s; }
#subtitle span { background: rgba(10, 2, 30, 0.72); padding: 4px 10px; border-radius: 8px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
#subtitle.on { opacity: 1; }
/* during play the lower screen belongs to the thumbs: subtitles sit under the HUD */
body[data-state="play"] #subtitle, body[data-state="clear"] #subtitle, body[data-state="shift"] #subtitle, body[data-state="over"] #subtitle { bottom: auto; top: 21%; }
body[data-state="card"] #subtitle { bottom: 2.5%; }

/* ---------- 9-slice art ---------- */
.panel {
  border-style: solid; border-color: transparent;
  border-width: 34px;
  border-image-source: url("assets/ui-frame.webp");
  border-image-slice: 17% fill;
  border-image-width: 40px;
  border-image-repeat: stretch;
}
.gbtn {
  font-family: var(--font); font-size: 20px; color: #fff; min-width: 150px; min-height: 52px; padding: 2px 18px; cursor: pointer; transition: transform 0.1s, filter 0.1s; outline: none; background: none;
  border-style: solid; border-color: transparent;
  border-width: 12px 14px;
  border-image-source: url("assets/ui-plate.webp");
  border-image-slice: 16% fill;
  border-image-width: 16px;
  border-image-repeat: stretch;
}
.gbtn:active { transform: scale(0.92); }
.gbtn:hover, .gbtn:focus-visible { filter: brightness(1.18); transform: scale(1.04); }
.gbtn.small { font-size: 16px; min-width: 96px; min-height: 44px; padding: 0 10px; }

/* ---------- card ---------- */
#card { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20, 6, 48, 0.55), rgba(5, 0, 15, 0.85)); }
#cardPanel { width: 90%; max-width: 420px; max-height: 86%; padding: 4px 6px 6px; text-align: center; animation: panelIn 0.35s cubic-bezier(.2,1.5,.4,1); display: flex; flex-direction: column; align-items: center; gap: 10px; }
#cardTitle { font-size: 26px; color: #fff; line-height: 1.15; }
#cardStory { font-size: 15px; line-height: 1.5; color: #e6dcff; font-weight: 700; text-align: left; }
#cardSyn { display: flex; flex-direction: column; gap: 5px; width: 100%; }
#cardSyn:empty { display: none; }
#cardSyn .syn { display: flex; align-items: center; gap: 8px; text-align: left; font-size: 14px; font-weight: 800; color: #fff; background: rgba(95, 244, 255, 0.12); border: 1px solid rgba(95, 244, 255, 0.5); border-radius: 10px; padding: 5px 8px; }
#cardSyn .syn img { width: 28px; height: 28px; flex: none; }
#cardSyn .syn.new { border-color: var(--gold); background: rgba(255, 213, 74, 0.15); animation: glowGold 0.9s infinite alternate; }
#cardTip { font-size: 14px; color: var(--gold); font-weight: 800; line-height: 1.4; }
#cardGo { margin-top: 4px; }

/* ---------- intro ---------- */
#intro { position: absolute; inset: 0; z-index: 25; background: #0b0420 url("assets/cover-bg.webp") center / cover no-repeat; }
#introVid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#skipBtn { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 2; }

/* ---------- title ---------- */
#title { position: absolute; inset: 0; z-index: 22; overflow: hidden; cursor: pointer; }
#titleArt { position: absolute; inset: -3%; background: #0b0420 url("assets/cover-bg.webp") center / cover no-repeat; animation: kb 18s ease-in-out infinite alternate; }
#title::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,2,30,0.35), transparent 30%, transparent 70%, rgba(10,2,30,0.6)); pointer-events: none; }
#logo { position: absolute; left: 50%; top: 4%; width: 84%; max-height: 30%; object-fit: contain; transform: translateX(-50%); z-index: 2; animation: logoIn 0.7s cubic-bezier(.2,1.6,.4,1) both, floaty 3s 0.7s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5)); }
#titleBottom { position: absolute; left: 0; right: 0; bottom: 7%; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 18px; }
#startPrompt { font-size: 21px; color: #fff; animation: pulse 1.4s ease-in-out infinite; text-align: center; padding: 0 12px; }
#lbBtn { font-size: 17px; }
#loadingNote { position: absolute; left: 0; right: 0; top: 50%; text-align: center; z-index: 21; font-size: 20px; font-weight: 900; animation: pulse 1s infinite; text-shadow: 0 2px 0 var(--ol); }

/* ---------- keyframes ---------- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes glow { from { filter: brightness(1); } to { filter: brightness(1.5); } }
@keyframes glowGold { from { box-shadow: 0 0 2px var(--gold); } to { box-shadow: 0 0 12px var(--gold); } }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
@keyframes scan { 0% { transform: translateY(0); } 100% { transform: translateY(9px); } }
@keyframes jit { 0% { transform: translateX(-6px); } 100% { transform: translateX(6px); } }
@keyframes flash { 0% { opacity: 0.9; } 100% { opacity: 0; } }
@keyframes slam { 0% { opacity: 0; transform: scale(2.6); } 14% { opacity: 1; transform: scale(0.94); } 22% { transform: scale(1); } 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1.1); } }
@keyframes rgb { 0% { filter: drop-shadow(3px 0 0 #ff3fd0) drop-shadow(-3px 0 0 #5ff4ff) drop-shadow(0 4px 0 #1a0636); } 100% { filter: drop-shadow(-3px 0 0 #ff3fd0) drop-shadow(3px 0 0 #5ff4ff) drop-shadow(0 4px 0 #1a0636); } }
@keyframes toastIn { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 20% { transform: translate(-50%, 0) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes panelIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes kb { from { transform: scale(1); } to { transform: scale(1.06) translateY(-1%); } }
@keyframes logoIn { 0% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(1.4); } 100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes floaty { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(0.96); } }
