/* registered so its computed value is a plain length (chrome.js reads it with parseFloat; --gc-bar may be var(--hud-top), which carries the safe-area inset) */
@property --gc-bar {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}

/*
 * Game chrome (chrome.js): the how-to-play dialog, and the room for the site bar on desktop and tablet.
 * (The ≡ menu and the deck are the site's own: src/core/menu.ts and src/core/soundtrack.ts.)
 * Colours follow kit.js's theme (--kit-bg / --kit-ink / --kit-accent, set per ?mode and ?accent), so dark and light both work.
 */

html {
  --gc-bg: var(--kit-bg, #07130d);
  --gc-ink: var(--kit-ink, #dff3e8);
  --gc-accent: var(--kit-accent, #ff4500);
  --gc-mono: 'Ioskeley Mono', ui-monospace, Menlo, monospace;
  --gc-display: 'Satoshi', 'Ioskeley Mono', sans-serif;
  /* the top bar's height: 0 on phones and with ?frame stills; the site bar's height elsewhere (chrome.js sets data-device) */
  --gc-bar: 0px;
  /* the Menu button's box at the top right of a phone, safe area included: a game's own HUD stays out of it */
  --gc-edge-right: 0px;
  --gc-edge-top: 0px;
}
html[data-device='desktop'], html[data-device='tablet'] { --gc-bar: var(--hud-top, 48px); }
html[data-device='phone'] { --gc-edge-right: calc(52px + env(safe-area-inset-right)); --gc-edge-top: calc(52px + env(safe-area-inset-top)); }
html[data-gc-bare] { --gc-bar: 0px; --gc-edge-right: 0px; --gc-edge-top: 0px; }

/* the play area is the page below the bar: the body is that box, and `contain` makes it the containing block for the
   games' own fixed overlays (inset: 0 means the play area, not the viewport) */
html.kit-game body { top: var(--gc-bar); height: calc(100% - var(--gc-bar)); contain: layout; }

/* ---------- the how-to-play dialog (spec C35.9, C35.12): one centred modal on every device ----------
   The site chrome's own terms (_docs/chrome.md 8.3a): an 8 px unit, one type step (14 px, 1.6 px tracking, uppercase for labels), 1 px rules,
   solid ink as the one primary. The scrim is translucent and unblurred (spec C39.3): the game shows through it. */

.gc-sheet {
  --gc-rule: color-mix(in srgb, var(--gc-ink) 16%, var(--gc-bg));
  --gc-line: color-mix(in srgb, var(--gc-ink) 45%, var(--gc-bg));
  --gc-faint: color-mix(in srgb, var(--gc-ink) 62%, var(--gc-bg));
  /* the clear space above and below the dialog: the same at both ends so it is centred in the viewport and never reaches the site bar */
  --gc-dlg-y: max(calc(var(--gc-bar) + 16px), calc(var(--dh-safe-top, env(safe-area-inset-top, 0px)) + 16px), calc(var(--dh-safe-bottom, env(safe-area-inset-bottom, 0px)) + 16px));
  --gc-dlg-x: max(16px, var(--dh-safe-left, env(safe-area-inset-left, 0px)), var(--dh-safe-right, env(safe-area-inset-right, 0px)));
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim, 200);
  box-sizing: border-box;
  padding: var(--gc-dlg-y) var(--gc-dlg-x);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--gc-mono);
  color: var(--gc-ink);
  -webkit-user-select: none;
  user-select: none;
}
.gc-sheet[hidden] { display: none; }
.gc-sheet__scrim { position: absolute; inset: 0; background: var(--gc-scrim, color-mix(in srgb, var(--gc-bg) 45%, transparent)); } /* no backdrop-filter over the canvas (spec C39.3) */

.gc-dialog {
  position: relative;
  box-sizing: border-box;
  width: min(520px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--gc-bg);
  border: 1px solid var(--gc-line);
  font: 400 14px/21px var(--gc-mono);
  letter-spacing: 0.02em;
  color: var(--gc-ink);
  outline: none;
}

.gc-dialog__head { flex: none; display: flex; align-items: stretch; min-height: 48px; border-bottom: 1px solid var(--gc-rule); }
.gc-dialog__title { flex: 1; min-width: 0; margin: 0; padding: 0 16px; display: flex; align-items: center; font: 400 15px/20px var(--gc-mono); letter-spacing: 3px; text-transform: uppercase; color: var(--gc-ink); }
.gc-dialog__x {
  flex: none;
  box-sizing: border-box;
  width: 48px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--gc-ink);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--gc-rule);
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.gc-dialog__x svg { width: 14px; height: 14px; display: block; }
.gc-dialog__x:hover { background: color-mix(in srgb, var(--gc-ink) 11%, var(--gc-bg)); }

