/* Board-first projection; canvas coordinates and gameplay remain unchanged. */
.ball-page .ball-hero { padding: 8px 0 10px; }
.ball-page .ball-hero .teacher-kicker { display: none; }
.ball-page .ball-hero h1 { margin: 0; font-size: 28px; line-height: 1.15; }
.ball-page .ball-scoreboard { gap: 12px; }
.ball-page .ball-card {
  width: min(100%, 720px);
  margin-inline: auto;
}
.ball-page .ball-hero { width: min(100%, 720px); margin-inline: auto; }
.ball-page .ball-stage {
  width: 100%;
  aspect-ratio: 720 / 880;
  min-height: 0;
}
.ball-page .ball-stage canvas {
  width: 100%; height: auto; max-height: none; aspect-ratio: 720 / 880;
}
.ball-page .arcade-sound-bar { min-height: 44px; padding: 4px 12px; gap: 8px; }
.ball-page .arcade-sound-bar > span { margin-right: auto; }
.ball-page .ball-info-strip { padding: 6px 8px; gap: 6px; grid-template-columns: minmax(0,.8fr) minmax(0,1.5fr) minmax(0,.55fr); }
.ball-page .ball-info-strip > span { min-width: 0; padding: 4px 6px; border-radius: 4px; }
.ball-page .ball-info-strip .ball-score-hud,
.ball-page .ball-info-strip .ball-next-hud { min-width: 0 !important; }
.ball-page .ball-next-copy { min-width: 0; }
.ball-page .ball-info-strip b { overflow-wrap: anywhere; }
.ball-page .ball-info-strip b { font-size: 16px; }
.ball-page .ball-info-strip small { font-size: 11px; letter-spacing: 0; }
.ball-page .ball-next-copy b { font-size: 13px; }
.ball-page .ball-next-preview { width: 28px; height: 28px; flex-basis: 28px; }
.ball-page .arcade-touch { flex-wrap: nowrap; padding: 6px 10px; gap: 8px; }
.ball-page .arcade-touch button,
.ball-page .ball-dialog #startGame,
.ball-page .ball-dialog #retryGame {
  min-height: 48px; min-width: 48px; border: 1px solid #244e43;
  border-radius: 6px; padding: 0 16px;
  background: #244e43; color: #fff;
  font: 800 16px/1.3 var(--tg-font, GomgomKkalkkeum, "Noto Sans KR", system-ui, sans-serif);
  box-shadow: inset 0 -3px 0 #16382e;
  transform: none;
}
.ball-page .arcade-touch button { flex: 1 1 64px; max-width: 96px; }
.ball-page .arcade-touch #dropButton { flex: 2 1 152px; max-width: 200px; }
.ball-page .arcade-touch #dropButton,
.ball-page .ball-dialog #startGame { background: #a94924; border-color: #a94924; box-shadow: inset 0 -3px 0 #783218; }
.ball-page .arcade-touch button:active,
.ball-page .ball-dialog #startGame:active,
.ball-page .ball-dialog #retryGame:active { transform: none; box-shadow: inset 0 2px 0 #16382e; }
.ball-page .arcade-touch button:focus-visible,
.ball-page .ball-dialog #startGame:focus-visible,
.ball-page .ball-dialog #retryGame:focus-visible { outline: 3px solid #2876d2; outline-offset: 2px; }
.ball-page .arcade-touch button:disabled { background: #69766f; border-color: #69766f; box-shadow: none; opacity: 1; cursor: default; }
.ball-page .ball-dialog { padding: 16px; border-radius: 8px; }
.ball-page .ball-dialog p { color: #52615d; }
.ball-page .score-submit { flex-wrap: wrap; gap: 8px; }
.ball-page .score-submit input { min-width: 0; flex: 1 1 120px; }
.ball-page .score-submit button { flex: 1 1 120px; }
.ball-page .ball-dialog-mark { width: 44px; height: 44px; margin-bottom: 10px; font-size: 24px; border-width: 3px; }
.ball-page .ball-dialog h2 { font-size: 26px; margin-bottom: 12px; }
.ball-page .arcade-status { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.ball-page .rank-button,
.ball-page .arcade-sound-bar button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 12px; border: 1px solid #c9d9d1;
  border-radius: 6px; background: transparent; color: #244e43;
  font-weight: 700; line-height: 1.3; text-decoration: none; box-shadow: none;
}
.ball-page .rank-button:hover,
.ball-page .arcade-sound-bar button:hover { background: #e6ede7; }
.ball-page .rank-button:focus-visible,
.ball-page .arcade-sound-bar button:focus-visible,
.ball-page .score-submit button:focus-visible { outline: 3px solid #2876d2; outline-offset: 2px; }
.ball-page .score-submit button {
  min-height: 44px; padding: 8px 12px; border: 1px solid #244e43;
  border-radius: 6px; background: #fffdf7; color: #244e43;
  font-size: 15px; line-height: 1.3; box-shadow: none;
}
.ball-page .score-submit button:hover { background: #e6ede7; }
/* A stopped board no longer dictates the result's height or scroll origin. */
.ball-page .ball-card:has(#gameResult:not([hidden])) { display: block; width: min(100%, 460px); }
.ball-page .ball-card:has(#gameResult:not([hidden])) .ball-info-strip,
.ball-page .ball-card:has(#gameResult:not([hidden])) #controls,
.ball-page .ball-card:has(#gameResult:not([hidden])) #gameStatus,
.ball-page .ball-stage:has(#gameResult:not([hidden])) canvas { display: none; }
.ball-page .ball-stage:has(#gameResult:not([hidden])) {
  display: block; width: 100%; min-height: 0; aspect-ratio: auto; background: transparent;
}
.ball-page #gameResult {
  position: relative; inset: auto; display: block; padding: 12px;
  background: transparent; overflow: visible;
}
.ball-page #gameResult[hidden] { display: none; }
.ball-page #gameResult .ball-dialog {
  width: 100%; max-height: none; overflow: visible; padding: 16px;
  border: 1px solid #c9d9d1; background: #fffdf7;
}
.ball-page #gameResult .teacher-kicker { font-size: 12px; line-height: 1.4; }
.ball-page #gameResult .final-score { margin: 4px 0 8px; font-size: 40px; line-height: 1.2; }
.ball-page #gameResult p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }
.ball-page #gameResult .score-submit { display: flex; flex-wrap: nowrap; }
.ball-page #gameResult .score-submit input { flex: 1 1 120px; min-height: 44px; }
.ball-page #gameResult .score-submit button { flex: 0 0 auto; }
.ball-page #gameResult .arcade-record-note { margin: 6px 0 12px; min-height: 21px; }
.ball-page #gameResult #retryGame { width: 100%; }
@media (max-width: 720px) {
  .ball-page .ball-hero h1 { font-size: 24px; }
  .ball-page .ball-scoreboard { display: none; }
  .ball-page .ball-info-strip { grid-template-columns: minmax(78px,.9fr) minmax(0,1.3fr) minmax(56px,.6fr); }
  .ball-page .ball-info-strip > span { min-width: 0; }
  .ball-page .ball-score-hud { min-width: 0 !important; }
}

/* The playing surface owns its HUD and controls within the viewport. */
.ball-page.ball-playing { overflow: hidden; }
.ball-page.ball-playing .gg-site-strip,
.ball-page.ball-playing .teacher-topbar,
.ball-page.ball-playing .ball-hero,
.ball-page.ball-playing .records-section { display: none; }
.ball-page.ball-playing main.teacher-shell { width: 100%; max-width: none; padding: 0; margin: 0; }
.ball-page.ball-playing .ball-card {
  position: fixed; inset: 0; z-index: 50; width: 100%; max-width: none; height: 100dvh; margin: 0; padding: 0;
  border: 0; border-radius: 0; display: grid;
  grid-template-columns: minmax(0,1fr);
  grid-template-rows: auto auto minmax(0,1fr) auto auto;
  background: #0f302c;
}
.ball-page.ball-playing .arcade-sound-bar { grid-row: 1; grid-column: 1; background: #f4f3ee; }
.ball-page.ball-playing .ball-info-strip { grid-row: 2; grid-column: 1; width: 100%; max-width: 720px; }
.ball-page.ball-playing .ball-stage {
  grid-row: 3; grid-column: 1; width: 100%; height: 100%; aspect-ratio: auto;
  display: flex; justify-content: center; align-items: center; overflow: hidden; container-type: size;
}
.ball-page.ball-playing .ball-stage canvas {
  width: min(100%, calc(100cqh * 720 / 880)); height: auto; max-width: 100%; max-height: 100%;
  object-fit: contain; aspect-ratio: 720 / 880;
}
.ball-page.ball-playing #controls { grid-row: 4; grid-column: 1; margin: 0; background: #f4f3ee; justify-content: center; }
.ball-page.ball-playing #gameStatus { grid-row: 5; grid-column: 1; margin: 0; background: #f4f3ee; text-align: center; }

.ball-page.ball-playing .teacher-game-layout { transform: none !important; width: 100%; max-width: none; margin: 0; position: static; display: block; }
.ball-page.ball-playing .teacher-game-layout > :not(.teacher-game-card) { display: none; }

.ball-page.ball-playing .teacher-topbar { display: flex; position: fixed; z-index: 51; top: 6px; left: 8px; width: 44px; height: 44px; margin: 0; padding: 0; background: transparent; border: 0; }
.ball-page.ball-playing .teacher-topbar > :not(.teacher-brand),
.ball-page.ball-playing .teacher-brand > span:last-child { display: none; }
.ball-page.ball-playing .teacher-topbar .teacher-brand { min-width: 44px; min-height: 44px; display: flex; justify-content: center; }
.ball-page.ball-playing .arcade-sound-bar { padding-left: 60px; }
.ball-page.ball-playing .arcade-sound-bar > span { display: none; }
