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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #05060f;
  font-family: "Segoe UI", Arial, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

#game { display: block; touch-action: none; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top));
  left: 104px; right: 8px;
  display: flex; gap: 8px; justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.chip {
  background: rgba(10, 14, 42, .78);
  border: 2px solid #ffd34d;
  color: #ffd34d;
  border-radius: 22px;
  padding: 6px 14px;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: .5px;
  box-shadow: 0 3px 10px rgba(0,0,0,.5), inset 0 0 12px rgba(255,211,77,.12);
  white-space: nowrap;
}
.chip b { color: #fff; }
#coinChip.bump { animation: bump .3s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }

#bossBar {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  width: 70%;
  height: 20px;
  background: rgba(0,0,0,.6);
  border: 2px solid #ff4b3e;
  border-radius: 12px;
  overflow: hidden;
  z-index: 5;
}
#bossFill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff4b3e, #ff9a3c);
  transition: width .15s;
}
#bossLabel {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: #fff;
  letter-spacing: 1px; text-shadow: 0 1px 2px #000;
}

.cornerBtns {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top));
  left: 8px;
  display: flex; gap: 8px;
  z-index: 8;
}
.roundBtn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255,211,77,.7);
  background: rgba(10,14,42,.8);
  color: #ffd34d;
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Abilities ---------- */
#abilBar {
  position: absolute;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  z-index: 6;
}
#energyWrap {
  width: 110px; height: 16px;
  background: rgba(0,0,0,.55);
  border: 2px solid #35e0ff;
  border-radius: 10px;
  overflow: hidden;
}
#energyFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #1f8fff, #35e0ff);
  transition: width .2s;
}
.abBtn {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 3px solid #ffd34d;
  background: radial-gradient(circle at 35% 30%, #3a3f7a, #171a3d);
  font-size: 26px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 14px rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.abImg {
  width: 46px; height: 44px;
  object-fit: contain;
  pointer-events: none;
  /* светлая тарелочка под коричневой какашкой — чтобы не растворялась на тёмной кнопке */
  background: radial-gradient(circle at 50% 46%, #fff7e2 0%, #ffe9b0 55%, rgba(255,233,176,0) 76%);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,233,176,.4), 0 0 12px rgba(255,233,176,.3);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)) saturate(1.15) brightness(1.05);
}
.abBtn:active { transform: scale(.92); }
.abBtn.poor { border-color: #555a7a; opacity: .55; }
.abCost {
  position: absolute;
  bottom: -4px; right: -6px;
  background: #0a0e2a;
  color: #35e0ff;
  border: 1.5px solid #35e0ff;
  font-size: 11px; font-weight: 900;
  padding: 1px 6px;
  border-radius: 10px;
}

/* ---------- Banner / tip ---------- */
#banner {
  position: absolute;
  top: 34%; left: 0; right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 7;
}
#bannerText {
  display: inline-block;
  font-size: 44px;
  font-weight: 900;
  color: #ffd34d;
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(255,120,40,.9), 0 4px 0 #7a2c00, 0 7px 18px rgba(0,0,0,.7);
  animation: bannerIn 1.9s ease forwards;
}
#bannerText.danger {
  color: #ff4b3e;
  text-shadow: 0 0 22px rgba(255,40,20,.9), 0 4px 0 #4d0000, 0 7px 18px rgba(0,0,0,.7);
}
@keyframes bannerIn {
  0% { transform: scale(.3); opacity: 0; }
  18% { transform: scale(1.15); opacity: 1; }
  30% { transform: scale(1); }
  78% { opacity: 1; }
  100% { transform: scale(1.06); opacity: 0; }
}
#tip {
  position: absolute;
  top: 140px; left: 0; right: 0;
  text-align: center;
  color: #fff;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: 1px;
  text-shadow: 0 0 14px rgba(255,60,20,.8), 0 3px 8px #000;
  pointer-events: none;
  z-index: 6;
  animation: tipPulse 1.2s infinite;
}
@keyframes tipPulse { 50% { opacity: .35; } }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0;
  background: rgba(4, 6, 20, .72);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