.gc-dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--gc-faint) transparent;
  outline: none;
  /* a soft edge only where more lies beyond (scrolling shadows: the rows are never covered) */
  background:
    linear-gradient(var(--gc-bg) 30%, transparent) 0 0 / 100% 24px no-repeat local,
    linear-gradient(transparent, var(--gc-bg) 70%) 0 100% / 100% 24px no-repeat local,
    linear-gradient(color-mix(in srgb, var(--gc-ink) 16%, transparent), transparent) 0 0 / 100% 8px no-repeat scroll,
    linear-gradient(transparent, color-mix(in srgb, var(--gc-ink) 16%, transparent)) 0 100% / 100% 8px no-repeat scroll;
}
.gc-dialog__body:focus-visible { outline: 1px solid var(--gc-ink); outline-offset: -3px; }
.gc-dialog__game { margin: 0 0 12px; font: 900 20px/1.1 var(--gc-display); letter-spacing: 0.02em; text-transform: uppercase; color: var(--gc-ink); }

.gc-help__list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.gc-help__list li { position: relative; padding-left: 16px; overflow-wrap: anywhere; }
.gc-help__list li::before { content: '\203A'; position: absolute; left: 0; color: var(--gc-faint); font-weight: 700; }

.gc-dialog__foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--gc-rule); }

.gc-btn {
  box-sizing: border-box;
  flex: none;
  min-width: 112px;
  min-height: 40px;
  margin: 0;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 400 14px/20px var(--gc-mono);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gc-bg);
  background: var(--gc-ink);
  border: 1px solid var(--gc-ink);
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.gc-btn:hover { background: color-mix(in srgb, var(--gc-ink) 88%, var(--gc-bg)); }

.gc-dialog :focus { outline: none; }
.gc-dialog :focus-visible { outline: 1px solid var(--gc-ink); outline-offset: 3px; }
.gc-dialog__x:focus-visible { outline-offset: -4px; }
.gc-btn:focus-visible { outline-color: var(--gc-ink); outline-offset: 3px; }

/* touch: the faces stay the desktop's, the targets are 44 and more */
html[data-touch='true'] .gc-btn { min-height: 48px; }
html[data-touch='true'] .gc-dialog__x { width: 48px; }

@media (max-width: 560px) {
  .gc-dialog__foot { flex-direction: column; align-items: stretch; }
  .gc-btn { width: 100%; }
}
@media (max-height: 420px) {
  .gc-dialog__body { padding-top: 12px; padding-bottom: 12px; }
  .gc-dialog__game { margin-bottom: 8px; font-size: 18px; }
  .gc-help__list { gap: 8px; }
}

/* ---------- the start card (spec C47): one start screen for every game with a start (attract) state, built by chrome.js ----------
   #start is the play area under the bar (the body is its containing block) under a light scrim, the same 45 % mix as the dialog's. It takes the pointer:
   a press anywhere on it starts the game. The card is centred in the viewport, not in the play area: the bar's height is added at the bottom.
   A game may set on <html>: --gc-start-face (its display face), --gc-start-ink and --gc-start-paper (default: the page's ink and background),
   --gc-start-smooth (-webkit-font-smoothing of the label: none for the pixel faces).
   .gc-cta is the one button of every card (spec C47.3, C53.3): the START button and the RESUME, CONTINUE and PLAY AGAIN buttons of the screens that wait; GameChrome.button() builds it. */
