/* 실제 보이는 높이를 우선 배분한 뒤, 부족할 때 전체 내용을 비례 축소한다. */
:root { --view-height: 100dvh; --view-width: 100vw; --view-top: 0px; --view-left: 0px; }
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
.shell {
  position: fixed; top: var(--view-top); left: var(--view-left);
  width: var(--view-width); height: var(--view-height); max-width: none;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: flex; justify-content: center; align-items: flex-start; overflow: clip;
}
.screen { flex: none; width: 100%; min-width: 0; margin: 0; transform: scale(var(--screen-fit, 1)); transform-origin: top center; }
#start-screen { max-width: 920px; }
.result-screen { max-width: 960px; }
.admin-screen { max-width: 490px; padding-top: 16px; }
.brand { height: clamp(56px, 10dvh, 100px); }
.brand h1, .play-header strong { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.brand-icon { flex-shrink: 0; }
.start-layout { margin-top: clamp(10px, 3dvh, 30px); gap: clamp(10px, 2.5dvh, 22px); }
.play-screen { max-width: 490px; --quiz-font: clamp(21px, 5.8vw, 25px); }
.play-header { height: auto; min-height: 42px; padding: 4px 0 8px; gap: 4px 10px; }
.play-header > span { max-width: 100%; }
.game-card { min-width: 0; padding: clamp(10px, 2dvh, 20px); }
.game-card > * { min-width: 0; max-width: 100%; }
.stats { margin-bottom: 10px; gap: 5px; }
.stats > div { min-width: 0; gap: 5px; }
.stats strong { font-size: clamp(20px, 3.3dvh, 27px); }
.question-top { margin: 12px 0 8px; gap: 8px; }
.clue { min-height: 0; width: 100%; font-size: var(--quiz-font); line-height: 1.4; letter-spacing: -.4px; word-break: normal; overflow-wrap: anywhere; }
.answer-slots { min-height: 34px; margin: 8px 0 10px; gap: 3px; }
.answer-slot { height: 34px; font-size: var(--quiz-font); flex: 0 1 34px; }
.hint-button { padding: 7px 9px; }
.feedback { min-height: 14px; margin: 4px 0 6px; }
.board {
  width: min(100%, var(--board-size, 250px)); aspect-ratio: 1; margin-inline: auto;
  grid-template-rows: repeat(5, minmax(0, 1fr)); gap: clamp(4px, 1.5vw, 8px);
}
.tile { aspect-ratio: auto; min-height: 0; width: 100%; height: 100%; font-size: var(--quiz-font); line-height: 1; }
.game-controls { margin-top: 7px; gap: 12px; }
.ranking { table-layout: fixed; }
.ranking td, .ranking th { overflow-wrap: anywhere; }
.ranking td:last-child { white-space: normal; }
.ranking td:nth-child(3) { max-width: none; }
dialog {
  position: fixed; top: calc(var(--view-top) + var(--view-height) / 2); left: calc(var(--view-left) + var(--view-width) / 2);
  margin: 0; width: min(390px, calc(var(--view-width) - 24px)); max-width: none; max-height: none; overflow: visible;
  transform: translate(-50%, -50%) scale(var(--dialog-fit, 1)); transform-origin: center;
}
@media (max-height: 600px) {
  .entry-card { padding: 16px; }
  .entry-card h2 { margin-bottom: 12px; }
  .howto h2 { margin-bottom: 6px; }
  .howto li { margin-bottom: 4px; }
  .course-prompt { margin-top: 14px; }
  .field input { padding-block: 10px; }
  .game-card { padding: 10px; }
  .play-header { min-height: 32px; }
  .question-top { margin-top: 8px; }
  .stats { margin-bottom: 7px; }
}
