* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #2b8fd6 0%, #6cc6ef 45%, #dfe3f2 100%);
  font-family: Nunito, system-ui, sans-serif;
  color: #263052;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #e4e6f2;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */
.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
  background: linear-gradient(180deg, #1fa9d6, #4cc3e6);
}

.round {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(180deg, #4fa3ff, #2a6fe0);
  box-shadow: 0 4px 0 #1b4fa8, inset 0 2px 0 rgba(255, 255, 255, 0.35);
  color: #fff;
  font: 900 20px Nunito, sans-serif;
  cursor: pointer;
}

.round:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #1b4fa8;
}

.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.lvl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(20, 60, 120, 0.55);
}

.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #ff4d5e;
  text-shadow: none;
}

.coins {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1px 10px 1px 4px;
  border-radius: 12px;
  background: rgba(10, 40, 90, 0.35);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}

.coin-ico {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3a6, #ffc21a 55%, #d98a00);
  box-shadow: inset 0 0 0 2px #e9a300;
}

/* ---------- Stage ---------- */
#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

#toast {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 9px 18px;
  border-radius: 20px;
  background: rgba(25, 30, 60, 0.85);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---------- Boosters ---------- */
.boosters {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-around;
  gap: 10px;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  background: #e4e6f2;
}

.booster {
  position: relative;
  flex: 1 1 0;
  max-width: 120px;
  height: 66px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(180deg, #6cc2ff, #3a8ff0);
  box-shadow: 0 5px 0 #2364c2, inset 0 2px 0 rgba(255, 255, 255, 0.4);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: Nunito, sans-serif;
}

.booster:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #2364c2;
}

.booster.active {
  background: linear-gradient(180deg, #ffd96a, #f2a51e);
  box-shadow: 0 5px 0 #b56f00, 0 0 18px rgba(255, 200, 60, 0.9);
}

.b-ico {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.2));
}

.b-name {
  font-weight: 900;
  font-size: 14px;
  text-shadow: 0 1px 0 rgba(0, 40, 100, 0.5);
}

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #ff3d4f;
  border: 2px solid #fff;
  font-weight: 900;
  font-size: 12px;
  line-height: 18px;
}

.badge.plus {
  background: #3fc24b;
  font-size: 16px;
}

/* ---------- Modal ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 20, 45, 0.55);
  animation: fade 0.2s;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}

.modal-card {
  width: 100%;
  max-width: 320px;
  max-height: 90%;
  overflow: auto;
  padding: 18px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff8e6, #ffe9b8);
  border: 4px solid #f2b632;
  box-shadow: 0 10px 0 #c98a12, 0 20px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: pop 0.22s ease-out;
}

.modal-card.wide {
  max-width: 400px;
}

.modal-icon {
  font-size: 42px;
  line-height: 1.1;
}

.modal-title {
  margin: 4px 0 6px;
  font-weight: 900;
  font-size: 22px;
  color: #7a4a00;
}

.modal-body {
  font-weight: 700;
  font-size: 15px;
  color: #6a5320;
  margin-bottom: 12px;
}

.modal-body .price {
  margin-top: 8px;
  color: #8a5a00;
}

.reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 22px;
  font-weight: 900;
  color: #b37400;
}

.reward .coin-ico {
  width: 22px;
  height: 22px;
}

.help {
  text-align: left;
  padding-left: 18px;
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

.help li {
  margin-bottom: 6px;
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mbtn {
  border: none;
  border-radius: 14px;
  padding: 11px 14px;
  font: 900 16px Nunito, sans-serif;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #8e97ad, #6b738a);
  box-shadow: 0 4px 0 #4c536a;
}

.mbtn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #4c536a;
}

.mbtn.green {
  background: linear-gradient(180deg, #5fe06a, #2fb43c);
  box-shadow: 0 4px 0 #1e7f29;
}

.mbtn.blue {
  background: linear-gradient(180deg, #5fb0ff, #2f7ce8);
  box-shadow: 0 4px 0 #1d55a8;
}

.mbtn.gold {
  background: linear-gradient(180deg, #ffd96a, #f2a51e);
  box-shadow: 0 4px 0 #b56f00;
}

.mbtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.levels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  padding: 4px;
}

.lv {
  aspect-ratio: 1;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #5fb0ff, #2f7ce8);
  box-shadow: 0 3px 0 #1d55a8;
  color: #fff;
  font: 900 16px Nunito, sans-serif;
  cursor: pointer;
}

.lv.next {
  background: linear-gradient(180deg, #5fe06a, #2fb43c);
  box-shadow: 0 3px 0 #1e7f29;
}

.lv.cur {
  outline: 3px solid #f2b632;
}
