/* Game hub design kit: warm paper, heavy ink, one loud accent per game. */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;800&display=swap');

:root {
  --paper: #f4efe6;
  --paper-2: #eae3d6;
  --card: #fffdf8;
  --ink: #17140f;
  --ink-2: #5d564b;
  --ink-3: #9a9285;
  --stage: #14121a;
  --stage-2: #1f1c28;
  --a: #ff5a36;          /* accent, overridden per game */
  --a-ink: #17140f;      /* text on accent */
  --good: #1fae5b;
  --bad: #e5383b;
  --r: 16px;
  --shadow: 4px 4px 0 var(--ink);
  --display: 'Bricolage Grotesque', 'Arial Black', sans-serif;
  --body: 'Instrument Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.stack > .pill, .stack > .btn { justify-self: start; }
html, body { margin: 0; }
body {
  background: var(--paper);
  background-image: radial-gradient(rgba(23, 20, 15, .07) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--ink);
  font: 500 16px/1.5 var(--body);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.02; letter-spacing: -.02em; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* Shell */
.gh-top {
  display: flex; align-items: center; gap: 10px;
  max-width: 880px; margin: 0 auto; padding: 14px 16px 6px;
}
.gh-top .gh-title { font: 800 22px/1 var(--display); letter-spacing: -.02em; flex: 1; display: flex; align-items: center; gap: 10px; }
.gh-top .gh-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--a); border: 2px solid var(--ink); flex: none; }
.gh-icon {
  width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--ink);
  background: var(--card); display: grid; place-items: center; text-decoration: none;
  font: 800 16px/1 var(--display); box-shadow: 2px 2px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.gh-icon:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.gh-wrap { max-width: 880px; margin: 0 auto; padding: 8px 16px 48px; }
.gh-narrow { max-width: 560px; }

/* Surfaces */
.card {
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 20px;
}
.stage {
  background: var(--stage); color: #f6f1e7; border: 2px solid var(--ink); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.stage canvas { display: block; width: 100%; height: auto; touch-action: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 2px solid var(--ink);
  background: var(--a); color: var(--a-ink); font: 800 17px/1 var(--display); letter-spacing: -.01em;
  box-shadow: var(--shadow); transition: transform .08s, box-shadow .08s; text-decoration: none; user-select: none;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.ghost { background: var(--card); color: var(--ink); }
.btn.dark { background: var(--ink); color: var(--paper); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; box-shadow: 2px 2px 0 var(--ink); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.stack { display: grid; gap: 14px; }

/* Bits */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--card); font: 700 12px/1 var(--body);
  text-transform: uppercase; letter-spacing: .06em;
}
.pill.a { background: var(--a); color: var(--a-ink); }
.kicker { font: 700 12px/1 var(--body); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.big { font: 800 clamp(40px, 9vw, 72px)/.95 var(--display); letter-spacing: -.035em; }
.num { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.mono { font-family: var(--mono); }
.input {
  width: 100%; min-height: 54px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--ink);
  background: #fff; font: 700 20px/1 var(--body); color: var(--ink); outline: none;
}
.input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--a) 45%, transparent); }
.bar { height: 12px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--a); transition: width .2s linear; }
.hud { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.stat { display: grid; gap: 2px; }
.stat b { font: 800 22px/1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font: 700 11px/1 var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }

/* Overlay used for intro / game over inside a stage or card */
.veil {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  background: rgba(20, 18, 26, .82); backdrop-filter: blur(3px); color: #f6f1e7; z-index: 5;
}
.veil[hidden] { display: none; }
.veil h2 { font-size: clamp(30px, 7vw, 52px); }
.veil p { color: #cfc8bb; max-width: 34ch; margin: 10px auto 18px; }

/* Toast + how-to dialog */
.gh-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px;
  font-weight: 700; transition: .2s; z-index: 50; pointer-events: none; white-space: nowrap;
}
.gh-toast.on { transform: translate(-50%, 0); opacity: 1; }
dialog.gh-how {
  border: 2px solid var(--ink); border-radius: var(--r); box-shadow: 6px 6px 0 var(--ink);
  background: var(--card); color: var(--ink); padding: 22px; max-width: min(440px, 92vw);
}
dialog.gh-how::backdrop { background: rgba(23, 20, 15, .5); }
dialog.gh-how h3 { font-size: 26px; margin-bottom: 10px; }
dialog.gh-how li { margin: 6px 0; }
dialog.gh-how ul { padding-left: 18px; margin: 0 0 16px; }

/* Motion */
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 60% { transform: scale(1.08) } 100% { transform: scale(1); opacity: 1 } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-8px) } 40% { transform: translateX(7px) } 60% { transform: translateX(-5px) } 80% { transform: translateX(3px) } }
@keyframes rise { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }
.pop { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.shake { animation: shake .35s both; }
.rise { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
.gh-spark { position: fixed; width: 10px; height: 10px; pointer-events: none; z-index: 60; border: 2px solid var(--ink); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (max-width: 520px) { .card { padding: 16px; } .gh-top .gh-title { font-size: 19px; } }

/* Immersive mode: the game scene fills the screen; chrome shrinks to floating glass buttons. GH.shell({ immersive: true }) */
body.gh-immersive { background: #0b0d18; background-image: none; overflow: hidden; height: 100dvh; color: #f6f1e7; }
.gh-top.gh-float { position: fixed; inset: 0 0 auto 0; max-width: none; padding: 12px; z-index: 30; pointer-events: none; }
.gh-top.gh-float > * { pointer-events: auto; }
.gh-top.gh-float .gh-title { visibility: hidden; }
.gh-top.gh-float .gh-icon {
  border-radius: 50%; background: rgba(12, 14, 28, .42); color: #fff; border: 1.5px solid rgba(255, 255, 255, .38);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.gh-top.gh-float .gh-icon:active { transform: scale(.92); box-shadow: none; }
.gh-scene { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; }

/* Help dialog in immersive mode: dark glass instead of paper. */
body.gh-immersive dialog.gh-how { background: rgba(18, 14, 38, .92); color: #f6f1e7; border: 1.5px solid rgba(255, 255, 255, .28); border-radius: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .55); backdrop-filter: blur(10px); }
body.gh-immersive dialog.gh-how::backdrop { background: rgba(6, 4, 18, .6); }
body.gh-immersive dialog.gh-how .btn { border: 0; border-radius: 999px; box-shadow: 0 4px 0 rgba(0, 0, 0, .35); }
