* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.88), transparent 30%),
    radial-gradient(circle at 12% 18%, rgba(179, 217, 190, .32), transparent 26%),
    linear-gradient(180deg, #edf4e7 0%, #efe7d9 58%, #eadfcf 100%);
  font-family: Arial, sans-serif;
  color: #433225;
  overscroll-behavior: none;
  touch-action: none;
}

.calm-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.leaf,
.wind {
  position: absolute;
  display: block;
  opacity: .62;
}

.leaf {
  width: 24px;
  height: 15px;
  border-radius: 100% 0 100% 0;
  background: linear-gradient(135deg, rgba(91, 149, 81, .78), rgba(199, 177, 91, .58));
  filter: blur(.1px);
  animation: leafFloat 15s linear infinite;
}

.leaf-1 { left: 8%; top: 16%; animation-duration: 16s; }
.leaf-2 { left: 72%; top: 8%; animation-duration: 19s; animation-delay: -9s; transform: scale(.82); }
.leaf-3 { left: 38%; top: 78%; animation-duration: 17s; animation-delay: -15s; transform: scale(1.12); }
.leaf-4 { left: 20%; top: 42%; animation-duration: 14s; animation-delay: -4s; transform: scale(1.2); }
.leaf-5 { left: 88%; top: 34%; animation-duration: 18s; animation-delay: -12s; transform: scale(.92); }
.leaf-6 { left: 58%; top: 62%; animation-duration: 16s; animation-delay: -7s; transform: scale(1.08); }
.leaf-7 { left: 3%; top: 68%; animation-duration: 13s; animation-delay: -10s; transform: scale(.78); }
.leaf-8 { left: 80%; top: 82%; animation-duration: 15s; animation-delay: -2s; transform: scale(1.28); }

.wind {
  width: 220px;
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(109, 145, 141, .34), transparent);
  animation: windDrift 11s ease-in-out infinite;
}

.wind-1 { left: -80px; top: 22%; }
.wind-2 { left: 38%; top: 48%; width: 280px; animation-delay: -6s; }
.wind-3 { left: 12%; top: 74%; width: 190px; animation-delay: -11s; }
.wind-4 { left: 64%; top: 18%; width: 240px; animation-delay: -3s; }
.wind-5 { left: 4%; top: 56%; width: 310px; animation-delay: -8s; }

@keyframes leafFloat {
  0% { transform: translate3d(-30px, 0, 0) rotate(0deg); }
  50% { transform: translate3d(34px, 42px, 0) rotate(88deg); }
  100% { transform: translate3d(78px, 86px, 0) rotate(176deg); }
}

@keyframes windDrift {
  0%, 100% { transform: translateX(-12px); opacity: .12; }
  50% { transform: translateX(34px); opacity: .42; }
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 14px;
}

.layout {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(330px, 620px) 250px;
  gap: 14px;
  align-items: stretch;
}

.mobile-head { display: none; }

.board-shell {
  background: rgba(255, 250, 239, 0.76);
  border: 2px solid rgba(94, 72, 50, 0.14);
  border-radius: 22px;
  padding: 12px;
  box-shadow: 0 18px 60px rgba(76, 52, 29, 0.13);
}

.board-title {
  height: 66px;
  display: flex;
  align-items: center;
  padding: 0 6px 10px;
}

.board-title h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1;
  letter-spacing: -1px;
}

