/* Shared game-screen chrome (BBG#152): one glass header bar on every game page, matching the
   Arcade Tiles home (#150). Loaded after theme.css and before each game's styles.css. */

body.game-page {
  /* The bar is one row (~60px), not the old two-row .header-row, so it needs far less clearance. */
  padding-top: calc(max(68px, 60px + env(safe-area-inset-top)));
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.game-icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.game-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 60px;
  padding: 0.4rem max(0.5rem, calc((100vw - 920px) / 2));
  padding-top: max(0.4rem, env(safe-area-inset-top));
  color: var(--text);
  background: rgba(var(--panel-rgb), 0.85);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

[data-theme="arcade"] .game-bar {
  color: #fdf6e3;
  background: rgba(4, 16, 10, 0.72);
  border-bottom-color: rgba(255, 215, 106, 0.22);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

.game-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  box-shadow: none;
  cursor: pointer;
}

.game-bar-back {
  width: 44px;
  height: 44px;
  min-height: 44px;
}

.game-bar-btn:hover {
  background: rgba(var(--panel-rgb), 0.6);
  border-color: var(--line);
}

[data-theme="arcade"] .game-bar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 215, 106, 0.3);
}

.game-bar-btn:focus-visible {
  outline: 3px solid #d8a64c;
  outline-offset: 1px;
}

.game-bar-art {
  width: 32px;
  height: 32px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
}

.game-bar-name {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.1;
}

.game-bar-title {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
}

[data-theme="arcade"] .game-bar-title {
  color: #ffd76a;
  text-shadow: 0 1px 0 #7a4c12;
}

.game-bar-sub {
  margin: 0.1rem 0 0;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}

[data-theme="arcade"] .game-bar-sub {
  color: #c4dccb;
}

.game-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: none;
  margin-left: auto;
}

/* Small mode chip on the right while a run is in progress (arcade games). */
.game-bar-mode {
  margin-right: 0.2rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
}

[data-theme="arcade"] .game-bar-mode {
  color: #ffd76a;
  border-color: rgba(255, 215, 106, 0.4);
  background: rgba(255, 215, 106, 0.08);
}

/* The page h1 and description now sit in the About block (still crawlable). */
.game-about .game-about-title {
  margin: 0 0 0.3rem;
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--gold-bright, var(--accent));
}

.game-about .game-about-lede {
  font-weight: 700;
  color: var(--cream, var(--text));
}

/* Practice and "today's puzzle" stay reachable as a quiet text link (dailies). */
.quiet-link {
  display: inline-block;
  min-height: 44px;
  padding: 0.6rem 0.4rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold-bright, var(--accent));
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}

@media (max-width: 360px) {
  .game-bar-title {
    font-size: 1.02rem;
  }
}

/* Kept for leaderboard.js (it fills the name in); theme.css forces it visible on narrow screens. */
.game-bar #welcome-username {
  display: none !important;
}

/* ===== Arcade template (BBG#152) ===== */

/* One HUD: hearts left, score centre, level (and combo chip) right. Doubled class so it beats each game's
   older .stats rules, which load later. */
.ghud.ghud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0 0;
  padding: 0.35rem 0.2rem;
}

.ghud p {
  margin: 0;
}

.ghud-lives {
  display: flex;
  align-items: center;
  justify-self: start;
}

.ghud-score,
.ghud-level {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}

.ghud-level {
  justify-self: end;
  align-items: flex-end;
}

.ghud-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cream-dim, var(--muted));
}

.ghud-value {
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--gold-bright, var(--accent));
}

.ghud-score .ghud-value {
  font-size: 1.9rem;
}

.ghud-level-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Combo/chain chip next to the level, shown only while a combo is live. */
.ghud .ghud-combo,
.ghud .combo-display {
  position: static;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.12rem 0.45rem;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  color: #3a2508;
  background: #ffd76a;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  transform: none;
  animation: none;
}

.ghud .combo-display[hidden],
.ghud .ghud-combo[hidden] {
  display: none;
}

/* Hearts: the game's own nodes (.strike-dot / .heart) drawn as SVG hearts; lost ones are outlined. */
.ghud .strikes,
.ghud .hearts {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0;
}

