/* YR guest games — shared chrome. "Night Market" palette (contrast measured: text 16.1:1, muted 8.2:1, ink-on-saffron 9.4:1). */
:root {
  --ymg-bg: #16131D;
  --ymg-surface: #221E2B;
  --ymg-raised: #2C2737;
  --ymg-cell: #1B1823;
  --ymg-text: #F6EFE4;
  --ymg-muted: #B3AABD;
  --ymg-accent: #FFB23F;
  --ymg-accent-ink: #2A1A00;
  --ymg-accent-shade: #B87A16;
  --ymg-font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--ymg-bg); color: var(--ymg-text); font: 400 15px/1.35 var(--ymg-font);
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
button { font: inherit; }

/* ---------- game page ---------- */
body.ymg-game { display: flex; flex-direction: column; overflow: hidden; user-select: none; -webkit-user-select: none; }
.ymg-bar {
  flex: none; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px;
  height: calc(64px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
}
.ymg-back, .ymg-icon {
  width: 44px; height: 44px; border-radius: 22px; background: var(--ymg-surface); color: var(--ymg-text);
  display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 20px; font-weight: 800; border: 0;
}
.ymg-mid { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.ymg-score { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ymg-best { font-size: 13px; color: var(--ymg-muted); white-space: nowrap; }
.ymg-extra { width: 44px; height: 44px; }
.ymg-stage { flex: 1; min-height: 0; position: relative; padding: 0 0 env(safe-area-inset-bottom); }
.ymg-stage canvas { display: block; touch-action: none; }

/* ---------- overlays ---------- */
.ymg-over {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgb(10 8 14 / .62);
}
.ymg-over-card {
  width: 100%; max-width: 342px; background: var(--ymg-surface); border-radius: 28px; padding: 28px 24px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 24px 60px rgb(0 0 0 / .5);
  animation: ymg-in .24s cubic-bezier(.22, 1, .36, 1) both;
}
.ymg-over h2 { margin: 0; font-size: 24px; font-weight: 900; }
.ymg-over.is-best h2 { color: var(--ymg-accent); }
.ymg-over-score { font-size: 60px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ymg-over-best, .ymg-over-note { font-size: 15px; color: var(--ymg-muted); text-align: center; }
.ymg-over-note:empty { display: none; }
.ymg-btn {
  margin-top: 16px; width: 100%; min-height: 56px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--ymg-accent); color: var(--ymg-accent-ink); font-size: 18px; font-weight: 900;
  box-shadow: 0 4px 0 var(--ymg-accent-shade);
}
.ymg-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ymg-accent-shade); }
.ymg-pause .ymg-btn { max-width: 300px; margin: 0; }
.ymg-link { display: flex; align-items: center; justify-content: center; min-height: 48px; width: 100%; color: var(--ymg-text); font-weight: 700; text-decoration: none; }
.ymg-banner {
  position: fixed; left: 50%; top: calc(84px + env(safe-area-inset-top)); z-index: 5; transform: translateX(-50%);
  background: var(--ymg-text); color: var(--ymg-bg); font-weight: 900; font-size: 17px; border-radius: 999px; padding: 8px 18px;
  white-space: nowrap; pointer-events: none; animation: ymg-banner 1.6s ease both;
}
@keyframes ymg-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes ymg-banner { 0% { opacity: 0; transform: translate(-50%, -8px) scale(.9); } 12%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -6px); } }
@media (prefers-reduced-motion: reduce) { .ymg-over-card, .ymg-banner { animation-duration: .01s; } }

/* ---------- hub ---------- */
.ymg-hub-page { min-height: 100%; }
.ymg-hub { max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 20px; }
.ymg-hub-top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.ymg-hub-menu { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px 0 4px; color: var(--ymg-text); text-decoration: none; font-weight: 700; }
.ymg-toggles { display: flex; gap: 8px; }
.ymg-toggle { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--ymg-surface); color: var(--ymg-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ymg-toggle[aria-pressed="true"] { background: var(--ymg-raised); color: var(--ymg-accent); }
.ymg-head { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.ymg-venue { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ymg-accent); }
.ymg-head h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 800; }
.ymg-head p { margin: 0; color: var(--ymg-muted); }
.ymg-streak { align-self: flex-start; font-size: 13px; font-weight: 800; color: var(--ymg-accent); background: var(--ymg-surface); border-radius: 999px; padding: 4px 10px; }
.ymg-streak:empty { display: none; }
.ymg-section { margin: 8px 4px -6px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ymg-muted); }
.ymg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ymg-card { text-decoration: none; color: var(--ymg-text); background: var(--ymg-surface); border-radius: 20px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.ymg-card:active { transform: scale(.98); }
.ymg-card-art { aspect-ratio: 1 / 1; border-radius: 14px; background: var(--ymg-raised); position: relative; overflow: hidden; }
.ymg-card-art canvas { width: 100%; height: 100%; display: block; }
.ymg-card-name { font-size: 17px; font-weight: 800; padding: 0 4px; }
.ymg-card-best { font-size: 13px; color: var(--ymg-muted); padding: 0 4px 4px; min-height: 18px; }
@media (hover: hover) and (pointer: fine) { .ymg-card:hover { background: var(--ymg-raised); } }

/* RTL (ar, fa): back arrows point the other way; canvases stay LTR (game physics are not mirrored). */
[dir="rtl"] .ymg-back svg, [dir="rtl"] .ymg-hub-menu svg { transform: scaleX(-1); }
[dir="rtl"] .ymg-stage canvas { direction: ltr; }

/* a11y review 2026-10-10: visible keyboard focus, screen-reader-only live region, safe wrapping for long translations. */
.ymg-card:focus-visible, .ymg-toggle:focus-visible, .ymg-back:focus-visible, .ymg-hub-menu:focus-visible, .ymg-btn:focus-visible, .ymg-link:focus-visible { outline: 3px solid var(--ymg-accent); outline-offset: 3px; }
.ymg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ymg-head h1, .ymg-card-name, .ymg-over h2 { overflow-wrap: anywhere; hyphens: auto; }
