/* Base look: pastel macaron + ornate lolita lace. Design box 396x704 px (#app), scaled by main.js. */
:root {
  --font: "Trebuchet MS", sans-serif;
  --cream: #fff7ef; --cream2: #fbe9e4; --rose: #e88aa5; --rose-d: #b4567a; --teal: #3f8f94; --teal-l: #8fd0c8;
  --lav: #b9a3d9; --cocoa: #5a3a44; --gold: #d9a441; --gold-l: #f6d88a; --ink: #4a2c3a; --outline: #7a3b58;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3a2436; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#wrap { position: fixed; inset: 0; background: radial-gradient(circle at 50% 30%, #6b4560, #2a1828); }
#app { position: absolute; left: 50%; top: 50%; width: 396px; height: 704px; transform-origin: 0 0; overflow: hidden;
  font-family: var(--font); color: var(--ink); background: var(--cream); }
.hidden { display: none !important; }
img { -webkit-user-drag: none; }

/* display text with outline */
.dtext, .sheet-title, .modal-title, .btn-primary .btn-lb {
  font-weight: 900; color: #fff; paint-order: stroke fill; -webkit-text-stroke: 4px var(--outline);
  text-shadow: 0 2px 0 var(--outline), 0 3px 4px rgba(80, 30, 50, .35);
}

/* ---------- title ---------- */
#title-screen { position: absolute; inset: 0; overflow: hidden; cursor: pointer; }
#title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: kenburns 18s ease-in-out infinite alternate; }
#title-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,240,245,.25) 0%, rgba(0,0,0,0) 35%, rgba(40,15,35,0) 70%, rgba(40,15,35,.55) 100%); }
#title-logo { position: absolute; left: 50%; top: 40px; width: 82%; max-height: 220px; object-fit: contain; transform: translateX(-50%);
  filter: drop-shadow(0 4px 10px rgba(80,30,60,.45)); animation: logoIn .7s cubic-bezier(.2,1.6,.4,1) both, logoFloat 4s 0.7s ease-in-out infinite; }
