:root {
  --ball-ink: #173b35;
  --ball-board: #0f302c;
  --ball-board-light: #1c5046;
  --ball-paper: #f4f3ee;
  --ball-coral: #ed7e6e;
  --ball-mint: #bce8d1;
}

.ball-page {
  overflow-x: hidden;
}

.ball-page .arcade-overlay { overflow-y: auto; }
.ball-page .ball-dialog { max-height: min(100%, calc(100svh - 24px)); overflow-y: auto; }
.ball-page .score-submit { flex-wrap: wrap; }
.ball-page .score-submit input { min-width: 0; flex: 1 1 120px; }
.ball-page .record-tabs { flex-wrap: wrap; }

.ball-brand-mark {
  color: var(--ball-mint) !important;
  background: var(--ball-ink) !important;
  font-size: 23px;
  line-height: 1;
}

.ball-scoreboard {
  gap: 18px;
}

.ball-scoreboard span {
  min-width: 58px;
  text-align: right;
}

.ball-scoreboard b {
  font-variant-numeric: tabular-nums;
}

.ball-hero {
  padding-bottom: 28px;
}

.ball-hero h1 {
  color: var(--ball-ink);
  font-size: clamp(48px, 8vw, 92px);
}

.ball-card {
  border-color: #c9d9d1;
  background: var(--ball-paper);
}

.ball-card::before {
  display: none !important;
}

.ball-stage {
  width: min(100%, 720px);
  margin-inline: auto;
  aspect-ratio: 720 / 880;
  min-height: 0;
  background: var(--ball-board);
}

.ball-stage canvas {
  width: min(100%, 720px);
  height: auto;
  max-height: calc(100svh - 150px);
  aspect-ratio: 720 / 880;
  cursor: crosshair;
}

.ball-info-strip {
  position: relative;
  z-index: 3;
  width: min(100%, 720px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(112px, .8fr) minmax(170px, 1.5fr) minmax(72px, .55fr);
  align-items: stretch;
  gap: 8px;
  padding: 12px 14px;
  background: var(--ball-board);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.ball-info-strip > span {
  min-width: 72px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
  background: rgba(9, 30, 27, .8);
  color: #fff;
  text-align: right;
}

.ball-info-strip b {
  display: block;
  font-size: 19px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.ball-score-hud {
  min-width: 92px !important;
  text-align: left !important;
}

.ball-score-hud em {
  display: block;
  margin-top: 3px;
  color: #ffd28d;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: .01em;
  white-space: nowrap;
}

@keyframes ball-score-pop {
  0% { transform: scale(1); color: #ffd28d; }
  35% { transform: scale(1.16); color: #fff3b0; }
  100% { transform: scale(1); color: #ffd28d; }
}

.ball-score-hud em.score-pop {
  transform-origin: left center;
  animation: ball-score-pop .42s ease-out;
}

.ball-next-hud {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 134px !important;
  text-align: left !important;
}

.ball-next-preview {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  overflow: hidden;
}

.ball-next-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ball-next-copy {
  display: block;
  min-width: 0;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.ball-next-copy b {
  font-size: 14px;
  white-space: nowrap;
}

.ball-info-strip small {
  display: block;
  margin-top: 3px;
  color: #c5ded4;
  font-size: 9px;
  letter-spacing: .06em;
}

.ball-danger-hud b {
  color: var(--ball-mint);
  font-size: 14px;
}

.ball-danger-hud.is-danger b {
  color: #ffc49b;
}

.ball-dialog {
  max-width: 360px;
  border-color: #c5ded4;
  box-shadow: 0 18px 50px rgba(9, 30, 27, .2);
}

.ball-dialog h2 {
  color: var(--ball-ink);
  font-size: 36px;
  letter-spacing: -.06em;
}

.ball-test-note {
  margin: -8px 0 18px;
  color: #a65a43;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
}

.ball-dialog-mark {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  margin: 0 auto 18px;
  border: 5px solid var(--ball-ink);
  border-radius: 50%;
  color: #f4cf76;
  background: #ef866f;
  font-size: 34px;
  line-height: 1;
  box-shadow: inset 12px 10px 0 rgba(255,255,255,.2);
}

.ball-dialog .final-score {
  color: var(--ball-ink);
}

.ball-dialog .retry-button {
  margin-top: 8px;
  background: var(--ball-ink);
  color: #fff;
}

.ball-best-note {
  min-height: 20px;
  margin: 0;
  color: var(--tg-muted);
  font-size: 13px;
}

.ball-page .arcade-touch {
  border-color: #c9d9d1;
  background: #f9faf6;
}

.ball-page .arcade-touch button {
  min-width: 64px;
  border-radius: 12px;
}

.ball-page .arcade-touch .accent {
  min-width: 170px;
  background: var(--ball-coral);
}

.ball-page .arcade-status {
  min-height: 44px;
  border-color: #c9d9d1;
  background: #f9faf6;
  color: var(--ball-ink);
  font-weight: 800;
}

@media (max-width: 720px) {
  .ball-scoreboard {
    justify-content: space-between;
    gap: 8px;
  }

  .ball-scoreboard span {
    min-width: 0;
    text-align: left;
  }

  .ball-hero {
    padding-top: 30px;
    padding-bottom: 20px;
  }

  .ball-hero h1 {
    margin-top: 8px;
    font-size: clamp(44px, 16vw, 70px);
  }

  .ball-stage canvas {
    max-height: calc(100svh - 205px);
  }

  .ball-info-strip {
    width: 100%;
    grid-template-columns: minmax(84px, .9fr) minmax(0, 1.35fr) minmax(62px, .65fr);
    gap: 6px;
    padding: 8px;
  }

  .ball-info-strip > span {
    min-width: 62px;
    padding: 5px 6px;
  }

  .ball-info-strip b {
    font-size: 16px;
  }

  .ball-score-hud {
    min-width: 75px !important;
  }

  .ball-score-hud em {
    font-size: 10px;
  }

  .ball-next-hud {
    min-width: 0 !important;
    gap: 5px;
  }

  .ball-next-preview {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .ball-next-copy b {
    font-size: 12px;
  }

  .ball-page .arcade-touch .accent {
    min-width: 0;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .ball-dialog { padding: 16px; }
  .ball-dialog p { margin-bottom: 8px; }
  .ball-dialog .final-score { font-size: 32px; }
  .ball-dialog .score-submit { margin-top: 8px; }

  .ball-stage canvas {
    width: min(100%, calc(100svh - 72px));
    max-height: calc(100svh - 72px);
  }

  .ball-page .arcade-touch {
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ball-stage canvas { cursor: default; }
}
