/* Homepage — compact, game-first layout */
.pacman-home .hero{padding:24px 0 20px;margin-bottom:22px;border-bottom:1px solid var(--line)}
.pacman-home .hero h1{margin:0 0 8px;color:var(--text);font:600 clamp(24px,3vw,34px)/1.2 var(--head);letter-spacing:-.3px}
.pacman-home .hero p{max-width:860px;margin:0;color:var(--text2);font-size:16px;line-height:1.6}
.pacman-home .platform-section{margin-bottom:32px;scroll-margin-top:16px}
.pacman-home .platform-title{display:flex;align-items:center;gap:10px;margin:0 0 14px;color:var(--text);font:600 clamp(20px,2.2vw,25px)/1.3 var(--head)}
.pacman-home .platform-title::before{content:"";flex:0 0 9px;width:9px;height:9px;border-radius:50%;background:var(--accent)}
.pacman-home .platform-section > p{margin:0 0 14px;color:var(--text2);font-size:16px;line-height:1.65}
.pacman-home .platform-section .game-grid{margin-top:0}
.pacman-home .home-about{padding:20px 0 0;margin:36px 0;border-top:1px solid var(--line)}
.pacman-home .home-about > p{max-width:900px;margin-bottom:10px}
.pacman-home .home-about > p:last-child{margin-bottom:0}
@media(max-width:600px){
    .pacman-home .hero{padding:18px 0 16px;margin-bottom:18px}
    .pacman-home .platform-section{margin-bottom:26px}
    .pacman-home .platform-title{gap:8px;margin-bottom:12px}
    .pacman-home .platform-title::before{flex-basis:7px;width:7px;height:7px}
    .pacman-home .home-about{margin:28px 0;padding-top:16px}
}