.board-title p {
  margin: 5px 0 0;
  font-size: 14px;
  color: rgba(67, 50, 37, .6);
  font-weight: 700;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 7 / 8.8;
  min-height: 570px;
  overflow: hidden;
  border-radius: 16px;
  border: 4px solid rgba(94, 72, 50, 0.13);
  background:
    radial-gradient(ellipse at 80% 80%, rgba(111, 96, 78, .13), transparent 22%),
    radial-gradient(ellipse at 15% 90%, rgba(111, 96, 78, .12), transparent 18%),
    linear-gradient(#fffdf4, #f7ead4);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.7);
}

.board::before,
.board::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

.board::before {
  width: 22px;
  height: 14px;
  left: 10%;
  top: -28px;
  border-radius: 100% 0 100% 0;
  background: linear-gradient(135deg, rgba(91, 149, 81, .66), rgba(207, 184, 94, .5));
  box-shadow:
    120px 90px 0 -2px rgba(91, 149, 81, .48),
    320px 170px 0 1px rgba(190, 168, 83, .44),
    470px 310px 0 -1px rgba(91, 149, 81, .42),
    210px 430px 0 0 rgba(190, 168, 83, .4);
  animation: boardLeaves 9s linear infinite;
}

.board::after {
  left: -25%;
  right: -25%;
  top: 18%;
  height: 58%;
  background:
    linear-gradient(100deg, transparent 5%, rgba(118, 148, 145, .16) 18%, transparent 32%),
    linear-gradient(100deg, transparent 28%, rgba(118, 148, 145, .12) 42%, transparent 58%),
    linear-gradient(100deg, transparent 58%, rgba(118, 148, 145, .11) 72%, transparent 88%);
  animation: boardWind 7s ease-in-out infinite;
}

.board.screen-shake {
  animation: boardShake 260ms ease-out;
}

@keyframes boardShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  18% { transform: translate3d(-4px, 2px, 0); }
  36% { transform: translate3d(5px, -2px, 0); }
  54% { transform: translate3d(-3px, -1px, 0); }
  72% { transform: translate3d(3px, 1px, 0); }
}

@keyframes boardLeaves {
  0% { transform: translate3d(-30px, -30px, 0) rotate(0deg); opacity: .2; }
  12% { opacity: .72; }
  100% { transform: translate3d(90px, 620px, 0) rotate(210deg); opacity: .12; }
}

@keyframes boardWind {
  0%, 100% { transform: translateX(-20px); opacity: .18; }
  50% { transform: translateX(42px); opacity: .36; }
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.boot-error {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 248, 234, .92);
  color: #5d3a2d;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 900;
  text-align: center;
}

.game-notice {
  position: absolute;
  left: 50%;
  top: 92px;
  z-index: 4;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  color: #4d3726;
  font-size: 14px;
  line-height: 1;
  font-weight: 950;
  box-shadow: 0 8px 24px rgba(76, 52, 29, .12);
  pointer-events: none;
  animation: noticePop 950ms ease both;
}

@keyframes noticePop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.96); }
  16% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(.98); }
}

.warning-line {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 132px;
  border-top: 2px dashed rgba(229, 98, 104, .55);
  pointer-events: none;
}

.warning-line span {
  position: absolute;
  left: 0;
  top: -31px;
  color: rgba(224, 92, 98, .78);
  font-size: 13px;
  font-weight: 900;
}

#aimLine {
  position: absolute;
  top: 24px;
  bottom: 0;
  width: 4px;
  background: rgba(224, 177, 58, 0.92);
  border-radius: 100px;
  transform: translateX(-50%);
  box-shadow: 0 0 14px rgba(224, 177, 58, .45);
  pointer-events: none;
}

#ghostCat {
  position: absolute;
  top: 42px;
  width: 54px;
  height: 54px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  opacity: .82;
  pointer-events: none;
  filter: drop-shadow(0 10px 12px rgba(76, 52, 29, .18));
}

#ghostCatLevel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .72);
  font-size: clamp(13px, 38%, 26px);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 1px 4px rgba(0, 0, 0, .34),
    0 0 1px rgba(67, 50, 37, .7);
  pointer-events: none;
}

#ghostCat img,
#nextPreview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

#ghostCat img {
  transform: rotate(10deg);
}

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

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.score-card,
.panel {
  background: rgba(255, 250, 239, .86);
  border: 2px solid rgba(94, 72, 50, 0.14);
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(76, 52, 29, 0.08);
}

.score-card {
  min-height: 64px;
  text-align: center;
  display: grid;
  place-items: center;
  padding: 7px 3px;
}

.score-card span {
  font-size: 12px;
  color: rgba(67, 50, 37, .62);
  font-weight: 800;
}

.score-card b {
  font-size: 28px;
  line-height: 1;
}

.panel {
  padding: 12px;
}

.panel-title {
  font-weight: 900;
  margin-bottom: 10px;
}

.leaderboard-panel {
  background: rgba(255, 255, 255, .9);
  padding: 12px;
}

.player-summary {
  border: 1px solid rgba(45, 138, 240, .16);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(244, 248, 255, .95), rgba(255,255,255,.92));
  padding: 8px 9px;
  margin-bottom: 9px;
}

.player-name {
  font-weight: 900;
  color: #25415f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  color: rgba(67, 50, 37, .66);
  font-size: 11px;
  font-weight: 800;
}