#start { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; box-sizing: border-box; padding: 16px 16px calc(16px + var(--gc-bar, 0px)); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; background: color-mix(in srgb, var(--gc-start-paper, var(--gc-bg)) 45%, transparent); }
#start[hidden] { display: none; }
#start .start-card { box-sizing: border-box; max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 32px 48px 40px; text-align: center; cursor: default; background: var(--gc-start-paper, var(--gc-bg)); border: 1px solid color-mix(in srgb, var(--gc-start-ink, var(--gc-ink)) 45%, var(--gc-start-paper, var(--gc-bg))); }
#start .start-logo { display: block; width: calc(min(240px, calc(36vh * var(--gc-start-ar, 1.2))) * var(--gc-start-k, 1)); max-width: 100%; height: auto; }
/* the START button: solid ink with the page colour as its text, the look of the dialog's Got it; the game's own face; no key tag (the keys are in the help window) */
.gc-cta, #start .start-btn { pointer-events: auto; appearance: none; position: relative; margin: 0; min-width: 200px; min-height: 56px; padding: 0 56px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font: 30px/1 var(--gc-start-face, var(--gc-display)); letter-spacing: 0.06em; text-indent: 0.06em; -webkit-font-smoothing: var(--gc-start-smooth, auto); color: var(--gc-start-paper, var(--gc-bg)); background: var(--gc-start-ink, var(--gc-ink)); border: 1px solid var(--gc-start-ink, var(--gc-ink)); border-radius: 0; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.gc-cta:hover, #start .start-btn:hover { background: color-mix(in srgb, var(--gc-start-ink, var(--gc-ink)) 86%, var(--gc-start-paper, var(--gc-bg))); }
.gc-cta:focus, #start .start-btn:focus { outline: none; }
.gc-cta:focus-visible, #start .start-btn:focus-visible { outline: 2px solid var(--gc-start-ink, var(--gc-ink)); outline-offset: 4px; }
.gc-cta:active, #start .start-btn:active { transform: translateY(2px); background: color-mix(in srgb, var(--gc-start-ink, var(--gc-ink)) 70%, var(--gc-start-paper, var(--gc-bg))); }
@media (max-width: 700px) { .gc-cta, #start .start-btn { font-size: 20px; min-width: 160px; min-height: 48px; padding: 0 40px; } #start .start-card { padding: 16px 24px 20px; gap: 16px; } #start .start-logo { width: calc(min(140px, calc(36vh * var(--gc-start-ar, 1.2))) * var(--gc-start-k, 1)); } }
@media (max-height: 500px) { .gc-cta, #start .start-btn { font-size: 20px; min-width: 160px; min-height: 48px; padding: 0 40px; } #start .start-card { padding: 16px 28px 20px; gap: 16px; } #start .start-logo { width: calc(min(150px, calc(36vh * var(--gc-start-ar, 1.2))) * var(--gc-start-k, 1)); } }
/* On touch screens only, the card beside a demo's action (spec C51.15): chrome.js sets data-start-form="row" and --gc-start-k (the logo's scale) on #start and moves the card with a transform. Desktop keeps the centred stack. */
#start[data-start-form='row'] .start-card { flex-direction: row; gap: 16px; padding: 10px 12px; }
#start[data-start-form='row'] .start-btn { min-width: 140px; padding: 0 24px; }
/* docked (a short landscape screen where nothing clears the demo's action, C51.15): one low row between the pad clusters, the button still 44 px tall */
#start[data-start-place='dock'] .start-card { padding: 4px 10px; gap: 12px; }
#start[data-start-place='dock'] .start-btn { min-width: 120px; min-height: 44px; padding: 0 20px; font-size: 18px; }

/* ---------- the start MENU (chrome.js, start.menu): the logo OUTSIDE and above, then ONE box of stacked buttons; on a short screen the logo stands beside the box ----------
   The veil (#start's 45 % scrim) and the demo behind it are as for the one-button card. The card itself has no box: the logo sits on the veil, whole-pixel scaled by chrome.js
   (--gc-start-scale, an integer; --gc-start-art-w the art's width), and the box holds the buttons (the START button's look, one after another, full width of the box).
   The layer scrolls if a tiny screen cannot hold the card (margin: auto centres without hiding the top). The `html` in the selectors outranks the one-button rules above. */
html #start[data-start-menu] { overflow: auto; align-items: flex-start; justify-content: flex-start; padding: max(16px, var(--gc-edge-top, 0px), var(--dh-safe-top, env(safe-area-inset-top, 0px))) max(16px, var(--dh-safe-right, env(safe-area-inset-right, 0px))) calc(max(16px, var(--gc-edge-top, 0px), var(--dh-safe-bottom, env(safe-area-inset-bottom, 0px))) + var(--gc-bar, 0px)) max(16px, var(--dh-safe-left, env(safe-area-inset-left, 0px))); }
html #start[data-start-menu] .start-card { flex: none; margin: auto; max-width: none; padding: 0; gap: 28px; background: none; border: 0; }
html #start[data-start-menu] .start-logo { flex: none; width: calc(var(--gc-start-art-w, 81) * var(--gc-start-scale, 3) * 1px); max-width: none; height: auto; image-rendering: pixelated; }
html #start[data-start-menu] .start-box { box-sizing: border-box; flex: none; width: min(320px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; padding: 16px; cursor: default; background: var(--gc-start-paper, var(--gc-bg)); border: 1px solid color-mix(in srgb, var(--gc-start-ink, var(--gc-ink)) 45%, var(--gc-start-paper, var(--gc-bg))); }
html #start[data-start-menu] .start-box .start-btn { width: 100%; min-width: 0; padding-left: 16px; padding-right: 16px; }
@media (max-width: 700px), (max-height: 500px) { html #start[data-start-menu] .start-card { gap: 20px; } html #start[data-start-menu] .start-box { gap: 10px; padding: 12px; } }
html #start[data-start-menu][data-start-form='row'] .start-card { display: grid; grid-template-columns: auto 300px; grid-template-rows: auto; align-items: center; justify-items: center; column-gap: 32px; row-gap: 16px; }
html #start[data-start-menu][data-start-form='row'] .start-logo { grid-column: 1; grid-row: 1; }
html #start[data-start-menu][data-start-form='row'] .start-box { grid-column: 2; grid-row: 1; width: 300px; }
html #start[data-start-menu][data-start-form='row'] .start-card > [data-street-cred] { grid-column: 2; grid-row: 2; }
html #start[data-start-menu][data-start-form='row'] .start-card:has(> [data-street-cred]) .start-logo { grid-row: 1 / span 2; }
/* a page is open (ABOUT, HISTORY): the card steps aside; the veil stays under the page's own scrim, so the demo is dimmed twice */
html[data-gc-page] #start .start-card { visibility: hidden; }

/* ---------- an in-game page (chrome.js pages): the dialog's sheet with a wider, longer body; the game's own face for the title ---------- */
.gc-sheet--page .gc-dialog { width: min(820px, 100%); }
.gc-dialog--page .gc-dialog__title { display: block; align-self: center; font: 400 42px/1 var(--gc-page-head, var(--gc-start-face, var(--gc-display))); font-synthesis: none; letter-spacing: 0.01em; text-transform: uppercase; text-box: trim-both cap alphabetic; } /* C47.11.4: the box is cap top to baseline, centred in the bar */
.gc-sheet--page .gc-page { padding: 24px 28px 28px; font: 400 28px/1.35 var(--gc-page-body, var(--gc-mono)); letter-spacing: 0; -webkit-user-select: text; user-select: text; }
@media (max-width: 560px) { .gc-sheet--page .gc-page { padding: 20px 16px 24px; font-size: 25px; } }
@media (max-height: 500px) { .gc-sheet--page .gc-page { padding-top: 14px; padding-bottom: 16px; } .gc-sheet--page .gc-dialog__head { min-height: 44px; } }
@media (max-height: 500px) { .gc-dialog--page .gc-dialog__title { font-size: 34px; } }
.gc-dialog--page .gc-dialog__head { min-height: 64px; } @media (max-height: 500px) { .gc-sheet--page .gc-dialog__head { min-height: 52px; } }