.ghud .strike-dot,
.ghud .heart {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  font-size: 0;
  color: transparent;
  background: #ff6b6b;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  animation: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-7.5-4.6-9.6-9.3C.9 8.4 3 4.5 6.7 4.5c2.2 0 3.6 1.2 5.3 3.1 1.7-1.9 3.1-3.1 5.3-3.1 3.7 0 5.8 3.9 4.3 7.2C19.5 16.4 12 21 12 21z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-7.5-4.6-9.6-9.3C.9 8.4 3 4.5 6.7 4.5c2.2 0 3.6 1.2 5.3 3.1 1.7-1.9 3.1-3.1 5.3-3.1 3.7 0 5.8 3.9 4.3 7.2C19.5 16.4 12 21 12 21z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.ghud .strike-dot.is-on,
.ghud .heart.lost {
  background: rgba(255, 155, 155, 0.75);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 20s-7-4.3-9-8.7C1.6 8.2 3.5 5 6.8 5c2 0 3.4 1.1 5.2 3 1.8-1.9 3.2-3 5.2-3 3.3 0 5.2 3.2 3.8 6.3-2 4.4-9 8.7-9 8.7z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 20s-7-4.3-9-8.7C1.6 8.2 3.5 5 6.8 5c2 0 3.4 1.1 5.2 3 1.8-1.9 3.2-3 5.2-3 3.3 0 5.2 3.2 3.8 6.3-2 4.4-9 8.7-9 8.7z'/%3E%3C/svg%3E");
}

/* Practice runs print "∞ practice" into the hearts node. */
.ghud .hearts.infinite {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--cream-dim, var(--muted));
}

/* Timer bar under the HUD for time-based games: gold, turning orange as it runs low. */
.ghud-timer {
  height: 8px;
  margin: 0.15rem 0 0.5rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
}

.ghud-timer > div {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #f5c451, #ffd76a);
  border-radius: inherit;
  box-shadow: none;
  transition: width 0.1s linear, background-color 0.2s;
}

.ghud-timer > div.warning,
.ghud-timer > div.danger,
.ghud-timer > div.is-low {
  background: linear-gradient(90deg, #f97316, #fb923c);
}

/* Mode picker: segmented control with line icons, one-line description, one gold Start. */
.gpick {
  margin-top: 0.9rem;
}

.gpick-seg {
  display: flex;
  gap: 0.2rem;
  padding: 0.25rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(245, 196, 81, 0.25);
  border-radius: 14px;
}

.gpick-opt {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.2rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  color: var(--cream-dim, var(--muted));
  background: transparent;
  border: 0;
  border-radius: 10px;
  box-shadow: none;
  cursor: pointer;
}

.gpick-opt[hidden] {
  display: none;
}

.gpick-opt[aria-checked="true"] {
  color: #3a2508;
  background: #ffd76a;
}

.gpick-opt:focus-visible {
  outline: 3px solid #d8a64c;
  outline-offset: 1px;
}

.gpick-desc {
  min-height: 1.4em;
  margin: 0.55rem 0.2rem 0.65rem;
  font-size: 0.92rem;
  text-align: center;
  color: var(--cream-dim, var(--muted));
}

.gpick-start {
  display: block;
  width: 100%;
  min-height: 52px;
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #3a2508;
  background: linear-gradient(180deg, #ffd76a 0%, #f5c451 100%);
  border: 1px solid #a06b1c;
  border-radius: 14px;
  box-shadow: 0 3px 0 #7a4c12, 0 8px 18px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.gpick-start:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #7a4c12, 0 4px 10px rgba(0, 0, 0, 0.3);
}

body.game-running .gpick {
  display: none;
}

/* Secondary actions under Start (Scores, Progress...): quiet text links. */
.glinks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem 1rem;
  margin-top: 0.4rem;
}

.glinks button,
.glinks a {
  min-height: 44px;
  padding: 0.5rem 0.3rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gold-bright, var(--accent));
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}

/* "Your best / rank this week" row; hidden until there is a score. */
.gbest {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  margin-top: 0.8rem;
  padding: 0.55rem 0.85rem;
  color: var(--cream, var(--text));
  text-decoration: none;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(245, 196, 81, 0.28);
  border-radius: 14px;
}

.gbest[hidden] {
  display: none;
}

.gbest strong {
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--gold-bright, var(--accent));
}

.gbest-rank {
  font-weight: 700;
  color: var(--cream-dim, var(--muted));
}

.gbest .game-icon {
  margin-left: auto;
  width: 18px;
  height: 18px;
}

/* About block collapsed in a <details> (still in the HTML for search). */
.game-about details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  cursor: pointer;
  list-style: none;
}

.game-about details > summary::-webkit-details-marker {
  display: none;
}

.game-about details > summary::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-right: 0.3rem;
}

.game-about details[open] > summary::after {
  transform: rotate(-135deg);
}

.game-about details > summary h2 {
  margin: 0;
}

/* Pause sheet behind the pause button (BBG#154). The board is hidden while paused, so a pause can't be
   used to study the question. */
body.game-paused main > :not(.game-bar) {
  visibility: hidden;
}

.game-leave-sheet {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.game-leave-sheet[hidden] {
  display: none;
}

.game-leave-card {
  width: min(100%, 520px);
  padding: 1.2rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
  color: #fdf6e3;
  background: #0e3b26;
  border: 1px solid rgba(245, 196, 81, 0.35);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
}

.game-leave-card h2 {
  margin: 0 0 0.3rem;
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-weight: 400;
  color: #ffd76a;
}

.game-leave-card p {
  margin: 0 0 1rem;
  color: rgba(253, 246, 227, 0.8);
}

.game-leave-actions {
  display: grid;
  gap: 0.5rem;
}

.game-leave-actions .gpick-start {
  font-size: 1.15rem;
}

.game-leave-actions a,
.game-leave-actions .game-leave-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  font-weight: 700;
  color: #fdf6e3;
  text-decoration: none;
  border: 1px solid rgba(253, 246, 227, 0.35);
  border-radius: 14px;
}

