/* HandShoot home + onboarding: quiet and light, with the pixel game tiles as the only colour.
   Games keep their own themes; everything here is scoped to .screen.hub */

.screen.hub {
    --ink: #16161a;
    --paper: #fbfbfa;
    --card: #ffffff;
    --muted: #8a8a93;
    --body: #55555e;
    --line: #e6e5e1;
    --line-strong: #d6d5d0;
    --accent: #e5352b;
    --live: #4fae2a;
    --warn: #e3a21a;
    --mono: 'Geist Mono', ui-monospace, monospace;

    font-family: 'Geist', system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    contain: none;
    -webkit-overflow-scrolling: touch;
}
.screen.hub h1, .screen.hub h2, .screen.hub h3 { font-weight: 500; letter-spacing: -0.03em; text-transform: none; margin: 0; }
.screen.hub p { margin: 0; }
.screen.hub button:focus-visible, .screen.hub a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- Buttons (override legacy .cta-button / .button) ---------- */
.screen.hub .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit; font-size: 16px; font-weight: 500; letter-spacing: 0; text-transform: none; text-decoration: none;
    padding: 14px 24px; border-radius: 999px; border: 1px solid var(--line-strong);
    background: var(--card); color: var(--ink); cursor: pointer; box-shadow: none; animation: none;
    transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.screen.hub .btn::before { display: none; }
.screen.hub .btn:hover { transform: none; box-shadow: none; background: #f2f2ef; color: var(--ink); border-color: var(--line-strong); }
.screen.hub .btn:active { transform: scale(.98); }
.screen.hub .btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.screen.hub .btn-primary:hover { background: #2c2c33; color: #fff; border-color: #2c2c33; }
.screen.hub .btn-block { width: 100%; }
.screen.hub .btn-link { border: none; background: none; color: var(--muted); font-size: 15px; padding: 6px; }
.screen.hub .btn-link:hover { background: none; color: var(--ink); }
.screen.hub .btn-ghost { font-size: 15px; padding: 11px 22px; }

/* ---------- Home ---------- */
.hub-nav { width: 100%; max-width: 1200px; box-sizing: border-box; padding: 28px 40px; display: flex; justify-content: space-between; align-items: center; flex: none; }
.hub-logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.hub-logo-mark { width: 18px; height: 18px; color: var(--accent); }
.hub-links { display: flex; gap: 24px; }
.hub-link { font-size: 15px; color: var(--body); text-decoration: none; }
.hub-link:hover { color: var(--ink); }

.hub-main { width: 100%; max-width: 1200px; box-sizing: border-box; padding: 0 40px; flex: 1 0 auto; }

.hero { padding: 96px 0 88px; display: flex; flex-direction: column; gap: 44px; }
.screen.hub .hero-title { font-size: clamp(42px, 6.6vw, 96px); line-height: 1.1; letter-spacing: -0.05em; }

/* Pixel game tiles that sit inside the headline like words */
.word-tile { position: relative; display: inline-grid; place-items: center; width: 1.15em; height: .82em; border-radius: .2em; background: var(--tile); vertical-align: -0.06em; }
.word-tile .pixel-icon { width: .56em; height: .56em; image-rendering: pixelated; transition: transform .25s steps(3); }
.word-tile.wide .pixel-icon { width: .6em; height: .34em; }
.word-tile:hover .pixel-icon { transform: translateY(-.06em); }
.word-aim { position: absolute; right: -.28em; top: -.26em; width: .62em; height: .62em; fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; animation: aimDrift 3.2s ease-in-out infinite; }
@keyframes aimDrift { 50% { transform: translate(-.05em, .04em); } }

.hero-title .nowrap { white-space: nowrap; }
.hero-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 28px; }
.hero-sub { font-size: 19px; line-height: 1.55; color: var(--body); max-width: 470px; }
.hero-actions { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.hero-note { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.games-section { padding: 28px 0 104px; border-top: 1px solid var(--line); scroll-margin-top: 24px; }
.games-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 24px; }
.screen.hub .games-head h2 { font-size: 15px; letter-spacing: 0; }
.games-head span { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.games-container { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px; }

.game-card { all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 14px; cursor: pointer; }
.game-card-tile { position: relative; aspect-ratio: 4 / 5; border-radius: 22px; background: var(--tile); display: grid; place-items: center; transition: transform .2s ease; }
.game-card-tile .pixel-icon { width: 52%; height: auto; image-rendering: pixelated; transition: transform .25s steps(3); }
.game-card:hover .game-card-tile, .game-card:focus-visible .game-card-tile { transform: translateY(-4px); }
.game-card:hover .pixel-icon, .game-card:focus-visible .pixel-icon { transform: translateY(-8px); }
.game-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 24px; }
.game-card-new { position: absolute; left: 14px; top: 14px; font-family: var(--mono); font-size: 11px; font-weight: 500; background: #fff; border-radius: 999px; padding: 4px 9px; }
.game-card-meta { display: flex; flex-direction: column; gap: 3px; padding: 0 4px; }
.game-card-title { font-weight: 500; font-size: 17px; letter-spacing: -0.01em; }
.game-card-input { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.no-games-message { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--muted); }

.hub-footer { width: 100%; max-width: 1200px; box-sizing: border-box; padding: 24px 40px 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); flex: none; }
.footer-links { display: flex; gap: 20px; }
.footer-link { color: var(--muted); text-decoration: none; }
.footer-link:hover { color: var(--ink); }

/* ---------- Onboarding ---------- */
.screen.onboard { justify-content: center; padding: 20px; box-sizing: border-box; }
.onboard-card { width: min(460px, 100%); max-height: 100%; overflow-y: auto; box-sizing: border-box; background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 60px rgba(20, 20, 26, .08); padding: 28px 32px 30px; display: flex; flex-direction: column; gap: 20px; animation: cardIn .35s ease both; }
.onboard-card.wide { width: min(860px, 100%); }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } }
.onboard-card h2 { font-size: 28px; }
.onboard-sub { color: var(--body); font-size: 16px; line-height: 1.5; }
.privacy-note { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.5; }

