:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --ink: #123064;
  --deep: #18105f;
  --aqua: #39f8ff;
  --cyan: #a2d4d7;
  --pink: #ff3fba;
  --lime: #baff4a;
  --white: #fbffff;
  --glass: rgba(245, 255, 255, .55);
  --glass-strong: rgba(255, 255, 255, .76);
  --shadow: 0 16px 44px rgba(20, 18, 100, .24);
  --pixel: "Courier New", ui-monospace, monospace;
  --round: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  background:
    radial-gradient(ellipse at 15% 8%, rgba(255,63,186,.75), transparent 31%),
    radial-gradient(ellipse at 86% 16%, rgba(57,248,255,.82), transparent 33%),
    radial-gradient(ellipse at 42% 88%, rgba(186,255,74,.72), transparent 42%),
    linear-gradient(145deg, #ebe7ff 0%, #92eef9 42%, #ffa5e0 100%);
  touch-action: manipulation;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.18) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.5), transparent 1px) 0 0/12px 12px;
  mix-blend-mode: soft-light;
  animation: shimmer 5s linear infinite;
}
@keyframes shimmer { from { transform: translateY(0); } to { transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.app-container {
  position: relative; z-index: 1;
  min-height: 100dvh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  display: flex;
  flex-direction: column;
}
.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 10px clamp(10px, 3vw, 18px) 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,.82), rgba(162,212,215,.44));
  border: 2px solid rgba(255,255,255,.92);
  box-shadow: inset 0 0 18px rgba(57,248,255,.35), var(--shadow);
  backdrop-filter: blur(14px);
}
.orb { width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto; background: radial-gradient(circle at 32% 25%, #fff 0 13%, #39f8ff 15% 38%, #ff3fba 55%, #7b5cff 100%); box-shadow: 0 0 18px #39f8ff; }
h1 { margin: 0; font-size: clamp(16px, 4.8vw, 28px); letter-spacing: -.03em; color: #16246b; text-shadow: 0 1px 0 #fff, 0 0 14px rgba(255,63,186,.48); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
button, .file-btn {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  color: #0d2361;
  font-weight: 900;
  letter-spacing: .01em;
  font-size: 12px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #ffffff, #bdfcff 48%, #ffabdf 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.9), inset 0 -4px 0 rgba(52,45,150,.14), 0 8px 18px rgba(30,30,120,.22);
  cursor: pointer;
  touch-action: none;
}
button:active { transform: translateY(1px) scale(.99); }
button[disabled] { opacity: .55; filter: grayscale(.35); cursor: not-allowed; }

.lang-select {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.6);
  padding: 8px 12px;
  font-weight: 900;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, #152c7a, #8a5cff);
  cursor: pointer;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
}
.lang-select option { color: #16246b; background: #fff; }

.counter { min-height: 38px; display: grid; place-items: center; padding: 7px 9px; border-radius: 999px; background: rgba(255,255,255,.64); border: 1px solid rgba(255,255,255,.9); font-family: var(--pixel); font-weight: 900; color: #16418c; white-space: nowrap; }

.workbench { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) clamp(94px, 25vw, 138px); gap: 10px; align-items: stretch; }
.left { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.control-rail { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.random { color: #fff; background: linear-gradient(135deg, #ff3fba, #753cff 52%, #39f8ff); text-shadow: 0 1px 0 rgba(0,0,0,.14); }
.done { margin-left: auto; background: linear-gradient(180deg, #fff, #dbe0ff); }
.done.glow { color: #fff; background: linear-gradient(135deg, #ff2eb4, #31f2ff, #baff4a); box-shadow: 0 0 22px rgba(255,63,186,.9), inset 0 2px 0 rgba(255,255,255,.85); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { filter: saturate(1.35) brightness(1.08); transform: translateY(-1px); } }
.photo-tools { display: none; gap: 6px; align-items: center; flex-wrap: wrap; padding: 7px; border-radius: 18px; background: rgba(255,255,255,.5); border: 1px solid rgba(255,255,255,.86); }
.photo-tools.on { display: flex; }
.photo-tools label { font-size: 11px; font-weight: 900; }
input[type="range"] { accent-color: var(--pink); max-width: 130px; }
#photoInput { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }

.stage-card {
  min-width: 0;
  position: relative;
  border-radius: var(--round);
  padding: 8px;
  background: linear-gradient(145deg, rgba(255,255,255,.72), rgba(162,212,215,.32));
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: inset 0 0 30px rgba(57,248,255,.28), var(--shadow);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.stage-card::before { content: ""; position: absolute; inset: -40px; background: conic-gradient(from 90deg, transparent, rgba(255,63,186,.18), transparent, rgba(57,248,255,.2), transparent); animation: spin 8s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage-wrap { position: relative; z-index: 1; width: 100%; aspect-ratio: 3 / 4; max-height: min(58dvh, 620px); min-height: 340px; border-radius: 19px; overflow: hidden; background: #ccfbff; border: 3px solid rgba(255,255,255,.95); box-shadow: inset 0 0 0 3px rgba(255,63,186,.18), inset 0 -18px 55px rgba(111,59,255,.18); touch-action: none; }
.room, .baseLayer, .stickers, .sparkles { position: absolute; inset: 0; }
.baseLayer { display: grid; place-items: center; pointer-events: none; }
.doll { width: 44%; height: 78%; transform-origin: 50% 62%; animation: sway 3s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(57,248,255,.65)); }
@keyframes sway { 50% { transform: rotate(-1.4deg) translateY(2px); } }
.photoBase { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: center; touch-action: none; cursor: grab; pointer-events: auto; filter: drop-shadow(0 0 14px rgba(57,248,255,.55)); }
.stickers { z-index: 4; }
.placed { position: absolute; left: 0; top: 0; width: 78px; height: 78px; transform-origin: center; touch-action: none; cursor: grab; filter: drop-shadow(0 8px 10px rgba(21,21,90,.25)); }
.placed.selected .handle, .placed.selected .remove { display: grid; }
.placed.pop { animation: pop .24s cubic-bezier(.2,1.8,.3,1); }
@keyframes pop { from { opacity: .3; filter: drop-shadow(0 0 20px rgba(255,63,186,.9)); } }
.placed svg { width: 100%; height: 100%; overflow: visible; }
.handle, .remove { position: absolute; display: none; place-items: center; width: 28px; height: 28px; min-height: 28px; padding: 0; border-radius: 50%; border: 2px solid #fff; font-weight: 900; z-index: 8; box-shadow: 0 4px 12px rgba(0,0,0,.22); }
.handle { right: -18px; bottom: -18px; background: linear-gradient(135deg, #39f8ff, #ff3fba); color: white; font-size: 14px; cursor: nwse-resize; }
.remove { right: -18px; top: -18px; background: linear-gradient(135deg, #fff, #ff84ca); color: #5b1452; cursor: pointer; }
.sparkle { position: absolute; width: 20px; height: 20px; pointer-events: none; color: white; text-shadow: 0 0 10px #ff3fba; animation: sparkle .55s ease-out forwards; }
@keyframes sparkle { from { opacity: 1; transform: scale(.2) rotate(0deg); } to { opacity: 0; transform: scale(1.8) rotate(90deg) translateY(-16px); } }

.instruction { position: relative; z-index: 1; margin: 8px 4px 0; text-align: center; font-size: clamp(11px, 3.1vw, 14px); line-height: 1.25; font-weight: 900; color: #17266c; text-shadow: 0 1px #fff; }
.loader { min-height: 34px; margin-top: 6px; display: grid; place-items: center; }
.loadbox { display: none; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 12px; background: #fff; border: 3px solid #12206a; box-shadow: 0 5px 0 rgba(18,32,106,.22); font-family: var(--pixel); font-size: 11px; font-weight: 900; color: #17266c; }
.loadbox.on { display: flex; }
.snail { animation: snail .42s steps(3) infinite; }
@keyframes snail { 50% { transform: translateX(3px); } }
.bar { width: 82px; height: 14px; padding: 2px; background: #d9faff; border: 2px solid #17266c; }
.fill { width: 0%; height: 100%; background: repeating-linear-gradient(90deg, #ff3fba 0 8px, #39f8ff 8px 16px, #baff4a 16px 24px); animation: loadfill .4s steps(5) forwards; }
@keyframes loadfill { to { width: 100%; } }

.closet { min-width: 0; border-radius: 22px; background: linear-gradient(145deg, rgba(255,255,255,.72), rgba(255,175,224,.42)); border: 2px solid rgba(255,255,255,.9); box-shadow: var(--shadow), inset 0 0 24px rgba(57,248,255,.28); backdrop-filter: blur(16px); padding: 7px; display: flex; flex-direction: column; gap: 7px; max-height: calc(100dvh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom) - 92px); }
.tabs { display: grid; grid-template-columns: 1fr; gap: 5px; flex: 0 0 auto; }
.tab { min-height: 36px; padding: 6px 4px; border-radius: 14px; font-size: 10px; background: rgba(255,255,255,.62); }
.tab.active { color: #fff; background: linear-gradient(135deg, #17317e, #ff3fba); }
.items { min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 2px; display: grid; gap: 8px; align-content: start; }
.thumb { min-height: 82px; border-radius: 18px; background: linear-gradient(145deg, rgba(255,255,255,.82), rgba(162,212,215,.42)); border: 2px solid rgba(255,255,255,.92); display: grid; place-items: center; padding: 4px; touch-action: none; box-shadow: inset 0 1px 0 white, 0 8px 16px rgba(25,30,100,.15); }
.thumb svg { width: min(70px, 100%); height: 66px; overflow: visible; }
.thumb-name { font-size: 9px; font-weight: 900; line-height: 1; text-align: center; color: #17317e; }
.note { min-height: 18px; font-size: 11px; font-weight: 900; color: #74205c; text-align: center; }

.result { display: none; width: min(720px, 100%); margin: 0 auto; border-radius: 26px; background: linear-gradient(145deg, rgba(255,255,255,.82), rgba(57,248,255,.32), rgba(255,63,186,.24)); border: 2px solid rgba(255,255,255,.92); box-shadow: var(--shadow); padding: 12px; backdrop-filter: blur(18px); }
.result.on { display: block; }
.result h2 { margin: 0 0 4px; text-align: center; font-size: clamp(19px, 6vw, 34px); letter-spacing: -.04em; color: #14256c; text-shadow: 0 1px #fff, 0 0 18px rgba(57,248,255,.8); }
.result p { margin: 0 0 8px; text-align: center; font-family: var(--pixel); font-weight: 900; font-size: 12px; }
.result-art { width: min(360px, 100%); aspect-ratio: 3/4; margin: 0 auto 10px; border-radius: 20px; overflow: hidden; border: 3px solid white; background: #cdfbff; position: relative; }
.result-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.result-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.share-note { display: none; margin-top: 8px; padding: 8px; border-radius: 14px; text-align: center; font-size: 12px; font-weight: 900; background: rgba(255,255,255,.68); }
.share-note.on { display: block; }
.hidden { display: none !important; }

@media (min-width: 760px) {
  .shell { padding-inline: 18px; }
  .workbench { grid-template-columns: minmax(0, 1fr) 160px; gap: 14px; }
  .tabs { grid-template-columns: 1fr 1fr; }
  .closet { max-height: calc(100dvh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom) - 86px); }
  .stage-wrap { max-height: 68dvh; min-height: 460px; }
  .thumb { min-height: 94px; }
}
@media (max-width: 390px) {
  .shell { gap: 8px; padding-inline: 8px; }
  .workbench { grid-template-columns: minmax(0, 1fr) 92px; gap: 7px; }
  .stage-wrap { min-height: 330px; }
  button, .file-btn { font-size: 10px; padding-inline: 9px; }
  .lang-select { font-size: 10px; padding-inline: 9px; }
  .control-rail { gap: 5px; }
  .thumb { min-height: 78px; border-radius: 15px; }
  .instruction { font-size: 10.5px; }
  h1 { font-size: 15px; }
  .brand { padding: 7px 8px; }
  .orb { width: 24px; height: 24px; }
}