/* Homepage Pac-Man game (standalone game in /games/pacman/, loaded into an iframe on demand) */
.pacman-home .home-game{--game-max:650px;scroll-margin-top:12px;margin: 5px}
.pacman-home .home-game-title{margin:0 auto 12px;max-width:var(--game-max);color:var(--text);font:600 clamp(20px,2.2vw,25px)/1.3 var(--head)}
.home-game-player{max-width:var(--game-max);margin:0 auto;overflow:hidden;background:#000;}
/* Height: the game canvas is 7:9 plus its own toolbar (desktop) or joystick (touch); never taller than the viewport */
.home-game-screen{position:relative;width:100%;height:min(calc(100svh - 96px),calc(min(100vw - 34px,var(--game-max)) * 1.3 + 56px));min-height:320px;background:#000}
.home-game-frame{position:absolute;inset:0;display:block;width:100%;height:100%;border:0;background:#000}
.home-game-frame[hidden]{display:none}
/* Start screen: intro text, a maze-corridor poster, the START GAME button and the control hint,
   one centred column with a shared width so every line lines up on the same axis */
.home-game-start{position:absolute;inset:0;z-index:2;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px 20px;background:radial-gradient(circle at 50% 40%,#10264d 0%,#050d1c 62%,#000 100%);text-align:center}
.home-game-start[hidden]{display:none}
.home-game-intro{width:100%;max-width:440px}
.home-game-kicker{margin:0 0 10px;color:#ffd33d;font:600 12px/1.2 var(--head);letter-spacing:.18em;text-transform:uppercase}
.home-game-heading{margin:0;color:#fff;font:600 clamp(26px,4.6vw,36px)/1.15 var(--head);letter-spacing:-.2px}
.home-game-lead{max-width:34ch;margin:12px auto 0;color:#c8d2ea;font:400 clamp(14px,2vw,16px)/1.55 var(--body);text-wrap:balance}
/* Poster: a short maze corridor (wall lines in the game's blue) with Pac-Man chased by the ghosts */
.home-game-poster{--poster-gap:clamp(12px,3vw,20px);display:flex;align-items:center;justify-content:center;gap:var(--poster-gap);width:100%;max-width:400px;margin:28px 0 30px;padding:12px 0;border-block:2px solid #2742c4}
.home-game-ghosts{display:flex;align-items:center;gap:clamp(4px,1.2vw,8px)}
/* Sprite sheets are 16 px frames laid out horizontally: show a single frame */
.home-game-sprite{display:block;flex:none;width:clamp(28px,6.4vw,40px);height:auto;aspect-ratio:1;object-fit:cover;object-position:0 0;image-rendering:pixelated}
.home-game-sprite-pacman{object-position:33.333% 0}
.home-game-pellets{display:flex;align-items:center;gap:clamp(8px,2vw,12px)}
.home-game-pellets span{display:block;flex:none;width:6px;height:6px;border-radius:50%;background:#ffb8ae}
.home-game-pellets span.is-power{width:12px;height:12px}
.home-game-note{display:flex;flex-wrap:wrap;justify-content:center;margin:18px 0 0;padding:0;list-style:none;color:#aab6ca;font:500 13px/1.4 var(--body)}
.home-game-note li+li::before{content:"\00B7";margin:0 8px;color:#5d6d88}
/* Loading state (set by /_js/home-game.js right after START GAME): the button reads "Loading…" */
.home-game-start.is-loading .game-play-button:disabled{opacity:1;animation:home-game-pulse 1.2s ease-in-out infinite}
@keyframes home-game-pulse{0%,100%{color:#fff3bf;border-color:#ffd54a}50%{color:#c9b97a;border-color:#a88a2c}}
.home-game-error{position:absolute;z-index:3;right:12px;bottom:12px;left:12px;padding:10px 14px;border:1px solid #a63d3d;border-radius:6px;background:#321919;color:#fff;font-size:13px;text-align:center}
.home-game-error[hidden]{display:none}
.home-game-bar{display:flex;align-items:center;gap:12px;min-height:48px;padding:6px 8px 6px 14px;border-top:1px solid var(--line);background:var(--surface)}
.home-game-help{flex:1;min-width:0;margin:0;color:var(--text2);font:500 13px/1.4 var(--body)}
/* START GAME button: same look as the play page (style/play.css), scoped to the homepage */
.home-game-start .game-play-button{position:relative;display:flex;align-items:center;justify-content:center;gap:14px;width:min(236px,100%);min-height:60px;padding:12px 18px;overflow:hidden;border:2px solid #ffd54a;border-radius:999px;background:linear-gradient(180deg,#16386d 0%,#0b1f45 100%);box-shadow:0 0 0 1px rgba(255,213,74,.18) inset,0 10px 26px rgba(0,0,0,.36);color:#fff3bf;font:800 16px/1 var(--head);letter-spacing:.12em;text-transform:uppercase;white-space:nowrap;cursor:pointer;transition:transform .15s ease,box-shadow .22s ease,border-color .22s ease,background .22s ease}
.home-game-start .game-play-button:hover:not(:disabled){background:linear-gradient(180deg,#1c4587 0%,#102b5f 100%);border-color:#ffe372;box-shadow:0 0 0 1px rgba(255,233,138,.24) inset,0 0 22px rgba(255,211,61,.22),0 14px 30px rgba(0,0,0,.4)}
.home-game-start .game-play-button:active:not(:disabled){transform:scale(.97)}
.home-game-start .game-play-button:focus-visible{outline:3px solid #ffad70;outline-offset:3px}
.home-game-start .game-play-button:disabled{opacity:.6;cursor:wait;transform:none}
/* Fullscreen: native on the player wrapper, or a fixed overlay where the API is missing (iPhone) */
.home-game-player:is(:fullscreen,.fake-fullscreen){display:flex;flex-direction:column;width:100vw;max-width:none;height:100vh;height:100dvh;margin:0;border:0;border-radius:0;box-shadow:none}
.home-game-player:-webkit-full-screen{display:flex;flex-direction:column;width:100vw;max-width:none;height:100vh;margin:0;border:0;border-radius:0}
.home-game-player:is(:fullscreen,.fake-fullscreen) .home-game-screen{flex:1 1 auto;height:auto;min-height:0}
.home-game-player:-webkit-full-screen .home-game-screen{flex:1 1 auto;height:auto;min-height:0}
.home-game-player:is(:fullscreen,.fake-fullscreen) .home-game-bar{display:none}
.home-game-player:-webkit-full-screen .home-game-bar{display:none}
.home-game-player.fake-fullscreen{position:fixed;z-index:2147483647;inset:0}
body.home-game-is-fullscreen{overflow:hidden;overscroll-behavior:none}
/* Touch devices: no keyboard hint; portrait leaves room for the joystick under the canvas */
@media (pointer:coarse){
    .home-game-help{display:none}
    .home-game-bar{display:none} /* touch: the game has its own buttons; nothing to show here */
}
@media (pointer:coarse) and (orientation:portrait){
    .home-game-screen{height:min(calc(100svh - 64px),calc((100vw - 2px) * 1.29 + 200px))}
}
@media (pointer:coarse) and (orientation:landscape){
    .home-game-screen{height:calc(100svh - 58px);min-height:280px}
}
@media(max-width:600px){
    .pacman-home .home-game{margin:0 -12px 28px}
    .pacman-home .home-game-title{padding:0 12px}
    .home-game-player{border-right:0;border-left:0;border-radius:0}
    .home-game-start{padding:20px 16px}
    .home-game-poster{margin:22px 0 24px;padding:10px 0}
    .home-game-start .game-play-button{width:min(200px,100%);min-height:56px;font-size:14px;letter-spacing:.1em}
    .home-game-note{margin-top:14px;font-size:12px}
}
@media (prefers-reduced-motion:reduce){
    .home-game-start .game-play-button{transition:none}
    .home-game-start.is-loading .game-play-button:disabled{animation:none}
}

/* Score submission status: a small badge to the right of the "Your Recent Games" title
   (the header also carries the sign-in state and CSRF token for /_js/home-game.js) */
.home-board-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;margin:0 0 10px;flex-direction: column;}
.pacman-home .home-board-head .home-board-title{flex:none;margin:0}
.home-game-score-status{min-width:0;max-width:58%;margin:2px 0 0;padding:4px 9px;border-radius:6px;background:var(--surface2);color:var(--text2);font:600 12px/1.35 var(--body);text-align:right}
.home-game-score-status:empty{display:none}
.home-game-score-status.is-best{color:var(--yellow)}
.home-game-score-status.is-error{color:var(--red)}

/* Game + score sidebar: side by side on wide screens, stacked below the game otherwise */
.home-arena{display:grid;gap:20px;align-items:start;max-width:var(--game-max);margin:0 auto}
.home-arena-main{min-width:0}
@media(min-width:1100px){
    .home-arena{grid-template-columns:minmax(0,var(--game-max)) 320px;max-width:calc(var(--game-max) + 340px)}
    /* not sticky: with the games list the sidebar is taller than the screen */
}
.home-board{display:grid;gap:14px;min-width:0}
.home-board-card{padding:14px 14px 12px;border:1px solid var(--line);border-radius:2px;}
.pacman-home .home-board-title{margin:0 0 10px;color:var(--text);font:600 18px/1.3 var(--head)}
.home-board-picker{display:flex;align-items:center;gap:10px;margin:0 0 10px}
.home-board-picker-label{flex:none;color:var(--muted);font:600 11px/1.2 var(--body);letter-spacing:.06em;text-transform:uppercase}
.home-board-select-wrap{position:relative;flex:1 1 auto;min-width:0}
.home-board-select-wrap::after{content:"";position:absolute;top:50%;right:12px;width:7px;height:7px;margin-top:-5px;border-right:2px solid var(--text2);border-bottom:2px solid var(--text2);transform:rotate(45deg);pointer-events:none}
.home-board-select{display:block;width:100%;min-height:36px;padding:6px 32px 6px 10px;border:1px solid var(--line);border-radius:6px;background:var(--surface2);color:var(--text);font:600 14px/1.2 var(--body);text-overflow:ellipsis;cursor:pointer;-webkit-appearance:none;appearance:none}
.home-board-select:hover{border-color:var(--text2)}
.home-board-select:focus-visible{outline:2px solid var(--focus-ring);outline-offset:1px}
.home-board-select option{background:var(--surface2);color:var(--text)}
.home-board-panel{min-height:120px;transition:opacity .15s ease}
.home-board-panel.is-loading{opacity:.5}
.home-board-table{width:100%;border-collapse:collapse;table-layout:fixed;font:500 14px/1.3 var(--body);font-variant-numeric:tabular-nums}
.home-board-table th{padding:0 6px 6px;border-bottom:1px solid var(--line);color:var(--muted);font:600 11px/1.2 var(--body);letter-spacing:.06em;text-align:left;text-transform:uppercase}
.home-board-table td{padding:7px 6px;border-bottom:1px solid var(--line);color:var(--text2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.home-board-table tbody tr:last-child td{border-bottom:0}
.home-board-table .col-rank{width:30px;padding-left:2px;color:var(--muted);font-weight:700;text-align:center}
.home-board-table .col-num{width:64px;text-align:right}
.home-board-table th.col-num{text-align:right}
.home-board-table .col-score{width:80px;color:var(--text);font-weight:700}
.home-board-table .col-name{color:var(--text)}
.home-board-table tr.is-top1 .col-rank{color:#ffd34d}
.home-board-table tr.is-top2 .col-rank{color:#c7d0dc}
.home-board-table tr.is-top3 .col-rank{color:#d9945a}
.home-board-table tr.is-me td{background:var(--brand-soft)}
.home-board-you{display:inline-block;margin-left:4px;padding:1px 5px;border-radius:4px;background:var(--brand-fill);color:var(--brand-on);font:700 10px/1.4 var(--body);vertical-align:1px}
.home-board-empty{margin:4px 0 2px;color:var(--text2);font:500 14px/1.5 var(--body)}
.home-board-empty[hidden]{display:none}
.home-recent{margin:0;padding:0;list-style:none}
.home-recent-item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 10px;padding:8px 2px;border-bottom:1px solid var(--line)}
.home-recent-item:last-child{border-bottom:0}
.home-recent-map{overflow:hidden;color:var(--text);font:600 14px/1.3 var(--body);text-overflow:ellipsis;white-space:nowrap}
.home-recent-score{color:var(--text);font:700 14px/1.3 var(--body);font-variant-numeric:tabular-nums;text-align:right}
.home-recent-meta{grid-column:1/-1;color:var(--muted);font:500 12px/1.3 var(--body)}
.home-recent-flag{color:var(--yellow)}
@media(max-width:600px){.home-board{padding:0 12px}}


/* Sign-in / sign-out inside the "Your Recent Games" card */
.home-board-account{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px;margin:0 0 6px;padding:0 0 10px;border-bottom:1px solid var(--line)}
.home-board-account-text{flex:1 1 180px;min-width:0;margin:0;color:var(--text2);font:500 13px/1.45 var(--body)}
.home-board-account-text strong{color:var(--text)}
.home-board-signout{flex:none;color:var(--accent);font:600 13px/1.45 var(--body)}
.home-board-signout:hover{text-decoration:underline;text-underline-offset:3px}
.home-board-google{display:flex;align-items:center;justify-content:center;gap:9px;width:100%;min-height:42px;margin:10px 0 2px;padding:0 14px;border:1px solid var(--line-dark);border-radius:999px;background:var(--surface2);color:var(--text);font:600 14px/1 var(--body)}
.home-board-google:hover{border-color:var(--accent);color:var(--accent)}
.home-board-google-g{display:grid;place-items:center;flex:none;width:20px;height:20px;border-radius:50%;background:#fff;color:#4285f4;font:700 13px/1 var(--body)}
/* "Top Pac-Man Games" in the sidebar: compact rows (thumbnail, name, year · platform) */
.home-games{display:grid;gap:2px;margin:0;padding:0;list-style:none}
.home-games-item{display:flex;align-items:center;gap:10px;padding:5px 4px;border-radius:6px;color:var(--text)}
.home-games-item:hover{background:var(--surface2)}
.home-games-item:hover .home-games-name{color:var(--accent)}
.home-games-item:focus-visible{outline:2px solid var(--focus-ring);outline-offset:1px}
.home-games-thumb{display:grid;place-items:center;flex:none;width:72px;height:48px;overflow:hidden;border:1px solid var(--line);border-radius:4px;background:#0c0c0a}
.home-games-thumb img{width:100%;height:100%;object-fit:contain}
.home-games-text{display:grid;gap:2px;min-width:0}
.home-games-name{overflow:hidden;font:600 14px/1.25 var(--head);text-overflow:ellipsis;white-space:nowrap}
.home-games-meta{color:var(--muted);font:600 11px/1.3 var(--head);letter-spacing:.35px;text-transform:uppercase}
/* Stacked below the game on medium screens: two columns of rows */
@media(min-width:560px) and (max-width:1099px){.home-games{grid-template-columns:1fr 1fr;column-gap:10px}}

/* Homepage header (_HTML_PAGES/header-home.html): on phones only the logo is shown, in a
   compact bar, so the game gets more height. Tablet and desktop keep the shared header. */
@media(max-width:600px){
    .home-header .header-inner{min-height:52px;padding-top:6px;padding-bottom:6px}
    .home-header .menu-toggle,
    .home-header .main-nav-mobile{display:none}
    .home-header .logo-img{width:36px;height:36px}
    .home-header .logo-text{font-size:20px}
    .home-header .logo-text small{margin-top:4px;font-size:9px}
}
