/* Only the twelve .game-page routes load this stylesheet.
   Reserve space for navigation, title and controls; the board uses
   the remaining small-viewport height. Additional copy stays in normal flow. */
.game-page {
  --game-note-space: 0px;
  --game-board-size: clamp(160px, calc(100svh - 384px - var(--game-note-space)), 480px);
}
.game-page:has(#rating-note:not(:empty)) { --game-note-space: 40px; }

.game-page .container {
  width: min(1120px, calc(100% - 24px));
}

.game-page .site-header {
  height: 64px;
  min-height: 64px;
  padding: 0 24px;
  gap: 18px;
}

.game-page .site-header .brand { font-size: 24px; gap: 10px; }
.game-page .site-header .logo-mark { width: 30px; height: 30px; }
.game-page .site-header nav { gap: 20px; font-size: 12px; }
.game-page .header-actions { gap: 16px; }
.game-page .site-header .account-link { padding: 7px 12px; font-size: 11px; }

.game-page .page-intro {
  padding-top: 10px;
  padding-bottom: 8px;
  gap: 20px;
}

.game-page .intro-eyebrow {
  margin-bottom: 4px;
  font-size: 8px;
  line-height: 1.2;
}

.game-page .page-intro h1 {
  margin: 0;
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.8px;
}

.game-page .game-container {
  display: flex;
  flex-direction: column;
}

.game-page .game-container > * { order: 5; }
.game-page .game-container > .game-area { order: 0; }
.game-page .game-container > .online-game-bar { order: 1; }
.game-page .game-container > .game-intro-copy { order: 2; }
.game-page .game-container > .info-banner { order: 3; }

.game-page .game-area {
  grid-template-columns: minmax(0, var(--game-board-size)) minmax(240px, 300px);
  align-items: start;
  gap: 28px;
  padding: 10px 16px;
}

.game-page .game-main {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-inline: auto;
  container-type: inline-size;
}

.game-page .game-topline {
  order: 0;
  min-height: 24px;
  margin-bottom: 6px;
  gap: 8px;
  font-size: 10px;
  line-height: 1.2;
}

.game-page .timer-wrap { gap: 5px; }
.game-page .icon-button { margin-left: 3px; }

.game-page .level-tabs {
  order: 1;
  min-height: 32px;
  margin-bottom: 8px;
  padding: 3px;
  gap: 3px;
}

.game-page .level-tabs button {
  min-height: 26px;
  padding: 3px 1px;
  font-size: 11px;
  line-height: 1.2;
}

.game-page .board-frame {
  order: 2;
  width: min(100%, var(--game-board-size));
  margin-inline: auto;
  container-type: inline-size;
}

.game-page .cell { font-size: clamp(15px, 6cqi, 28px); }
.game-page .cell .notes-grid { font-size: clamp(6px, 2cqi, 10px); }

.game-page .number-pad {
  order: 3;
  margin-top: 8px;
  gap: 4px;
}

.game-page .number-pad button {
  min-height: 40px;
  padding: 3px 0;
  font-size: 22px;
  line-height: 1;
}

.game-page .number-pad small { height: 9px; font-size: 7px; line-height: 9px; }

.game-page .game-tools {
  order: 4;
  margin-top: 6px;
  padding-bottom: 6px;
  gap: 4px;
}

.game-page .game-tools button {
  flex: 1;
  flex-direction: row;
  justify-content: center;
  min-width: 0;
  min-height: 40px;
  padding: 3px 2px;
  gap: 4px;
  font-size: 11px;
  line-height: 1.2;
}

.game-page .game-tools button svg { width: 18px; height: 18px; }
.game-page .game-tools button small {
  position: static;
  padding: 1px 2px;
  font-size: 7px;
  line-height: 1.2;
}

.game-page .game-bottom {
  order: 5;
  align-items: center;
  min-height: 24px;
  margin-top: 6px;
  gap: 8px;
  font-size: 9px;
  line-height: 1.25;
}

.game-page .game-bottom > span { min-width: 0; }
.game-page .game-bottom .text-link { flex-shrink: 0; font-size: 10px; white-space: nowrap; }

.game-page .game-message {
  order: 6;
  min-height: 16px;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
}

.game-page #rating-note {
  order: 7;
  font-size: 10px;
  line-height: 1.5;
}

.game-page #rating-note:empty { margin: 0; }

.game-page .online-game-bar {
  display: flex;
  flex-wrap: wrap;
  min-height: 0;
  margin: 12px 0;
  padding: 12px 16px;
  gap: 10px 16px;
}

