/* Lyloria (Phaser rebuild) — UI styles
 * Cozy pink/peach aesthetic. DOM overlays sit above the fullscreen canvas.
 * Conventions: dvh units with vh fallback, env(safe-area-inset-*), 44px+
 * touch targets, touch-action:none on the game surface + joystick. */

/* ---------- base ---------- */
*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body{ height:100%; height:100dvh; }
body{
  margin:0; background:#2b1d33; color:#6b4a3a;
  font-family:"Trebuchet MS","Comic Sans MS",system-ui,sans-serif;
  overflow:hidden; overscroll-behavior:none;
  user-select:none; -webkit-user-select:none;
  touch-action:manipulation;
}
.hidden{ display:none !important; }

/* ---------- game canvas: fullscreen fixed behind UI ---------- */
#game{
  position:fixed; inset:0; z-index:0;
  touch-action:none; /* no scroll / pinch-zoom gestures on the game area */
}
#game canvas{
  position:absolute; inset:0;
  width:100% !important; height:100% !important;
  image-rendering:pixelated; image-rendering:crisp-edges;
  touch-action:none;
  display:block;
}

/* ---------- HUD ---------- */
#hud{
  position:fixed; top:0; left:0; right:0; z-index:20;
  display:flex; justify-content:space-between; align-items:flex-start;
  gap:6px; flex-wrap:wrap;
  padding:calc(8px + env(safe-area-inset-top)) 10px 8px;
  pointer-events:none;
}
#hudLeft, #hudRight{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  pointer-events:auto;
}
.pill{
  background:rgba(255,250,243,.94); border:2px solid #ffd3e0; border-radius:999px;
  padding:4px 12px; font-size:14px; font-weight:bold; color:#8a5a44;
  white-space:nowrap;
}
.pill.clock{ background:rgba(232,240,255,.94); border-color:#bcd2f5; }
.pill.wx{ background:rgba(255,248,230,.94); border-color:#f0d9a8; }
#xpbar{
  width:80px; height:12px; background:rgba(255,255,255,.7);
  border:2px solid #ffd3e0; border-radius:999px; overflow:hidden;
}
#xpfill{ display:block; height:100%; width:0%;
  background:linear-gradient(90deg,#ffb3cd,#f76d96); }
.hbtn{
  font-family:inherit; font-size:20px; line-height:1;
  background:rgba(255,250,243,.94); border:2px solid #ffd3e0;
  border-radius:14px; padding:6px 10px; cursor:pointer; color:#8a5a44;
  min-width:44px; min-height:44px;
}
.hbtn.on{ background:#ffe3ee; border-color:#f76d96; }

/* ---------- touch controls ---------- */
#touchUI{ position:fixed; inset:0; z-index:15; pointer-events:none; }
#joy{
  position:absolute; left:18px; bottom:calc(24px + env(safe-area-inset-bottom));
  width:110px; height:110px; border-radius:50%;
  background:rgba(255,255,255,.18); border:2px solid rgba(255,255,255,.5);
  pointer-events:auto; touch-action:none;
}
#joyKnob{
  position:absolute; left:35px; top:35px; width:40px; height:40px; border-radius:50%;
  background:rgba(255,255,255,.65);
}
#btnAct{
  position:absolute; right:22px; bottom:calc(40px + env(safe-area-inset-bottom));
  width:64px; height:64px; border-radius:50%;
  font-size:26px; color:#fff; border:3px solid #fff;
  background:linear-gradient(#ff9ebb,#f76d96); pointer-events:auto;
  box-shadow:0 4px 14px rgba(0,0,0,.3);
}

/* ---------- dialog (bottom sheet) ---------- */
#dlg{
  position:fixed; left:50%; transform:translateX(-50%); bottom:12px; z-index:25;
  width:min(94vw,560px); background:rgba(255,250,243,.97);
  border:4px solid #fff; border-radius:20px; padding:12px 16px;
  box-shadow:0 8px 30px rgba(0,0,0,.35);
}
#dlgName{ font-weight:bold; color:#d14e7c; margin-bottom:2px; font-size:16px; }
#dlgHearts{ font-size:14px; letter-spacing:2px; margin-bottom:4px; }
#dlgText{ font-size:15px; color:#6b4a3a; min-height:40px; line-height:1.45; }
#dlgBtns{ display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
.dlg-hint{ font-size:11px; color:#c9a08a; text-align:right; margin-top:6px; }

/* ---------- toast ---------- */
#toast{
  position:fixed; left:50%; bottom:120px; transform:translateX(-50%); z-index:60;
  background:#6b4a3a; color:#fff; padding:10px 20px; border-radius:999px;
  font-size:15px; box-shadow:0 6px 18px rgba(0,0,0,.3);
  max-width:92vw; text-align:center;
}

