* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: #0b2a52; overscroll-behavior: none; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #123; min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(180deg, #1e90e8 0%, #0b2a52 340px, #0b2a52 100%);
}
#app { max-width: 480px; margin: 0 auto; padding: 14px 12px 28px; }
.hidden { display: none !important; }

/* Playing mode: the whole game fits exactly one screen — no page scroll, no pull-down. */
body.playing { overflow: hidden; }
body.playing #app { height: 100vh; height: 100dvh; padding: 10px 10px 8px; display: flex; flex-direction: column; }
body.playing #game-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; touch-action: none; }

.logo { text-align: center; color: #fff; font-size: 40px; font-weight: 900; letter-spacing: .5px; text-shadow: 0 3px 0 #0b2a52; margin: 10px 0 4px; }
.logo span { color: #ffd83d; }
.logo.small { font-size: 30px; }
.tagline { text-align: center; color: #d8efff; font-size: 15px; margin-bottom: 14px; padding: 0 8px; }

.card { background: #fff; border-radius: 16px; padding: 12px 14px; margin: 12px 0; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.card-title { font-weight: 800; font-size: 15px; margin-bottom: 8px; color: #0b2a52; }
.howto ul, .earn-list { margin-left: 18px; font-size: 14px; line-height: 1.5; }

.big-btn {
  display: block; width: 100%; border: none; cursor: pointer; margin: 12px 0;
  background: #ffd83d; color: #5b4300; font-size: 22px; font-weight: 900;
  padding: 15px; border-radius: 16px; box-shadow: 0 5px 0 #c9a400;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #c9a400; }
.big-btn.disabled { background: #cfd6dd; color: #6b7680; box-shadow: 0 5px 0 #9aa4ad; cursor: not-allowed; }
.ghost-btn {
  display: block; width: 100%; border: none; cursor: pointer; margin: 8px 0;
  background: rgba(255,255,255,.14); color: #fff; font-size: 16px; font-weight: 700;
  padding: 11px; border-radius: 12px;
}
.ghost-btn.danger { background: rgba(255,80,80,.25); }
.stars-badge { background: #a83fd5; border-radius: 999px; padding: 2px 9px; font-size: 14px; }

#color-picker { display: flex; gap: 9px; flex-wrap: wrap; }
.color-dot { width: 42px; height: 42px; border-radius: 50%; border: 3px solid #dfe6ec; cursor: pointer; }
.color-dot.sel { border-color: #0b2a52; transform: scale(1.13); box-shadow: 0 0 0 3px #ffd83d; }
.you-name { margin-top: 9px; font-size: 14px; }

.bests-grid, .end-stats { display: flex; justify-content: space-around; text-align: center; }
.best-num { font-size: 24px; font-weight: 900; color: #0b2a52; }
.best-lbl { font-size: 12px; color: #678; }

/* HUD */
.hud { display: flex; gap: 6px; flex-wrap: wrap; flex: 0 0 auto; }
.hud-chip { flex: 1 1 17%; background: #fff; border-radius: 12px; padding: 6px 4px; text-align: center; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.hud-chip span { display: block; font-weight: 900; font-size: 16px; color: #0b2a52; white-space: nowrap; }
.hud-chip label { font-size: 8.5px; font-weight: 700; color: #789; letter-spacing: .3px; }
.hud-chip.terr { background: #ffd83d; }
.hud-chip.terr span { font-size: 21px; }
.hud-chip.stars { background: #a83fd5; cursor: pointer; }
.hud-chip.stars span, .hud-chip.stars label { color: #fff; }

#board-wrap { position: relative; margin-top: 8px; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
#board { display: block; border-radius: 14px; background: #eef6fb; box-shadow: 0 5px 0 rgba(0,0,0,.3); touch-action: none; }
#toast {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(11,42,82,.92); color: #fff; font-weight: 800; font-size: 15px;
  padding: 8px 16px; border-radius: 999px; pointer-events: none; white-space: nowrap; z-index: 5;
}

.game-row { display: flex; gap: 10px; margin-top: 8px; align-items: flex-start; flex: 0 0 auto; }
.lb-card { flex: 1.25; background: #fff; border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.lb-card ol, #final-board { margin-left: 20px; font-size: 14px; line-height: 1.65; }
.lb-card ol { font-size: 12.5px; line-height: 1.45; }
.lb-card li.me, #final-board li.me { font-weight: 900; }
.lb-card li.dead, #final-board li.dead { color: #9aa; text-decoration: line-through; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.controls-card { flex: 1; }
#dpad { text-align: center; background: rgba(255,255,255,.12); padding: 8px; border-radius: 14px; }
.dbtn { width: 46px; height: 46px; font-size: 20px; border: none; border-radius: 12px; background: #fff; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.3); margin: 2px; touch-action: none; }
.controls-card .ghost-btn { padding: 8px 11px; font-size: 15px; margin: 6px 0; }
.dbtn:active { transform: translateY(2px); }
#event-log { color: #bfe0ff; font-size: 12px; margin-top: 6px; line-height: 1.5; min-height: 18px; flex: 0 0 auto; }

/* End screen */
.end-place { text-align: center; font-size: 52px; font-weight: 900; color: #0b2a52; }
#stars-breakdown { margin-left: 18px; font-size: 14.5px; line-height: 1.6; }
.stars-total { font-weight: 900; font-size: 17px; margin-top: 8px; color: #7b1fa2; }

/* Power bar */
#power-bar { display: flex; align-items: center; gap: 7px; margin: 8px 0 2px; }
.power-slot {
  width: 46px; height: 46px; font-size: 21px; border: none; border-radius: 12px;
  background: rgba(255,255,255,.35); color: #fff; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.power-slot.filled { background: #ffd83d; box-shadow: 0 3px 0 #c9a400, 0 0 10px rgba(255,216,61,.8); }
.power-slot:active { transform: translateY(2px); }
#power-status { color: #ffe97a; font-size: 13px; font-weight: 800; }

/* Stars & Skins modal */
.modal { position: fixed; inset: 0; background: rgba(4,20,40,.7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box { background: #fff; border-radius: 18px; padding: 20px; width: 100%; max-width: 420px; position: relative; max-height: 92vh; overflow-y: auto; }
.modal-box h2 { color: #0b2a52; margin-bottom: 8px; }
.modal-close { position: absolute; top: 10px; right: 10px; border: none; background: #eef2f5; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; }
.stars-balance { font-size: 30px; font-weight: 900; color: #7b1fa2; }
.shop-blurb { font-size: 13.5px; color: #456; margin: 2px 0 12px; }
#shop-grid, #upgrade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.skin-item { border: 1.5px solid #e0e7ee; border-radius: 12px; padding: 9px; text-align: center; }
.skin-item.equipped { border-color: #a83fd5; background: #faf0ff; }
.skin-swatch { width: 52px; height: 52px; border-radius: 10px; display: block; margin: 0 auto 6px; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.12); }
.skin-emoji { font-size: 34px; line-height: 52px; height: 52px; }
.skin-name { font-weight: 800; font-size: 14px; color: #0b2a52; }
.skin-desc { font-size: 12px; color: #678; margin-top: 2px; }
.skin-price { font-size: 12.5px; color: #7b1fa2; font-weight: 700; margin: 3px 0 7px; }
.skin-btn { border: none; cursor: pointer; border-radius: 9px; padding: 7px 10px; font-weight: 800; font-size: 13.5px; background: #ffd83d; color: #5b4300; box-shadow: 0 3px 0 #c9a400; width: 100%; }
.skin-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9a400; }
.skin-btn.disabled { background: #cfd6dd; color: #6b7680; box-shadow: 0 3px 0 #9aa4ad; cursor: not-allowed; }
.skin-btn.equip { background: #a83fd5; color: #fff; box-shadow: 0 3px 0 #6d1f96; }
.skin-btn.equip.disabled { background: #cfd6dd; color: #6b7680; box-shadow: 0 3px 0 #9aa4ad; }
.shop-stats { font-size: 12px; color: #789; text-align: center; margin-top: 6px; }
