:root {
  --ink: #1c2b24;
  --cream: #fbf3dc;
  --cream-2: #f1e6c4;
  --green: #3fbf6a;
  --green-d: #1f7a46;
  --leaf: #bff0c6;
  --sun: #ffd23f;
  --red: #ff5a4d;
  --bg: #10261f;
  --font: system-ui, -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { overflow: hidden; -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1b4a3a, var(--bg) 70%); }
#stage { position: relative; overflow: hidden; background: #000; box-shadow: 0 0 0 3px #0b1814, 0 12px 60px rgba(0,0,0,.6); }
#game { display: block; image-rendering: pixelated; touch-action: none; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; padding: max(8px, env(safe-area-inset-top)) 8px 0;
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "p m l" "s s t"; gap: 6px 8px; align-items: center; pointer-events: none; }
.hud-btn { grid-area: p; pointer-events: auto; width: 34px; height: 34px; border-radius: 10px; border: 2px solid #0b1814; background: rgba(16,38,31,.78);
  color: #fff; font-size: 12px; font-weight: 900; letter-spacing: -2px; }
.meter { grid-area: m; display: flex; align-items: center; gap: 6px; min-width: 0; }
.meter-ico { width: 18px; height: 24px; flex: none; background: #59c8ff; clip-path: polygon(50% 0, 85% 45%, 100% 70%, 85% 100%, 15% 100%, 0 70%, 15% 45%); filter: drop-shadow(0 1px 0 rgba(0,0,0,.5)); }
.bar { position: relative; flex: 1; height: 22px; border-radius: 8px; background: rgba(16,38,31,.8); border: 2px solid #0b1814; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(#8be9ff, #34b4f0); transition: width .1s linear; }
.bar em { position: absolute; inset: 0; display: grid; place-items: center; font: 800 11px/1 var(--font); font-style: normal; color: #fff; text-shadow: 0 1px 2px #000; }
.meter.low .bar i { background: linear-gradient(#ff9a8a, #ff4d4d); }
.meter.low .bar { animation: throb .5s infinite alternate; }
@keyframes throb { to { box-shadow: 0 0 0 3px rgba(255,77,77,.7); } }
#lives { grid-area: l; display: flex; gap: 3px; padding: 3px 6px; border-radius: 10px; background: rgba(16,38,31,.78); border: 2px solid #0b1814; height: 34px; align-items: center; }
#lives img { width: 20px; height: 20px; image-rendering: pixelated; }
#lives img.lost { filter: grayscale(1) brightness(.4); opacity: .6; }
#score { grid-area: s; justify-self: start; font: 900 20px/1 var(--font); color: #fff; text-shadow: 0 2px 0 #0b1814, 0 0 6px #000; font-variant-numeric: tabular-nums; }
#light { grid-area: t; justify-self: end; display: flex; gap: 4px; padding: 4px 6px; border-radius: 10px; background: rgba(16,38,31,.78); border: 2px solid #0b1814; }
#light i { width: 12px; height: 12px; border-radius: 50%; background: #333; }
#light.green .g { background: #4cff7a; box-shadow: 0 0 8px #4cff7a; }
#light.yellow .y { background: #ffd23f; box-shadow: 0 0 8px #ffd23f; }
#light.red .r { background: #ff4d4d; box-shadow: 0 0 8px #ff4d4d; }

#charge { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(86%, 340px); pointer-events: none; text-align: center; }
#charge .track { position: relative; height: 26px; border-radius: 13px; background: rgba(16,38,31,.85); border: 3px solid #0b1814; overflow: hidden; }
#charge .zone { position: absolute; top: 0; bottom: 0; }
#charge .zone.cap { left: 66.7%; width: 11.1%; background: rgba(255,210,63,.25); }
#charge .zone.over { left: 77.8%; right: 0; background: repeating-linear-gradient(45deg, rgba(255,77,77,.55) 0 5px, rgba(255,77,77,.2) 5px 10px); }
#charge-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#b8ff9a, #3fbf6a); }
#charge-fill.over { background: linear-gradient(#ff9a8a, #ff4d4d); }
#charge .tick { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.85); }
#charge .tick b { position: absolute; top: 50%; left: 5px; transform: translateY(-50%); font: 900 12px/1 var(--font); color: #fff; text-shadow: 0 1px 2px #000; }
#charge small { display: block; margin-top: 5px; font: 700 11px/1.2 var(--font); color: #fff; text-shadow: 0 1px 3px #000; }
#charge u { text-decoration: none; background: rgba(255,255,255,.2); padding: 0 4px; border-radius: 4px; }

#hint { position: absolute; left: 50%; top: 60%; transform: translate(-50%, -50%); text-align: center; color: #fff; pointer-events: none; font-weight: 700;
  text-shadow: 0 2px 4px #000; background: rgba(16,38,31,.66); padding: 8px 14px; border-radius: 14px; width: max-content; max-width: 86%; border: 2px solid rgba(255,255,255,.25); animation: fade 4s forwards; }
#hint p { margin: 6px 0 0; font-size: 13px; line-height: 1.45; }
#hint b { color: var(--sun); }
.finger { width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.85); margin: 0 auto; animation: press 1.4s infinite; }
@keyframes press { 0%,100% { transform: scale(1); } 40%,70% { transform: scale(.7); background: rgba(255,210,63,.95); } }
@keyframes fade { 0%,80% { opacity: 1; } 100% { opacity: 0; } }
#banner { position: absolute; left: 50%; top: 17%; width: max-content; transform: translateX(-50%); padding: 8px 16px; border-radius: 14px; background: rgba(16,38,31,.85); color: #fff; font-weight: 800;
  border: 2px solid var(--sun); text-align: center; pointer-events: none; animation: bannerIn .25s ease-out; max-width: 90%; font-size: 14px; }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -8px); } }
body.lowthirst #stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 40px rgba(255,40,40,.55); animation: throb2 .6s infinite alternate; }
@keyframes throb2 { from { opacity: .35; } to { opacity: 1; } }

/* ---------------------------------------------------------------- Screens */
#layer, #modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; z-index: 5; }
#modal { z-index: 9; }
.veil { position: absolute; inset: 0; background: rgba(8,20,16,.62); backdrop-filter: blur(2px); }
.veil.clear { background: rgba(8,20,16,.18); backdrop-filter: none; }
.sheet { position: relative; width: min(440px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  background: var(--cream); border-radius: 22px; border: 4px solid #0b1814; box-shadow: 0 6px 0 #0b1814, 0 18px 50px rgba(0,0,0,.5); padding: 18px 18px 20px;
  -webkit-user-select: text; user-select: text; animation: pop .22s ease-out; }
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }
.sheet h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: .02em; color: var(--green-d); text-align: center; }
.sheet h1 small { display: block; font-size: 15px; font-weight: 800; color: #476; letter-spacing: .12em; margin-top: 4px; }
.sheet h2 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.sheet h3 { margin: 16px 0 6px; font-size: 15px; color: var(--green-d); }
.sheet p { margin: 6px 0; line-height: 1.6; font-size: 14.5px; }
.muted { color: #6d6a5c; font-size: 12.5px; }
.center { text-align: center; }
.logo-frog { display: block; margin: 0 auto 4px; width: 150px; height: 120px; image-rendering: pixelated; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.steps div { background: #fff; border: 2px solid var(--cream-2); border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 12px; font-weight: 700; line-height: 1.35; }
.steps b { display: block; font-size: 20px; }

.btn { appearance: none; display: block; width: 100%; margin: 10px 0 0; padding: 13px 16px; border-radius: 16px; border: 3px solid #0b1814; background: var(--green);
  color: #fff; font: 900 18px/1.2 var(--font); text-shadow: 0 2px 0 rgba(0,0,0,.28); box-shadow: 0 5px 0 #0b1814; cursor: pointer; text-align: center; text-decoration: none; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #0b1814; }
.btn.sec { background: #fff; color: var(--ink); text-shadow: none; font-size: 15px; padding: 10px 12px; box-shadow: 0 4px 0 #0b1814; }
.btn.sun { background: var(--sun); color: #3a2a00; text-shadow: none; }
.btn.warn { background: var(--red); }
.btn.google { background: #fff; color: #333; text-shadow: none; font-size: 15px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { padding: 8px 12px; border-radius: 999px; border: 2px solid #0b1814; background: #fff; font: 800 13px var(--font); cursor: pointer; }
.chip.on { background: var(--sun); }

.big-score { text-align: center; font: 900 46px/1 var(--font); color: var(--green-d); font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.big-score small { font-size: 16px; color: #6d6a5c; margin-left: 4px; }
.break { list-style: none; margin: 8px 0; padding: 8px 12px; background: #fff; border-radius: 12px; border: 2px solid var(--cream-2); font-size: 13.5px; }
.break li { display: flex; justify-content: space-between; padding: 2px 0; }
.break li b { font-variant-numeric: tabular-nums; }
.break li.total { border-top: 2px dashed var(--cream-2); margin-top: 4px; padding-top: 6px; font-size: 15px; }

.panel { margin: 14px 0 0; padding: 12px; border-radius: 16px; background: #fff; border: 3px solid #0b1814; }
.panel.login { background: linear-gradient(135deg, #e7fbe9, #fff6d0); }
.panel h3 { margin-top: 0; }
.panel .btn { margin-top: 8px; }
.cta { background: linear-gradient(135deg, #2b1f55, #4a2d88); color: #fff; border-color: #0b1814; }
.cta h3 { color: #ffe27a; }
.cta p { color: #efe9ff; }

.cardshow { display: flex; justify-content: center; margin: 10px 0 4px; }
.cardshow canvas, .cardgrid canvas { width: 190px; height: auto; border-radius: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.35); animation: flip .8s ease-out; }
@keyframes flip { from { transform: rotateY(90deg) scale(.8); opacity: 0; } 60% { transform: rotateY(-8deg) scale(1.05); } }
.cardgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; justify-items: center; margin-top: 10px; }
.cardgrid canvas { width: 100%; max-width: 190px; animation: none; }

.field { display: block; margin: 10px 0; font-size: 13px; font-weight: 800; }
.field input[type=email] { display: block; width: 100%; margin-top: 4px; padding: 12px; font: 600 16px var(--font); border: 3px solid #0b1814; border-radius: 12px; background: #fff; -webkit-user-select: text; user-select: text; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; font-size: 13.5px; line-height: 1.5; font-weight: 600; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--green-d); }
details.notice { margin: 8px 0; background: #fff; border-radius: 12px; border: 2px solid var(--cream-2); padding: 8px 12px; font-size: 12.5px; }
details.notice summary { cursor: pointer; font-weight: 800; }
details.notice dl { margin: 8px 0 0; } details.notice dt { font-weight: 800; margin-top: 6px; color: var(--green-d); } details.notice dd { margin: 2px 0 0; color: #4a473b; }
.err { color: #c0392b; font-weight: 800; font-size: 13px; min-height: 1.2em; margin: 4px 0; }

.coupon { border: 3px dashed #0b1814; border-radius: 16px; background: #fffbe6; padding: 12px; text-align: center; }
.coupon h3 { margin: 0 0 4px; } .coupon .code { font: 900 28px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; color: var(--green-d); }
.coupon img { width: 190px; height: 190px; image-rendering: pixelated; border: 6px solid #fff; border-radius: 6px; margin: 8px auto; display: block; }
.coupon ul { text-align: left; margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: #5a5748; }
.coupon.locked { filter: grayscale(.4); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--sun); font-size: 11px; font-weight: 900; }

.lb { list-style: none; padding: 0; margin: 10px 0; }
.lb li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 7px 10px; background: #fff; border-radius: 10px; margin-bottom: 5px; font-size: 14px; font-weight: 700; }
.lb li.me { background: var(--sun); border: 2px solid #0b1814; }
.lb li i { font-style: normal; font-weight: 900; color: var(--green-d); text-align: center; }
.lb li:nth-child(-n+3) i { color: #d98a00; }
.lb li span:last-child { font-variant-numeric: tabular-nums; }

.share-preview { display: block; width: 62%; max-width: 250px; margin: 10px auto; border-radius: 12px; border: 3px solid #0b1814; box-shadow: 0 6px 0 #0b1814; }
.xbtn { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #0b1814; background: #fff; font-weight: 900; cursor: pointer; }
.spin { display: inline-block; width: 16px; height: 16px; border: 3px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 20; padding: 10px 16px; border-radius: 14px; background: #0b1814; color: #fff; font-weight: 800;
  font-size: 14px; pointer-events: none; transition: .25s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-height: 560px) { .sheet { padding: 12px; } .sheet h1 { font-size: 26px; } .logo-frog { display: none; } .steps { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; } }

.poc-badge { display: inline-block; margin-bottom: 6px; padding: 3px 12px; border-radius: 999px; background: var(--sun); border: 2px solid #0b1814; font: 900 12px var(--font); letter-spacing: .1em; }
.poc-note { margin: 10px 0 0; padding: 8px 10px; border-radius: 10px; background: #fff3c4; border: 2px dashed #b58900; font-size: 12px; line-height: 1.5; color: #5a4600; }
