@font-face { font-family: "LabRound"; src: url("../fonts/Fredoka.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "LabDisplay"; src: url("../fonts/LilitaOne.ttf") format("truetype"); font-weight: 400; font-display: swap; }
:root {
  --ink: #1d1433; --purple: #7b5cff; --blue: #339af0; --green: #37b24d; --orange: #ff922b;
  --red: #f03e3e; --yellow: #ffd43b; --pink: #f06595; --teal: #20c997; --cream: #fff9ec;
  --display: "LabDisplay", "LabRound", "Fredoka", system-ui, sans-serif;
  --font: "LabRound", "Fredoka", "Baloo 2", "Nunito", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--ink); font-weight: 600;
  background: radial-gradient(circle at 20% 10%, #b197fc 0, transparent 40%), radial-gradient(circle at 90% 80%, #74c0fc 0, transparent 45%), linear-gradient(160deg, #7b5cff, #4dabf7);
  background-attachment: fixed; min-height: 100vh; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
input { -webkit-user-select: text; user-select: text; font-family: var(--font); }
button, label.file-btn { font-family: var(--font); cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(29, 20, 51, .25); backdrop-filter: blur(6px);
}
#title { flex: 1; color: #fff; font-size: 1.6rem; font-weight: 700; text-shadow: 0 3px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { font-size: 1.8rem; width: 60px; height: 60px; border-radius: 20px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 5px 0 var(--ink); }
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.kid-chip { font-size: 1.1rem; background: #fff; border: 4px solid var(--ink); border-radius: 999px; padding: 6px 14px 6px 8px; display: none; align-items: center; gap: 6px; max-width: 40vw; overflow: hidden; white-space: nowrap; }
.kid-chip.show { display: flex; }
.kid-chip b { font-size: 1.6rem; }
main { padding: 12px 12px calc(40px + env(safe-area-inset-bottom)); max-width: 980px; margin: 0 auto; }
.screen { display: none; animation: screenIn .35s ease; }
.screen.active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- buttons ---------- */
.big-btn {
  font-size: 2.2rem; line-height: 1; padding: 12px 18px 10px; min-width: 104px; min-height: 92px;
  border-radius: 26px; border: 4px solid var(--ink); box-shadow: 0 7px 0 var(--ink);
  color: #fff; font-weight: 700; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--blue); position: relative; transition: transform .08s;
}
.big-btn span { font-size: 1.05rem; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.big-btn:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); }
.big-btn.wide { width: 100%; flex-direction: row; font-size: 1.8rem; }
.big-btn.wide span { font-size: 1.3rem; }
.b-blue { background: var(--blue); } .b-green { background: var(--green); } .b-orange { background: var(--orange); }
.b-purple { background: var(--purple); } .b-red { background: var(--red); } .b-pink { background: var(--pink); } .b-teal { background: var(--teal); }
.b-gray { background: #adb5bd; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 18px 0 8px; }

/* ---------- profiles ---------- */
.logo { text-align: center; color: #fff; font-size: clamp(2.6rem, 9vw, 4.4rem); margin: 18px 0 0; text-shadow: 0 5px 0 var(--ink); display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo b { color: var(--yellow); }
.logo-flask { display: inline-block; animation: wiggle 2.2s ease-in-out infinite; }
.sub { text-align: center; color: #fff; font-size: 1.6rem; margin: 6px 0 18px; text-shadow: 0 3px 0 var(--ink); }
.profile-list { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; }
.profile-btn {
  width: min(42vw, 300px); aspect-ratio: 1 / 1.1; border-radius: 40px; border: 6px solid var(--ink); box-shadow: 0 10px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; font-weight: 700;
  font-size: clamp(1.3rem, 4.5vw, 2rem); text-shadow: 0 3px 0 var(--ink); animation: bob 3s ease-in-out infinite;
}
.profile-btn:nth-child(2) { animation-delay: -1.5s; }
.profile-btn .av { font-size: clamp(4rem, 18vw, 8rem); text-shadow: none; filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); }
.profile-btn:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--ink); }
.parent-btn {
  display: block; margin: 40px auto 0; position: relative; overflow: hidden; border-radius: 999px; border: 3px solid rgba(255,255,255,.7);
  background: rgba(29,20,51,.35); color: #fff; font-size: 1rem; padding: 10px 20px; --p: 0;
}
.parent-btn .fill { position: absolute; inset: 0; width: calc(var(--p) * 100%); background: var(--yellow); opacity: .8; }
.parent-btn .lbl { position: relative; }
.parent-btn.holding { transform: scale(1.06); }

/* ---------- lab ---------- */
.lab-greet { color: #fff; font-size: 1.8rem; text-align: center; margin: 4px 0 14px; text-shadow: 0 3px 0 var(--ink); }
#s-lab {
  border-radius: 36px; padding: 16px; border: 6px solid var(--ink);
  background:
    linear-gradient(transparent 82%, #ffe066 82%, #ffe066 84%, transparent 84%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.12) 0 2px, transparent 2px 70px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.12) 0 2px, transparent 2px 70px),
    linear-gradient(#8ce99a, #63e6be 70%, #3bc9db);
  box-shadow: inset 0 -30px 0 rgba(0,0,0,.08), 0 10px 0 var(--ink);
}
.machines { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (min-width: 720px) { .machines { grid-template-columns: repeat(3, 1fr); } }
.machine {
  position: relative; border-radius: 30px; border: 5px solid var(--ink); box-shadow: 0 9px 0 var(--ink);
  min-height: 180px; padding: 30px 8px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: #fff; font-size: 1.35rem; font-weight: 700; text-shadow: 0 3px 0 var(--ink); overflow: hidden;
}
.machine::before { content: ""; position: absolute; left: 12%; right: 12%; top: 34px; height: 92px; border-radius: 22px; background: rgba(255,255,255,.28); border: 4px solid rgba(29,20,51,.5); }
.machine:active { transform: translateY(8px); box-shadow: 0 1px 0 var(--ink); }
.m-icon { font-size: 4.2rem; position: relative; text-shadow: none; animation: bob 2.6s ease-in-out infinite; }
.m-name { position: relative; text-align: center; }
.m-mixer { background: linear-gradient(#cc5de8, #9c36b5); }
.m-toon { background: linear-gradient(#ff8787, #f03e3e); }
.m-card { background: linear-gradient(#ffa94d, #f76707); }
.m-shelf { background: linear-gradient(#4dabf7, #1971c2); }
.m-battle { background: linear-gradient(#ff6b6b, #c92a2a 60%, #862e9c); }
.m-story { background: linear-gradient(#38d9a9, #0ca678 60%, #1864ab); }
.machine.locked { background: linear-gradient(#ced4da, #868e96); }
.machine.locked .m-icon { filter: grayscale(.8); opacity: .7; animation: none; }
.lock { position: absolute; top: 8px; right: 10px; background: var(--ink); padding: 3px 10px; border-radius: 999px; font-size: .95rem; }
.m-lights { position: absolute; top: 9px; left: 14px; display: flex; gap: 6px; }
.m-lights i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: var(--yellow); animation: blink 1.2s infinite; }
.m-lights i:nth-child(2) { background: #69db7c; animation-delay: .4s; } .m-lights i:nth-child(3) { background: #ff6b6b; animation-delay: .8s; }
.badge { position: absolute; top: 8px; right: 10px; background: var(--yellow); color: var(--ink); text-shadow: none; border: 3px solid var(--ink); border-radius: 999px; min-width: 38px; padding: 0 8px; font-size: 1.1rem; }
.badge:empty { display: none; }
.lab-floor { display: flex; justify-content: space-around; font-size: 2.6rem; margin-top: 18px; }
.lab-floor span { animation: bob 2s ease-in-out infinite; } .lab-floor span:nth-child(2n) { animation-delay: -1s; }

/* ---------- mixer ---------- */
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.slot { position: relative; background: #fff; border: 5px solid var(--ink); border-radius: 26px; padding: 8px; box-shadow: 0 6px 0 var(--ink); display: flex; flex-direction: column; gap: 6px; }
.slot.optional { border-style: dashed; background: #f8f9fa; }
.slot-tag { font-size: 1rem; text-align: center; font-weight: 700; }
.slot-img { aspect-ratio: 1; border-radius: 18px; background: repeating-linear-gradient(45deg, #e7f5ff 0 12px, #d0ebff 12px 24px); display: flex; align-items: center; justify-content: center; font-size: 3rem; overflow: hidden; }
.slot-img img { width: 100%; height: 100%; object-fit: cover; animation: popIn .4s cubic-bezier(.3,1.6,.6,1); }
.slot-btns { display: flex; gap: 6px; }
.mini-btn { flex: 1; font-size: 1.9rem; min-height: 58px; border-radius: 16px; border: 3px solid var(--ink); background: var(--yellow); box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; justify-content: center; }
.mini-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.slot-label { width: 100%; font-size: 1.1rem; padding: 8px; border-radius: 14px; border: 3px solid #ced4da; text-align: center; font-weight: 600; min-width: 0; }
.slot-x { position: absolute; top: -10px; right: -10px; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); background: var(--red); color: #fff; font-size: 1.1rem; display: none; }
.slot.filled .slot-x { display: block; }
.mix-machine { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 22px 0 10px; }
.tank { position: relative; width: 120px; height: 150px; border-radius: 50px 50px 24px 24px; border: 6px solid var(--ink); background: rgba(255,255,255,.55); overflow: hidden; box-shadow: 0 8px 0 var(--ink); }
.liquid { position: absolute; left: 0; right: 0; bottom: 0; height: 55%; background: linear-gradient(#69db7c, #2f9e44); transition: height .4s; }
.tank-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.bubbles i { position: absolute; bottom: -20px; width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.8); border: 2px solid rgba(29,20,51,.3); animation: bubble 2.4s infinite ease-in; }
.bubbles i:nth-child(1) { left: 10%; animation-delay: 0s; } .bubbles i:nth-child(2) { left: 30%; animation-delay: .5s; width: 10px; height: 10px; }
.bubbles i:nth-child(3) { left: 50%; animation-delay: 1.1s; } .bubbles i:nth-child(4) { left: 70%; animation-delay: .3s; width: 22px; height: 22px; }
.bubbles i:nth-child(5) { left: 85%; animation-delay: 1.6s; width: 12px; height: 12px; } .bubbles i:nth-child(6) { left: 20%; animation-delay: 1.9s; } .bubbles i:nth-child(7) { left: 60%; animation-delay: .8s; width: 8px; height: 8px; }
.lever-btn { position: relative; width: 170px; height: 170px; border-radius: 50%; border: 6px solid var(--ink); box-shadow: 0 10px 0 var(--ink); background: radial-gradient(circle at 35% 30%, #ff8787, #e03131 70%); color: #fff; font-size: 2.6rem; font-weight: 700; text-shadow: 0 4px 0 var(--ink); }
.lever-btn.ready { animation: pulse 1.1s ease-in-out infinite; }
.lever-btn.disabled { filter: grayscale(.85); opacity: .75; }
.lever-btn:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--ink); }
.lever { position: absolute; top: -46px; left: 50%; width: 12px; height: 56px; margin-left: -6px; background: #868e96; border: 3px solid var(--ink); border-radius: 6px; transform-origin: bottom center; transition: transform .2s; }
.knob { position: absolute; top: -22px; left: -14px; width: 34px; height: 34px; border-radius: 50%; background: var(--yellow); border: 4px solid var(--ink); }
.mix-machine.mixing .tank { animation: shake .15s linear infinite; }
.mix-machine.mixing .liquid { height: 95%; animation: rainbow 0.6s linear infinite; }
.mix-machine.mixing .bubbles i { animation-duration: .6s; }
.mix-machine.mixing .lever { transform: rotate(60deg); }
.mix-machine.mixing .lever-btn { animation: shake .2s linear infinite; }
.result { margin-top: 16px; background: #fff; border: 6px solid var(--ink); border-radius: 34px; padding: 16px; box-shadow: 0 10px 0 var(--ink); text-align: center; }
.result.pop { animation: popIn .6s cubic-bezier(.3,1.6,.6,1); }
.name-plate { display: inline-block; font-size: clamp(1.6rem, 6vw, 2.6rem); font-weight: 700; color: #fff; background: var(--purple); border: 5px solid var(--ink); border-radius: 22px; padding: 6px 18px; margin-bottom: 12px; text-shadow: 0 3px 0 var(--ink); transform: rotate(-2deg); }
.art { display: block; width: 100%; max-width: 512px; margin: 0 auto; border-radius: 26px; border: 5px solid var(--ink); background: #fff; }
.speech { position: relative; display: inline-block; margin: 18px auto 6px; padding: 12px 18px; font-size: 1.35rem; background: #fff3bf; border: 4px solid var(--ink); border-radius: 22px; max-width: 520px; }
.speech::before { content: ""; position: absolute; top: -16px; left: 50%; margin-left: -12px; border: 12px solid transparent; border-bottom-color: var(--ink); border-top: 0; }
.stats { max-width: 520px; margin: 10px auto 0; display: grid; gap: 8px; }
.stat { display: grid; grid-template-columns: 2.2rem 1fr 2.8rem; align-items: center; gap: 8px; font-size: 1.4rem; }
.stat .bar { height: 24px; border-radius: 999px; border: 3px solid var(--ink); background: #f1f3f5; overflow: hidden; }
.stat .bar i { display: block; height: 100%; border-radius: 999px; transition: width .8s cubic-bezier(.3,1.4,.6,1); }
.stat b { font-size: 1.3rem; }

/* ---------- toon ---------- */
.pick-row { text-align: center; padding: 30px 10px; background: rgba(255,255,255,.9); border: 6px solid var(--ink); border-radius: 34px; box-shadow: 0 10px 0 var(--ink); }
.big-hint { font-size: 2rem; margin: 6px 0; text-align: center; }
.file-btn { min-width: 150px; min-height: 130px; font-size: 3.4rem; }
.canvas-wrap { position: relative; max-width: 512px; margin: 0 auto; touch-action: none; }
.target { position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; border: 5px dashed #fff; box-shadow: 0 0 0 3px var(--ink); pointer-events: none; animation: spin 4s linear infinite; }
.hint { text-align: center; color: #fff; font-size: 1.4rem; text-shadow: 0 3px 0 var(--ink); margin: 10px 0; }
.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 640px; margin: 0 auto; }
.style-btn { font-size: 2.6rem; border-radius: 24px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 6px 0 var(--ink); padding: 10px 2px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.style-btn span { font-size: 1rem; font-weight: 700; color: var(--ink); }
.style-btn.active { background: var(--yellow); transform: translateY(-4px) rotate(-3deg); }
.sliders { max-width: 640px; margin: 18px auto 0; display: grid; gap: 12px; }
.slider { display: flex; align-items: center; gap: 12px; background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 8px 16px; font-size: 1.8rem; }
.slider .lbl { font-size: 1.05rem; min-width: 6.5rem; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 22px; border-radius: 999px; background: linear-gradient(90deg, #ffd43b, #ff6b6b); border: 3px solid var(--ink); min-width: 0; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 42px; height: 42px; border-radius: 50%; background: #fff; border: 5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
input[type=range]::-moz-range-thumb { width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 5px solid var(--ink); }
.slider b { min-width: 2.4rem; text-align: right; font-size: 1.3rem; }

/* ---------- card ---------- */
.card-pick { display: flex; gap: 10px; overflow-x: auto; padding: 6px 4px 14px; scroll-snap-type: x mandatory; }
.card-pick button { flex: 0 0 auto; width: 96px; height: 96px; border-radius: 20px; border: 4px solid var(--ink); padding: 0; overflow: hidden; background: #fff; box-shadow: 0 5px 0 var(--ink); scroll-snap-align: start; }
.card-pick button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-pick button.active { border-color: var(--yellow); box-shadow: 0 0 0 4px var(--ink), 0 5px 0 4px var(--ink); transform: translateY(-3px); }
.card-stage { display: grid; gap: 16px; align-items: start; }
@media (min-width: 820px) { .card-stage { grid-template-columns: 1fr 1fr; } }
.card-art { display: block; width: 100%; max-width: 420px; margin: 0 auto; filter: drop-shadow(0 10px 0 rgba(29,20,51,.6)); }
.card-controls { display: grid; gap: 10px; }
.text-in { display: flex; align-items: center; gap: 10px; background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 6px 14px; font-size: 1.8rem; }
.text-in input { flex: 1; border: 0; outline: 0; font-size: 1.3rem; font-weight: 600; min-width: 0; background: transparent; padding: 8px 0; }
#card-sliders { display: grid; gap: 10px; }
.card-empty { text-align: center; background: rgba(255,255,255,.92); border: 6px solid var(--ink); border-radius: 34px; padding: 24px; box-shadow: 0 10px 0 var(--ink); }
.empty-emoji { font-size: 5rem; animation: wiggle 2s ease-in-out infinite; display: inline-block; }

/* ---------- shelf ---------- */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.tab { font-size: 2rem; border-radius: 22px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 5px 0 var(--ink); padding: 8px 2px; display: flex; flex-direction: column; align-items: center; }
.tab span { font-size: .9rem; color: var(--ink); }
.tab.active { background: var(--yellow); transform: translateY(-3px); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.tile { position: relative; border-radius: 24px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 6px 0 var(--ink); padding: 0; overflow: hidden; animation: popIn .4s cubic-bezier(.3,1.6,.6,1) both; }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #f1f3f5; }
.tile.t-card img { object-fit: contain; background: #e7f5ff; }
.tile.t-story img { aspect-ratio: 4 / 3; }
.tile .tname { display: block; padding: 6px 6px 8px; font-size: .95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.tile .ttype { position: absolute; top: 6px; left: 6px; font-size: 1.4rem; background: #fff; border-radius: 50%; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border: 3px solid var(--ink); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(29,20,51,.6); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s; }
.modal-card { background: #fff; border: 6px solid var(--ink); border-radius: 34px; box-shadow: 0 10px 0 var(--ink); padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; text-align: center; animation: popIn .35s cubic-bezier(.3,1.6,.6,1); }
.modal-card .m-emoji { font-size: 4rem; }
.modal-card h2 { margin: 6px 0 12px; font-size: 1.8rem; }
.modal-card .m-input { width: 100%; font-size: 1.5rem; padding: 12px; border-radius: 18px; border: 4px solid var(--ink); text-align: center; font-weight: 600; }
.modal-card img.view { width: 100%; border-radius: 22px; border: 4px solid var(--ink); display: block; }
.modal-card .actions .big-btn { min-width: 90px; min-height: 84px; font-size: 2rem; }

/* ---------- parent ---------- */
.parent-wrap { background: #fff; border: 6px solid var(--ink); border-radius: 30px; padding: 18px; box-shadow: 0 10px 0 var(--ink); }
.parent-wrap h2 { margin: 0 0 10px; font-size: 2rem; } .parent-wrap h3 { margin: 22px 0 10px; font-size: 1.4rem; }
.parent-kids { display: grid; gap: 14px; }
@media (min-width: 720px) { .parent-kids { grid-template-columns: 1fr 1fr; } }
.kid-edit { border: 4px solid var(--ink); border-radius: 22px; padding: 12px; background: #f8f9fa; }
.kid-edit .row { display: flex; gap: 8px; align-items: center; }
.kid-edit .cur-av { font-size: 3rem; }
.kid-edit .age-row { margin-top: 10px; flex-wrap: wrap; font-size: 1.1rem; }
.kid-edit input.age-in { flex: 0 0 90px; text-align: center; }
.kid-edit .age-row .small { flex-basis: 100%; }
.modal-card .wins { font-size: 1.3rem; margin: 8px 0 0; }
.kid-edit input { flex: 1; font-size: 1.3rem; padding: 10px; border-radius: 14px; border: 3px solid var(--ink); min-width: 0; font-weight: 600; }
.av-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.av-grid button { font-size: 1.8rem; width: 50px; height: 50px; border-radius: 14px; border: 3px solid #dee2e6; background: #fff; }
.av-grid button.active { border-color: var(--ink); background: var(--yellow); }
.kid-edit .save-kid { margin-top: 10px; font-size: 1.1rem; padding: 10px 18px; border-radius: 14px; border: 3px solid var(--ink); background: var(--green); color: #fff; font-weight: 700; }
.parent-items { display: grid; gap: 8px; }
.p-item { display: flex; align-items: center; gap: 10px; border: 3px solid #dee2e6; border-radius: 16px; padding: 6px; }
.p-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.p-item .pi-name { flex: 1; text-align: left; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-item button { font-size: 1.4rem; border: 3px solid var(--ink); border-radius: 12px; background: #ffe3e3; padding: 6px 10px; }
.small { font-size: .95rem; color: #495057; font-weight: 500; }

/* ---------- toast & fx ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 150%); z-index: 60; background: var(--ink); color: #fff; font-size: 1.4rem; padding: 14px 22px; border-radius: 999px; transition: transform .3s cubic-bezier(.3,1.6,.6,1), visibility .3s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.toast { visibility: hidden; }
.toast.show { transform: translate(-50%, 0); visibility: visible; }
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti { position: absolute; top: -20px; width: 14px; height: 20px; border-radius: 4px; animation: fall 1.8s ease-in forwards; }
.wiggle { animation: wiggle .5s ease-in-out; }

@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes bubble { 0% { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-180px) scale(1.2); opacity: 0; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes shake { 0% { transform: translate(0,0) rotate(0); } 25% { transform: translate(-4px,2px) rotate(-3deg); } 50% { transform: translate(3px,-2px) rotate(2deg); } 75% { transform: translate(-2px,3px) rotate(-1deg); } 100% { transform: translate(0,0) rotate(0); } }
@keyframes rainbow { from { filter: hue-rotate(0); } to { filter: hue-rotate(360deg); } }
@keyframes popIn { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(110vh) rotate(720deg); opacity: .9; } }
@keyframes screenInNone {}
@media (max-width: 520px) {
  .kid-chip span { display: none; }
  .kid-chip { padding: 4px 8px; }
  #title { font-size: 1.25rem; }
}
@media (max-width: 420px) {
  .big-btn { min-width: 84px; min-height: 84px; font-size: 1.9rem; padding: 10px 12px; }
  .lever-btn { width: 140px; height: 140px; font-size: 2.2rem; }
  .tank { width: 96px; height: 130px; }
  .slot-label { font-size: .95rem; }
  .mini-btn { font-size: 1.5rem; min-height: 50px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; } }

/* ---------- add-on stage (Battle Arena / Story Theater) ---------- */
.addon-stage { position: fixed; inset: 0; z-index: 45; overflow: auto; -webkit-overflow-scrolling: touch; background: #2b2350; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.addon-open { overflow: hidden; }
#addon-stage .ba-root, #addon-stage .st-root { font-family: var(--font); min-height: 100%; }
@media (max-width: 520px) { .tab span { font-size: .72rem; } .tab { font-size: 1.7rem; } }

/* ---------- add-on layout fixes (scoped overrides; add-on files stay untouched) ---------- */
/* Story Theater: villain actor shares the .st-big class with the 116px end buttons -> keep it square */
#addon-stage .st-root .st-actor.st-big { height: auto; }
/* long page text: start at the top instead of centring, so overflow scrolls instead of being clipped */
#addon-stage .st-root .st-text { justify-content: flex-start; }
#addon-stage .st-root .st-text > :first-child { margin-top: auto; }
#addon-stage .st-root .st-text > :last-child { margin-bottom: auto; }
#addon-stage .st-root .st-text .st-pnum { margin: 0; }
#addon-stage .st-root .st-text .st-words { margin-top: auto; margin-bottom: auto; }
@media (max-width: 560px) {
  /* Story Theater on phones */
  #addon-stage .st-root .st-topbar { gap: 6px; padding: 8px 10px; }
  #addon-stage .st-root .st-round { width: 58px; height: 58px; min-width: 58px; min-height: 58px; }
  #addon-stage .st-root .st-round .st-btn-icon { font-size: 28px; }
  #addon-stage .st-root .st-steps { gap: 4px; }
  #addon-stage .st-root .st-step { width: 44px; height: 44px; font-size: 22px; }
  #addon-stage .st-root .st-book { margin: 0 8px; }
  #addon-stage .st-root .st-scene { flex: 1 1 48%; }
  #addon-stage .st-root .st-text { max-height: 52%; padding: 10px 14px 22px; }
  #addon-stage .st-root .st-words { font-size: 19px; line-height: 1.3; }
  #addon-stage .st-root .st-title { font-size: 26px; }
  #addon-stage .st-root .st-sub { font-size: 17px; }
  #addon-stage .st-root .st-nav { gap: 6px; padding: 10px 8px 14px; }
  #addon-stage .st-root .st-arrow { width: 70px; height: 70px; min-width: 70px; }
  #addon-stage .st-root .st-arrow .st-btn-icon { font-size: 38px; }
  #addon-stage .st-root .st-read, #addon-stage .st-root .st-auto { width: 60px; height: 60px; min-width: 60px; min-height: 60px; padding: 0; border-radius: 50%; }
  #addon-stage .st-root .st-read .st-btn-icon, #addon-stage .st-root .st-auto .st-btn-icon { font-size: 28px; }
  #addon-stage .st-root .st-dots { gap: 4px; min-width: 0; }
  #addon-stage .st-root .st-dot { width: 11px; height: 11px; border-width: 2px; }
  #addon-stage .st-root .st-end-btns { gap: 8px; }
  #addon-stage .st-root .st-end-btns .st-big { width: 76px; height: 76px; min-width: 76px; min-height: 76px; }
  #addon-stage .st-root .st-end-btns .st-big .st-btn-icon { font-size: 32px; }
  #addon-stage .st-root .st-btn-sub { font-size: 14px; }

  #addon-stage .st-root .st-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 8px 10px 16px; }
  #addon-stage .st-root .st-card-name { font-size: 15px; }
  #addon-stage .st-root .st-dice { font-size: 64px; }
  #addon-stage .st-root .st-heading { font-size: 28px; }

  /* Battle Arena on phones: let the pick screen scroll instead of squashing both grids */
  #addon-stage .ba-root.ba-phase-pick { height: auto; overflow: visible; }
  #addon-stage .ba-root.ba-phase-pick .ba-pick-cols { flex: 0 0 auto; gap: 12px; padding: 0 10px; }
  #addon-stage .ba-root.ba-phase-pick .ba-pick-col { flex: 0 0 auto; }
  #addon-stage .ba-root .ba-grid { flex: 0 0 auto; max-height: 52vh; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; }
  #addon-stage .ba-root .ba-pick-head { gap: 6px; padding: 8px; flex-wrap: nowrap; }
  #addon-stage .ba-root .ba-player-badge { font-size: 24px; padding: 0 2px; white-space: nowrap; }
  #addon-stage .ba-root .ba-chips { gap: 4px; flex-wrap: nowrap; min-width: 0; }
  #addon-stage .ba-root .ba-chip { min-height: 48px; padding: 2px 8px 2px 4px; font-size: 15px; border-width: 3px; white-space: nowrap; }
  #addon-stage .ba-root .ba-avatar-emoji { font-size: 24px; }
  #addon-stage .ba-root .ba-dice { width: 52px; height: 52px; min-width: 52px; min-height: 52px; font-size: 26px; }
  #addon-stage .ba-root .ba-topbar { gap: 8px; padding: 8px 10px; }
  #addon-stage .ba-root .ba-btn-round { width: 58px; height: 58px; min-height: 58px; font-size: 28px; }
  #addon-stage .ba-root .ba-title { font-size: 24px; }
  #addon-stage .ba-root.ba-phase-pick .ba-fight { position: sticky; bottom: 10px; z-index: 5; margin: 12px auto; }
  #addon-stage .ba-root .ba-result-card { padding: 14px 14px 18px; max-width: 94%; }
  #addon-stage .ba-root .ba-result-btns { gap: 10px; flex-wrap: wrap; justify-content: center; }
  #addon-stage .ba-root .ba-big { width: 88px; height: 88px; min-height: 88px; font-size: 38px; }
  #addon-stage .ba-root .ba-btn-sub { font-size: 15px; }
  #addon-stage .ba-root .ba-crown { font-size: 60px; }
  #addon-stage .ba-root .ba-result-name { font-size: 28px; }
}


/* =====================================================================
   v3 ART DIRECTION – one illustrated style: chunky ink + sticker whites,
   display font for titles, painted backgrounds per machine, softer motion
   ===================================================================== */
.logo, #title, .name-plate, .m-name, .lab-greet, .sub, .big-hint, .modal-card h2, .parent-wrap h2, .mix-word, .ml-title, .tab span, .style-btn span, .big-btn span, .pname {
  font-family: var(--display); font-weight: 400; letter-spacing: .4px;
}
.big-btn span, .style-btn span, .tab span { letter-spacing: .6px; }
.logo { text-shadow: 0 4px 0 var(--ink), 0 10px 18px rgba(29,20,51,.35); }
.logo b { color: var(--yellow); -webkit-text-stroke: 0; }
#title { text-shadow: 0 2px 0 var(--ink), 0 6px 12px rgba(29,20,51,.3); }
#topbar { background: linear-gradient(rgba(29,20,51,.42), rgba(29,20,51,.18)); border-bottom: 2px solid rgba(255,255,255,.18); }

/* ---- painted backgrounds per screen (body[data-screen]) ---- */
body { transition: background-color .4s; }
body[data-screen=profiles] {
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.18) 0 2px, transparent 3px) 0 0 / 46px 46px,
    radial-gradient(circle at 80% 10%, #ffa8d6 0, transparent 38%),
    radial-gradient(circle at 10% 90%, #74c0fc 0, transparent 42%),
    linear-gradient(165deg, #6741d9, #7b5cff 45%, #4dabf7);
  background-attachment: fixed;
}
body[data-screen=lab] {
  background:
    linear-gradient(rgba(255,255,255,.06) 2px, transparent 2px) 0 0 / 60px 60px,
    linear-gradient(90deg, rgba(255,255,255,.06) 2px, transparent 2px) 0 0 / 60px 60px,
    radial-gradient(circle at 50% -10%, #b2f2bb 0, transparent 55%),
    linear-gradient(170deg, #12b886, #0c8599 60%, #1864ab);
  background-attachment: fixed;
}
body[data-screen=mixer] {
  background:
    radial-gradient(circle, rgba(255,255,255,.16) 0 5px, transparent 6px) 0 0 / 64px 64px,
    radial-gradient(circle, rgba(255,255,255,.1) 0 9px, transparent 10px) 32px 32px / 64px 64px,
    radial-gradient(circle at 85% 15%, #f783ac 0, transparent 40%),
    radial-gradient(circle at 10% 85%, #63e6be 0, transparent 40%),
    linear-gradient(160deg, #862e9c, #7048e8 55%, #3b5bdb);
  background-attachment: fixed;
}
body[data-screen=toon] {
  background:
    radial-gradient(circle, rgba(29,20,51,.12) 0 3px, transparent 4px) 0 0 / 22px 22px,
    radial-gradient(circle at 80% 0%, #ffe066 0, transparent 45%),
    linear-gradient(160deg, #ff6b6b, #f76707 55%, #fcc419);
  background-attachment: fixed;
}
body[data-screen=card] {
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.05) 0 18px, transparent 18px 46px),
    radial-gradient(circle at 70% 20%, rgba(177,151,252,.55) 0, transparent 45%),
    radial-gradient(circle at 15% 80%, rgba(99,230,190,.4) 0, transparent 45%),
    linear-gradient(165deg, #1b1446, #3b2a7a 55%, #1864ab);
  background-attachment: fixed;
}
body[data-screen=shelf] {
  background:
    linear-gradient(transparent 0 calc(100% - 14px), rgba(29,20,51,.22) calc(100% - 14px)) 0 0 / 100% 210px,
    repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 3px, transparent 3px 26px),
    linear-gradient(170deg, #e8590c, #d9480f 40%, #862e9c);
  background-attachment: fixed;
}
body[data-screen=parent] { background: linear-gradient(165deg, #364fc7, #1c7ed6 60%, #15aabf); background-attachment: fixed; }

/* ---- motion: softer screen entrance + staggered children ---- */
.screen.active { animation: screenIn2 .45s cubic-bezier(.2,.9,.25,1.15); }
:where(.screen.active) > * { animation: riseIn .5s cubic-bezier(.2,.9,.25,1.1) both; }
:where(.screen.active) > :where(:nth-child(2)) { animation-delay: .05s; } :where(.screen.active) > :where(:nth-child(3)) { animation-delay: .1s; } :where(.screen.active) > :where(:nth-child(4)) { animation-delay: .15s; }
@keyframes screenIn2 { from { opacity: 0; transform: translateY(14px) scale(.985); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.machine { transition: transform .15s cubic-bezier(.3,1.6,.6,1), box-shadow .15s; }
@media (hover: hover) { .machine:hover { transform: translateY(-3px) rotate(-.6deg); } }

/* ---- profiles ---- */
.profile-btn { position: relative; background: linear-gradient(160deg, var(--kid, #339af0), var(--kid2, #1c7ed6)); overflow: hidden; }
.profile-btn::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 30% 18%, rgba(255,255,255,.45), transparent 45%); pointer-events: none; }
.profile-btn .av { filter: drop-shadow(0 0 0 #fff) drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 8px 6px rgba(29,20,51,.35)); }
.kid-lock { position: absolute; top: 12px; right: 14px; font-size: 1.8rem; background: #fff; border: 4px solid var(--ink); border-radius: 50%; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; text-shadow: none; z-index: 1; }
.parent-btn { border: 3px solid rgba(255,255,255,.75); background: rgba(29,20,51,.42); font-family: var(--display); letter-spacing: .5px; font-size: 1.15rem; padding: 12px 24px; min-height: 52px; }
.parent-btn:active { transform: scale(.97); }

/* ---- machine tiles: painted gloss ---- */
.machine::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 25% 12%, rgba(255,255,255,.35), transparent 40%), linear-gradient(transparent 70%, rgba(29,20,51,.18)); pointer-events: none; }
.m-icon { filter: drop-shadow(0 0 0 #fff) drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(0 6px 4px rgba(29,20,51,.35)); }
#s-lab { background: linear-gradient(transparent 82%, rgba(255,224,102,.9) 82%, rgba(255,224,102,.9) 84%, transparent 84%), repeating-linear-gradient(90deg, rgba(255,255,255,.12) 0 2px, transparent 2px 70px), repeating-linear-gradient(0deg, rgba(255,255,255,.12) 0 2px, transparent 2px 70px), linear-gradient(#b2f2bb, #63e6be 70%, #3bc9db); }

/* ---- result + art: sticker-like presentation ---- */
.result { background: linear-gradient(#fff, #fff9ec); }
.art { border-radius: 28px; box-shadow: 0 0 0 6px #fff, 0 0 0 9px var(--ink), 0 14px 22px rgba(29,20,51,.3); border: 0; }
#toon-canvas.art { background: transparent; box-shadow: none; border-radius: 0; filter: drop-shadow(0 10px 14px rgba(29,20,51,.35)); }
.name-plate { background: linear-gradient(#9775fa, #7048e8); box-shadow: 0 6px 0 var(--ink); }

/* ---- mixer slots with cut-outs ---- */
.slot-img { position: relative; cursor: pointer; }
.slot-img.has-cut { background: radial-gradient(circle at 50% 40%, #fff 0, #e5dbff 70%); }
.slot-img img.cut { object-fit: contain; padding: 8px; filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(0 5px 4px rgba(29,20,51,.35)); }
.cut-badge { position: absolute; right: 6px; bottom: 6px; font-size: 1.1rem; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 1px 6px; animation: popIn .4s cubic-bezier(.3,1.6,.6,1); }
.slot-img.picking { outline: 4px dashed var(--purple); outline-offset: -4px; }
.pick-hint { position: absolute; left: 4px; right: 4px; bottom: 6px; font-size: .85rem; background: rgba(29,20,51,.8); color: #fff; border-radius: 999px; padding: 4px 6px; text-align: center; pointer-events: none; }
.slot-img.cutting::after { content: "✂️"; position: absolute; top: 6px; right: 8px; font-size: 1.4rem; animation: wiggle .6s ease-in-out infinite; }
.scan { position: absolute; left: 0; right: 0; height: 30%; top: -30%; background: linear-gradient(transparent, rgba(132,94,247,.45), transparent); animation: scan 1.1s linear infinite; pointer-events: none; }
@keyframes scan { to { top: 100%; } }
.result[data-mode=smart] .art { box-shadow: 0 0 0 6px #fff, 0 0 0 9px var(--ink), 0 14px 22px rgba(29,20,51,.3); }

/* ---- lab brain loader ---- */
.ml-loader { display: none; align-items: center; gap: 14px; margin: 0 auto 12px; max-width: 520px; background: #fff; border: 4px solid var(--ink); border-radius: 22px; padding: 10px 16px; box-shadow: 0 6px 0 var(--ink); }
.ml-loader.show { display: flex; animation: popIn .4s cubic-bezier(.3,1.6,.6,1); }
.ml-loader.done { background: #d3f9d8; } .ml-loader.failed { background: #fff3bf; }
.ml-loader.done .brain-jar, .ml-loader.failed .brain-jar { animation: none; }
.brain-jar { position: relative; flex: 0 0 auto; width: 58px; height: 64px; border: 4px solid var(--ink); border-radius: 22px 22px 14px 14px; background: linear-gradient(transparent 35%, #b2f2bb 35%, #63e6be); overflow: hidden; animation: jarShake 1.2s ease-in-out infinite; }
.brain-jar .brain { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.9rem; animation: bob 1.4s ease-in-out infinite; }
.brain-jar i { position: absolute; bottom: -10px; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: bubble 1.6s infinite ease-in; }
.brain-jar i:nth-of-type(1) { left: 8px; } .brain-jar i:nth-of-type(2) { left: 22px; animation-delay: .4s; } .brain-jar i:nth-of-type(3) { left: 36px; animation-delay: .8s; } .brain-jar i:nth-of-type(4) { left: 14px; animation-delay: 1.2s; }
.ml-text { display: flex; align-items: baseline; gap: 6px; font-size: 1.25rem; text-align: left; }
.ml-dots i { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--ink); animation: blink 1s infinite; }
.ml-dots i:nth-child(2) { animation-delay: .2s; } .ml-dots i:nth-child(3) { animation-delay: .4s; }
.ml-loader.done .ml-dots, .ml-loader.failed .ml-dots { display: none; }
@keyframes jarShake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

/* ---- toon ---- */
.canvas-wrap.auto-face { cursor: default; }
.style-btn.active { background: linear-gradient(#ffe066, #fcc419); }

/* ---- trading card: foil shimmer overlay ---- */
.card-holo { position: relative; width: 100%; max-width: 420px; margin: 0 auto; border-radius: 6.5% / 4.6%; }
.card-holo .card-art { max-width: 100%; }
.card-holo.foil::after {
  content: ""; position: absolute; inset: 1%; border-radius: 6% / 4.3%; pointer-events: none; mix-blend-mode: color-dodge; opacity: .38;
  background: linear-gradient(115deg, transparent 20%, rgba(255,135,135,.8) 30%, rgba(255,212,59,.8) 38%, rgba(105,219,124,.8) 46%, rgba(77,171,247,.8) 54%, rgba(177,151,252,.8) 62%, transparent 72%) 0 0 / 250% 250%;
  animation: foil 4.5s ease-in-out infinite;
}
.card-holo[data-rarity=legendary]::after { opacity: .5; }
@keyframes foil { 0% { background-position: 100% 100%; } 50% { background-position: 0 0; } 100% { background-position: 100% 100%; } }
.tile.t-card img { background: radial-gradient(circle, #fff, #e5dbff); }

/* ---- shelf tiles: sticker frames ---- */
.tile { box-shadow: 0 6px 0 var(--ink), 0 12px 18px rgba(29,20,51,.25); }
.tile img { border-bottom: 3px solid var(--ink); }

/* ---- PIN keypad + picture PIN ---- */
.pin-box h2 { margin-bottom: 6px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 10px 0 4px; min-height: 30px; }
.pin-dots i { width: 24px; height: 24px; border-radius: 50%; border: 4px solid var(--ink); background: #fff; transition: transform .12s, background .12s; }
.pin-dots i.on { background: var(--purple); transform: scale(1.12); }
.pin-msg { min-height: 1.6em; margin: 6px 0 10px; font-size: 1.1rem; }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 330px; margin: 0 auto; }
.pin-key { font-family: var(--display); font-size: 2rem; min-height: 72px; border-radius: 22px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 5px 0 var(--ink); color: var(--ink); }
.pin-key:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.pin-key.ok { background: var(--green); color: #fff; } .pin-key.del { background: #f1f3f5; }
.pin-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.link-btn { background: none; border: 0; color: #5f3dc4; font-size: 1.05rem; text-decoration: underline; padding: 10px 6px; min-height: 44px; }
.pin-box.busy .pin-keys, .pin-box.busy .pic-grid { opacity: .5; pointer-events: none; }
.pic-slots { display: flex; justify-content: center; gap: 14px; margin: 8px 0 2px; }
.pic-slot { width: 64px; height: 64px; border-radius: 20px; border: 4px dashed #adb5bd; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; background: #f8f9fa; }
.pic-slot.on { border: 4px solid var(--ink); background: #fff3bf; animation: popIn .3s cubic-bezier(.3,1.6,.6,1); }
.pic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 340px; margin: 0 auto; }
.pic-btn { font-size: 2.8rem; min-height: 88px; border-radius: 24px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 5px 0 var(--ink); }
.pic-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); background: #fff3bf; }

/* ---- parent security ---- */
.parent-sec { display: grid; gap: 10px; }
.sec-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; border: 3px solid #dee2e6; border-radius: 16px; padding: 10px 12px; text-align: left; }
.sec-row b { min-width: 9.5rem; }
.sec-val { flex: 1 1 14rem; font-weight: 500; }
.sec-row .small { flex-basis: 100%; }
.mini-act { font-family: var(--font); font-size: 1rem; font-weight: 700; padding: 8px 14px; min-height: 44px; border-radius: 14px; border: 3px solid var(--ink); background: #fff3bf; color: var(--ink); }
.mini-act:disabled { opacity: .6; }
.pic-row { margin-top: 10px; flex-wrap: wrap; font-size: 1.05rem; }
.pic-row > span { flex: 1 1 10rem; }
@media (max-width: 420px) {
  .pin-key { min-height: 64px; font-size: 1.8rem; }
  .pic-btn { min-height: 76px; font-size: 2.4rem; }
  .pic-slot { width: 56px; height: 56px; }
  .ml-text { font-size: 1.05rem; }
  .style-btn span { font-size: .8rem; letter-spacing: .2px; }
  .style-btn { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) { .card-holo.foil::after { animation: none; } .scan { display: none; } }

/* ---------- AI Lab (v4) ---------- */
.art-wrap { position: relative; max-width: 512px; margin: 0 auto; }
.art-wrap.is-ai::after { content: "✨ AI"; position: absolute; top: 12px; left: 12px; background: linear-gradient(135deg, #cc5de8, #7b5cff); color: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 2px 12px; font-size: 1.05rem; box-shadow: 0 3px 0 var(--ink); }
.ai-wait { position: absolute; inset: 0; border-radius: 26px; background: rgba(29,20,51,.78); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; text-shadow: 0 3px 0 var(--ink); z-index: 2; }
.ai-wait p { font-size: 1.5rem; margin: 10px 12px 4px; text-align: center; min-height: 2em; }
.cauldron { position: relative; width: 150px; height: 150px; }
.cauldron .pot { position: absolute; left: 50%; top: 50%; font-size: 92px; transform: translate(-50%, -50%); animation: potWobble 1.1s ease-in-out infinite; }
.cauldron i { position: absolute; bottom: 70%; left: 50%; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #b197fc 60%, #7b5cff); border: 2px solid var(--ink); animation: bubbleUp 1.8s ease-in infinite; opacity: 0; }
.cauldron i:nth-child(2) { margin-left: -30px; animation-delay: .3s; } .cauldron i:nth-child(3) { margin-left: 18px; animation-delay: .7s; width: 12px; height: 12px; }
.cauldron i:nth-child(4) { margin-left: -12px; animation-delay: 1.1s; width: 24px; height: 24px; } .cauldron i:nth-child(5) { margin-left: 30px; animation-delay: 1.4s; }
@keyframes potWobble { 0%, 100% { transform: translate(-50%, -50%) rotate(-8deg); } 50% { transform: translate(-50%, -54%) rotate(8deg); } }
@keyframes bubbleUp { 0% { transform: translateY(0) scale(.4); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-90px) scale(1.2); opacity: 0; } }
.ai-dots b { display: inline-block; width: 12px; height: 12px; margin: 0 4px; border-radius: 50%; background: #ffd43b; animation: aiDot 1s infinite; }
.ai-dots b:nth-child(2) { animation-delay: .15s; } .ai-dots b:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.backstory { max-width: 520px; margin: 8px auto 4px; font-size: 1.15rem; line-height: 1.45; background: #f3f0ff; border: 3px dashed #9775fa; border-radius: 18px; padding: 10px 14px; text-align: left; }
.ai-panel { max-width: 560px; margin: 16px auto 4px; background: linear-gradient(160deg, #f3f0ff, #fff0f6); border: 5px solid var(--ink); border-radius: 26px; padding: 12px; box-shadow: 0 6px 0 var(--ink); }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 1.4rem; margin-bottom: 8px; flex-wrap: wrap; }
.sparks { font-size: 1.05rem; background: #fff3bf; border: 3px solid var(--ink); border-radius: 999px; padding: 2px 12px; }
.ai-styles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 12px; }
.ai-styles .style-btn { font-size: 2rem; padding: 6px 2px; border-radius: 18px; box-shadow: 0 4px 0 var(--ink); }
.ai-styles .style-btn span { font-size: .85rem; }
.b-magic { background: linear-gradient(135deg, #f06595, #cc5de8 45%, #7b5cff); }
.big-btn:disabled, .big-btn.disabled { filter: grayscale(.7); opacity: .65; }
.ai-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 280px; margin: 12px auto 0; }
.ai-toggle .tab { font-size: 1.5rem; }
.ai-note { margin: 10px 4px 0; text-align: center; }
@media (max-width: 520px) { .ai-styles { grid-template-columns: repeat(3, 1fr); } }
/* shelf */
.shelf-bar { display: flex; gap: 8px; margin: -4px 0 12px; }
.shelf-ev { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 1.5rem; border-radius: 18px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 4px 0 var(--ink); padding: 6px 10px; }
.shelf-ev span { font-size: 1rem; font-weight: 700; color: var(--ink); }
.shelf-ev.active { background: #d3f9d8; }
.shelf-sync { width: 60px; font-size: 1.6rem; border-radius: 18px; border: 4px solid var(--ink); background: #fff; box-shadow: 0 4px 0 var(--ink); }
.shelf-sync.spinning { animation: spin 1s linear infinite; }
.tile .towner, .tile .tai, .tile .tcloud { position: absolute; top: 6px; font-size: 1.3rem; background: #fff; border: 3px solid var(--ink); border-radius: 999px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.tile .towner { right: 6px; } .tile .tai { left: 6px; } .tile .tcloud { right: 46px; font-size: 1.1rem; }
/* parent zone: AI Lab */
.cf-wrap { display: grid; gap: 12px; text-align: left; }
.cf-card { border: 4px solid var(--ink); border-radius: 20px; padding: 12px 14px; background: #f8f9fa; display: grid; gap: 8px; }
.cf-card h4 { margin: 0; font-size: 1.25rem; }
.cf-card p { margin: 0; }
.cf-row { display: grid; gap: 4px; font-size: 1.05rem; }
.cf-row input:not([type=checkbox]), .cf-row select { font-family: var(--font); font-size: 1.15rem; padding: 10px; border-radius: 14px; border: 3px solid var(--ink); font-weight: 600; min-width: 0; background: #fff; }
.cf-row .cf-num { max-width: 140px; }
.cf-inline { grid-template-columns: auto 1fr; align-items: center; column-gap: 10px; }
.cf-inline .small { grid-column: 1 / -1; }
.cf-toggle { width: 30px; height: 30px; accent-color: var(--purple); }
.cf-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cf-tab { font-family: var(--font); font-size: 1.05rem; font-weight: 700; padding: 10px; border-radius: 14px; border: 3px solid var(--ink); background: #fff; }
.cf-tab.on { background: var(--yellow); }
.cf-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cf-ok { color: #2b8a3e; font-weight: 700; }
.cf-err { color: #c92a2a; font-weight: 700; min-height: 1em; }
.cf-meter { height: 16px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.cf-meter i { display: block; height: 100%; background: linear-gradient(90deg, #69db7c, #ffd43b, #ff6b6b); }
.cf-kid { border: 3px solid #dee2e6; border-radius: 16px; padding: 10px; display: grid; gap: 6px; background: #fff; }
.cf-kid-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 1.15rem; }
.cf-qr { display: grid; justify-items: center; gap: 8px; text-align: center; }
.cf-qr-canvas { width: min(280px, 70vw); height: auto; image-rendering: pixelated; border: 4px solid var(--ink); border-radius: 16px; }
.cf-code { font-size: 2rem; letter-spacing: 3px; font-weight: 700; background: #fff; border: 3px dashed var(--ink); border-radius: 14px; padding: 4px 14px; user-select: all; }
.cf-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; border-bottom: 2px solid #e9ecef; padding: 6px 0; }
.cf-dev .mini-act { margin-left: auto; }
/* QR scanner */
.scan-box h2 { margin-top: 0; }
.scan-frame { position: relative; width: min(320px, 76vw); aspect-ratio: 1; margin: 0 auto; border: 5px solid var(--ink); border-radius: 22px; overflow: hidden; background: #000; }
.scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-line { position: absolute; left: 8%; right: 8%; height: 4px; background: #69db7c; box-shadow: 0 0 12px #69db7c; animation: scanLine 1.6s ease-in-out infinite alternate; }
@keyframes scanLine { from { top: 10%; } to { top: 88%; } }
.toast { pointer-events: none; white-space: normal; text-align: center; border-radius: 26px; width: max-content; line-height: 1.25; }

/* ---- AI monster flow (v5): small style chips above MIX, fallback note, waiting state ---- */
.mix-styles { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; max-width: 620px; margin: 4px auto 10px; }
.mix-styles .style-lbl { font-weight: 800; font-size: .95rem; margin-right: 2px; }
.style-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 1.05rem; padding: 4px 10px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; box-shadow: 0 3px 0 var(--ink); color: var(--ink); }
.style-chip span { font-size: .9rem; font-weight: 800; }
.style-chip.active { background: linear-gradient(#ffe066, #fcc419); transform: translateY(-2px); }
.style-chip[data-style=surprise].active { background: linear-gradient(135deg, #e599f7, #91a7ff); }
.mix-note { max-width: 560px; margin: 8px auto; padding: 8px 12px; background: #fff9db; border: 3px dashed var(--ink); border-radius: 16px; font-weight: 700; text-align: center; }
.result[data-mode=ai-wait] .actions, .result[data-mode=ai-wait] .stats, .result[data-mode=ai-wait] .ai-panel { display: none; }
.result[data-mode=ai-wait] .speech { opacity: .5; }
.af-card { background: transparent; border: 0; padding: 0; text-align: left; }
.af-card h2, .af-card .m-emoji { text-align: center; }
#mix-ask, #mix-ai-go { margin-top: 6px; }

/* ---- machine descriptions + How to play help ---- */
.m-desc { position: relative; display: block; font-size: .82rem; font-weight: 700; line-height: 1.2; text-align: center; opacity: .85; margin-top: 2px; padding: 0 6px; font-family: var(--font); letter-spacing: 0; }
.help-btn { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 4px solid var(--ink); background: linear-gradient(#ffe066, #fcc419); color: var(--ink); font-size: 1.9rem; font-weight: 900; line-height: 1; box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; justify-content: center; padding: 0; }
.help-btn.help-float { position: fixed; z-index: 48; right: 10px; top: calc(env(safe-area-inset-top) + 74px); width: 52px; height: 52px; font-size: 1.9rem; }
@media (max-width: 420px) { .help-btn { width: 44px; height: 44px; font-size: 1.6rem; } }
.help-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.help-card { position: fixed; inset: 0; z-index: 52; background: rgba(29,20,51,.6); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .2s; }
.help-inner { background: #fff9ec; border: 5px solid var(--ink); border-radius: 28px; box-shadow: 0 8px 0 var(--ink); padding: 16px 18px; max-width: 440px; width: 100%; max-height: 92vh; overflow: auto; text-align: center; }
.help-icon { font-size: 3.2rem; line-height: 1; }
.help-inner h2 { margin: 4px 0 2px; }
.help-line { margin: 0 0 10px; font-weight: 700; }
.help-steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.help-steps li { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 6px 10px; text-align: left; }
.help-num { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.help-emoji { font-size: 2.1rem; line-height: 1; }
.help-txt { font-size: 1.2rem; font-weight: 800; }
#help-ok { font-size: 1.6rem; }

/* ---- creature picker (Monster Mixer slot 3) ---- */
.creature-slot .slot-img { cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 3.2rem; background: linear-gradient(160deg, #e7f5ff, #fff0f6); }
.creature-slot .cr-emoji { font-size: 4rem; line-height: 1; }
.creature-slot .cr-name { font-weight: 800; text-align: center; font-size: 1rem; min-height: 1.3em; text-transform: capitalize; }
.cp-box { display: flex; flex-direction: column; gap: 8px; width: min(640px, 94vw); max-height: 86vh; }
.cp-head { display: flex; align-items: center; gap: 8px; }
.cp-head h2 { margin: 0; flex: 1; text-align: left; }
.cp-search { flex: 1; font-size: 1.2rem; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 999px; min-width: 0; }
.cp-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.cp-tab { flex: none; border: 3px solid var(--ink); border-radius: 999px; background: #fff; padding: 4px 10px; font-weight: 800; font-size: .95rem; white-space: nowrap; color: var(--ink); }
.cp-tab.on { background: linear-gradient(#ffe066, #fcc419); }
.cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; overflow-y: auto; padding: 4px; min-height: 200px; -webkit-overflow-scrolling: touch; }
.cp-item { border: 3px solid var(--ink); border-radius: 18px; background: #fff; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 3px 0 var(--ink); color: var(--ink); }
.cp-item .cp-e { font-size: 2.6rem; line-height: 1.1; }
.cp-item .cp-n { font-size: .85rem; font-weight: 800; text-transform: capitalize; line-height: 1.1; text-align: center; }
.cp-item.on { background: linear-gradient(#d3f9d8, #b2f2bb); transform: translateY(-2px); }
.cp-empty { grid-column: 1 / -1; text-align: center; font-weight: 700; }
