/* ===== Brine Storm ===== */
:root {
    --green: #6cb33f;
    --green-dark: #3d6b1f;
    --ink: #2d3a16;
    --brine: #0e2a1c;
    --cream: #fff7e6;
    --pop: #ff7eb3;
    --pop2: #ffd166;
    --font: 'Baloo 2', 'Comic Sans MS', 'Chalkboard SE', 'Segoe UI Rounded', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }   /* no link preview or magnifier on a long press (phone) */

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--brine);
    font-family: var(--font);
    color: var(--cream);
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Letterboxed 360×640 logical playfield; main.js sets the pixel size. */
#stage { position: relative; }
#game { display: block; touch-action: none; }

/* DOM overlay for menus. Sized by main.js in logical px via a CSS scale. */
#ui {
    position: absolute;
    inset: 0;
    width: 360px;
    height: 640px;
    transform-origin: top left;
    pointer-events: none;
}
#ui > * { pointer-events: auto; touch-action: manipulation; }   /* buttons: no double-tap zoom; the map's scroller keeps its own pan-y */

/* ===== DOM screens (map, level end) — logical 360×640 px, scaled by main.js ===== */
.ui-btn {
    font: 800 16px var(--font); color: var(--ink); background: var(--pop2); min-height: 44px;   /* every button is a 44 pt target */
    border: 3px solid var(--ink); border-radius: 16px; padding: 10px 16px; cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: transform .08s;
}
.ui-btn:active { transform: translateY(3px); box-shadow: none; }
.ui-btn.big { font-size: 22px; padding: 14px 26px; }
.ui-btn.huge { font-size: 28px; padding: 18px 40px; }
.ui-btn.small { padding: 6px 12px; font-size: 14px; }
.ui-btn.ghost { background: transparent; color: var(--ink); border: 2px dashed rgba(45,58,22,.5); box-shadow: none; font-size: 13px; }
.ui-btn:disabled { opacity: .5; cursor: default; }

.map { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--brine); color: var(--cream); }
.map-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 8px; }
.map-title { font-weight: 800; font-size: 20px; }
.chip { background: rgba(255,255,255,.15); border-radius: 999px; padding: 4px 10px; font-weight: 800; }
.map-scroll { flex: 1; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; padding-bottom: 20px; }   /* the map's scroll end never rubber-bands the page */
.map-stars { text-align: center; font-weight: 800; opacity: .8; padding: 4px; }
.world { margin: 10px 12px; border-radius: 22px; padding: 12px; color: var(--ink); }
.world h2 { margin: 0 0 8px; font-size: 17px; }
.world p { margin: 6px 0; font-size: 13px; }
.world.rush { text-align: center; }
.nodes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.node {
    font: 800 12px var(--font); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 16px;
    padding: 8px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-height: 78px;
}
.node-num { font-size: 15px; }
.node-name { font-size: 9px; font-weight: 700; opacity: .8; text-align: center; line-height: 1.1; }
.node-stars { font-size: 11px; color: #e0a800; }
.node-best { font-size: 8px; opacity: .6; }
.node.boss { background: #ffe0e6; }
.node.locked { opacity: .45; }
.node.next { animation: nodePulse 1.1s ease-in-out infinite; border-color: var(--pop); }
@keyframes nodePulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(255,126,179,.35); } }

