:root { --ink: #4a2a14; --cream: #fff6dc; --sun: #ffcf3a; --sky: #7fd3fb; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); font-family: system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--cream); box-shadow: 0 4px 0 #c59a52, 0 6px 12px rgba(0,0,0,.2); font-size: 24px; font-weight: 900; }
.pill { padding: 12px 22px; border-radius: 999px; background: var(--cream); box-shadow: 0 4px 0 #c59a52; font-weight: 800; font-size: 17px; }
.pill.primary { background: var(--sun); box-shadow: 0 4px 0 #c98a14; }
.round:active, .pill:active { transform: translateY(3px); box-shadow: 0 1px 0 #c59a52; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; position: absolute; }
#btn-menu { left: max(14px, env(safe-area-inset-left)); top: 14px; }
#btn-retry { left: calc(max(14px, env(safe-area-inset-left)) + 60px); top: 14px; }
#score { right: max(18px, env(safe-area-inset-right)); top: 12px; font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 var(--ink), 0 0 6px rgba(0,0,0,.25); pointer-events: none; }
#ability-hint { left: 50%; top: 16px; transform: translateX(-50%); background: rgba(74,42,20,.72); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; pointer-events: none; opacity: 0; transition: opacity .3s; white-space: nowrap; }
#ability-hint.on { opacity: 1; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: rgba(127,211,251,.25); padding: 16px; }
.screen[hidden], #hud[hidden], #rotate[hidden] { display: none; }
h1 { margin: 0; font-size: clamp(34px, 7vw, 64px); font-weight: 900; color: var(--sun); -webkit-text-stroke: 2px var(--ink); text-shadow: 0 5px 0 var(--ink); letter-spacing: 1px; }
.sub { margin: 0; font-weight: 900; font-size: 18px; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 4px var(--ink); }
#levels { display: grid; grid-template-columns: repeat(5, minmax(64px, 92px)); gap: 12px; }
.lv { aspect-ratio: 1; border-radius: 18px; background: var(--cream); box-shadow: 0 5px 0 #c59a52; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; }
.lv .st { display: flex; gap: 1px; margin-top: 2px; }
.lv .st img { width: 16px; height: 16px; }
.lv.locked { opacity: .45; }
.panel { background: var(--cream); border-radius: 26px; padding: 22px 28px; box-shadow: 0 8px 0 #c59a52, 0 16px 30px rgba(0,0,0,.25); text-align: center; min-width: min(420px, 92vw); }
.panel h2 { margin: 0 0 6px; font-size: 32px; font-weight: 900; }
#stars { display: flex; justify-content: center; gap: 8px; margin: 6px 0; }
#stars img { width: 64px; height: 64px; transform: scale(0); transition: transform .35s cubic-bezier(.3,1.8,.5,1); }
#stars img.in { transform: scale(1); }
#stars img:nth-child(2) { width: 80px; height: 80px; margin-top: -10px; }
#result-score { font-size: 28px; font-weight: 900; margin-bottom: 14px; }
.row { display: flex; gap: 10px; justify-content: center; }
#rotate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--sky); font-size: 22px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink); z-index: 10; }
#btn-mute { position: absolute; right: 16px; bottom: 16px; }
/* v2: coins, item bar, item popup, shop, result milestones */
.coins { position: absolute; left: max(16px, env(safe-area-inset-left)); top: 14px; display: flex; align-items: center; gap: 6px; background: rgba(74,42,20,.75); color: #fff; border-radius: 999px; padding: 4px 14px 4px 6px; font-weight: 900; font-size: 20px; }
.coin-ic { width: 30px; height: 30px; }
#enemies { right: max(18px, env(safe-area-inset-right)); top: 52px; background: rgba(74,42,20,.7); color: #fff; font-weight: 900; padding: 2px 12px; border-radius: 999px; pointer-events: none; }
#itembar { left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; transition: opacity .25s, transform .25s; }
#itembar.away { opacity: 0; transform: translate(-50%, 30px); pointer-events: none; }
.it { position: relative; width: 58px; height: 58px; border-radius: 16px; background: rgba(255,246,220,.92); box-shadow: 0 4px 0 #c59a52; padding: 4px; }
.it img { width: 100%; height: 100%; object-fit: contain; }
.it .n { position: absolute; right: -6px; top: -6px; min-width: 22px; height: 22px; border-radius: 11px; background: #2f6fd6; color: #fff; font-size: 13px; font-weight: 900; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.it .price { position: absolute; left: 50%; bottom: -10px; transform: translateX(-50%); background: #4a2a14; color: #ffd34a; font-size: 11px; font-weight: 900; border-radius: 8px; padding: 0 5px; white-space: nowrap; }
.it.used { opacity: .45; }
.it.active { outline: 3px solid #ffcf3a; }
.item-panel { max-width: 420px; }
#ip-icon { width: 96px; height: 96px; object-fit: contain; }
#ip-desc { margin: 6px 0 4px; font-weight: 700; line-height: 1.45; }
#ip-own { margin: 0 0 8px; font-weight: 800; color: #8a5a2a; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; }
.shop-panel { width: min(640px, 94vw); max-height: 86vh; overflow: auto; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.tab { padding: 8px 18px; border-radius: 999px; background: #eadcb8; font-weight: 800; }
.tab.on { background: var(--sun); }
#shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.card { background: #fff; border-radius: 16px; padding: 10px; box-shadow: 0 3px 0 #e2cfa2; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.card img { width: 64px; height: 64px; object-fit: contain; }
.card b { font-size: 16px; }
.card small { color: #7a5a3a; font-weight: 600; min-height: 32px; }
.card .pill { padding: 6px 14px; font-size: 14px; }
.card .pill[disabled] { opacity: .5; }
#milestones { display: flex; justify-content: center; gap: 10px; margin: 4px 0 8px; }
.ms { background: #2c4a86; color: #fff; font-weight: 900; padding: 4px 12px; border-radius: 10px; opacity: .45; }
.ms.on { opacity: 1; background: #3aa34a; }
#result-coins { font-weight: 900; color: #b07a10; margin-bottom: 10px; min-height: 22px; }
#toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(74,42,20,.85); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 800; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 20; }
#toast.on { opacity: 1; }
.menu-row { margin-top: 6px; }
#btn-mute { position: static; }