.leaderboard-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  font-size: 12px;
  font-weight: 800;
}

.leaderboard-row-current {
  border: 1px solid rgba(45, 138, 240, .18);
  border-radius: 10px;
  background: rgba(45, 138, 240, .1);
  padding: 6px 8px;
  color: #25415f;
}

.leaderboard-rank {
  color: rgba(67, 50, 37, .55);
}

.leaderboard-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #1765c8;
  font-size: 12px;
}

.leaderboard-current {
  margin-top: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(45, 138, 240, .1);
  border: 1px solid rgba(45, 138, 240, .18);
  color: #25415f;
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-status {
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 250, 239, .86);
  color: rgba(67, 50, 37, .64);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.next-box {
  height: 116px;
  border-radius: 12px;
  border: 2px dashed rgba(94, 72, 50, .15);
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.5);
}

#nextPreview {
  display: grid;
  place-items: center;
  filter: drop-shadow(0 8px 10px rgba(76, 52, 29, .16));
}

.next-name {
  margin-top: 8px;
  text-align: center;
  color: rgba(67, 50, 37, .7);
  font-weight: 800;
  font-size: 13px;
}

.level-row {
  display: grid;
  grid-template-columns: 24px 1fr 20px;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-weight: 800;
  font-size: 12px;
}

.level-row i {
  width: 20px;
  height: 14px;
  display: inline-block;
  border: 2px dashed var(--c);
  border-radius: 8px;
}

.level-row b {
  text-align: right;
  color: rgba(67, 50, 37, .65);
}

.actions {
  display: grid;
  grid-template-columns: minmax(78px, .8fr) minmax(132px, 1.2fr);
  gap: 9px;
}

button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 10px;
  color: white;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #6fad3d;
  box-shadow: 0 4px 0 rgba(0,0,0,.14);
  max-width: 100%;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,.14);
}

#pauseBtn { background: #65a5de; }
#musicBtn {
  background: #75ad39;
  font-size: 13px;
}

#restartBtn {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #2d8af0, #1765c8);
  box-shadow:
    0 7px 18px rgba(31, 111, 212, .22),
    0 3px 0 rgba(0,0,0,.14);
}

#restartBtn:hover,
#restartBtn:focus-visible {
  filter: brightness(1.06);
  transform: translateY(-1px);
  outline: none;
}

#restartBtn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,.14);
}

.gameover-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.challenge-copy {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .58);
  color: #433225;
}

.challenge-copy strong {
  font-size: 16px;
  line-height: 1.1;
  font-weight: 950;
}

.challenge-copy span {
  font-size: 12px;
  line-height: 1.25;
  font-weight: 800;
  color: rgba(67, 50, 37, .68);
}

.share-score-btn,
.add-chat-btn {
  background: linear-gradient(180deg, #2d8af0, #1765c8);
  box-shadow:
    0 7px 18px rgba(31, 111, 212, .22),
    0 3px 0 rgba(0,0,0,.14);
}

.share-score-btn:hover,
.share-score-btn:focus-visible,
.add-chat-btn:hover,
.add-chat-btn:focus-visible,
.add-chat-link:hover,
.add-chat-link:focus-visible {
  filter: brightness(1.06);
  transform: translateY(-1px);
  outline: none;
}

.share-score-btn:active,
.add-chat-btn:active,
.add-chat-link:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0,0,0,.14);
}

.add-chat-link {
  margin-top: 8px;
  min-height: 0;
  padding: 8px 10px;
  background: transparent;
  color: #1f63b7;
  box-shadow: none;
  font-size: 12px;
}

.chat-card {
  border: 1px solid rgba(48, 105, 188, 0.16);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f4f8ff);
  padding: 12px;
  text-align: left;
  box-shadow:
    0 12px 30px rgba(54, 83, 126, 0.1),
    inset 0 0 0 1px rgba(255,255,255,.82);
}

.chat-title {
  font-size: 16px;
  line-height: 1.08;
  font-weight: 950;
  color: #163e73;
}

.chat-text {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.28;
  color: rgba(35, 55, 83, 0.76);
  font-weight: 700;
}

.add-chat-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px 11px;
  font-size: 13px;
}

.hint {
  background: rgba(255, 250, 239, .64);
  border-left: 4px solid #75ad39;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 800;
  color: rgba(67, 50, 37, .64);
}

