* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: #2a211b; color: #3a2e26; font: 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
#app { height: 100%; display: flex; flex-direction: column; max-width: 1400px; margin: 0 auto; }
#stage { position: relative; flex: none; aspect-ratio: 4 / 3; width: 100%; max-height: 50vh; overflow: hidden; cursor: pointer; background: #9cc9d9; }
#cv { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; image-rendering: pixelated; display: block; }
#fx { position: absolute; inset: 0; pointer-events: none; }
#fx .lantern { pointer-events: auto; }
#panel { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #f4ecda; }
#top { padding: 10px 14px 6px; background: #3a2e26; color: #f4ecda; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px; }
.coins { font-size: 28px; font-weight: 800; display: flex; align-items: center; gap: 8px; letter-spacing: .5px; }
#cps { grid-column: 1; font-size: 13px; color: #e5cf9a; }
#cps.boost { color: #ffcf4a; font-weight: 700; }
#dyn { grid-column: 2; grid-row: 1 / 3; text-align: right; font-size: 12px; color: #cdbb95; max-width: 46vw; }
.coin { display: inline-block; width: 1em; height: 1em; border-radius: 50%; background: radial-gradient(circle, transparent 0 18%, #c8962e 19% 60%, #e8c45a 61% 74%, #9a6d1c 75%); position: relative; flex: none; }
.coin::after { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; background: #3a2e26; }
#panel .coin::after { background: #f4ecda; }
#top .coin::after { background: #3a2e26; }
#modes { display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid #ddd0b2; font-size: 13px; }
#modes span { color: #8a7a62; margin-right: 2px; }
#modes button { padding: 4px 12px; border-radius: 14px; background: #e6dbc2; font-weight: 600; }
#modes button.on { background: #9a3b2b; color: #fff; }
#list { flex: 1; overflow-y: auto; padding: 6px 8px 10px; -webkit-overflow-scrolling: touch; }
.row { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 7px 9px; margin: 4px 0; border-radius: 10px; background: #e9dfc6; opacity: .6; transition: transform .08s; }
.row[hidden] { display: none; }
.row.can { opacity: 1; background: #fffaf0; box-shadow: 0 2px 0 #d6c7a3; }
.row:active { transform: scale(.98); }
.row.no { animation: shake .25s; }
.row.mystery .ic { filter: brightness(0) opacity(.35); }
.row.pulse { outline: 3px solid #e0a43a; animation: pulse 1s infinite; }
.ic canvas { width: 60px; height: 42px; image-rendering: pixelated; border-radius: 6px; display: block; }
.mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nm { font-size: 15px; }
.ds { color: #7a6a52; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ea { color: #3f7d4f; font-size: 12px; font-weight: 600; }
.bar { height: 3px; background: #dccfb0; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #c9873a; width: 0; }
.rt { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.own { font-size: 22px; font-weight: 800; color: #9a3b2b; min-height: 26px; }
.cost { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.cost em { font-style: normal; }
#prest { padding: 8px 10px 12px; border-top: 1px solid #ddd0b2; }
#pbtn { width: 100%; padding: 10px; border-radius: 10px; background: linear-gradient(#b5462f, #8a2f22); color: #fff3d6; font-size: 16px; box-shadow: 0 3px 0 #5e1f17; }
#pbtn small, .plock small { display: block; font-size: 12px; opacity: .85; }
.plock { text-align: center; font-size: 13px; color: #7a6a52; }
#hint { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%); background: rgba(58, 46, 38, .88); color: #fff3d6; padding: 8px 14px; border-radius: 18px; font-weight: 700; font-size: 15px; white-space: nowrap; pointer-events: none; animation: bob 1.2s ease-in-out infinite; }
#mute { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%; background: rgba(58, 46, 38, .55); }
#mute::before { content: ""; position: absolute; left: 9px; top: 11px; width: 6px; height: 12px; background: #fff3d6; clip-path: polygon(0 30%, 40% 30%, 100% 0, 100% 100%, 40% 70%, 0 70%); width: 14px; }
#mute.off::after { content: ""; position: absolute; left: 6px; top: 16px; width: 22px; height: 2px; background: #ff8a6a; transform: rotate(-40deg); }
#toast { position: absolute; left: 50%; top: 10px; transform: translate(-50%, -60px); background: #fff3d6; color: #9a3b2b; font-weight: 800; padding: 6px 14px; border-radius: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.25); pointer-events: none; white-space: nowrap; }
#toast.on { animation: toast 2.4s; }
.float { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 20px; color: #fff3d6; text-shadow: 0 2px 0 #6b4a1c, 0 0 6px rgba(0,0,0,.4); animation: up .9s ease-out forwards; white-space: nowrap; }
.float.gold { color: #ffd34a; font-size: 22px; }
.spark { position: absolute; width: 5px; height: 5px; background: #ffd34a; animation: spark .6s ease-out forwards; }
.lantern { position: absolute; bottom: -40px; width: 34px; height: 44px; animation: rise 12s linear forwards; cursor: pointer; }
.lantern::before { content: ""; position: absolute; inset: 6px 3px 6px; border-radius: 45%; background: radial-gradient(circle at 50% 40%, #ffe08a, #e0502e 60%, #a8322a); box-shadow: 0 0 16px #ffb04a; }
.lantern::after { content: ""; position: absolute; left: 10px; right: 10px; top: 2px; bottom: 2px; border-top: 4px solid #5a3e26; border-bottom: 4px solid #5a3e26; }
#modal { position: fixed; inset: 0; background: rgba(30, 22, 16, .6); display: flex; align-items: center; justify-content: center; z-index: 9; }
#modal[hidden] { display: none; }
.box { background: #f4ecda; border-radius: 14px; padding: 20px 22px 16px; max-width: 340px; width: 88%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.box h2 { font-size: 20px; margin-bottom: 8px; color: #9a3b2b; }
.box p { margin: 6px 0; }
.box .big { font-size: 30px; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 8px; }
.box .sm { font-size: 12px; color: #8a7a62; }
.btns { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.btns button { padding: 9px 18px; border-radius: 10px; background: #e6dbc2; font-weight: 700; }
.btns .primary { background: #9a3b2b; color: #fff; }
@keyframes up { to { transform: translate(-50%, -160%); opacity: 0; } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
@keyframes rise { from { bottom: -40px; } to { bottom: 110%; } }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }
@keyframes pulse { 50% { outline-color: #f7d27a; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes toast { 10%, 85% { transform: translate(-50%, 0); } }
/* landscape: scene left, shop right */
@media (min-aspect-ratio: 4/3) and (min-width: 640px) {
  #app { flex-direction: row; }
  #stage { flex: 1 1 auto; height: 100%; max-height: none; aspect-ratio: auto; }
  #panel { flex: 0 0 min(400px, 38%); }
  #dyn { max-width: 160px; }
}
