/* Shared finishing layer for the five hub surfaces and their game boards. */
:root {
  --ui-paper: #f3efe4;
  --ui-surface: #fffdf7;
  --ui-forest: #234b3d;
  --ui-ink: #203b2c;
  --ui-muted: #455b47;
  --ui-border: #b7c5ac;
  --ui-gold: #f3d17b;
  --ui-radius: 16px;
  --ui-shadow: 0 2px 0 #bdc9ae, 0 7px 18px #34462c0b;
}

/* The same action hierarchy applies in every hub and every game. */
.button, .library-type, .pack-families a, .game-heading .play-tools>summary {
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-ink);
  box-shadow: none;
  font-weight: 600;
}
.button.primary, .library-type.selected, .pack-families a[aria-current] {
  background: var(--ui-forest);
  color: #fffef7;
  border-color: var(--ui-forest);
}
.button.primary:hover { background: #315f49; border-color: #315f49; }
.button:disabled, .button.primary:disabled { background: #e3e5de; color: #586153; border-color: #969e91; }
.button, .library-type, .pack-families a, .game-heading .play-tools>summary {
  min-height: 44px;
}
.game-heading #use-boost {
  background: #f8e7b7;
  color: #49370f;
  border: 1px solid #a58235;
  box-shadow: none;
  border-radius: 12px;
}
.game-heading .play-tools>summary { letter-spacing: 0; }
.game-play { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow); }
.game-play:has(.journey-complete) { background: transparent; border: 0; box-shadow: none; }
.play-tools>div { border-radius: 14px; }