.hidden { display: none !important; }

#gameOver {
  position: absolute;
  inset: 0;
  background: rgba(67, 50, 37, .34);
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  z-index: 5;
}

.modal {
  width: min(82%, 330px);
  background: #fff8ea;
  border-radius: 22px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 70px rgba(0,0,0,.25);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 28px;
}

.modal p {
  margin: 7px 0;
  font-size: 18px;
}

.modal .muted {
  color: rgba(67, 50, 37, .65);
}


.ad-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(48, 105, 188, 0.16);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f4f8ff);
  padding: 12px;
  text-align: left;
  box-shadow:
    0 12px 30px rgba(54, 83, 126, 0.12),
    inset 0 0 0 1px rgba(255,255,255,.82);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.ad-card:hover,
.ad-card:focus-visible {
  border-color: rgba(31, 111, 212, .32);
  box-shadow:
    0 14px 34px rgba(54, 83, 126, 0.16),
    inset 0 0 0 1px rgba(255,255,255,.92);
  transform: translateY(-1px);
  outline: none;
}

.ad-card::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto 35%;
  height: 88px;
  background: rgba(72, 143, 230, 0.13);
  filter: blur(24px);
  pointer-events: none;
}

.ad-card > * {
  position: relative;
  z-index: 1;
}

.ad-label {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(42, 113, 209, 0.1);
  color: #1f63b7;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ad-badge {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 22px;
  margin-bottom: 7px;
  padding: 0 8px;
  border-radius: 999px;
  background: #1f6fd4;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: .3px;
}

.ad-title {
  font-size: 17px;
  line-height: 1.05;
  font-weight: 950;
  color: #163e73;
  text-shadow: none;
}

.ad-text {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.28;
  color: rgba(35, 55, 83, 0.76);
  font-weight: 700;
}

.ad-points {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.ad-points span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(31, 111, 212, .08);
  color: #235b9e;
  font-size: 11px;
  line-height: 1;
  font-weight: 850;
}

.ad-points span::before {
  content: "•";
  font-size: 12px;
  line-height: 1;
}

.ad-accent {
  margin-top: 7px;
  color: #1f63b7;
  font-size: 12px;
  line-height: 1.15;
  font-weight: 950;
}

.ad-button {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: linear-gradient(180deg, #2d8af0, #1765c8);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
  text-decoration: none;
  box-shadow:
    0 7px 18px rgba(31, 111, 212, .22),
    0 2px 0 rgba(0,0,0,.12);
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
}

.ad-button:hover,
.ad-button:focus-visible {
  filter: brightness(1.06);
  transform: translateY(-1px);
  outline: none;
}

.ad-sidebar {
  min-height: 112px;
  display: grid;
  align-content: center;
}

.ad-gameover {
  margin: 12px 0 14px;
  min-height: 0;
  display: grid;
  align-content: center;
  text-align: center;
}

@media (max-width: 760px) {
  html,
  body {
    overflow-x: hidden;
  }

  .leaf,
  .wind {
    opacity: .42;
  }

  .page {
    display: block;
    width: 100%;
    padding: 8px;
  }

  .mobile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
  }

  .logo {
    font-size: 25px;
    line-height: 1;
    font-weight: 950;
  }

  .tagline {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(67, 50, 37, .62);
    font-weight: 800;
  }

  .head-score {
    width: 74px;
    height: 58px;
    border-radius: 14px;
    background: rgba(255,250,239,.86);
    border: 2px solid rgba(94, 72, 50, 0.14);
    text-align: center;
    display: grid;
    place-items: center;
  }

  .head-score span {
    font-size: 11px;
    opacity: .64;
    font-weight: 900;
  }

  .head-score b {
    font-size: 24px;
    line-height: 1;
  }

  .layout {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .board-shell {
    padding: 7px;
    border-radius: 16px;
  }

  .board-title {
    display: none;
  }

  .board {
    width: 100%;
    min-height: 310px;
    height: min(64svh, calc((100vw - 30px) * 1.25));
    max-height: calc(100svh - 206px);
    aspect-ratio: auto;
    border-width: 3px;
    border-radius: 14px;
  }

  .side {
    margin-top: 8px;
    gap: 8px;
  }

  .score-grid,
  .next,
  .levels,
  .hint {
    display: none;
  }

  .leaderboard-panel {
    padding: 10px;
  }

  .leaderboard-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 10px;
  }

  .leaderboard-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    font-size: 11px;
  }

  .actions {
    grid-template-columns: minmax(68px, .75fr) minmax(124px, 1.25fr);
    padding: 7px;
    gap: 7px;
  }

  #musicBtn {
    font-size: 12px;
  }

  button {
    min-height: 46px;
    font-size: 12px;
    padding: 10px 7px;
    border-radius: 10px;
  }

  .warning-line {
    top: 112px;
  }

  .warning-line span {
    font-size: 11px;
  }


  .ad-sidebar {
    min-height: 72px;
    padding: 9px 10px;
    margin-top: 8px;
  }

  .chat-card {
    padding: 10px;
  }

  .chat-title {
    font-size: 14px;
  }

  .chat-text {
    font-size: 11px;
  }

  .add-chat-btn {
    min-height: 42px;
    font-size: 12px;
  }

  .ad-sidebar .ad-title {
    font-size: 13px;
  }

  .ad-sidebar .ad-text {
    font-size: 11px;
  }

  .modal {
    width: min(92vw, 360px);
    max-height: calc(100svh - 18px);
    overflow: auto;
    padding: 14px;
    border-radius: 18px;
  }

  .modal h2 {
    font-size: 24px;
  }

  .modal p {
    font-size: 16px;
  }

  .challenge-copy {
    margin: 10px 0;
    padding: 9px 10px;
  }

  .challenge-copy strong {
    font-size: 15px;
  }

  .challenge-copy span {
    font-size: 11px;
  }

  .ad-gameover {
    min-height: 0;
    margin: 10px 0 12px;
    padding: 10px 11px;
  }

  .ad-gameover .ad-title {
    font-size: 14px;
  }

  .ad-gameover .ad-text {
    font-size: 11px;
  }

  .ad-button {
    padding: 9px 10px;
    font-size: 12px;
  }

}