.game-page .online-game-bar p { flex: 1 1 320px; font-size: 12px; line-height: 1.55; }
.game-page .online-game-bar .button {
  flex: 0 1 auto;
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  font-size: 11px;
  white-space: normal;
}

.game-page .game-intro-copy {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.game-page .game-sidebar { padding-top: 0; }
.game-page .game-area > .online-game-bar { order: 1; grid-column: 1 / -1; grid-row: 2; }
.game-page .game-area > .game-sidebar { grid-column: 2; grid-row: 1; }
.game-page .game-sidebar .daily-card { padding: 24px; }
.game-page .game-sidebar .tip-card { margin-top: 20px; }

/* In a shorter/narrower window, flatten only this presentation wrapper.
   The account/competition actions then follow the controls before the cards. */
@media (max-width: 1100px), (max-height: 800px) {
  .game-page { --game-board-size: clamp(160px, calc(100svh - 384px - var(--game-note-space)), 480px); }
  .game-page .game-area { display: contents; }
  .game-page .game-main {
    order: 0;
    width: min(100%, calc(var(--game-board-size) + 22px));
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 6px 28px #163c3210;
  }
  .game-page .game-sidebar {
    order: 4;
    width: min(100%, 720px);
    margin: 16px auto 0;
    padding: 0;
    border: 0;
  }
}

@media (max-width: 800px) {
  .game-page .site-header {
    height: auto;
    min-height: 78px;
    padding: 8px 12px 0;
    gap: 6px 12px;
    flex-wrap: wrap;
  }
  .game-page .site-header .brand { font-size: 23px; }
  .game-page .site-header .logo-mark { width: 29px; height: 29px; }
  .game-page .site-header nav {
    order: 3;
    width: 100%;
    height: 30px;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
  }
  .game-page .site-header nav a { padding-bottom: 4px; }
  .game-page .header-actions { margin-left: auto; gap: 10px; }
  .game-page .page-intro { padding: 8px 0; }
  .game-page .page-intro h1 { font-size: 25px; line-height: 1.08; }
  .game-page .game-main { width: min(100%, 500px); }
  .game-page .online-game-bar p { flex-basis: 100%; }
  .game-page .online-game-bar .button { flex: 1 1 140px; }
}

@media (max-width: 620px) {
  .game-page .game-main { padding: 8px; }
  .game-page .game-topline { min-height: 22px; margin-bottom: 4px; }
  .game-page .level-tabs { min-height: 30px; margin-bottom: 6px; }
  .game-page .level-tabs button { min-height: 24px; font-size: 10px; }
  .game-page .game-tools { margin-top: 4px; padding-bottom: 4px; }
  .game-page .game-tools button { flex-direction: column; gap: 2px; padding: 2px 0; font-size: 11px; }
  .game-page .game-tools button small { position: absolute; top: 0; right: 0; }
  .game-page .game-bottom { min-height: 26px; margin-top: 4px; }
  .game-page .game-sidebar .daily-card { margin-top: 0; }
}

@media (max-width: 620px) and (max-height: 680px) {
  .game-page { --game-board-size: clamp(160px, calc(100svh - 352px - var(--game-note-space)), 320px); }
  .game-page:has(#rating-note:not(:empty)) { --game-note-space: 20px; }
  .game-page .game-main { padding: 6px; }
  .game-page .site-header { min-height: 68px; padding-top: 6px; row-gap: 4px; }
  .game-page .site-header .brand { font-size: 21px; line-height: 1.2; }
  .game-page .site-header .logo-mark { width: 26px; height: 26px; }
  .game-page .site-header nav { height: 28px; }
  .game-page .page-intro { padding: 6px 0; }
  .game-page .page-intro h1 { font-size: 21px; line-height: 1.05; letter-spacing: -0.5px; }
  .game-page .intro-eyebrow { margin-bottom: 3px; font-size: 7px; }
  .game-page .number-pad { margin-top: 6px; }
  .game-page .game-tools { margin-top: 3px; padding-bottom: 3px; }
  .game-page .game-bottom { margin-top: 3px; }
  .game-page .game-message { margin-top: 6px; }
}

/* Short landscape: a square board beside the same controls, with all text
   and feedback continuing underneath rather than being clipped. */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 480px) {
  .game-page { --game-board-size: clamp(140px, calc(100svh - 126px), 280px); }
  .game-page .page-intro { padding: 5px 0; }
  .game-page .page-intro h1 { font-size: 22px; line-height: 1.05; }
  .game-page .intro-eyebrow { margin-bottom: 2px; font-size: 7px; }
  .game-page .game-main {
    display: grid;
    grid-template-columns: minmax(0, var(--game-board-size)) minmax(0, 1fr);
    grid-template-areas: "board topline" "board levels" "board numbers" "board tools" "board bottom" "board message" "board rating";
    align-items: start;
    width: min(100%, 760px);
    padding: 8px;
    column-gap: 12px;
    row-gap: 4px;
  }
  .game-page .board-frame { grid-area: board; width: 100%; margin: 0; }
  .game-page .game-topline { grid-area: topline; min-height: 22px; margin: 0; }
  .game-page .level-tabs { grid-area: levels; min-height: 28px; margin: 0; padding: 2px; }
  .game-page .level-tabs button { min-height: 24px; font-size: 10px; }
  .game-page .number-pad { grid-area: numbers; margin: 0; gap: 3px; }
  .game-page .number-pad button { min-height: 34px; padding: 2px 0; font-size: 18px; }
  .game-page .game-tools { grid-area: tools; margin: 0; padding-bottom: 2px; }
  .game-page .game-tools button { min-height: 36px; font-size: 10px; }
  .game-page .game-bottom { grid-area: bottom; min-height: 22px; margin: 0; font-size: 8px; }
  .game-page .game-message { grid-area: message; margin-top: 4px; }
  .game-page #rating-note { grid-area: rating; }
}

/* The hint stays in the page: its target and evidence remain visible on the
   board. It never opens the blurred, blocking notice dialog. */
.game-page .hint-panel {
  order: 4;
  grid-column: 1 / -1;
  margin: 8px 0 4px;
  padding: 12px;
  border: 1px solid #a9813c;
  border-radius: 8px;
  background: #fffbef;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.55;
}
.game-page .hint-panel[hidden] { display: none; }
.game-page .hint-panel h3 { margin: 0 0 5px; font-size: 16px; line-height: 1.3; }
.game-page .hint-panel p { margin: 5px 0; }
.game-page .hint-panel .hint-technique { color: #6a4b16; font-weight: 700; }
.game-page .hint-actions { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; }
.game-page .hint-actions button { min-height: 44px; padding: 8px 10px; font-size: 12px; }
.game-page .hint-dismiss { background: transparent; color: var(--green); text-decoration: underline; border: 0; cursor: pointer; }
.game-page .cell.hint-evidence { background: #f8f0dc; }
.game-page .cell.hint-target { background: #f7df9c; box-shadow: inset 0 0 0 3px #815d16; }

/* This switch changes only presentation; it never replaces a saved puzzle. */
.game-page .game-topline { flex-wrap: wrap; }
.game-page .game-view-toggle {
  min-height: 28px;
  margin: 0;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  color: var(--green);
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  cursor: pointer;
}
.game-page .game-view-toggle:focus-visible,
.game-page .hint-actions button:focus-visible { outline: 3px solid #a9813c; outline-offset: 2px; }
.game-page .game-view-toggle[aria-pressed="true"] { border-color: var(--green); background: #e7f0e7; }
.game-page:has(#game[data-view="comfortable"]) { --game-board-size: 480px; }
.game-page #game[data-view="comfortable"] .game-main {
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
}
.game-page #game[data-view="comfortable"] .board-frame { width: min(100%, 480px); margin-inline: auto; }
.game-page #game[data-view="comfortable"] .cell { font-size: clamp(18px, 6cqi, 32px); }
.game-page #game[data-view="comfortable"] .cell .notes-grid { font-size: clamp(7px, 2cqi, 11px); }
.game-page #game[data-view="comfortable"] .level-tabs button,
.game-page #game[data-view="comfortable"] .number-pad button,
.game-page #game[data-view="comfortable"] .game-tools button,
.game-page #game[data-view="comfortable"] .game-view-toggle { min-height: 44px; }
.game-page #game[data-view="comfortable"] .number-pad button { font-size: 24px; }
.game-page #game[data-view="comfortable"] .game-tools button { font-size: 12px; padding: 5px 2px; }
.game-page #game[data-view="comfortable"] .game-topline { font-size: 11px; }
.game-page #game[data-view="comfortable"] .game-view-toggle { font-size: 11px; padding: 5px 8px; }
@media (max-width: 620px) {
  .game-page #game[data-view="comfortable"] .number-pad { display: grid; grid-template-columns: repeat(5, minmax(44px, 1fr)); }
}
