/* Self-hosted Baloo 2 (SIL Open Font License, see /fonts/OFL.txt): works offline. */
@font-face { font-family: 'Baloo 2'; font-style: normal; font-weight: 400 800; font-display: swap; src: url(/fonts/baloo2-latin.woff2) format('woff2'); }
:root {
  --green: #3fae4f; --green-d: #23803a; --cream: #fff9e8; --ink: #1d3b2a; --gold: #ffcc33; --red: #e3121b;
  --font: "Baloo 2", ui-rounded, "Segoe UI Rounded", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; height: 100%; background: #0f3a30; overflow: hidden; font-family: var(--font); color: var(--ink); overscroll-behavior: none; }
#app { position: fixed; inset: 0; max-width: 560px; margin: 0 auto; overflow: hidden; background: #1f6f5c; box-shadow: 0 0 40px rgba(0,0,0,.5); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; user-select: none; -webkit-user-select: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; touch-action: manipulation; }

/* HUD */
#hud { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 8px) 10px 0; pointer-events: none; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
#hud button { pointer-events: auto; }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud-row2 { margin-top: 2px; }
.hud-mid { text-align: center; line-height: 1; }
.hud-level { font-weight: 800; font-size: 20px; }
.hud-level.swarm { color: #ffdd55; animation: pulse 0.8s infinite alternate; }
.hud-pond { font-size: 13px; opacity: .85; }
.coin-pill { background: rgba(0,0,0,.3); border-radius: 99px; padding: 2px 10px 2px 6px; font-weight: 800; font-size: 17px; min-width: 70px; text-align: right; }
.coin { margin-right: 3px; }
.hud-goal { font-weight: 800; font-size: 16px; background: rgba(0,0,0,.25); border-radius: 99px; padding: 0 10px; }
.hud-lives { font-size: 15px; letter-spacing: 1px; }
.goal-bar { height: 6px; background: rgba(0,0,0,.25); border-radius: 9px; margin-top: 5px; overflow: hidden; }
#goalFill { height: 100%; width: 0; background: linear-gradient(90deg, #9be032, #ffdd55); transition: width .2s; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: none; background: rgba(0,0,0,.3); color: #fff; font-size: 18px; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* Screens */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8,40,30,.45); backdrop-filter: blur(2px); }
.menu-card, .modal-card { background: var(--cream); border-radius: 26px; padding: 18px 18px 16px; width: 100%; max-width: 400px; box-shadow: 0 10px 0 rgba(0,0,0,.15), 0 20px 40px rgba(0,0,0,.3); border: 4px solid #fff; text-align: center; position: relative; max-height: calc(100% - 10px); overflow-y: auto; }
.title { margin: 0; font-size: 42px; line-height: .95; font-weight: 800; color: var(--green-d); text-shadow: 0 3px 0 #b7e39a; letter-spacing: -1px; }
.title span:nth-child(2) { font-size: 26px; color: #7a5a2a; text-shadow: none; }
#menuFrog { width: 150px; height: 128px; display: block; margin: 0 auto; }
.menu-stats { display: flex; justify-content: space-around; background: #eaf6d9; border-radius: 16px; padding: 6px; margin: 4px 0 12px; }
.menu-stats div { display: flex; flex-direction: column; line-height: 1.1; }
.menu-stats b { font-size: 20px; color: var(--green-d); }
.menu-stats small { font-size: 12px; opacity: .7; }
.btn { border: none; border-radius: 16px; padding: 10px 14px; font-size: 17px; font-weight: 800; background: #fff; color: var(--ink); box-shadow: 0 4px 0 #d6cfb6; transition: transform .06s; width: 100%; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d6cfb6; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-d); }
.btn.gold { background: var(--gold); color: #5a3d00; box-shadow: 0 4px 0 #c99a10; }
.btn.danger { background: #ff6b6b; color: #fff; box-shadow: 0 4px 0 #c43c3c; }
.btn.ghost { background: transparent; box-shadow: none; text-decoration: underline; font-size: 15px; margin-top: 4px; }
.btn.big { font-size: 24px; padding: 12px; margin-bottom: 10px; }
.btn:disabled { opacity: .5; }
.btn.small { width: auto; font-size: 14px; padding: 6px 10px; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; }
.toggles { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.toggle { border: 2px solid #d6cfb6; background: #fff; border-radius: 99px; padding: 4px 10px; font-size: 14px; font-weight: 700; color: var(--ink); }
.toggle.off { opacity: .55; }
.hint { font-size: 13px; opacity: .7; margin: 8px 0 0; }
.close-btn { position: absolute; z-index: 2; top: 8px; right: 10px; border: none; background: none; font-size: 20px; color: #9a9070; }

/* Modal content */
.modal-card h2 { margin: 0 0 4px; font-size: 28px; color: var(--green-d); line-height: 1.1; }
.modal-card h2.swarm { color: #c0242f; }
.modal-card p { margin: 4px 0 10px; }
.big-num { font-size: 44px; font-weight: 800; color: var(--green-d); line-height: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 6px -4px 10px; padding: 0 4px 4px; scrollbar-width: none; }
.tab { flex: 0 0 auto; border: none; border-radius: 12px; padding: 6px 11px; font-weight: 800; font-size: 14px; background: #ece4c9; color: var(--ink); }
.tab.on { background: var(--green); color: #fff; }
.shop-coins { font-weight: 800; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item { background: #fff; border-radius: 14px; padding: 6px 4px 8px; border: 3px solid transparent; display: flex; flex-direction: column; align-items: center; font-size: 13px; font-weight: 700; line-height: 1.1; }
.item.equipped { border-color: var(--green); }
.item canvas { width: 72px; height: 62px; }
.item .nm { min-height: 28px; display: flex; align-items: center; text-align: center; }
.item .btn { margin-top: 4px; font-size: 13px; padding: 4px 6px; border-radius: 10px; }
.upg { background: #fff; border-radius: 16px; padding: 10px 12px; text-align: left; margin-bottom: 10px; }
.upg h3 { margin: 0; font-size: 18px; display: flex; justify-content: space-between; }
.upg .lvbar { height: 10px; border-radius: 9px; background: #ece4c9; overflow: hidden; margin: 6px 0; }
.upg .lvbar div { height: 100%; background: linear-gradient(90deg, #3fae4f, #9be032); }
.upg small { display: block; opacity: .75; font-size: 13px; margin-bottom: 6px; }
.upg .btn-row .btn { font-size: 14px; padding: 7px; }
form { display: flex; flex-direction: column; gap: 8px; text-align: left; }
label { font-weight: 700; font-size: 14px; }
input { width: 100%; font: inherit; font-size: 17px; padding: 9px 12px; border-radius: 12px; border: 2px solid #d6cfb6; background: #fff; }
input:focus { outline: none; border-color: var(--green); }
input.pin { letter-spacing: 10px; text-align: center; font-size: 24px; font-weight: 800; }
.err { color: #c0242f; font-weight: 700; font-size: 14px; min-height: 18px; }
.lb { list-style: none; padding: 0; margin: 8px 0; text-align: left; }
.lb li { display: flex; gap: 8px; align-items: center; background: #fff; border-radius: 12px; padding: 6px 10px; margin-bottom: 5px; font-weight: 700; }
.lb li.me { background: #e3f6c9; }
.lb .rk { width: 30px; font-weight: 800; color: #9a7a2a; }
.lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.lb .fl { color: var(--green-d); }
.toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: rgba(20,30,25,.9); color: #fff; padding: 8px 16px; border-radius: 99px; font-weight: 700; z-index: 9; max-width: 90%; text-align: center; }
.tap-start { animation: pulse .7s infinite alternate; }
.btn.install { background: #2f7ee8; color: #fff; box-shadow: 0 4px 0 #1a4f9e; margin-top: 10px; }
input { -webkit-user-select: text; user-select: text; }
.steps { text-align: left; margin: 8px 0 12px; padding-left: 22px; line-height: 1.5; }
body.playing { touch-action: none; }

/* Tutorial */
#tut { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 84px); display: flex; justify-content: center; padding: 0 12px; pointer-events: none; z-index: 5; }
.tut-card { pointer-events: auto; background: var(--cream); border: 3px solid #fff; border-radius: 20px; padding: 10px 14px 12px; max-width: 400px; width: 100%; box-shadow: 0 6px 0 rgba(0,0,0,.15), 0 14px 30px rgba(0,0,0,.3); text-align: center; animation: tutIn .25s ease-out; }
.tut-card h3 { margin: 2px 0 2px; font-size: 21px; color: var(--green-d); line-height: 1.15; }
.tut-card p { margin: 2px 0 8px; font-size: 15px; line-height: 1.3; }
.tut-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; color: #9a7a2a; }
.tut-skip { border: none; background: #ece4c9; border-radius: 99px; padding: 3px 10px; font-size: 12px; font-weight: 800; color: var(--ink); }
.tut-dots { display: flex; gap: 4px; justify-content: center; margin-bottom: 8px; }
.tut-dots i { width: 7px; height: 7px; border-radius: 9px; background: #d6cfb6; }
.tut-dots i.done { background: #9fd38a; } .tut-dots i.on { background: var(--green); width: 18px; }
.tut-next { font-size: 18px; padding: 8px; }
.tut-wait { font-weight: 800; color: #c07a00; animation: pulse .6s infinite alternate; }
.tut-hand { position: absolute; left: 0; top: 0; font-size: 40px; pointer-events: none; z-index: 6; filter: drop-shadow(0 3px 2px rgba(0,0,0,.4)); animation: tap 0.9s ease-in-out infinite; transition: transform .25s ease; }
.tut-hand::after { content: ''; }
@keyframes tap { 0%, 100% { margin-top: 10px; } 50% { margin-top: -4px; } }
@keyframes tutIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Offline badge + messages */
.net-badge { position: absolute; top: calc(env(safe-area-inset-top) + 6px); left: 50%; transform: translateX(-50%); z-index: 8; background: #3a3a3a; color: #fff; font-size: 13px; font-weight: 800; padding: 3px 12px; border-radius: 99px; box-shadow: 0 2px 6px rgba(0,0,0,.35); pointer-events: none; white-space: nowrap; }
body.playing .net-badge { top: auto; bottom: calc(env(safe-area-inset-bottom) + 6px); opacity: .85; }
.offline-box { background: #fff3d6; border: 2px dashed #e0b44c; border-radius: 16px; padding: 10px 12px; margin: 8px 0; font-weight: 700; }
.offline-box .big { font-size: 34px; line-height: 1; }
.lb-age { font-size: 12px; opacity: .65; }
.btn-row.row2 { margin-top: 10px; }
.btn-row.row2 .btn.install { margin-top: 0; }
.btn-row.row2 .btn { font-size: 15px; }
.scene-tag { font-size: 12px; font-weight: 800; color: #7a6a3a; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.modal-card h2.night { color: #3a3f8f; }
.new-species { background: linear-gradient(135deg, #fff4c2, #ffe0f0); border: 2px solid #ffd24a; border-radius: 16px; padding: 6px 10px 8px; margin: 6px 0 10px; text-align: left; }
.ns-badge { text-align: center; font-weight: 800; color: #c2410c; font-size: 16px; animation: pulse .7s infinite alternate; }
.ns-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 14px; line-height: 1.2; }
.ns-row canvas { width: 54px; height: 46px; flex: 0 0 auto; }
.tut-bugs { display: flex; justify-content: center; gap: 2px; margin: -2px 0 6px; flex-wrap: wrap; }
.tut-bugs canvas { width: 35px; height: 33px; }