/* Hub cards use one paper and border system; color belongs to gameplay and badges. */
.daily-stop, .library-card, .pack-card, .mission-card, .badge-keep,
.pack-quickstart, .pack-intro, .passport-focus, .compact-resume {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
}
.daily-stop, .library-card, .pack-card, .mission-card, .badge-keep {
  background: var(--ui-surface);
}
.daily-stops .up-next .daily-stop { border-color: #647f60; box-shadow: inset 3px 0 var(--ui-forest), var(--ui-shadow); }
.daily-stops .collected .daily-stop { background: #eef3e6; }
.daily-edition, .passport-cover { background: var(--ui-forest); border-color: #294d3b; box-shadow: none; }
.daily-edition .begin-journey { background: #fffdf7; color: var(--ui-forest); border-color: #fffdf7; }
.daily-edition .begin-journey:hover { background: #e8eedf; border-color: #e8eedf; }
.library-card .card-picture { border-bottom: 1px solid #d7dfce; }
.library-card h2, .pack-card h2 { line-height: 1.17; }
.library-action, .pack-card strong { color: var(--ui-forest); }
.library-type.selected span { color: inherit; }

/* Challenge packs keep their illustrated badges, without a competing color wash. */
.pack-quickstart { background: #eef2e7; }
.pack-intro { background: #eef2e7; }
.pack-card .pack-scene {
  background: #eef2e7;
  border-right: 1px solid #d7dfce;
}
.pack-card .pack-scene>span { background: transparent; color: var(--ui-muted); border: 0; }
.pack-card progress { accent-color: var(--ui-forest); }
.passport-focus { background: var(--ui-surface); }
.passport-focus>p, .focus-heading>span { color: var(--ui-muted); }
.focus-meter progress { accent-color: var(--ui-forest); }

/* Common Ground borrows the tactile key treatment used by Sudoku and Crossword. */
body[data-view=groups] .game-heading { display: flex; align-items: center; gap: 12px; }
body[data-view=groups] .game-heading h1 { flex: 1; min-width: 0; }
body[data-view=groups] .game-play { max-width: 660px; margin-inline: auto; }
.groups-board { max-width: 560px; }
.group-tiles { gap: 7px; margin: 10px 0 14px; }
.group-tile {
  min-height: 64px;
  padding: 6px 4px;
  border: 1px solid #8b9c7d;
  border-radius: 10px;
  background: linear-gradient(#fffefa, #e9efdf);
  color: var(--ui-ink);
  box-shadow: inset 0 1px 0 #fff, 0 2px 0 #bdc9ae;
  font: 650 clamp(15px, 3.8vw, 18px)/1.2 var(--font);
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.group-tile:hover:not(:disabled):not(.selected) { background: #e3ebda; }
.group-tile.selected { background: var(--ui-forest); color: white; border-color: #152f24; box-shadow: inset 0 0 0 2px #b6caa9; }
.group-tile.selected:hover { background: var(--ui-forest); color: white; }
.group-tile:focus-visible { outline: 3px solid #9b4500; outline-offset: 2px; }
.solved-group { border: 1px solid #b6c7a9; border-radius: 12px; padding: 13px 10px; color: var(--ui-ink); }
.solved-group span { font-size: 16px; }
.group-1 { background: #e5eedb; }
.group-2 { background: #e4edf1; }
.group-3 { background: #f0e9dc; }
.groups-board #group-submit { min-height: 46px; min-width: 170px; }

/* Status is readable in text and outline, with gold reserved for hints/selection. */
.game-heading, .game-play, .groups-board { color: var(--ui-ink); }
.status:not(:empty) { border-radius: 10px; }
.group-tile.selected, .search-cell.selected, .sudoku-cell.selected, .cross-cell.selected { font-weight: 700; }

@media (max-width: 759px) {
  body.in-puzzle-journey[data-view] main { padding-bottom: 12px; }
  /* Catalogues can scroll; their labels should remain readable. */
  .library-type, .library-refine>summary { font-size: 15px; }
  .library-type span, .library-count { font-size: 14px; }
  .library-card .card-picture { width: 92px; height: auto; min-height: 120px; flex-direction: column; gap: 6px; justify-content: center; }
  .library-card { grid-template-columns: 92px minmax(0, 1fr); }
  .library-card .library-card-copy { padding: 12px; }
  .library-card h2 { font-size: 21px; line-height: 1.18; }
  .library-kind, .library-detail, .library-action { font-size: 15px; line-height: 1.35; }
  .library-card .library-pace { font-size: 13px; }
  .library-card .card-picture svg { width: 69px; height: 69px; }
  .library-card .library-pace { position: static; align-self: center; margin: 0; }

  .pack-families a { font-size: 15px; }
  .pack-grid { grid-template-columns: 1fr; gap: 12px; }
  .pack-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); }
  .pack-card .pack-scene { min-height: 120px; padding: 10px 6px; gap: 6px; }
  .pack-card .pack-scene .garden-badge { width: 61px; height: 68px; }
  .pack-card .pack-scene>span { font-size: 13px; line-height: 1.3; padding: 0; }
  .pack-card>div:last-child { padding: 12px; }
  .pack-card h2 { font-size: 22px; min-height: 0; }
  .pack-card .pack-game-types { margin: 8px 0; }
  .pack-card strong { font-size: 15px; }
  .pack-quickstart { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 8px 12px; padding: 14px; }
  .pack-quickstart>.garden-badge { width: 48px; height: 53px; }
  .pack-quickstart .eyebrow { display: block; font-size: 13px; }
  .pack-quickstart p:not(.eyebrow) { font-size: 15px; }
  .pack-quickstart strong { font-size: 22px; }
  .pack-quickstart .button { grid-column: 1/-1; font-size: 16px; margin: 0; }
  .pack-quickstart .button:after { content: none; }
  .pack-intro-copy p, .pack-intro-action p { font-size: 16px; }
  .pack-intro-action .button { font-size: 16px; }

  .passport-compact-identity>span, .passport-compact .passport-cover-stats { font-size: 14px; }
  .passport-focus>p, .focus-heading>span { font-size: 16px; }
  .passport-focus .button { font-size: 16px; }
  .badge-keep strong { font-size: 17px; }
  .badge-keep span { font-size: 14px; }

  body[data-view=groups] main { padding: 5px 10px calc(76px + env(safe-area-inset-bottom)); }
  body[data-view=groups] .game-top, body[data-view=groups] .subtitle,
  body[data-view=groups] .side-note, body[data-view=groups] .board-caption { display: none; }
  body[data-view=groups] .game-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 3px 0;
    padding: 4px 6px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: var(--ui-surface);
    box-shadow: 0 4px 12px #213d2e24;
  }
  body[data-view=groups] .game-heading h1 { grid-column: 1; min-width: 0; font-size: clamp(18px, 5vw, 22px); }
  body[data-view=groups] .game-heading #use-boost { grid-column: 2; margin: 0; }
  body[data-view=groups] .game-heading .play-tools { grid-column: 3; margin: 0; }
  body[data-view=groups] .game-heading .play-tools>summary { min-width: 66px; padding: 5px; }
  body[data-view=groups] .game-play { padding: 8px 7px; box-shadow: none; }
  body[data-view=groups] .group-tiles { gap: 5px; margin: 7px 0 10px; }
  body[data-view=groups] .group-tile { min-height: 57px; font-size: clamp(14px, 3.7vw, 17px); padding: 4px 2px; }
  body[data-view=groups] .group-tile.long-word { font-size: clamp(12px, 3vw, 14px); font-weight: 600; letter-spacing: -.04em; }
  body[data-view=groups] .groups-board #group-submit { width: 100%; }
  body[data-view=cross] .game-heading h1 { overflow-wrap: anywhere; }
}

@media (max-width: 359px) {
  .group-tile { font-size: 14px; }
  .pack-card { grid-template-columns: 88px minmax(0, 1fr); }
  #mobile-navigation { gap: 4px; padding-left: 6px; padding-right: 6px; }
  #mobile-navigation a { gap: 3px; }
  #mobile-navigation a span { white-space: nowrap; overflow-wrap: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .group-tile { transition: none; }
}

/* Short instructions stay in a dismissible layer, without reflowing a puzzle. */
.play-help-dialog { width: min(420px, calc(100vw - 32px)); max-height: calc(100svh - 32px); padding: 22px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-ink); }
.play-help-dialog::backdrop { background: #203b2c66; }
.play-help-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.play-help-heading h2 { font: 28px/1.2 var(--serif); margin: 0; }
.play-help-heading .plain { min-width: 44px; min-height: 44px; padding: 8px; font-size: 20px; }
.play-help-dialog ol { margin: 18px 0 22px; padding-left: 24px; }
.play-help-dialog li { font-size: 17px; line-height: 1.45; padding-left: 4px; margin: 10px 0; }
.play-help-dialog .keep-playing { width: 100%; }
.boost-intro-seen { visibility: hidden; }
.group-tiles { min-height: 277px; align-content: start; }

@media (max-width: 759px) {
  body.in-puzzle-journey .game-heading { border: 0; border-radius: 0; background: transparent; box-shadow: none; position: relative; }
  body.in-puzzle-journey .game-play { border: 0; box-shadow: none; }
  body.in-puzzle-journey .status { display: block; min-height: 56px; margin: 8px 0 0; padding: 8px 12px; font-size: 15px; line-height: 1.35; }
  body.in-puzzle-journey .status:empty { visibility: hidden; }
  body.puzzle-finished .status { display: none; }
  body[data-view=sudoku] .sudoku-grid { max-width: min(100%, max(280px, calc(100svh - 430px))); }
  body[data-view=cross].cross-touch-keyboard:not(.puzzle-finished) .play-layout { height: calc(100svh - 215px - env(safe-area-inset-bottom)); min-height: 340px; }
  body.cross-touch-keyboard .cross-pan-note { display: block; font-size: 14px; line-height: 1.3; text-align: center; margin: 3px 0; }
  .cross-pan-note[hidden] { display: none !important; }
  .play-tools>div { max-height: min(70svh, calc(100svh - 140px)); overflow: auto; overscroll-behavior: contain; }
  .play-tools .all-clues { margin: 0; }
  .play-tools .all-clues>summary { min-height: 44px; font-size: 17px; }
  body[data-view=groups] .group-tiles { min-height: 243px; }
  body[data-view=search] .board-wrap>.word-list { scrollbar-width: none; touch-action: pan-x; }
  body[data-view=search] .word-list::-webkit-scrollbar { display: none; }
  .word-bank-swipe { margin: 0 0 5px; font-size: 13px; line-height: 1.3; text-align: center; color: var(--ui-muted); }
  .word-bank-swipe[hidden] { display: none; }
}
.passport-guidance { margin: 16px 0; }
.passport-guidance .button { font-size: 16px; }
.passport-tour { width: min(420px, calc(100vw - 32px)); max-height: calc(100svh - 32px); padding: 22px; box-sizing: border-box; color: var(--ui-ink); background: var(--ui-paper); border: 1px solid var(--ui-border); border-radius: 20px; }
.passport-tour::backdrop { background: #173e30a8; }
.passport-tour-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.passport-tour-heading .eyebrow { margin: 0; }
.passport-tour-heading button { width: 44px; min-height: 44px; flex: none; }
.passport-tour-count { font-size: 14px; color: var(--ui-muted); margin: 12px 0 6px; }
.passport-tour h2 { font-size: 28px; line-height: 1.15; margin: 0 0 12px; }
.passport-tour-copy { font-size: 17px; line-height: 1.45; margin: 0 0 12px; }
.passport-tour-link { display: inline-block; font-size: 16px; min-height: 44px; padding-block: 10px; }
.passport-tour-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.passport-tour-controls .button { min-height: 48px; font-size: 16px; }
.passport-tour-dismiss { display: block; min-height: 44px; margin: 10px auto 0; font-size: 16px; }
.completion-passport-guide { max-width: 420px; margin: 18px auto 0; font-size: 15px; line-height: 1.4; color: var(--ui-muted); }
.completion-passport-guide .plain { min-height: 44px; font-size: 15px; text-decoration: underline; }
@media (max-width: 759px) and (max-height: 700px) {
  /* Keep long jumble clues readable while saving space around, not inside, controls. */
  body[data-view=scramble] .scramble-wrap { padding-block: 4px !important; margin-block: 4px; }
  body[data-view=scramble] .scramble-wrap .scramble-clue { margin-block: 4px; }
  body[data-view=scramble] .scramble-wrap .scramble-letters { margin-block: 6px; }
  body:is([data-view=search],[data-view=sudoku]) .play-instruction { display: none; }
  body.in-puzzle-journey:not(.review-game-ads)[data-view=search] .search-grid { max-width: min(100%, max(250px, calc(100svh - 360px))) !important; }
  body[data-view=search] .search-cell { font-size: 19px; }
  body[data-view=maze] .maze-viewport { height: min(360px, max(185px, calc(100svh - 380px))); }
}
