@font-face { font-family: 'Barlow'; src: url('../../assets/fonts/barlow-condensed-latin-800-italic.woff2') format('woff2'); font-weight: 800; font-style: italic; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url('../../assets/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'DM'; src: url('../../assets/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'DM'; src: url('../../assets/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root { --ink: #23301f; --ink2: #5a6b55; --panel: #fffaf0f0; --card: #f4ecd8; --line: #e6d9b8; --green: #4fbf3a; --green2: #348a26; --sun: #ffd23f; --sun2: #e0a800; --red: #e8413c; --shadow: 0 18px 50px #1a2a1455; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9bd8f5; color: var(--ink); font-family: DM, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible + span { outline: 3px solid #3fa9ff; outline-offset: 3px; }
[hidden] { display: none !important; }
#board { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.coin { display: inline-block; width: .8em; height: .8em; margin-right: 4px; border-radius: 50%; vertical-align: -1px; background: radial-gradient(circle at 35% 30%, #fff3b0 0 18%, #ffd23f 22% 60%, #d99a00 64%); box-shadow: inset 0 0 0 2px #c98d00; font-style: normal; }
.back { position: fixed; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); z-index: 6; padding: 10px 14px; border-radius: 999px; background: #ffffffe0; color: var(--ink); font-weight: 700; font-size: 13px; text-decoration: none; box-shadow: 0 6px 18px #0003; }
body:not(.menu-on) .back { display: none; }

.panel { position: fixed; z-index: 5; top: 18px; right: 18px; bottom: 18px; width: min(430px, 42vw); overflow-y: auto; overscroll-behavior: contain; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 26px; padding: 22px; box-shadow: var(--shadow); border: 3px solid #fff; }
.logo { font: 800 italic 72px/.82 Barlow, sans-serif; display: flex; gap: 10px; letter-spacing: -1px; text-shadow: 0 4px 0 #23301f18; }
.logo span { color: var(--green); }
.logo b { color: #8f5cf2; font-weight: 800; }
.tag { margin: 8px 0 14px; color: var(--ink2); font-size: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.card-head b { font: 800 italic 24px Barlow, sans-serif; }
.card-head span { font: 800 italic 18px Barlow, sans-serif; color: #b07d00; }
.maps { display: grid; gap: 7px; }
.map { display: grid; grid-template-columns: 34px 1fr auto; gap: 1px 10px; align-items: center; text-align: left; padding: 9px 12px; border-radius: 15px; background: #fff; border: 3px solid var(--line); }
.map .num { grid-row: 1 / 3; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font: 800 italic 20px Barlow, sans-serif; color: #fff; }
.theme-meadow .num { background: #4fbf3a; } .theme-beach .num { background: #3fc0e0; } .theme-snow .num { background: #8fb6d2; } .theme-candy .num { background: #ff7ab8; } .theme-volcano .num { background: #e0662a; }
.map b { font: 800 italic 20px/1.05 Barlow, sans-serif; }
.map small { grid-column: 2; font-size: 11px; color: var(--ink2); line-height: 1.3; }
.map .stars { grid-column: 3; grid-row: 1 / 3; font-size: 18px; letter-spacing: -1px; }
.stars i, .big-stars i { font-style: normal; color: #e0d6bd; }
.stars i.on, .big-stars i.on { color: #ffc21a; text-shadow: 0 1px 0 #c98d00; }
.map.on { border-color: var(--green); box-shadow: 0 4px 0 var(--green2); }
.map.locked { opacity: .6; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.modes button { background: #fff; border: 3px solid var(--line); border-radius: 15px; padding: 8px 4px; text-align: center; }
.modes button b { display: block; font: 800 italic 20px Barlow, sans-serif; }
.modes button small { display: block; font-size: 10.5px; color: var(--ink2); }
.modes button[aria-pressed=true] { border-color: var(--green); background: #eaf8e3; box-shadow: 0 4px 0 var(--green2); }
.play { width: 100%; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 15px 20px; border-radius: 20px; background: var(--sun); color: var(--ink); font: 800 italic 38px/1 Barlow, sans-serif; letter-spacing: 1px; box-shadow: 0 7px 0 var(--sun2), 0 12px 24px #b0800044; transition: transform .08s, box-shadow .08s; }
.play span { font-size: .6em; }
.play:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--sun2); }
.fine { font-size: 11.5px; color: var(--ink2); line-height: 1.45; }
.center { text-align: center; }
.menu-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.menu-buttons button { background: #fff; border: 3px solid var(--line); border-radius: 15px; padding: 9px 4px 8px; font-weight: 700; font-size: 13px; position: relative; }
.menu-buttons button span { display: block; font-size: 22px; margin-bottom: 2px; }
.menu-buttons button i { position: absolute; top: 5px; right: 6px; font-style: normal; font-size: 10px; background: var(--red); color: #fff; border-radius: 999px; padding: 1px 6px; }
.settings { display: grid; gap: 10px; margin-top: 10px; background: var(--card); border-radius: 15px; padding: 12px 14px; }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span { width: 46px; height: 26px; border-radius: 999px; background: #d9cdb0; position: relative; flex: none; transition: background .2s; }
.switch > span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { left: 23px; }
.help { text-align: center; font-size: 11.5px; color: var(--ink2); margin: 12px 0 0; }

.side-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.side-head h2 { font: 800 italic 34px/1 Barlow, sans-serif; margin: 0; flex: 1; }
.count { font: 800 italic 20px Barlow, sans-serif; color: #b07d00; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; background: #fff; border: 3px solid var(--line); font: 800 italic 18px Barlow, sans-serif; display: grid; place-items: center; flex: none; box-shadow: 0 4px 12px #0002; }
.list { display: grid; gap: 8px; margin-top: 10px; }
.row-item { background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 10px 12px; display: grid; grid-template-columns: 46px 1fr auto; gap: 3px 12px; align-items: center; text-align: left; }
.row-item .icon { grid-row: 1 / 4; width: 46px; height: 46px; border-radius: 13px; background: var(--card); display: grid; place-items: center; font-size: 25px; }
.row-item b { font: 800 italic 20px/1 Barlow, sans-serif; }
.row-item small { font-size: 11.5px; color: var(--ink2); }
.row-item .buy { grid-column: 3; grid-row: 1 / 4; min-width: 78px; text-align: center; padding: 9px; border-radius: 11px; background: var(--sun); font-weight: 700; font-size: 13px; box-shadow: 0 3px 0 var(--sun2); }
.row-item .buy.short { background: #ece4d0; box-shadow: 0 3px 0 #d9cdb0; color: #8a7a5a; }
.row-item .buy.max { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green2); }
.pips { display: flex; gap: 4px; }
.pips i { width: 18px; height: 7px; border-radius: 9px; background: #ece4d0; }
.pips i.on { background: linear-gradient(90deg, #ffc21a, #ffe27a); }

/* in-game HUD */
#hud { position: fixed; inset: 0 0 auto 0; z-index: 4; pointer-events: none; }
.top { display: flex; align-items: center; gap: 8px; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); flex-wrap: wrap; }
.top > * { pointer-events: auto; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #ffffffeb; border-radius: 999px; padding: 6px 13px; font: 800 italic 22px Barlow, sans-serif; box-shadow: 0 4px 12px #0002; }
.chip small { font: 700 11px DM, sans-serif; letter-spacing: 1px; color: var(--ink2); }
.chip.bump { animation: bump .3s ease; }
@keyframes bump { 40% { transform: scale(1.18); background: #ffd6d6; } }
.speed { min-width: 54px; justify-content: center; }
.next { background: var(--green); color: #fff; border-radius: 999px; padding: 9px 16px; font: 800 italic 20px Barlow, sans-serif; box-shadow: 0 4px 0 var(--green2), 0 6px 14px #0003; display: inline-flex; gap: 8px; align-items: center; }
.next i { font-style: normal; background: #ffd23f; color: var(--ink); border-radius: 999px; padding: 0 6px; font-size: 15px; }
.next span { font-size: 14px; opacity: .85; }
.next:disabled { background: #8f9a8c; box-shadow: 0 4px 0 #6f7a6c; }
.next.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.hint { text-align: center; margin: 8px auto 0; font-weight: 700; font-size: 13px; color: #fff; text-shadow: 0 2px 6px #000a; min-height: 18px; }
#palette { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 0 max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.towers { display: grid; grid-template-columns: repeat(5, minmax(0, 92px)); gap: 7px; pointer-events: auto; background: #ffffffd9; padding: 7px; border-radius: 20px; box-shadow: 0 8px 22px #0003; }
.tw { position: relative; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px 4px 5px; display: grid; justify-items: center; gap: 0; }
.tw .ico { font-size: 26px; line-height: 1.1; }
.tw b { font: 800 italic 16px/1 Barlow, sans-serif; }
.tw small { font-size: 12px; font-weight: 700; }
.tw kbd { position: absolute; top: 3px; left: 5px; font: 700 9px DM, sans-serif; color: #b9ad90; }
.tw.armed { border-color: var(--green); background: #eaf8e3; box-shadow: 0 4px 0 var(--green2); transform: translateY(-3px); }
.tw.poor { opacity: .55; }
.tw:disabled { opacity: .45; }
.info { pointer-events: auto; display: flex; align-items: center; gap: 8px; background: #fffaf0f5; border-radius: 18px; padding: 8px 10px; box-shadow: 0 8px 22px #0003; border: 3px solid #fff; max-width: calc(100vw - 20px); flex-wrap: wrap; justify-content: center; }
.ti { display: flex; gap: 8px; align-items: center; }
.ti .ico { font-size: 28px; }
.ti b { font: 800 italic 19px/1 Barlow, sans-serif; display: block; }
.ti em { font-style: normal; font-size: 14px; letter-spacing: -1px; }
.ti em i { font-style: normal; color: #e0d6bd; }
.ti em i.on { color: #ffc21a; }
.ti small { font-size: 11.5px; color: var(--ink2); }
.info button { border-radius: 12px; padding: 9px 12px; font-weight: 700; font-size: 13px; }
.info .up { background: var(--sun); box-shadow: 0 3px 0 var(--sun2); }
.info .up:disabled { background: #ece4d0; box-shadow: 0 3px 0 #d9cdb0; color: #8a7a5a; }
.info .sell { background: #fff; border: 3px solid var(--line); }
.info .x { width: 38px; height: 38px; padding: 0; background: #fff; border: 3px solid var(--line); }
#banner { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%) scale(.9); z-index: 6; text-align: center; color: #fff; pointer-events: none; opacity: 0; transition: opacity .35s, transform .35s; text-shadow: 0 4px 0 #1a2a14aa, 0 0 22px #0007; }
#banner.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner small { display: block; font: 700 16px Barlow, sans-serif; letter-spacing: 4px; }
#banner b { display: block; font: 800 italic clamp(54px, 10vw, 100px)/.95 Barlow, sans-serif; }
#toasts { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 64px); left: 50%; transform: translateX(-50%); z-index: 8; display: grid; gap: 8px; pointer-events: none; width: min(420px, calc(100vw - 24px)); }
.toast { background: #fffaf0f2; border-radius: 16px; padding: 10px 14px; box-shadow: 0 10px 26px #0003; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; animation: tin .35s ease; border: 3px solid #fff; }
.toast span { font-size: 22px; }
.toast small { display: block; font-weight: 400; color: var(--ink2); font-size: 12px; }
.toast.out { animation: tout .4s ease forwards; }
@keyframes tin { from { transform: translateY(-14px); opacity: 0; } }
@keyframes tout { to { transform: translateY(-14px); opacity: 0; } }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: #1a2a1466; padding: 18px; }
.sheet { width: min(400px, 100%); background: var(--panel); border-radius: 26px; padding: 22px; box-shadow: var(--shadow); border: 3px solid #fff; text-align: center; animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.sheet h2 { font: 800 italic 46px/1 Barlow, sans-serif; margin: 4px 0 6px; }
.big-stars { font-size: 54px; letter-spacing: 2px; }
.notes { display: grid; gap: 6px; margin: 10px 0 14px; }
.notes span { background: #fffbea; border: 2px solid #f2c94c; border-radius: 12px; padding: 7px 10px; font-size: 13px; font-weight: 700; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.row button { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 11px; font-weight: 700; font-size: 15px; }

@media (max-width: 760px) and (orientation: portrait) {
  .panel { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 58vh; border-radius: 24px; padding: 16px; }
  .logo { font-size: 52px; }
  .tag { margin: 4px 0 10px; font-size: 13px; }
  .play { font-size: 32px; padding: 12px; }
  .chip { font-size: 18px; padding: 5px 10px; }
  .next { font-size: 17px; padding: 8px 12px; }
  .top .spacer { display: none; }
  .top { justify-content: center; }
  .towers { grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
  .tw .ico { font-size: 22px; }
  .tw b { font-size: 13px; }
  .tw kbd { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .panel { top: 8px; bottom: 8px; right: 8px; width: min(380px, 48vw); padding: 14px; border-radius: 20px; }
  .logo { font-size: 44px; margin-bottom: 8px; }
  .tag { display: none; }
  .play { font-size: 26px; padding: 9px; }
  .towers { grid-template-columns: repeat(5, 70px); padding: 4px; gap: 5px; border-radius: 16px; }
  .tw { padding: 3px 2px; border-radius: 11px; }
  .tw .ico { font-size: 18px; }
  .tw b { font-size: 12px; }
  .tw small { font-size: 11px; }
  .tw kbd { display: none; }
  #palette { gap: 4px; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .info { padding: 4px 8px; gap: 6px; }
  .info button { padding: 6px 9px; }
  .ti small { display: none; }
  .top { padding-top: max(6px, env(safe-area-inset-top)); }
  .hint { margin-top: 4px; }
  .chip { font-size: 18px; padding: 4px 10px; }
  .next { font-size: 16px; padding: 7px 12px; }
  .back { top: 8px; left: 8px; }
}