.panel {
  background: linear-gradient(160deg, #1c2148, #12152e 70%);
  border: 3px solid #ffd34d;
  border-radius: 22px;
  padding: 22px 18px;
  width: min(86vw, 360px);
  max-height: 86vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 14px 50px rgba(0,0,0,.8);
  color: #fff;
}

.gameTitle {
  font-size: 42px; font-weight: 900; line-height: 1.02;
  color: #ffd34d;
  text-shadow: 0 0 20px rgba(255,140,40,.55), 0 4px 0 #7a2c00;
  letter-spacing: 1px;
}
.gameSub {
  margin-top: 4px;
  color: #9fb0ff;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
  font-size: 12px;
}
.menuArt { margin: 8px 0 2px; }
.menuArt img, .goRooster img { width: 130px; filter: drop-shadow(0 8px 16px rgba(255,40,20,.35)); }
.goRooster img { width: 100px; }
.menuArt img { animation: strut 1.4s ease-in-out infinite; }
@keyframes strut {
  0%, 100% { transform: rotate(-3deg) translateY(0); }
  50% { transform: rotate(3deg) translateY(-6px); }
}
.hint {
  margin: 10px 0 16px;
  font-size: 14px;
  color: #c9d2ff;
  line-height: 1.45;
}
.hint b { color: #ffd34d; }
.bestLine { margin-top: 12px; color: #9fb0ff; font-size: 13px; font-weight: 700; }

.bigBtn {
  width: 100%;
  padding: 14px 10px;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #3a1500;
  background: linear-gradient(180deg, #ffd34d, #ff9a3c);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 0 #b45a10, 0 10px 24px rgba(0,0,0,.5);
  transition: transform .06s;
}
.bigBtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b45a10; }
.midBtn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  font-size: 15px;
  font-weight: 800;
  color: #c9d2ff;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(159,176,255,.4);
  border-radius: 12px;
  cursor: pointer;
}

/* ---------- Shop ---------- */
.shopPanel h2 { color: #ffd34d; letter-spacing: 2px; margin-bottom: 4px; }
.shopCoins { font-size: 20px; font-weight: 900; margin-bottom: 12px; }
.shopCoins b { color: #ffd34d; }
.upg {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(159,176,255,.25);
  border-radius: 14px;
  padding: 9px 10px;
  margin-bottom: 8px;
  text-align: left;
}
.upg .ico { font-size: 24px; }
.upg .icoImg { width: 32px; height: 36px; object-fit: contain; display: block; }
.upg .info { flex: 1; min-width: 0; }
.upg .name { font-weight: 900; font-size: 14px; color: #fff; }
.upg .desc { font-size: 11.5px; color: #9fb0ff; margin-top: 2px; }
.upg .lvl { color: #35e0ff; font-weight: 800; font-size: 11px; }
.upgBtn {
  padding: 8px 10px;
  min-width: 76px;
  font-weight: 900;
  font-size: 13px;
  color: #3a1500;
  background: linear-gradient(180deg, #ffd34d, #ffb03c);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 3px 0 #b45a10;
}
.upgBtn:disabled {
  background: #2a2f55; color: #7a81b0;
  box-shadow: none; cursor: not-allowed;
}
.upgBtn.maxed { background: linear-gradient(180deg, #59e08d, #2fae62); color: #04361c; box-shadow: 0 3px 0 #1b7a42; }

/* ---------- Game over ---------- */
.goTitle {
  font-size: 30px; font-weight: 900;
  color: #ff4b3e;
  text-shadow: 0 0 18px rgba(255,40,20,.6), 0 3px 0 #4d0000;
  margin-bottom: 8px;
}
.goStats { margin: 10px 0 6px; font-size: 16px; line-height: 1.6; color: #c9d2ff; }
.goStats b { color: #ffd34d; font-size: 22px; }
.goQuote {
  margin: 4px 0 14px;
  color: #ffd34d;
  font-style: italic;
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

/* ---------- Пропуск в крепость ---------- */
.gateOverlay { z-index: 30; }
.gatePanel {
  padding: 14px 16px;
  scrollbar-width: none;
}
.gatePanel::-webkit-scrollbar { display: none; }
.gateShield {
  font-size: 50px;
  line-height: 1;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 18px rgba(255,211,77,.45));
  animation: shieldFloat 2.6s ease-in-out infinite;
}
@keyframes shieldFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}
.gateTitle {
  font-size: 17px; font-weight: 900;
  color: #ffd34d;
  text-shadow: 0 0 16px rgba(255,140,40,.5), 0 3px 0 #7a2c00;
  letter-spacing: 1px;
  line-height: 1.2;
}
.gateSub {
  color: #9fb0ff; font-size: 10.5px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  margin: 2px 0 10px;
}
.gateInput {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,.07);
  border: 2px solid rgba(159,176,255,.4);
  border-radius: 12px;
  outline: none;
  text-align: center;
}
.gateInput:focus { border-color: #ffd34d; }
.gateErr {
  color: #ff6b5e;
  font-weight: 800;
  font-size: 12px;
  margin: -2px 0 8px;
  animation: gateShake .4s;
}
@keyframes gateShake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}
.gateHint {
  margin-top: 6px;
  color: #9fb0ff;
  font-size: 11px;
  font-weight: 700;
}
.gateBoard {
  margin-top: 10px;
  background: rgba(255,255,255,.05);
  border: 1.5px solid rgba(255,211,77,.35);
  border-radius: 14px;
  padding: 8px;
}
.gateBoardTitle {
  color: #ffd34d;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 6px;
  line-height: 1.3;
}
.boardRow {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  padding: 4px 2px;
  font-weight: 900;
}
.boardRow .rk { width: 24px; font-weight: 900; font-size: 15px; text-align: center; }
.boardRow .info { flex: 1; min-width: 0; }
.boardRow .nm { font-size: 14px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.boardRow .st { font-size: 10px; font-weight: 800; opacity: .85; letter-spacing: .3px; }
.boardEmpty { color: #7a81b0; font-size: 12px; padding: 4px 0; }
.gateDisclaimer {
  margin-top: 8px;
  color: #6a739e;
  font-size: 10px;
  line-height: 1.45;
}
