html, body { margin: 0; height: 100%; overflow: hidden; background: #050814; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; box-shadow: 0 0 40px #000c; }
body::before { content: ''; position: fixed; inset: -40px; background: var(--scene-bg, none) center / cover no-repeat; filter: blur(22px) brightness(.45) saturate(1.2); }
#toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 180%); z-index: 50; max-width: min(560px, 90vw);
  padding: 10px 18px; border-radius: 12px; border: 2px solid #ffd76a; background: linear-gradient(#24356d, #121b3e);
  color: #fff; font: 15px "UTM Azuki", system-ui, sans-serif; text-align: center; box-shadow: 0 6px 24px #000a; transition: transform .25s; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); }
#sound { position: fixed; right: 10px; bottom: 10px; z-index: 40; width: 40px; height: 40px; border-radius: 50%; border: 2px solid #ffd76a;
  background: #1b2752cc; font-size: 18px; cursor: pointer; }

/* lobby states */
.pg-locked { filter: grayscale(1) brightness(.55); }
/* Locked island: only the art is greyed, its name and lock line stay readable. */
.pg-island-locked > .ug-img { filter: grayscale(1) brightness(.5); }
.pg-cleared::after { content: '★'; position: absolute; right: 6%; top: 4%; color: #ffd700; font: 26px "UTM Erie Black", sans-serif; text-shadow: 0 0 3px #000, 0 0 6px #ff9a00; }
.pg-selected { outline: 3px solid #ffd700; outline-offset: 2px; border-radius: 8px; box-shadow: 0 0 14px #ffd700; }
.pg-notice::after { content: '!'; position: absolute; right: -4px; top: -4px; width: 20px; height: 20px; border-radius: 50%; background: #ff2a2a; color: #fff;
  font: 14px/20px "UTM Erie Black", sans-serif; text-align: center; box-shadow: 0 0 6px #f00; }
.pg-pet-idle > .ug-img, .pg-pet > .ug-img { animation: pg-bob 2.2s ease-in-out infinite; transform-origin: 50% 100%; }

/* battle board */
.pg-board > .ug-img { border-radius: 8px; }
.pg-grid { pointer-events: auto; position: absolute; inset: 4.2%; display: grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr); }
.pg-gem { position: relative; background: center / 92% 92% no-repeat; cursor: pointer; transition: transform .17s ease; border-radius: 6px; }
.pg-gem.selected { box-shadow: inset 0 0 0 2px #fff, 0 0 10px #ffe35a; animation: pg-pulse .7s ease-in-out infinite; z-index: 2; }
.pg-gem.hint { animation: pg-pulse .7s ease-in-out infinite; }
.pg-gem.ulti { box-shadow: inset 0 0 0 2px #ff5ad1; background-color: #ff5ad133; }
.pg-gem.pop { animation: pg-pop .26s ease-in forwards; }
.pg-gem.drop { animation: pg-drop .26s cubic-bezier(.3,1.4,.6,1); }
.pg-gem.reject { animation: pg-shake .28s; }
.pg-grid.shuffle { animation: pg-spin .3s; }

/* pets & effects */
.pg-pet { overflow: visible !important; }
.pg-framed > .ug-img { animation: none !important; }
.pg-pet.pg-framed.lunge { translate: none !important; }
.pg-pet.pg-framed.hurt { animation: none; filter: brightness(1.4); }
.pg-anim { position: absolute; background-repeat: no-repeat; pointer-events: none; }
.pg-pet.lunge.pg-pet-mine { translate: 60px 0; transition: translate .2s; }
.pg-pet.lunge.pg-pet-foe { translate: 60px 0; transition: translate .2s; }
.pg-pet.hurt { animation: pg-shake .35s; filter: brightness(1.8) saturate(.4); }
.pg-fx { position: absolute; width: 220px; height: 220px; margin: -110px 0 0 -110px; pointer-events: none; background-repeat: no-repeat; z-index: 3; }
.pg-fx-attack { background-image: url(/assets/classic/fx-attack.webp); background-size: 2300% 100%; animation: pg-sheet23 .8s steps(22) forwards; }
.pg-fx-lightning { background-image: url(/assets/classic/fx-lightning.webp); background-size: 1800% 100%; animation: pg-sheet18 .8s steps(17) forwards; width: 300px; margin-left: -150px; }
.pg-fx-awaken { background-image: url(/assets/classic/fx-awaken.webp); background-size: 1500% 100%; animation: pg-sheet15 .9s steps(14) forwards; }
.pg-fx-heal { background-image: url(/assets/classic/fx-aura.webp); background-size: 1500% 100%; animation: pg-sheet15 .9s steps(14) forwards; filter: hue-rotate(80deg); }
.pg-pop { position: absolute; margin-top: -110px; transform: translateX(-50%); font: 34px "UTM Erie Black", sans-serif; z-index: 4; pointer-events: none;
  animation: pg-float 1.1s ease-out forwards; white-space: nowrap; }
.pg-pop.dmg { color: #ffe14a; text-shadow: -2px -2px 0 #8a0000, 2px -2px 0 #8a0000, -2px 2px 0 #8a0000, 2px 2px 0 #8a0000; }
.pg-pop.heal { color: #8dff6a; text-shadow: -2px -2px 0 #0b4d00, 2px -2px 0 #0b4d00, -2px 2px 0 #0b4d00, 2px 2px 0 #0b4d00; }
.pg-turn-cue { animation: pg-cue 1.3s ease-out; }
.pg-seq { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); display: flex; gap: 8px; z-index: 5; }
.pg-seq i { width: 44px; height: 44px; border-radius: 10px; background: #0e1a3f none; border: 2px solid #4b6bd6; position: relative; }
.pg-seq i::before { content: '◀'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 24px sans-serif; }
.pg-seq i.a1::before { content: '▲'; } .pg-seq i.a2::before { content: '▼'; } .pg-seq i.a3::before { content: '▶'; }
.pg-seq i.done { background-color: #1f7a2c; border-color: #8dff6a; }
.pg-seq i.now { border-color: #ffd700; box-shadow: 0 0 12px #ffd700; }
[data-scene="battle"] .ug[data-name="btnUp"] > .ug-img { transform: rotate(-90deg); }
[data-scene="battle"] .ug[data-name="btnDown"] > .ug-img { transform: rotate(90deg); }
[data-scene="battle"] .ug[data-name="btnLeft"] > .ug-img { transform: rotate(180deg); }

@keyframes pg-bob { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.015); } }
@keyframes pg-bob-flip { 0%,100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-6px); } }
@keyframes pg-pulse { 50% { transform: scale(1.1); } }
@keyframes pg-pop { to { transform: scale(1.5); opacity: 0; } }
@keyframes pg-drop { from { transform: translateY(-120%); opacity: .3; } }
@keyframes pg-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes pg-spin { 50% { transform: scale(.9) rotate(3deg); opacity: .6; } }
@keyframes pg-float { from { opacity: 0; transform: translate(-50%, 20px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } to { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
@keyframes pg-cue { from { transform: scale(.3); opacity: 0; } 25% { transform: scale(1.15); opacity: 1; } 75% { transform: scale(1); opacity: 1; } to { opacity: 0; } }
@keyframes pg-sheet23 { to { background-position: 100% 0; } }
@keyframes pg-sheet18 { to { background-position: 100% 0; } }
@keyframes pg-sheet15 { to { background-position: 100% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.pg-fallen .ug-img { filter: grayscale(1) brightness(.6); }
.pg-dim .ug-img { filter: grayscale(.9) brightness(.55); }
.pg-live { animation: pg-live-glow 1.6s ease-in-out infinite; }
@keyframes pg-live-glow { 50% { filter: drop-shadow(0 0 14px #ffd700) brightness(1.15); } }
.pg-ended > .ug-img { filter: grayscale(.85) brightness(.6); }
/* Lobby panels open over a dimmed lobby so its labels never show through glass frames. */
.pg-modal { background-color: rgba(3, 8, 24, .4); }

/* Newcomer intro (public/pg/tutorial.mjs): guide dialogue, starter pick, spotlight and battle coach. */
#tut { position: fixed; inset: 0; z-index: 45; pointer-events: none; font: 17px/1.45 "UTM Azuki", system-ui, sans-serif; color: #fff; }
#tut:empty { display: none; }
#tut button { font: inherit; cursor: pointer; pointer-events: auto; }
#tut.tut-dim { pointer-events: auto; background: radial-gradient(ellipse at 50% 40%, #0a103080, #02040ccc); }
#tut.tut-solid { background: radial-gradient(ellipse at 50% 35%, #1b2a66fa, #050816fe); }
#tut.tut-hidden > * { visibility: hidden; }
.tut-talk { position: absolute; left: 50%; bottom: 3vh; transform: translateX(-50%); width: min(860px, 94vw); min-height: 150px; box-sizing: border-box;
  padding: 18px 22px 16px clamp(130px, 22vw, 230px); border: 3px solid #ffd76a; border-radius: 18px; cursor: pointer;
  background: linear-gradient(#24356df2, #111a3cf2); box-shadow: 0 10px 40px #000c, inset 0 0 0 2px #ffffff14; animation: tut-in .28s ease-out; }
.tut-npc { position: absolute; left: clamp(4px, 1vw, 14px); bottom: 0; height: clamp(190px, 46vh, 330px); filter: drop-shadow(0 6px 10px #000a); pointer-events: none; }
.tut-name { position: absolute; top: -17px; left: clamp(130px, 22vw, 230px); padding: 3px 14px; border-radius: 10px; background: linear-gradient(#ffe48a, #e0a52c);
  color: #4a2a00; font: 15px "UTM Erie Black", sans-serif; box-shadow: 0 2px 6px #0008; }
.tut-text { min-height: 74px; font-size: clamp(15px, 2.1vh + .4vw, 19px); text-shadow: 0 1px 2px #000; }
.tut-text b, .tut-bubble b { color: #ffe066; }
.tut-bar { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 10px; }
.tut-btn, .tut-card em { padding: 7px 22px; border: 2px solid #fff6; border-radius: 22px; background: linear-gradient(#ffd76a, #e8962a); color: #4a2400;
  font: 16px "UTM Erie Black", sans-serif; box-shadow: 0 3px 0 #9a5a10, 0 4px 10px #0008; }
.tut-btn:active, .tut-card:active em { transform: translateY(2px); box-shadow: 0 1px 0 #9a5a10; }
.tut-skip { background: none; border: 0; color: #c9d3ff; text-decoration: underline; font-size: 14px !important; opacity: .85; }
.tut-pick { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px; box-sizing: border-box; animation: tut-in .3s ease-out; }
.tut-pick h2 { margin: 0; font: clamp(22px, 4.5vh, 34px) "UTM Erie Black", sans-serif; color: #ffe066; text-shadow: 0 3px 0 #8a4b00, 0 0 18px #ffb300a0; }
.tut-pick p { margin: 0 0 1.5vh; color: #d7defa; text-align: center; }
.tut-cards { display: flex; gap: clamp(10px, 2vw, 26px); justify-content: center; }
.tut-card { width: clamp(170px, 26vw, 250px); padding: 10px 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff;
  border: 3px solid #6d86e0; border-radius: 18px; background: linear-gradient(#2c3f86, #15204a); box-shadow: 0 8px 24px #000a; transition: transform .15s, border-color .15s; }
.tut-card:hover { transform: translateY(-6px); border-color: #ffd76a; box-shadow: 0 10px 30px #000c, 0 0 22px #ffd76a66; }
.tut-art { width: 100%; height: clamp(110px, 26vh, 190px); overflow: visible; }
.tut-art img { display: block; width: 100%; height: 100%; object-fit: contain; animation: pg-bob 2.2s ease-in-out infinite; filter: drop-shadow(0 8px 6px #0009); }
.tut-card b { font: clamp(17px, 2.8vh, 22px) "UTM Erie Black", sans-serif; color: #ffe066; text-shadow: 0 2px 0 #000; }
.tut-el { display: flex; align-items: center; gap: 6px; font-size: 15px; } .tut-el img { width: 24px; height: 24px; }
.tut-stats { display: grid; grid-template-columns: auto auto auto auto; gap: 2px 8px; font: 15px "UTM Erie Black", sans-serif; }
.tut-stats i { font: 13px "UTM Azuki", sans-serif; color: #9fb3ff; font-style: normal; align-self: center; }
.tut-card small { min-height: 2.9em; font-size: 13px; line-height: 1.4; color: #cfd8ff; text-align: center; }
.tut-shade { position: absolute; background: #02061acc; pointer-events: auto; }
#tut.tut-free .tut-shade { display: none; }
.tut-ring { position: absolute; border-radius: 14px; box-shadow: 0 0 0 3px #ffe066, 0 0 22px 6px #ffd76acc; animation: tut-ring 1.2s ease-in-out infinite; pointer-events: none; }
.tut-hand { position: absolute; font-size: 40px; line-height: 1; animation: tut-tap 1s ease-in-out infinite; pointer-events: none; filter: drop-shadow(0 3px 3px #000a); }
.tut-bubble { position: absolute; display: flex; align-items: center; gap: 10px; max-width: min(460px, 86vw); padding: 10px 14px 10px 10px; box-sizing: border-box;
  border: 2px solid #ffd76a; border-radius: 14px; background: linear-gradient(#24356df5, #111a3cf5); box-shadow: 0 8px 26px #000b; pointer-events: auto; font-size: 15px; animation: tut-in .25s ease-out; }
.tut-bubble > img { width: 54px; height: 64px; object-fit: cover; object-position: top; border-radius: 10px; background: #ffffff18; flex: none; }
.tut-bubble .tut-skip { align-self: flex-end; white-space: nowrap; }
/* Battle tips sit in the left column (over the player's pet), clear of the board, the cards and the name bars. */
.tut-coachcard { left: 1vw; top: 36vh; width: min(330px, 27vw); max-width: none; padding-right: 30px; align-items: flex-start; font-size: clamp(12px, 1.6vh + .3vw, 15px); }
.tut-coachcard > img { width: 44px; height: 54px; }
.tut-x { position: absolute; right: 6px; top: 4px; border: 0; background: none; color: #fff; font-size: 16px !important; opacity: .8; }
.tut-gem { width: 24px; height: 24px; vertical-align: -6px; }
@keyframes tut-in { from { opacity: 0; translate: 0 14px; } }
@keyframes tut-ring { 50% { box-shadow: 0 0 0 5px #fff3a0, 0 0 32px 12px #ffd76aee; } }
@keyframes tut-tap { 50% { translate: 0 8px; } }

/* Connection badge (game.mjs net): latency in battle, banner while the live link is down. */
#net { position: fixed; top: 6px; right: 8px; z-index: 46; padding: 2px 9px 2px 20px; border-radius: 10px; background: #050a1ccc; color: #dfe6ff;
  font: 12px/18px "UTM Azuki", system-ui, sans-serif; pointer-events: none; }
#net::before { content: ''; position: absolute; left: 7px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: #9aa3b8; }
#net.good::before { background: #5dff7a; } #net.ok::before { background: #ffd34a; } #net.bad::before, #net.down::before { background: #ff4a4a; }
#net.down { top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%); padding: 10px 18px 10px 30px; font-size: 16px; border: 2px solid #ff6a6a; }
#net.down::before { left: 12px; top: 17px; }

/* Tabs: the open one stands up and glows, the others sink back (no outline box around a tab). */
.pg-tab-off { filter: brightness(.68) saturate(.55); }
.pg-tab-on { translate: 0 -3px; scale: 1.06; z-index: 2; filter: brightness(1.08) drop-shadow(0 0 7px #ffd34dcc) drop-shadow(0 3px 0 #0007); }
/* Character pick cards (tutorial): taller art for the full figure. */
.tut-look .tut-art { height: clamp(170px, 42vh, 330px); }
/* Aola breath loops (public/pg/breath.mjs) sit where the still portrait was; ended world bosses stay greyed. */
.pg-breath { position: absolute; inset: 0; pointer-events: none; }
.pg-breath > i { position: absolute; background-repeat: no-repeat; }
.pg-ended > .pg-breath { filter: grayscale(.85) brightness(.6); }
.pg-pet-idle > .pg-breath { animation: pg-bob 2.2s ease-in-out infinite; transform-origin: 50% 100%; }

/* Initial asset load; removed before the first interactive scene. */
#boot{position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;flex-direction:column;background:radial-gradient(ellipse at center,#263c73,#0b1228);color:#fff;text-align:center;padding:24px;font:16px system-ui,sans-serif}
#boot strong{font-size:36px;color:#ffdb74}#boot p{max-width:400px;line-height:1.5}#boot button{padding:10px 24px;border:1px solid #ffe391;border-radius:18px;background:#ffcf65;color:#352304;font-weight:700;cursor:pointer}
.boot-orbit{height:36px;width:36px;border:3px solid #ffffff35;border-top-color:#ffdb74;border-radius:50%;margin-bottom:18px;animation:boot-spin 1s linear infinite}@keyframes boot-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.boot-orbit{animation:none}}