.game-leave-actions .game-leave-alt {
  width: 100%;
  font: inherit;
  font-weight: 700;
  background: transparent;
  cursor: pointer;
}

.game-leave-actions .game-leave-alt[hidden] {
  display: none;
}

.ghud .strikes,
.ghud .hearts {
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.ghud .strike-dot::before,
.ghud .heart::before {
  content: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== Daily template (BBG#152) ===== */

/* Guess pips above the board: filled = used guesses, ringed = the current one. */
.gpips-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.gpips {
  display: flex;
  gap: 0.3rem;
}

.gpip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(253, 246, 227, 0.35);
}

.gpip.is-used {
  background: #ffd76a;
  border-color: #ffd76a;
}

.gpip.is-current {
  border-color: #ffd76a;
}

.gpips-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cream-dim, var(--muted));
}

/* End-of-game result as a bottom sheet. The game still shows/hides #result-panel itself. */
.result-panel.gsheet {
  position: fixed !important;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9998;
  width: min(100%, 560px);
  max-height: min(84vh, 760px);
  margin: 0 auto !important;
  overflow-y: auto;
  padding: 0.5rem 1.1rem calc(1rem + env(safe-area-inset-bottom)) !important;
  text-align: center;
  background: linear-gradient(180deg, #124631 0%, #0a2a1b 100%) !important;
  border: 1px solid rgba(245, 196, 81, 0.35) !important;
  border-bottom: 0 !important;
  border-radius: 22px 22px 0 0 !important;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5), 0 -10px 30px rgba(0, 0, 0, 0.45) !important;
  animation: gsheet-in 260ms ease-out;
}

.result-panel.gsheet.is-collapsed {
  max-height: none;
  overflow: hidden;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45) !important;
}

.result-panel.gsheet.is-collapsed > :not(.gsheet-head) {
  display: none !important;
}

@keyframes gsheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-panel.gsheet {
    animation: none;
  }
}

.gsheet-head {
  display: flex;
  justify-content: center;
}

.gsheet-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 120px;
  min-height: 44px;
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cream-dim, var(--muted));
  background: none;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}

.gsheet-toggle::before {
  content: "";
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: rgba(253, 246, 227, 0.35);
}

/* The page gets room at the bottom so a collapsed sheet never covers the last control. */
body.gsheet-open main {
  padding-bottom: 5rem;
}

.gsheet .result-actions {
  flex-direction: column;
  align-items: stretch;
}

.gsheet #share-btn {
  width: 100%;
  min-height: 52px;
  font-size: 1.25rem;
  border-radius: 14px;
}

.gsheet #practice-btn {
  align-self: center;
  min-height: 44px;
  padding: 0.5rem 0.4rem;
  font-weight: 600;
  color: var(--gold-bright, var(--accent));
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  box-shadow: none;
}

.gsheet-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 0.8rem 0 0.2rem;
}

.gsheet-stats p {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.gsheet-stats strong {
  font-family: var(--font-display, "Lilita One", "Outfit", system-ui, sans-serif);
  font-size: 1.45rem;
  font-weight: 400;
  color: var(--gold-bright, var(--accent));
}

.gsheet-stats span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cream-dim, var(--muted));
}

/* Colour grid of the guesses (Bookle). */
.gsheet-grid {
  display: inline-grid;
  grid-auto-flow: row;
  gap: 4px;
  margin: 0.7rem auto 0.2rem;
}

.gsheet-grid-row {
  display: flex;
  gap: 4px;
}

.gsheet-grid-row span {
  width: 22px;
  height: 22px;
  border-radius: 5px;
}

.gsheet-grid .is-exact { background: #1b7d48; }
.gsheet-grid .is-near { background: #f5c451; }
.gsheet-grid .is-far { background: #2a3b33; border: 1px solid rgba(253, 246, 227, 0.25); }

/* "Keep going": the dailies not yet done today. */
.gsheet-more {
  margin-top: 1rem;
  text-align: left;
}

.gsheet-more[hidden] {
  display: none;
}

.gsheet-more h3 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream-dim, var(--muted));
}

.gsheet-more-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.gsheet-more-list a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 52px;
  padding: 0.4rem 0.6rem;
  font-weight: 700;
  color: #fdf6e3;
  text-decoration: none;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(245, 196, 81, 0.3);
  border-radius: 12px;
}

.gsheet-more-list img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex: none;
}

.daily-links {
  margin: 0.4rem 0 0;
  text-align: center;
}

.game-bar-mode {
  max-width: 32vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