/* ---------- modal ---------- */
#modal{
  position:fixed; inset:0; z-index:70; background:rgba(60,30,45,.5);
  display:flex; align-items:center; justify-content:center; padding:12px;
  padding-bottom:calc(12px + env(safe-area-inset-bottom));
}
#modalBox{
  background:#fffaf3; border:5px solid #fff; border-radius:22px;
  padding:16px; width:min(96vw,520px);
  max-height:88vh; max-height:88dvh; overflow-y:auto;
  box-shadow:0 14px 44px rgba(0,0,0,.4); text-align:center;
  overscroll-behavior:contain;
}
#modalBox h2{ margin:0 0 10px; color:#d14e7c; }
#modalBox p{ color:#6b4a3a; }
.mrow{ display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin:8px 0; }

/* ---------- buttons ---------- */
.btn{
  font-family:inherit; font-weight:bold; font-size:15px; color:#fff;
  background:linear-gradient(#ff9ebb,#f76d96); border:none; border-radius:14px;
  padding:10px 18px; cursor:pointer; box-shadow:0 4px 0 #d14e7c;
  min-height:44px;
}
.btn:active{ transform:translateY(3px); box-shadow:none; }
.btn:disabled{ filter:grayscale(.8); opacity:.55; cursor:default; transform:none; box-shadow:0 4px 0 #d14e7c; }
.btn-ghost{
  font-family:inherit; font-weight:bold; font-size:14px; color:#c05a7e;
  background:#fff; border:2px solid #ffd3e0; border-radius:14px;
  padding:8px 14px; cursor:pointer; min-height:44px;
}
.btn-ghost:active{ background:#fff0f5; }
.tabbtn{
  font-family:inherit; font-weight:bold; font-size:14px; color:#c05a7e;
  background:#fff; border:2px solid #ffd3e0; border-radius:999px;
  padding:8px 16px; cursor:pointer; min-height:44px;
}
.tabbtn.sel{ background:#ffe3ee; border-color:#f76d96; color:#d14e7c; }
.etabs{ display:flex; gap:8px; justify-content:center; margin:4px 0 10px; }
.ownedpill{
  display:inline-block; font-size:13px; font-weight:bold; color:#5da25d;
  background:#eefbe8; border:2px solid #b8e6b8; border-radius:999px;
  padding:6px 12px; white-space:nowrap;
}

/* ---------- creator / pick cards ---------- */
.pick{
  border:4px solid transparent; border-radius:16px; background:#fff;
  padding:8px; cursor:pointer; min-width:74px; min-height:44px;
}
.pick.sel{ border-color:#f76d96; box-shadow:0 4px 12px rgba(247,109,150,.4); }
.pick.locked{ opacity:.45; }
.pick img{ width:52px; height:52px; image-rendering:pixelated; display:block; margin:0 auto; }
.pick small{ display:block; font-size:11px; color:#a9806a; margin-top:2px; pointer-events:none; }
.noimg{ display:block; width:52px; height:52px; margin:0 auto; }
canvas#doll{
  image-rendering:pixelated; width:96px; height:120px;
  background:#fff; border-radius:14px; border:3px solid #ffe3ee;
}
input.txt{
  font-family:inherit; font-size:16px; padding:10px 14px; border:3px solid #ffd3e0;
  border-radius:14px; text-align:center; width:80%; margin:8px 0; outline:none;
  color:#6b4a3a; background:#fff; user-select:text; -webkit-user-select:text;
}

/* ---------- shop rows ---------- */
#shoprows{ text-align:left; }
.shopitem{
  display:flex; align-items:center; gap:10px; background:#fff;
  border:2px solid #ffe3ee; border-radius:14px; padding:8px; margin:6px 0; text-align:left;
}
.shopitem .sicon{ flex:0 0 44px; }
.shopitem img{ width:44px; height:44px; image-rendering:pixelated; display:block; }
.eimg{ font-size:34px; line-height:44px; width:44px; height:44px; display:inline-block; text-align:center; }
.shopitem .inf{ flex:1; min-width:0; }
.shopitem .inf b{ color:#8a5a44; }
.shopitem .inf small{ display:block; color:#b89a86; }
.shopitem .btn{ white-space:nowrap; }

/* ---------- backpack / chest grids ---------- */
.baggrid{ display:grid; grid-template-columns:repeat(6,1fr); gap:8px; margin:10px 0; }
.bagslot{
  background:#fff; border:2px solid #ffe3ee; border-radius:12px; padding:6px 2px;
  cursor:pointer; position:relative; min-height:64px;
}
.bagslot img{ width:36px; height:36px; image-rendering:pixelated; display:block; margin:0 auto; }
.bagslot .eimg{ font-size:26px; line-height:32px; width:32px; height:32px; display:block; margin:0 auto; }
.bagslot .n{ position:absolute; top:2px; right:6px; font-size:11px; font-weight:bold; color:#d14e7c; }
.bagslot small{ font-size:9px; color:#b89a86; display:block; pointer-events:none;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bagslot.sel{ border-color:#f76d96; background:#fff0f5; }
.bagacts{ display:flex; gap:8px; justify-content:center; flex-wrap:wrap; margin:6px 0 2px; }
.sectitle{ font-weight:bold; color:#d14e7c; margin:10px 0 2px; text-align:left; }

/* ---------- quest log ---------- */
#qlist{ max-height:46vh; max-height:46dvh; overflow-y:auto; margin:6px 0; overscroll-behavior:contain; }
.qcard{ display:flex; align-items:center; gap:10px; background:#fff;
  border:2px solid #ffe3ee; border-radius:14px; padding:8px; margin:6px 0; text-align:left; }
.qcard .qicon{ font-size:30px; flex:0 0 auto; }
.qcard .qinf{ flex:1; min-width:0; }
.qcard .qinf b{ color:#8a5a44; }
.qcard .qinf small{ display:block; color:#b89a86; }
.qcard .qhint{ color:#c9a227 !important; }
.qcard .qact{ flex:0 0 auto; }
.qcard.qlock{ opacity:.6; }
.qcard.qdone{ border-color:#b8e6b8; }
.qbar{ height:8px; background:#ffe3ee; border-radius:99px; overflow:hidden; margin:4px 0 2px; }
.qbar div{ height:100%; background:linear-gradient(#ff9ebb,#f76d96); border-radius:99px; }

/* ---------- decor bar ---------- */
#decorBar{
  position:fixed; left:50%; transform:translateX(-50%); bottom:12px; z-index:18;
  display:flex; align-items:center; gap:8px;
  max-width:94vw; overflow-x:auto;
  background:rgba(255,250,243,.96); border:3px solid #ffd3e0; border-radius:999px;
  padding:6px 14px; box-shadow:0 6px 20px rgba(0,0,0,.25);
  overscroll-behavior:contain;
}
.dhint{ font-size:12px; font-weight:bold; color:#a9806a; white-space:nowrap; }
.dchip{
  display:flex; align-items:center; gap:2px; background:#fff;
  border:2px solid #ffe3ee; border-radius:999px; padding:4px 10px 4px 4px;
  cursor:pointer; min-height:44px; position:relative;
}
.dchip img{ width:32px; height:32px; image-rendering:pixelated; display:block; }
.dchip .eimg{ font-size:24px; line-height:32px; width:32px; height:32px; }
.dchip .n{ font-size:11px; font-weight:bold; color:#d14e7c; }
.dchip.sel{ border-color:#f76d96; background:#fff0f5; }
/* farm decorate palette: big kid-friendly chips with labels */
.dchip.farm{
  flex-direction:column; gap:0; padding:6px 10px; border-radius:20px;
  min-width:60px; min-height:64px; justify-content:center;
}
.dchip.farm .eimg{ font-size:28px; line-height:34px; width:38px; height:34px; }
.dchip.farm .dl{ font-size:10px; font-weight:bold; color:#a9806a; white-space:nowrap; }
.dchip.farm.sel .dl{ color:#d14e7c; }

/* ---------- fade overlay ---------- */
#fade{
  position:fixed; inset:0; z-index:100; background:#06060f;
  opacity:0; transition:opacity 1.2s ease; pointer-events:none;
}

/* ---------- title / save select ---------- */
#title{
  position:fixed; inset:0; z-index:50; display:none;
  flex-direction:column; align-items:center; justify-content:center; padding:16px;
  padding-top:calc(16px + env(safe-area-inset-top));
  padding-bottom:calc(16px + env(safe-area-inset-bottom));
  background:linear-gradient(#aee3ff 0%,#cdeec0 55%,#8fd07a 100%);
  overflow-y:auto;
}
#title.show{ display:flex; }
#title h1{ margin:0; font-size:54px; color:#e2547e; text-shadow:2px 2px 0 #ffd9e6; }
#title .sub{ color:#a9806a; margin:4px 0 14px; font-size:18px; }
#slots{ width:min(94vw,440px); }
.slotbtn{
  display:block; width:100%; margin:8px 0; padding:12px;
  border:3px solid #ffd3e0; background:#fff; border-radius:16px;
  font-family:inherit; cursor:pointer; text-align:left; min-height:44px;
  box-shadow:0 4px 12px rgba(90,50,20,.15);
}
.slotbtn b{ color:#d14e7c; }
.slotbtn small{ color:#b89a86; display:block; pointer-events:none; }
.tiny{ font-size:12px; color:#c9a08a; margin-top:12px; text-align:center; }
#modalBox .tiny, #title .tiny{ color:#a9806a; }

/* ---------- small / portrait screens ---------- */
@media (max-width:600px){
  /* Dialog becomes a bottom sheet on portrait phones. */
  #dlg{
    left:0; right:0; bottom:0; transform:none; width:auto;
    border-radius:20px 20px 0 0; border-left:none; border-right:none; border-bottom:none;
    padding-bottom:calc(12px + env(safe-area-inset-bottom));
  }
  .pill{ font-size:12px; padding:3px 10px; }
  #xpbar{ width:56px; }
  .hbtn{ font-size:18px; }
  #modalBox{ padding:12px; }
  .baggrid{ gap:6px; }
  .bagslot small{ font-size:8px; }
  #toast{ bottom:150px; font-size:14px; }
}

/* Decor bar sits above the joystick / action button on touch devices. */
@media (pointer:coarse){
  #decorBar{ bottom:calc(150px + env(safe-area-inset-bottom)); }
}

/* ---------- area transition screen ---------- */
#areaTrans{
  position:fixed; inset:0; z-index:90;
  display:flex; align-items:center; justify-content:center;
  background:radial-gradient(circle at 50% 40%, rgba(90,80,160,.92), rgba(30,24,60,.96));
  opacity:0; pointer-events:none; transition:opacity .25s ease;
}
#areaTrans.show{ opacity:1; pointer-events:auto; }
.at-card{
  background:#fffaf3; border:5px solid #fff; border-radius:26px;
  padding:28px 34px; text-align:center; max-width:min(88vw,360px);
  box-shadow:0 16px 50px rgba(0,0,0,.45);
  transform:scale(.92); transition:transform .25s ease;
}
#areaTrans.show .at-card{ transform:scale(1); }
.at-icon{ font-size:56px; line-height:1.1; }
.at-name{
  font-family:'Baloo 2','Comic Sans MS',cursive; font-size:30px; font-weight:700;
  color:#8a5a72; margin:6px 0 10px;
}
.at-tip{
  font-size:15px; color:#6b4a3a; background:#ffeef5; border-radius:14px;
  padding:10px 12px; margin:0 0 8px; line-height:1.35;
}
.at-hint{ font-size:11px; color:#c9a08a; }