.lend { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(14,42,28,.78); }
.lend-card { width: 320px; background: var(--cream); color: var(--ink); border-radius: 26px; padding: 18px 16px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: cardIn .35s cubic-bezier(.2,.9,.3,1.3); }
@keyframes cardIn { from { transform: scale(.6); opacity: 0; } }
.lend-title { margin: 0; font-size: 34px; color: #2e7d32; }
.lose .lend-title { color: #c0392b; }
.stars { font-size: 44px; height: 56px; line-height: 56px; }
.star { display: inline-block; color: #d6d0c4; transform: scale(0); animation: stamp .35s cubic-bezier(.2,.9,.3,1.4) forwards; }
.star.on { color: #ffb300; text-shadow: 0 2px 0 #c68a00; }
.star.brine { font-size: 40px; }
@keyframes stamp { to { transform: scale(1); } }
.bonus { list-style: none; padding: 0; margin: 6px 0; text-align: left; }
.bonus li { display: flex; justify-content: space-between; font-weight: 700; padding: 3px 6px; opacity: 0; animation: fadeUp .3s forwards; }
@keyframes fadeUp { from { transform: translateY(8px); opacity: 0; } to { opacity: 1; } }
.total { display: flex; justify-content: space-between; font-size: 22px; font-weight: 800; border-top: 3px dashed #cfc7b8; padding: 8px 6px; }
.ribbon { background: var(--pop); color: #fff; font-weight: 800; display: inline-block; padding: 4px 14px; border-radius: 999px; transform: rotate(-4deg); animation: cardIn .4s 2.6s both; }
.reward { font-weight: 800; color: #1f5f8b; margin: 6px 0; }
.next-star { font-weight: 700; font-size: 13px; color: #6d5a1f; margin: 2px 0 4px; }
.next-star.late { opacity: 0; animation: fadeUp .3s forwards; }   /* arrives after the stars have stamped: no spoilers */
.lend.instant .next-star { animation: none; opacity: 1; }
.tbtn { min-height: 44px; }
.next-star b { color: #c0392b; }
.near { font-weight: 700; font-size: 15px; margin: 4px 0 10px; }
.btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 6px; }
.fine { font-size: 10px; opacity: .55; margin: 4px 0 0; }

/* ===== Flight School coach ===== */
#ui > .coach { pointer-events: none; }
#ui > .coach-skip { position: absolute; right: 12px; top: 54px; font-size: 12px; padding: 4px 10px; }
.coach {
    position: absolute; transform: translate(-50%, -50%); background: var(--cream); color: var(--ink);
    border: 3px solid var(--ink); border-radius: 16px; padding: 8px 12px; font: 800 15px var(--font); text-align: center;
    box-shadow: 0 4px 0 rgba(0,0,0,.25); animation: cardIn .3s cubic-bezier(.2,.9,.3,1.3); white-space: nowrap; width: max-content; max-width: 300px;
    transition: left .15s, top .15s; --ax: 50%;
}
.coach.done { background: #e8f5e9; border-color: var(--green-dark); }
.coach.done .coach-copy::after { content: ' ✓'; color: var(--green-dark); }
.coach::after { content: ''; position: absolute; border: 10px solid transparent; }
.coach[data-dir="up"]::after { left: var(--ax); top: -20px; margin-left: -10px; border-bottom-color: var(--ink); }
.coach[data-dir="down"]::after { left: var(--ax); bottom: -20px; margin-left: -10px; border-top-color: var(--ink); }
.coach[data-dir="right"]::after { right: -20px; top: 50%; margin-top: -10px; border-left-color: var(--ink); }
.coach-dots { display: flex; justify-content: center; gap: 5px; margin-bottom: 4px; }
.coach-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(45,58,22,.2); }
.coach-dots i.done { background: var(--green); }
.coach-dots i.now { background: var(--pop); transform: scale(1.3); }
.coach-copy { white-space: normal; line-height: 1.2; }
.coach .finger { display: inline-block; font-size: 22px; animation: fingerDrag 1.2s ease-in-out infinite; }
@keyframes fingerDrag { 0%,100% { transform: translateX(-14px); } 50% { transform: translateX(14px); } }
.coach .finger.tap { animation: fingerTap .8s ease-in-out infinite; }
@keyframes fingerTap { 0%,100% { transform: translateY(0) scale(1); } 40% { transform: translateY(7px) scale(.85); } }
.pause .lend-title { color: var(--ink); }

/* ===== hub / chests / streak ===== */
.hub-title { text-align: center; font-size: 30px; font-weight: 800; margin: 6px 0; }
.rank { flex: 1; font-size: 13px; }
.rank small { opacity: .75; font-size: 10px; }
.xpbar { height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; margin: 3px 0; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--pop2); }
.chests { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chest { font: 700 10px var(--font); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 70px; cursor: pointer; }
.chest.empty { opacity: .35; border-style: dashed; }
.chest .c-ico { font-size: 22px; }
.chest.ready { background: #fff3b0; animation: nodePulse 1s ease-in-out infinite; }
.chest.ticking .c-time { color: #c0392b; font-variant-numeric: tabular-nums; }
.days { display: flex; justify-content: space-between; margin: 8px 0; }
.day { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--ink); display: grid; place-items: center; font-weight: 800; background: #fff; color: var(--ink); }
.day.done { background: var(--pop2); }
.day.big { width: 40px; height: 40px; }
.world small { font-weight: 700; opacity: .6; font-size: 11px; margin-left: 6px; }
.ad-slot { margin: 10px 12px 24px; background: rgba(255,255,255,.12); border: 2px dashed rgba(255,255,255,.35); border-radius: 14px; padding: 10px; text-align: center; font-size: 13px; }
.ad-slot small { display: block; opacity: .6; font-size: 10px; }
.sad-ad { font-size: 28px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.sad-ad span { font-size: 14px; font-weight: 800; }
.map a.ui-btn { display: inline-block; text-decoration: none; }

/* ===== fake ad ===== */
.ad { position: absolute; inset: 0; color: var(--ink); text-align: center; padding: 30px 20px; }
.ad-tag { font-size: 11px; font-weight: 800; opacity: .7; }
.ad-ico { font-size: 80px; margin: 30px 0 10px; animation: flyBob 1.2s ease-in-out infinite; }
@keyframes flyBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.ad-name { font-size: 28px; margin: 6px 0; }
.ad-pitch { font-size: 16px; font-weight: 700; margin: 6px 0; }
.ad-phone { font-size: 14px; font-weight: 800; margin: 12px 0; }
.ad-price { font-size: 18px; }
.ad-price b { color: #c0392b; font-size: 26px; }
.ad-skip { position: absolute; right: 16px; top: 16px; transition: left .15s, top .15s; }
.ad-bar { position: absolute; left: 20px; right: 20px; bottom: 90px; height: 8px; background: rgba(0,0,0,.2); border-radius: 4px; overflow: hidden; }
.ad-bar i { display: block; height: 100%; width: 0; background: var(--ink); animation: adbar linear forwards; }
@keyframes adbar { to { width: 100%; } }
.ad-claim { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); animation: cardIn .4s cubic-bezier(.2,.9,.3,1.3); }

/* ===== store ===== */
.banner { margin: 8px 12px; background: var(--pop2); color: var(--ink); border-radius: 14px; padding: 8px; text-align: center; font-weight: 800; animation: nodePulse 1.4s ease-in-out infinite; }
.timer { text-align: center; font-weight: 800; color: #ffd166; margin: 6px; }
.bundles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 12px; }
.bundle { position: relative; font: 800 13px var(--font); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 12px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.bundle.best { background: #fff3b0; }
.ribbon-tag { position: absolute; top: -8px; right: -6px; background: var(--pop); color: #fff; font-size: 10px; padding: 3px 8px; border-radius: 999px; transform: rotate(8deg); }
.b-ico { font-size: 26px; }
.b-what { font-weight: 700; font-size: 12px; opacity: .8; }
.b-price { color: #c0392b; }
.premium-card { background: linear-gradient(135deg,#ffd166,#ff7eb3); }
.lend-title.small { font-size: 22px; }
.terms-text { max-height: 200px; overflow-y: auto; text-align: left; font-size: 10px; line-height: 1.4; background: #fff; border: 2px solid #ddd; border-radius: 10px; padding: 8px; margin: 8px 0; }
.check { display: block; font-weight: 800; margin: 8px 0; }

/* ===== settings ===== */
.setting { display: flex; justify-content: space-between; align-items: center; font-weight: 800; padding: 10px 4px; border-bottom: 2px dashed rgba(0,0,0,.1); }
.setting small { display: block; font-weight: 700; opacity: .6; font-size: 11px; }
.setting input { width: 30px; height: 30px; }

.top10 { margin: 6px auto; padding: 0 0 0 26px; width: max-content; text-align: left; font-size: 13px; }
.top10 li { padding: 1px 0; } .top10 small { margin-left: 8px; opacity: .6; }
.tiers { margin: 8px 12px; background: rgba(255,255,255,.1); border-radius: 16px; padding: 6px; }
.tier { display: grid; grid-template-columns: 56px 1fr 1fr; gap: 6px; align-items: center; padding: 4px 2px; border-bottom: 1px solid rgba(255,255,255,.12); font-weight: 800; font-size: 13px; opacity: .55; }
.tier.open { opacity: 1; }
.tier.head { opacity: .8; font-size: 11px; text-transform: uppercase; }
.tier small { display: block; font-size: 9px; opacity: .7; font-weight: 700; }
.tbtn { font: 800 12px var(--font); color: var(--ink); background: var(--pop2); border: 2px solid var(--ink); border-radius: 10px; padding: 6px 4px; cursor: pointer; }
.tbtn.done { background: #c8e6c9; } .tbtn.locked { background: #e0e0e0; } .tbtn:disabled { cursor: default; }
.toast-layer { position: absolute; left: 0; right: 0; top: 70px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 5; }
.toast { background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 14px; font: 800 13px var(--font); box-shadow: 0 4px 0 rgba(0,0,0,.25); animation: toastIn .25s cubic-bezier(.2,.9,.3,1.3); }
.toast.award { background: var(--pop2); }
@keyframes toastIn { from { transform: translateY(-10px) scale(.8); opacity: 0; } }
.lend.instant .star, .lend.instant .bonus li, .lend.instant .ribbon, .lend.instant .lend-card { animation: none; transform: none; opacity: 1; }
.trails { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
