* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #e3c8d4; color: #6a4a58;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; touch-action: manipulation; cursor: pointer; }
#bg {
  position: fixed; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, var(--bg1, #f1dfe6) 0%, var(--bg2, #e3c8d4) 55%, var(--bg3, #c9a6b7) 100%);
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui > .hint, #ui > .load { pointer-events: none; }

.load { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 15px; letter-spacing: .1em; }
.load .blob { width: 64px; height: 56px; border-radius: 50% 50% 46% 46%; background: #ffd1dc; box-shadow: inset -6px -8px 0 rgba(255,255,255,.55), 0 6px 14px rgba(170,90,120,.18); animation: squish 1s ease-in-out infinite; }
@keyframes squish { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.18,.78) translateY(6px); } }

.card { background: rgba(255,255,255,.86); border-radius: 24px; box-shadow: 0 10px 34px rgba(150,80,110,.16), 0 1px 0 rgba(255,255,255,.9) inset; }

/* 主選單 */
.screen { position: absolute; inset: 0; pointer-events: none; }
.screen > * { pointer-events: auto; }
.title { position: absolute; left: 0; right: 0; top: calc(6vh + env(safe-area-inset-top)); text-align: center; pointer-events: none; }
.title h1 { margin: 0; font-size: clamp(38px, 9vw, 64px); letter-spacing: .12em; color: #e2789c; text-shadow: 0 3px 0 #fff, 0 6px 18px rgba(226,120,156,.3); font-weight: 900; }
.title p { margin: 6px 0 0; font-size: clamp(14px, 3.4vw, 18px); letter-spacing: .3em; color: #9b7184; }
.menuCard {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(5vh + env(safe-area-inset-bottom));
  width: min(360px, calc(100% - 64px)); padding: 18px 18px 12px; display: flex; flex-direction: column; gap: 10px;
}
.big, .mid { border: 0; border-radius: 18px; background: #fff; box-shadow: 0 3px 0 #f1cfdc, 0 4px 12px rgba(180,100,130,.12); font-weight: 700; letter-spacing: .08em; transition: transform .08s; }
.big { height: 54px; font-size: 18px; }
.mid { height: 46px; font-size: 16px; flex: 1; }
.big.pri, .mid.pri, .pri { background: linear-gradient(180deg, #ff9fbf, #f27aa3); color: #fff; box-shadow: 0 3px 0 #d95f8a, 0 6px 16px rgba(242,122,163,.35); }
.down { transform: translateY(2px) scale(.98); }
.row2 { display: flex; gap: 10px; }
.more { align-self: center; margin-top: 4px; padding: 8px 14px; font-size: 13px; color: #b0849a; text-decoration: none; letter-spacing: .1em; border-radius: 12px; }
.more:active { background: #fbe8ef; }

/* 製作面板：直式在下方、橫式在右側 */
.panel { position: absolute; background: rgba(255,255,255,.9); box-shadow: 0 -6px 30px rgba(150,80,110,.14); touch-action: pan-y; }
.craft {
  left: 0; right: 0; bottom: 0; max-height: 47vh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  border-radius: 26px 26px 0 0;
  padding: 10px max(30px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)) max(30px, env(safe-area-inset-right));
}
@media (min-aspect-ratio: 1/1) and (min-width: 640px), (orientation: landscape) and (max-height: 520px) {
  .craft { left: auto; top: calc(76px + env(safe-area-inset-top)); bottom: calc(16px + env(safe-area-inset-bottom)); right: max(30px, env(safe-area-inset-right)); width: min(360px, 44vw); max-height: none; border-radius: 24px; padding: 12px 20px 14px; }
}
.tabs { display: flex; gap: 6px; margin: 2px 0 8px; }
.tab { flex: 1; height: 36px; border: 0; border-radius: 12px; background: #fbeef3; font-size: 14px; font-weight: 700; color: #b08397; }
.tab.on { background: #ffdbe7; color: #d9628d; }
.sec { margin: 8px 0 10px; }
.sec h3 { margin: 0 0 7px; font-size: 14px; letter-spacing: .1em; color: #a07688; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.sec h3 small { font-weight: 400; font-size: 12px; color: #c29aac; letter-spacing: .05em; }
.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pill { height: 38px; min-width: 56px; padding: 0 14px; border: 0; border-radius: 19px; background: #fbeef3; font-size: 15px; font-weight: 700; color: #9b7184; }
.pill.on { background: #f48bb0; color: #fff; box-shadow: 0 3px 10px rgba(244,139,176,.35); }
.sw { display: flex; flex-wrap: wrap; gap: 9px; }
.dot { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 2px 6px rgba(150,80,110,.2); padding: 0; font-size: 11px; color: #b08397; }
.dot.on { outline: 3px solid #f48bb0; outline-offset: 1px; }
.dot.none { background: #fff; border-color: #f3dbe5; }
.dot.rb { background: conic-gradient(#ffb3c7, #ffe7a3, #c4efd3, #bfe3ff, #d8cbff, #ffb3c7); }
.range { width: 100%; height: 30px; accent-color: #f27aa3; touch-action: pan-x; }
.nav { display: flex; gap: 10px; margin-top: 8px; position: sticky; bottom: calc(-12px - env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); margin-bottom: calc(-12px - env(safe-area-inset-bottom)); }
@media (max-width: 480px) { .hold { height: 62px; } .dot { width: 34px; height: 34px; } .sec { margin: 6px 0 8px; } }
.nav .mid { height: 48px; }
.holdrow { display: flex; gap: 10px; margin: 6px 0; }
.hold {
  flex: 1; height: 74px; border: 0; border-radius: 22px; font-size: 17px; font-weight: 800; letter-spacing: .08em; color: #fff;
  background: linear-gradient(180deg, #ffb0c9, #f27aa3); box-shadow: 0 4px 0 #d95f8a, 0 8px 18px rgba(242,122,163,.3);
  position: relative; touch-action: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.hold small { font-size: 11px; font-weight: 500; opacity: .9; letter-spacing: .15em; }
.hold.dry { background: linear-gradient(180deg, #a7dcff, #6fb6ef); box-shadow: 0 4px 0 #4f93cf, 0 8px 18px rgba(111,182,239,.3); }
.hold.down { transform: translateY(3px) scale(.97); }
.hold:disabled { filter: grayscale(.8); opacity: .45; }
.hold:not(:disabled)::after { content: ""; position: absolute; inset: -5px; border-radius: 26px; border: 2px dashed rgba(242,122,163,.45); animation: pulse 1.6s ease-in-out infinite; pointer-events: none; }
.hold.dry:not(:disabled)::after { border-color: rgba(111,182,239,.5); }
@keyframes pulse { 0%,100% { opacity: .3; transform: scale(.98); } 50% { opacity: 1; transform: scale(1.02); } }
.meters { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 13px; color: #a07688; margin: 8px 0 4px; }
.meter { height: 10px; border-radius: 5px; background: #fbeef3; overflow: hidden; }
.meter i { display: block; height: 100%; width: calc(var(--v, 0) * 100%); background: linear-gradient(90deg, #ffc2d6, #f27aa3); border-radius: 5px; }
.meter.dryM i { background: linear-gradient(90deg, #cde9ff, #6fb6ef); }
.layers { display: flex; gap: 6px; align-items: center; font-size: 13px; color: #a07688; min-height: 26px; }
.layers b { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(150,80,110,.25); background: var(--c); }
.note { font-size: 12.5px; color: #b08ea0; line-height: 1.6; margin: 4px 0; }
.small { height: 36px; padding: 0 14px; border: 0; border-radius: 12px; background: #fbeef3; font-size: 13px; color: #a07688; font-weight: 700; }

/* 遊玩畫面 */
.hbtn {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); right: calc(32px + env(safe-area-inset-right));
  width: 50px; height: 50px; border: 0; border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: 0 4px 14px rgba(150,80,110,.16);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.hbtn i { display: block; width: 22px; height: 3px; border-radius: 2px; background: #d9799d; }
.hint {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(26px + env(safe-area-inset-bottom));
  width: max-content; max-width: calc(100% - 72px); padding: 10px 18px; border-radius: 18px; background: rgba(255,255,255,.82); font-size: 13.5px; line-height: 1.7; text-align: center; color: #9b6a80;
  box-shadow: 0 4px 16px rgba(150,80,110,.14); transition: opacity .6s;
}
.hint.fade { opacity: 0; }
.toast {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(76px + env(safe-area-inset-top));
  width: max-content; max-width: calc(100% - 72px); padding: 10px 14px 10px 18px; border-radius: 18px; background: rgba(255,255,255,.92); font-size: 14px; color: #9b6a80;
  box-shadow: 0 6px 18px rgba(150,80,110,.18); display: flex; align-items: center; gap: 10px; line-height: 1.5;
}
.toast button { flex: none; height: 36px; padding: 0 14px; border: 0; border-radius: 12px; font-weight: 700; }

/* 彈出視窗 */
.modal { position: absolute; inset: 0; background: rgba(120,70,90,.22); display: flex; align-items: center; justify-content: center; padding: 20px 32px; }
.modalCard { background: rgba(255,255,255,.95); width: min(380px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 18px 12px; display: flex; flex-direction: column; gap: 10px; touch-action: pan-y; }
.modalCard h2 { margin: 2px 0 4px; text-align: center; font-size: 20px; letter-spacing: .15em; color: #d9628d; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 15px; }
.opt .seg { display: flex; gap: 6px; }
.opt .seg button { height: 36px; padding: 0 12px; border: 0; border-radius: 12px; background: #fbeef3; font-size: 14px; font-weight: 700; color: #a07688; }
.opt .seg button.on { background: #f48bb0; color: #fff; }
.opt input[type=range] { width: 52%; accent-color: #f27aa3; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cell { position: relative; border: 0; padding: 0; border-radius: 16px; overflow: hidden; background: #fbeef3; aspect-ratio: 1; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.cell .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); font-size: 14px; line-height: 26px; color: #c0607f; padding: 0; }
.empty { text-align: center; color: #b08ea0; font-size: 14px; padding: 20px 0; }

.hbtn2 {
  position: absolute; top: calc(72px + env(safe-area-inset-top)); right: calc(32px + env(safe-area-inset-right));
  min-width: 50px; height: 40px; padding: 0 12px; border: 0; border-radius: 14px; background: rgba(255,255,255,.75);
  box-shadow: 0 4px 14px rgba(150,80,110,.16); font-size: 13px; font-weight: 700; color: #c0607f; letter-spacing: .05em;
}
.dot.pick { position: relative; display: inline-block; overflow: hidden; cursor: pointer; }
.dot.pick input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* ---------- v4：可以選取文字的輸入框 ---------- */
textarea, input[type=text] { -webkit-user-select: text; user-select: text; touch-action: auto; }
.txt { border: 2px solid #f6d6e2; border-radius: 12px; background: #fff; padding: 8px 10px; font-size: 15px; color: #6a4a58; outline: none; }
.txt:focus { border-color: #f48bb0; }
.opt .txt { width: 60%; }
.area { width: 100%; min-height: 96px; resize: none; font-size: 13px; word-break: break-all; }
.mtext { margin: 0; text-align: center; font-size: 14px; color: #9b7184; line-height: 1.7; }
.mtext.big2 { font-size: 19px; font-weight: 800; color: #d9628d; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 2px 0; }
.tags span { padding: 4px 10px; border-radius: 12px; background: #fbeef3; font-size: 12.5px; color: #a07688; }

/* 主選單 */
.blindBtn { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; background: linear-gradient(180deg, #fff, #fff2f8); }
.blindBtn small { font-size: 11px; font-weight: 500; color: #c08aa2; letter-spacing: .04em; }
.tipLink { align-self: center; border: 0; background: none; font-size: 12.5px; color: #c08aa2; text-decoration: underline; text-underline-offset: 3px; padding: 4px 8px; }

/* 製作：三顆按住按鈕排一列 */
.hold.roll { background: linear-gradient(180deg, #ffd59e, #f0a65a); box-shadow: 0 4px 0 #d0843a, 0 8px 18px rgba(240,166,90,.3); }
.hold.roll:not(:disabled)::after { border-color: rgba(240,166,90,.5); }
@media (max-width: 480px) { .holdrow .hold { font-size: 14.5px; letter-spacing: .02em; } }

/* 遊玩：右上角的直排按鈕 */
.side { position: absolute; top: calc(72px + env(safe-area-inset-top)); right: calc(32px + env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.side > * { pointer-events: auto; }
.side .hbtn2 { position: static; }
.hbtn2.on { background: linear-gradient(180deg, #ff9fbf, #f27aa3); color: #fff; }
.chip {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(16px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; border-radius: 22px; background: rgba(255,255,255,.8);
  box-shadow: 0 4px 14px rgba(150,80,110,.16); font-size: 13.5px; color: #9b6a80;
}
.chip b { font-variant-numeric: tabular-nums; color: #d9628d; min-width: 3.2em; text-align: center; }
.chip button { height: 32px; padding: 0 12px; border: 0; border-radius: 16px; background: #fbeef3; font-weight: 700; color: #c0607f; font-size: 13px; }

/* 彈出視窗：分享卡片、安裝說明 */
.cardImg { width: 100%; max-width: 300px; align-self: center; border-radius: 16px; box-shadow: 0 6px 20px rgba(150,80,110,.2); display: block; pointer-events: none; }
.steps p { display: flex; gap: 10px; align-items: center; margin: 6px 0; font-size: 14.5px; color: #8e6276; line-height: 1.5; }
.steps p > b:first-child { flex: none; width: 26px; height: 26px; border-radius: 50%; background: #f48bb0; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.ico { display: inline-block; padding: 1px 8px; border-radius: 8px; background: #eaf2ff; color: #3b7be0; font-size: 13px; }
.opt.sub { min-height: 34px; font-size: 13.5px; color: #a07688; padding-left: 14px; }
.opt.sub input[type=range] { width: 52%; }

/* 展示架 */
.shelfUI { position: absolute; inset: 0; pointer-events: none; }
.shelfUI > * { pointer-events: auto; }
.shead { position: absolute; left: 0; right: 0; top: calc(14px + env(safe-area-inset-top)); display: flex; align-items: baseline; justify-content: center; gap: 10px; pointer-events: none; }
.shead h2 { margin: 0; font-size: 22px; letter-spacing: .2em; color: #d9628d; text-shadow: 0 2px 0 #fff; }
.shead span { font-size: 13px; color: #a8869a; }
.sbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); width: min(420px, calc(100% - 64px)); display: flex; align-items: center; gap: 10px; }
.sbar .arrow { flex: none; width: 54px; height: 54px; border: 0; border-radius: 18px; background: rgba(255,255,255,.88); font-size: 30px; line-height: 1; color: #d9628d; box-shadow: 0 3px 0 #f1cfdc, 0 4px 12px rgba(180,100,130,.12); }
.sbar .arrow:disabled { opacity: .35; }
.smid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.smid .mid { width: 100%; flex: none; height: 46px; }
.smid span { font-size: 12px; color: #a8869a; min-height: 14px; }
.sempty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(300px, calc(100% - 64px)); padding: 18px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.sempty p { margin: 0; color: #9b7184; font-size: 14px; line-height: 1.8; }
.scard { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); width: min(380px, calc(100% - 64px)); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.scard h3 { margin: 0 24px; text-align: center; font-size: 17px; color: #d9628d; letter-spacing: .06em; }
.scard .x { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #fbeef3; color: #c0607f; font-size: 15px; }

/* 盲盒 */
.blindUI { position: absolute; inset: 0; pointer-events: none; }
.blindUI > * { pointer-events: auto; }
.bhead { position: absolute; left: 0; right: 0; top: calc(14px + env(safe-area-inset-top)); text-align: center; pointer-events: none; padding: 0 70px; }
.bhead h2 { margin: 4px 0 2px; font-size: clamp(20px, 5.4vw, 26px); letter-spacing: .12em; color: #d9628d; text-shadow: 0 2px 0 #fff; }
.bhead p { margin: 0; font-size: 13px; color: #a8869a; letter-spacing: .1em; }
.rare { display: inline-block; padding: 4px 14px; border-radius: 14px; color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .15em; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.rare.r0 { background: #f0a2bd; } .rare.r1 { background: linear-gradient(90deg, #7aa8ff, #a68bff); } .rare.r2 { background: linear-gradient(90deg, #f7b733, #fc4a8a); }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.bfoot { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); width: min(360px, calc(100% - 64px)); display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.bfoot.card { padding: 16px 16px 10px; animation: popc .4s ease-out; }
@keyframes popc { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
.bfoot .small { align-self: center; }
.tapHint { align-self: center; padding: 10px 22px; border-radius: 20px; background: rgba(255,255,255,.85); color: #9b6a80; font-size: 15px; letter-spacing: .1em; box-shadow: 0 4px 14px rgba(150,80,110,.14); animation: pulse 1.6s ease-in-out infinite; }
.tapHint b { color: #d9628d; }

/* 全螢幕的透明圖層本身不能吃點擊（#ui > * 的規則比較強，要用同樣強度蓋回去），只有裡面的按鈕可以點 */
#ui > .screen, #ui > .shelfUI, #ui > .blindUI, #ui > .side { pointer-events: none; }
