:root {
  --ink: #2b3532;
  --paper: #fffdf8;
  --yellow: #ffd34d;
  --orange: #ff9b54;
  --red: #f2665c;
  --green: #3fae7a;
  --blue: #4a97dd;
  --font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #bfe9f7; color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- 上方狀態列 ---------- */
#hud { position: fixed; left: 0; right: 0; top: calc(10px + var(--st)); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; pointer-events: none; z-index: 5; }
#hud[hidden] { display: none; }
.pill { display: flex; align-items: center; gap: 6px; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px 4px 8px; box-shadow: 0 3px 0 var(--ink); font-weight: 900; font-size: 20px; min-width: 64px; }
.pill b { font-variant-numeric: tabular-nums; }
.pill .ic { font-size: 18px; line-height: 1; }
.pill.coin { padding: 4px 8px 4px 14px; }
.pill.coin.bump { animation: bump 0.18s ease-out; }
@keyframes bump { 50% { transform: scale(1.15); } }
.coin-ic { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #ffc93c 0 52%, #fff1b8 53% 62%, #ffc93c 63%); box-shadow: 0 2px 0 #c98a00; }
.mapbtn { position: absolute; right: 10px; top: 52px; pointer-events: auto; display: flex; align-items: center; gap: 4px; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 10px 3px 6px; font-weight: 900; font-size: 14px; box-shadow: 0 3px 0 var(--ink); }
.mapbtn .mi { width: 20px; height: 16px; border-radius: 4px; background: linear-gradient(90deg, #7ed389 0 33%, #ffd34d 33% 66%, #5aa9e6 66%); border: 2px solid var(--ink); }
.mapbtn.on { background: #fff1a8; }
.mapbtn.flip { top: 94px; }
.mapbtn .fi { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #5aa9e6; color: #fff; border: 2px solid var(--ink); font-size: 14px; line-height: 1; }
.mapbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.wave { flex: 1; max-width: 260px; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 3px 10px 6px; box-shadow: 0 3px 0 var(--ink); text-align: center; font-weight: 900; font-size: 15px; }
.wave .bar { height: 7px; border-radius: 6px; background: #e7e1d3; margin-top: 3px; overflow: hidden; }
.wave .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7ed389, #3fae7a); border-radius: 6px; transition: width 0.3s; }

/* ---------- 橫幅、提示、飄字 ---------- */
.banner { position: fixed; left: 50%; top: 28%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; z-index: 6; pointer-events: none; white-space: nowrap;
  font-size: clamp(30px, 8vw, 54px); font-weight: 900; color: var(--yellow); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; letter-spacing: 1px; text-shadow: 0 5px 0 var(--ink); transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1); }
.banner.good { color: #8ff0a4; }
.banner.bad { color: #ff9a8f; }
.banner.boss { color: #ffb36b; }
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hint { position: fixed; left: 50%; bottom: calc(18px + var(--sb)); transform: translate(-50%, 20px); opacity: 0; z-index: 6; pointer-events: none; width: max-content; max-width: min(92vw, 520px);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; padding: 10px 16px; font-size: 17px; font-weight: 800; line-height: 1.45; text-align: center; box-shadow: 0 4px 0 var(--ink); transition: opacity 0.25s, transform 0.25s; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }
#toasts { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.toast { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 22px; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.toast.good { color: var(--yellow); }
.toast.bad { color: #ff9a8f; }
.edge { position: fixed; left: 0; top: 0; width: 40px; height: 40px; z-index: 4; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.edge::before { content: ""; position: absolute; inset: 0; background: var(--yellow); border: 3px solid var(--ink); border-radius: 50%; }
.edge::after { content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0; border-left: 14px solid var(--ink); border-top: 9px solid transparent; border-bottom: 9px solid transparent; transform: translate(-30%, -50%); }
.edge.on { opacity: 1; }

/* ---------- 搖桿 ---------- */
#joy { position: fixed; left: 0; top: 0; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; background: rgba(255, 253, 248, 0.35); border: 3px solid rgba(43, 53, 50, 0.35); pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.12s; }
#joy.on { opacity: 1; }
/* 手機:左下角淡淡的搖桿位置提示(手指放上去就換成真的搖桿) */
.joyhome { display: none; position: fixed; left: 26px; bottom: calc(150px + var(--sb)); width: 96px; height: 96px; border-radius: 50%; border: 3px dashed rgba(43, 53, 50, 0.3); background: rgba(255, 253, 248, 0.22); pointer-events: none; z-index: 3; }
.joyhome i { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; background: rgba(255, 253, 248, 0.6); border: 3px solid rgba(43, 53, 50, 0.35); }
body.touch .joyhome { display: block; }
body.touch #hud[hidden] ~ .joyhome, body.joying .joyhome { display: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }

/* ---------- 按鈕 ---------- */
.skip { position: fixed; right: 12px; bottom: calc(84px + var(--sb)); z-index: 5; background: var(--yellow); border: 3px solid var(--ink); border-radius: 999px; padding: 8px 16px; font-weight: 900; font-size: 16px; box-shadow: 0 4px 0 var(--ink); }
.skip[hidden] { display: none; }
.mute { position: fixed; left: 12px; bottom: calc(84px + var(--sb)); z-index: 5; width: 44px; height: 44px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-size: 20px; line-height: 1; padding: 0; }
/* ---------- 格子上方的價格牌 ---------- */
#tags { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.ptag { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 3px; padding: 2px 9px 2px 4px; margin-top: -10px;
  background: var(--paper); border: 3px solid #5b3b22; border-radius: 999px; box-shadow: 0 3px 0 #5b3b22; font-weight: 900; font-size: 16px; line-height: 1.15; white-space: nowrap; transition: background-color 0.2s; }
.ptag::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 9px; height: 9px; margin-left: -6px; background: inherit; border-right: 3px solid #5b3b22; border-bottom: 3px solid #5b3b22; transform: rotate(45deg); }
.ptag b { font-variant-numeric: tabular-nums; }
.ptag .ci { width: 17px; height: 17px; border-radius: 50%; background: radial-gradient(circle at 40% 38%, #fff3b0 0 18%, #ffd23f 19% 60%, #f0a800 61%); box-shadow: inset 0 0 0 2px #e09a00; }
.ptag .ic { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.ptag .ic.bubble { background: radial-gradient(circle at 34% 32%, #fff 0 16%, rgba(207,240,255,0.9) 17% 55%, #7cc8f2 56% 72%, #4a97dd 73%); }
.ptag .ic.honey { border-radius: 7px 7px 9px 9px; background: linear-gradient(#9b6a43 0 26%, #ffc93c 27%); box-shadow: inset 0 0 0 2px #e0a000; }
.ptag .lv { background: #3fae7a; color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 13px; margin-right: 2px; }
.ptag.up { font-size: 15px; }
.ptag.can { background: #fff1a8; animation: tagbob 0.9s ease-in-out infinite; }
.ptag.paying { background: #d6f5e2; animation: none; }
@keyframes tagbob { 50% { scale: 1.08; } }
.fly { position: fixed; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%; z-index: 7; pointer-events: none;
  background: radial-gradient(circle at 40% 38%, #fff3b0 0 18%, #ffd23f 19% 60%, #f0a800 61%); box-shadow: 0 2px 0 #c98a00; transition: transform 0.45s cubic-bezier(0.55, -0.35, 0.75, 1); }

.skip:active, .mute:active, .big:active, .look:active, .hero:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- 開始、結束畫面 ---------- */
.screen { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--st)) 16px calc(16px + var(--sb)); background: linear-gradient(180deg, rgba(191, 233, 247, 0.55), rgba(255, 253, 248, 0.25)); overflow-y: auto; }
#start { background: linear-gradient(180deg, rgba(191, 233, 247, 0.1), rgba(255, 253, 248, 0.2)); }
.screen[hidden] { display: none; }
@media (orientation: portrait) {
  #start { align-items: flex-end; background: linear-gradient(180deg, rgba(191, 233, 247, 0) 30%, rgba(191, 233, 247, 0.5)); }
  #start .card { margin: auto auto 0; padding: 16px 16px 12px; }
  #start .card h1 { font-size: 34px; }
  #start .tag { margin: 2px 0 8px; }
  #start .steps { gap: 6px; margin-bottom: 8px; }
  #start .steps li { padding: 6px 10px; font-size: 15px; }
  #start .pick { margin: 4px 0 6px; }
  #start .heroes { margin-bottom: 10px; }
  #start .big { padding: 10px; font-size: 22px; }
  #start .note { margin-top: 8px; font-size: 11px; }
}
.card { width: min(420px, 100%); background: var(--paper); border: 4px solid var(--ink); border-radius: 28px; padding: 22px 20px 18px; box-shadow: 0 7px 0 var(--ink); text-align: center; margin: auto; }
.card h1 { margin: 2px 0 2px; font-size: 40px; font-weight: 900; color: #7cc8f2; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; letter-spacing: 2px; text-shadow: 0 5px 0 var(--ink); }
.card h2 { margin: 4px 0; font-size: 30px; font-weight: 900; }
.tag { margin: 6px 0 12px; font-size: 17px; font-weight: 800; color: #5d6d68; }
.steps { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; display: grid; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; background: #f3f9ff; border-radius: 14px; padding: 8px 10px; font-size: 16px; font-weight: 700; line-height: 1.4; }
.steps .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--yellow); border: 2.5px solid var(--ink); display: grid; place-items: center; font-weight: 900; font-size: 15px; }
.pick { margin: 6px 0 8px; font-weight: 800; font-size: 15px; color: #5d6d68; }
.heroes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.hero { display: flex; align-items: center; gap: 8px; background: #fff; border: 3px solid #d9d3c5; border-radius: 16px; padding: 8px 8px; text-align: left; }
.hero i { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid #5b3b22; flex: none; }
.hero b { display: block; font-size: 15px; font-weight: 900; }
.hero small { display: block; font-size: 12px; color: #7a8580; font-weight: 700; }
.hero.on { border-color: var(--ink); background: #fff7d6; box-shadow: 0 3px 0 var(--ink); }
.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.look { display: flex; align-items: center; justify-content: center; gap: 6px; background: #fff; border: 3px solid #d9d3c5; border-radius: 14px; padding: 7px 4px; font-weight: 800; font-size: 14px; }
.look i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.look.on { border-color: var(--ink); background: #fff7d6; box-shadow: 0 3px 0 var(--ink); }
.big { width: 100%; background: var(--yellow); border: 4px solid var(--ink); border-radius: 18px; padding: 13px; font-size: 24px; font-weight: 900; box-shadow: 0 5px 0 var(--ink); }
.note { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: #8a958f; }
.emoji { font-size: 58px; line-height: 1.1; }
.stats { list-style: none; padding: 0; margin: 4px 0 18px; display: grid; gap: 6px; font-size: 17px; font-weight: 700; }
.stats li { background: #f3f9ff; border-radius: 12px; padding: 8px; }
.stats b { font-size: 21px; color: var(--blue); }

@media (max-height: 640px) {
  .card { padding: 14px 16px 12px; }
  .card h1 { font-size: 32px; }
  .steps li { padding: 6px 8px; font-size: 14.5px; }
  .big { padding: 10px; font-size: 21px; }
}