#title-start { position: absolute; left: 0; right: 0; bottom: 92px; text-align: center; font-size: 22px; animation: pulse 1.6s ease-in-out infinite; }
#title-hint { position: absolute; left: 0; right: 0; bottom: 64px; text-align: center; font-size: 13px; color: #fff; opacity: .85; text-shadow: 0 1px 3px #000; }
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.06) translateY(-6px); } }
@keyframes logoIn { from { opacity: 0; transform: translateX(-50%) scale(.4) translateY(-40px); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes logoFloat { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .65; transform: scale(.96); } }

/* ---------- intro ---------- */
#intro-wrap { position: absolute; inset: 0; z-index: 900; background: #000 url(assets/cover-bg.webp) center/cover; }
#intro-video { width: 100%; height: 100%; object-fit: cover; }
#intro-sub { position: absolute; left: 16px; right: 16px; bottom: 120px; text-align: center; color: #fff; font-size: 16px; font-weight: 700; text-shadow: 0 2px 4px #000, 0 0 8px #000; }
#intro-skip { position: absolute; right: 18px; bottom: 28px; min-width: 96px; min-height: 48px; box-sizing: border-box; }

/* ---------- layout ---------- */
#game { position: absolute; inset: 0; }
#scene { position: absolute; left: 0; right: 0; top: 0; bottom: 70px; overflow: hidden; background: #e9d4c8; z-index: 1; isolation: isolate; }
#game.sheet-open #side, #game.sheet-open #scene button { visibility: hidden; }
#hud { position: absolute; left: 0; right: 0; top: 0; height: 56px; pointer-events: none; z-index: 20; }
#hud > * { pointer-events: auto; }
#side { position: absolute; right: 8px; top: 132px; display: flex; flex-direction: column; gap: 10px; z-index: 20; }
#sheets { position: absolute; left: 0; right: 0; top: 0; bottom: 70px; pointer-events: none; z-index: 30; }
#sheets > * { pointer-events: auto; }
#nav { position: absolute; left: 0; right: 0; bottom: 0; height: 70px; z-index: 40; display: flex; justify-content: space-around; align-items: stretch;
  background: linear-gradient(180deg, #fff3f4, #f7dfe3); border-top: 3px solid var(--gold-l); box-shadow: 0 -4px 12px rgba(120,50,80,.18); padding: 4px 4px 6px; }
#modals { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
#modals > * { pointer-events: auto; }
#fxlayer { position: absolute; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }

/* ---------- buttons ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; min-width: 46px; padding: 6px 16px;
  border: 2px solid #c98a6a; border-radius: 22px; font: 800 15px var(--font); color: var(--ink); cursor: pointer;
  background: linear-gradient(180deg, #fffaf3 0%, #fbe3d6 100%); box-shadow: inset 0 2px 0 #fff, 0 3px 0 #c98a6a, 0 4px 8px rgba(100,40,60,.2);
  transition: transform .08s, filter .15s; }
.btn:active { transform: translateY(2px) scale(.96); box-shadow: inset 0 2px 0 #fff, 0 1px 0 #c98a6a; }
.btn-primary { background: linear-gradient(180deg, #ffb3c7 0%, #e88aa5 55%, #d26f8f 100%); border-color: #f6d88a; box-shadow: inset 0 2px 0 rgba(255,255,255,.6), 0 3px 0 #a94d6f, 0 4px 10px rgba(160,60,100,.35); }
.btn-primary .btn-lb { -webkit-text-stroke: 3px #a04468; text-shadow: 0 1px 0 #a04468; }
.btn-small { min-height: 46px; padding: 4px 12px; font-size: 14px; }
.btn.disabled { filter: grayscale(.8) brightness(.95); opacity: .6; }
.btn-ic { width: 26px; height: 26px; object-fit: contain; }
.btn-gold { display: inline-flex; align-items: center; gap: 3px; font-weight: 900; }
.btn-gold img { width: 18px; height: 18px; }
.btn-x { position: absolute; left: 8px; top: 6px; width: 46px; height: 46px; box-sizing: border-box; border-radius: 50%; border: 2px solid #f6d88a; cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #ffc6d4, #d9789a); color: #fff; font: 900 18px var(--font); box-shadow: 0 2px 0 #a94d6f; }
.focus { outline: none; box-shadow: 0 0 0 3px #fff, 0 0 0 6px #ff7fa8, 0 0 14px #ffb3c7 !important; filter: brightness(1.08); }

/* ---------- sheet ---------- */
.sheet { position: absolute; left: 0; right: 0; top: 52px; bottom: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(255,248,240,.97), rgba(252,234,232,.97)); border-top: 3px solid var(--gold-l);
  border-radius: 22px 22px 0 0; box-shadow: 0 -6px 18px rgba(80,30,60,.3); animation: sheetIn .26s cubic-bezier(.2,1.3,.4,1); }
.sheet.out { animation: sheetOut .2s ease-in forwards; }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheetOut { to { transform: translateY(40px); opacity: 0; } }
.sheet-head { position: relative; height: 56px; flex: none; display: flex; align-items: center; justify-content: center;
  background: url(assets/ui-panel.webp) center/cover; border-radius: 20px 20px 0 0; border-bottom: 2px dashed rgba(201,138,106,.5); }
.sheet-head { background: linear-gradient(180deg, #ffe3ea, #fbd3dd); }
.sheet-title { font-size: 21px; padding: 0 56px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 12px 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sheet-body::-webkit-scrollbar { display: none; }

/* ---------- modal ---------- */
.modal-back { position: absolute; inset: 0; z-index: 1; background: rgba(50, 20, 40, .45); display: flex; align-items: center; justify-content: center; animation: fadeIn .18s; }
.modal-back.out { animation: fadeOut .18s forwards; }
.modal { position: relative; width: 346px; max-height: 640px; display: flex; flex-direction: column; padding: 26px 22px 20px;
  border: 26px solid transparent; border-image: url(assets/ui-panel.webp) 22% fill / 26px stretch; animation: pop .26s cubic-bezier(.2,1.6,.4,1); }
.modal-title { text-align: center; font-size: 20px; margin: 0 auto 8px; padding: 0 40px; width: fit-content; max-width: 100%; box-sizing: border-box; }
.modal-inner { overflow-y: auto; scrollbar-width: none; font-size: 15px; line-height: 1.45; }
.modal-inner::-webkit-scrollbar { display: none; }
.modal-btns { display: flex; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.modal-x { left: auto; right: -14px; top: -16px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.overlay { position: absolute; inset: 0; animation: fadeIn .25s; }
.overlay.out { animation: fadeOut .25s forwards; }

/* ---------- common bits ---------- */
.rar { display: inline-block; padding: 1px 7px; border-radius: 8px; font: 900 12px var(--font); color: #fff; letter-spacing: .5px; text-shadow: 0 1px 0 rgba(0,0,0,.35); }
.rar-N { background: #9fb7a8; } .rar-R { background: #6fa8d8; } .rar-SR { background: linear-gradient(90deg, #c58be0, #e39bd0); } .rar-SSR { background: linear-gradient(90deg, #f0b44a, #f7d977, #f0b44a); }
.rar-UR { background: linear-gradient(90deg, #d8322e, #f6c24a 45%, #ffe9a0 55%, #d8322e); background-size: 200% 100%; box-shadow: 0 0 0 1.5px #fff3c4, 0 0 8px rgba(232,80,74,.7); animation: rarUR 2.4s linear infinite; }
@keyframes rarUR { to { background-position: -200% 0; } }
.bar { position: relative; height: 10px; border-radius: 6px; background: rgba(120,60,80,.18); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #ff9fbd, #e8648f); transition: width .3s; }
.gold-ic { width: 18px; height: 18px; vertical-align: -3px; }
.card { position: relative; border-radius: 16px; background: linear-gradient(180deg, #fff, #fdeee9); border: 2px solid #f0c9b8; box-shadow: 0 3px 0 #e6b8a5; cursor: pointer; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.muted { color: #9a7484; font-size: 13px; }
.badge-dot { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: #ff5f8a; color: #fff; font: 900 12px/20px var(--font); text-align: center; border: 2px solid #fff; padding: 0 4px; }

/* ---------- toast / subtitle / fx ---------- */
#toast { position: absolute; left: 50%; top: 168px; transform: translate(-50%, -20px); opacity: 0; z-index: 95; pointer-events: none; display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 20px; background: rgba(90, 40, 66, .88); color: #fff; font-size: 14px; font-weight: 700; max-width: 340px; transition: all .2s; border: 2px solid var(--gold-l); }
#toast img { width: 22px; height: 22px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#subtitle { position: absolute; left: 14px; right: 14px; bottom: 84px; z-index: 96; pointer-events: none; opacity: 0; transition: opacity .2s; text-align: center;
  padding: 10px 14px; border-radius: 16px; background: rgba(60, 25, 45, .82); color: #fff; font-size: 15px; line-height: 1.4; border: 2px solid rgba(246,216,138,.7); }
#subtitle.show { opacity: 1; }
#subtitle b { display: block; color: var(--gold-l); font-size: 13px; }
.float-txt { position: absolute; transform: translate(-50%, -50%); font: 900 18px var(--font); color: #ffe27a; paint-order: stroke fill; -webkit-text-stroke: 4px #8a4a20; animation: floatUp 1.1s ease-out forwards; white-space: nowrap; }
.float-txt.pink { color: #ffd0de; -webkit-text-stroke-color: #b4567a; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }
.burst { position: absolute; font-size: 18px; transform: translate(-50%, -50%); animation: burst .9s ease-out forwards; text-shadow: 0 0 6px #fff; }
@keyframes burst { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.5); opacity: 0; } }
.coin-fly { position: absolute; width: 26px; height: 26px; transform: translate(-50%, -50%); transition: all .5s cubic-bezier(.5,0,.8,.6); z-index: 90; }
.vfx { position: absolute; pointer-events: none; mix-blend-mode: plus-lighter; background-repeat: no-repeat; }
.flash { position: absolute; inset: 0; animation: flash .6s ease-out forwards; }
@keyframes flash { from { opacity: .9; } to { opacity: 0; } }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { translate: 0 0; } 20% { translate: -5px 2px; } 40% { translate: 5px -2px; } 60% { translate: -3px 1px; } 80% { translate: 3px 0; } }
.pop { animation: popIc .3s; }
@keyframes popIc { 50% { transform: scale(1.35); } }
.spr { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.spr-still, .spr-anim { position: absolute; }
.spr-still { left: 0; top: 0; }
.spr-still img { position: absolute; max-width: none; pointer-events: none; }
.spr-anim { background-repeat: no-repeat; pointer-events: none; }