@media (max-width: 380px) {
  .page {
    padding: 6px;
  }

  .board {
    min-height: 290px;
    height: min(60svh, calc((100vw - 26px) * 1.22));
    max-height: calc(100svh - 198px);
  }

  .logo {
    font-size: 22px;
  }

  .tagline {
    display: none;
  }

  .head-score {
    height: 52px;
  }

  button {
    min-height: 44px;
    font-size: 11px;
    padding-inline: 5px;
  }

  #musicBtn {
    font-size: 11px;
  }
}

/* ===== TG MOBILE UI FIX V1 ===== */
body.is-telegram .page {
  padding: 8px;
}

body.is-telegram .mobile-head,
body.is-telegram .board-title {
  margin-bottom: 8px;
}

body.is-telegram .logo,
body.is-telegram .board-title h1 {
  font-size: 28px !important;
  line-height: 1.05;
}

body.is-telegram .tagline,
body.is-telegram .board-title p {
  font-size: 12px !important;
  line-height: 1.2;
}

body.is-telegram .head-score,
body.is-telegram .score-card {
  min-width: 86px;
  padding: 8px 10px !important;
  border-radius: 18px !important;
}

body.is-telegram .head-score span,
body.is-telegram .score-card span {
  font-size: 11px !important;
}

body.is-telegram .head-score b,
body.is-telegram .score-card b {
  font-size: 18px !important;
}

body.is-telegram .board-shell,
body.is-telegram .board {
  border-radius: 18px !important;
}

body.is-telegram .board {
  min-height: 66vh !important;
}

body.is-telegram .side {
  gap: 10px !important;
  margin-top: 10px !important;
}

body.is-telegram .panel,
body.is-telegram .ad-card,
body.is-telegram .hint,
body.is-telegram .leaderboard,
body.is-telegram .leaderboard-panel,
body.is-telegram .score-grid {
  padding: 12px !important;
  border-radius: 16px !important;
}

body.is-telegram .panel-title,
body.is-telegram .leaderboard-title {
  font-size: 15px !important;
  margin-bottom: 8px !important;
}

body.is-telegram .actions {
  gap: 8px !important;
}

body.is-telegram .actions button,
body.is-telegram button {
  min-height: 46px;
  font-size: 16px !important;
  border-radius: 16px !important;
}

/* Красную линию выше */
body.is-telegram .warning-line {
  top: 13% !important;
}