.stepper { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.stepper-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stepper-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stepper-bar i { height: 4px; border-radius: 4px; background: var(--line); }
.stepper-bar i.on { background: var(--ink); }

.onboard-title { display: flex; gap: 16px; align-items: center; }
.onboard-title h1 { font-size: 30px; }
.onboard-title .onboard-sub { font-size: 15px; color: var(--muted); }
.onboard-icon { flex: none; width: 72px; height: 72px; border-radius: 16px; background: #e7efe2; display: grid; place-items: center; }
.onboard-icon .pixel-icon { width: 48px; height: 48px; image-rendering: pixelated; }

.instructions { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; margin: 0; animation: none; }
.instruction-item { display: grid; grid-template-columns: 22px 64px 1fr; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid #eeece5; font-size: 15px; color: var(--body); }
.instruction-item:last-child { border-bottom: 0; }
.instruction-item b { color: var(--ink); font-weight: 600; }
.instruction-icon { display: grid; color: var(--ink); }

.permission-body { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 8px 0 0; }
.permission-ring { position: relative; width: 84px; height: 84px; display: grid; place-items: center; margin-bottom: 4px; color: var(--ink); }
.permission-ring > svg { position: relative; }
.loading-spinner { position: absolute; inset: 0; width: auto; height: auto; margin: 0; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 1.1s linear infinite; }

.walkthrough-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: stretch; }
.walkthrough-container { display: flex; flex-direction: column; }
.walkthrough-step { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid #eeece5; opacity: 1; animation: none; transform: none; background: none; }
.walkthrough-step:last-child { border-bottom: 0; }
.step-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #eeece5; font-size: 13px; font-weight: 600; display: grid; place-items: center; }
.walkthrough-step.active .step-num { background: var(--ink); color: #fff; }
.step-content h3 { font-size: 16px; letter-spacing: 0; }
.step-content p { font-size: 14px; color: var(--body); margin-top: 2px; }
.walkthrough-camera-preview { position: relative; min-height: 240px; background: #edece6; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
#walkthrough-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.walkthrough-hand-status { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulseDot 1.2s ease-in-out infinite; }
.walkthrough-hand-status.detected .status-dot { background: var(--live); animation: none; }
@keyframes pulseDot { 50% { opacity: .35; } }
.walkthrough-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.walkthrough-tip { font-size: 13px; color: var(--muted); }

.screen.calibrate { justify-content: center; background-image: radial-gradient(#d6d4cb 1px, transparent 1.2px); background-size: 24px 24px; }
.calib-stepper { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); width: 260px; align-items: center; }
.calib-stepper .stepper { align-items: center; }
.calib-stepper .stepper-bar { width: 260px; }
.calib-center { position: relative; z-index: 1; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 60px rgba(20, 20, 26, .08); padding: 28px 36px; width: min(400px, 86vw); box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.calib-center h2 { font-size: 28px; }
.calib-center p { font-size: 16px; color: var(--body); }
.calib-center .btn { margin-top: 10px; }
#calibration-progress { position: absolute; inset: 0; width: auto; height: auto; pointer-events: none; }
.corner-marker { position: absolute; width: 72px; height: 72px; box-sizing: border-box; border: 2px solid var(--ink); border-radius: 50%; background: var(--card); color: inherit; opacity: 1; animation: markerPulse 1.6s ease-in-out infinite; transition: background .2s; }
.corner-marker::before { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--ink); }
.corner-marker.visited { background: var(--ink); animation: none; transform: none; }
.corner-marker.visited::before { width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 0; background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23C8F33A' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E"); }
@keyframes markerPulse { 50% { transform: scale(1.1); } }
#corner-tl { top: 60px; left: 40px; } #corner-tr { top: 60px; right: 40px; }
#corner-bl { bottom: 40px; left: 40px; } #corner-br { bottom: 40px; right: 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
    .games-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .hub-nav { padding: 20px 16px; } .hub-main { padding: 0 16px; }
    .hero { padding: 48px 0 56px; gap: 32px; }
    .screen.hub .hero-title { font-size: clamp(34px, 10.4vw, 56px); }
    .hero-title br { display: none; }
    .hero-sub { font-size: 17px; }
    .hero-actions { flex-direction: column-reverse; align-items: stretch; width: 100%; text-align: center; }
    .games-container { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
    .game-card-tile { border-radius: 18px; }
    .hub-footer { padding: 22px 16px 32px; }
    .onboard-card { padding: 22px 20px 24px; border-radius: 18px; }
    .instruction-item { grid-template-columns: 22px 56px 1fr; gap: 10px; padding: 12px; }
    .walkthrough-layout { grid-template-columns: 1fr; gap: 16px; }
    .walkthrough-camera-preview { order: -1; min-height: 0; height: 26vh; }
    .walkthrough-foot { flex-direction: column-reverse; align-items: stretch; text-align: center; }
    .corner-marker { width: 56px; height: 56px; }
    #corner-tl, #corner-tr { top: 80px; } #corner-tl, #corner-bl { left: 16px; } #corner-tr, #corner-br { right: 16px; } #corner-bl, #corner-br { bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    .screen.hub *, .screen.hub *::before { animation: none !important; transition: none !important; }
}