body.is-telegram .warning-line span {
  font-size: 12px !important;
  padding: 0 6px !important;
}

/* Вертикальная линия — желтая и полупрозрачная вниз */
body.is-telegram #aimLine {
  width: 4px !important;
  border-radius: 999px !important;
  background: linear-gradient(
    180deg,
    rgba(220, 178, 52, 0.98) 0%,
    rgba(220, 178, 52, 0.92) 45%,
    rgba(220, 178, 52, 0.70) 75%,
    rgba(220, 178, 52, 0.24) 100%
  ) !important;
  box-shadow: 0 0 10px rgba(220, 178, 52, 0.20) !important;
}

/* Модалка конца игры компактнее */
body.is-telegram .modal {
  padding: 16px !important;
  border-radius: 18px !important;
}

body.is-telegram .modal h2 {
  font-size: 22px !important;
  line-height: 1.1;
}

body.is-telegram .modal p {
  font-size: 15px !important;
}

/* Ещё компактнее на узких экранах */
@media (max-width: 768px) {
  .page {
    padding: 8px !important;
  }

  .logo,
  .board-title h1 {
    font-size: 26px !important;
  }

  .tagline,
  .board-title p {
    font-size: 12px !important;
  }

  .head-score,
  .score-card {
    min-width: 82px !important;
    padding: 8px 10px !important;
  }

  .head-score b,
  .score-card b {
    font-size: 17px !important;
  }

  .board {
    min-height: 64vh !important;
  }

  .warning-line {
    top: 12.5% !important;
  }

  .warning-line span {
    font-size: 11px !important;
  }

  #aimLine {
    width: 4px !important;
  }

  .panel,
  .ad-card,
  .hint,
  .leaderboard,
  .leaderboard-panel {
    padding: 10px !important;
  }

  .actions button,
  button {
    min-height: 44px !important;
    font-size: 15px !important;
  }
}

/* ===== TG SCROLL FIX V1 ===== */
html,
body {
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

body.is-telegram {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

body.is-telegram .page {
  min-height: auto !important;
  height: auto !important;
  overflow: visible !important;
  padding-bottom: 130px !important;
}

body.is-telegram .layout {
  min-height: auto !important;
  height: auto !important;
  overflow: visible !important;
}

body.is-telegram .board-shell,
body.is-telegram .board,
body.is-telegram .side {
  overflow: visible !important;
}

body.is-telegram canvas {
  touch-action: manipulation !important;
}

body.is-telegram .side {
  display: flex !important;
  flex-direction: column !important;
  padding-bottom: 130px !important;
}

/* На мобилке поле чуть компактнее, чтобы рейтинг и баннеры были ближе */
@media (max-width: 768px) {
  body.is-telegram .board {
    min-height: 58vh !important;
  }

  body.is-telegram .page {
    padding-bottom: 150px !important;
  }

  body.is-telegram .side {
    padding-bottom: 150px !important;
  }
}

/* ===== TG HARD SCROLL FIX V2 ===== */
html {
  height: auto !important;
  min-height: 100% !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: auto !important;
}

body {
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

body.is-telegram,
body.is-telegram .page,
body.is-telegram .layout,
body.is-telegram main,
body.is-telegram .board-shell,
body.is-telegram .side {
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  position: relative !important;
}

body.is-telegram .page {
  display: block !important;
  padding-bottom: 180px !important;
}

body.is-telegram .layout {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

body.is-telegram .board {
  min-height: 52vh !important;
  max-height: none !important;
  overflow: hidden !important;
  touch-action: pan-y !important;
}

body.is-telegram canvas,
body.is-telegram #game {
  touch-action: pan-y !important;
}

body.is-telegram .side {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  padding-bottom: 180px !important;
}

/* Чтобы нижние кнопки и баннеры не прятались под панелью iPhone/Telegram */
body.is-telegram .actions,
body.is-telegram .ad-card,
body.is-telegram .hint,
body.is-telegram .leaderboard,
body.is-telegram .leaderboard-panel {
  flex-shrink: 0 !important;
}

/* На мобильном делаем поле ниже, чтобы был реальный скролл */
@media (max-width: 768px) {
  body.is-telegram .board {
    min-height: 50vh !important;
  }

  body.is-telegram .page {
    padding-bottom: 220px !important;
  }

  body.is-telegram .side {
    padding-bottom: 220px !important;
  }
}
