/* games.haldaman.io: the site's look, self-contained */
@font-face { font-family: "Geist"; src: url("/fonts/geist.woff2") format("woff2"); font-weight: 400 800; font-style: normal; font-display: block; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono.woff2") format("woff2"); font-weight: 400 500; font-style: normal; font-display: block; }
:root {
  --bg: #151D27; --bg-2: #1C2632; --panel: rgba(255,255,255,.03); --line: rgba(255,255,255,.10);
  --text: #F4F6F8; --muted: #A3ADB8;
  --green: #4ADE80; --cyan: #5BCFE6; --pink: #EC4899; --amber: #F7C873;
  --grad: linear-gradient(90deg, var(--green), var(--cyan));
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  color: var(--text); font-family: "Geist", system-ui, sans-serif; font-size: 1.0625rem; line-height: 1.6; -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0), radial-gradient(900px 500px at 15% 0%, rgba(74,222,128,.10), transparent 70%), linear-gradient(135deg, #13232B 0%, #161C28 50%, #1E1A2D 100%);
  background-size: 28px 28px, auto, auto; background-attachment: scroll, fixed, fixed;
}
main { flex: 1; width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 4px; }
.g { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 700px) { .wrap { padding: 0 18px; } }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
code { font-family: var(--mono); font-size: .9em; }

/* Header */
/* Header: brand row, then the tab bar. The active tab's underline slides to the new tab between pages. */
header.top { position: sticky; top: 0; z-index: 10; background: rgba(17,26,34,.82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); view-transition-name: site-header; }
.bar { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.ext { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; margin-right: -10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .9rem; white-space: nowrap; transition: color .2s, background .2s; }
.ext:hover { color: var(--text); background: rgba(255,255,255,.05); }
.ext svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs .tab-row { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs .tab-row::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; display: flex; align-items: center; height: 46px; padding: 0 16px; border-radius: 9px 9px 0 0; color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500; white-space: nowrap; transition: color .2s, background .2s; -webkit-tap-highlight-color: transparent; }
.tab:first-child { margin-left: -16px; }
.tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab:active { background: rgba(255,255,255,.07); }
.tab[aria-current] { color: var(--text); }
.tab .ink { position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--grad); transform: scaleX(0); opacity: 0; transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.tab:hover .ink { transform: scaleX(.35); opacity: .45; }
.tab[aria-current] .ink { transform: none; opacity: 1; view-transition-name: tab-ink; }
.tab:focus-visible { outline-offset: -3px; }
@media (max-width: 700px) {
  .bar { height: 54px; }
  .tabs .tab-row { padding: 0 18px; margin: 0; max-width: none; }
  .tab { height: 44px; padding: 0 13px; font-size: .92rem; }
  .tab:first-child { margin-left: -13px; }
}

/* Moving between tabs: same-site page changes animate (browsers without view transitions just navigate). */
@view-transition { navigation: auto; }
main { view-transition-name: page; }
::view-transition-group(tab-ink) { animation-duration: .38s; animation-timing-function: cubic-bezier(.2,.8,.2,1); }
::view-transition-old(root), ::view-transition-new(root), ::view-transition-new(site-header) { animation: none; }
::view-transition-old(site-header) { display: none; }
::view-transition-old(page) { animation: page-out .12s ease-in both; }
::view-transition-new(page) { animation: page-in .32s cubic-bezier(.2,.8,.2,1) .1s both; }
html:active-view-transition-type(forward)::view-transition-old(page) { animation-name: page-out-left; }
html:active-view-transition-type(forward)::view-transition-new(page) { animation-name: page-in-right; }
html:active-view-transition-type(back)::view-transition-old(page) { animation-name: page-out-right; }
html:active-view-transition-type(back)::view-transition-new(page) { animation-name: page-in-left; }
@keyframes page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes page-out-left { to { opacity: 0; transform: translateX(-28px); } }
@keyframes page-out-right { to { opacity: 0; transform: translateX(28px); } }
@keyframes page-in-right { from { opacity: 0; transform: translateX(36px); } }
@keyframes page-in-left { from { opacity: 0; transform: translateX(-36px); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .tab .ink, .tab { transition: none; }
}
.brand { font-weight: 600; letter-spacing: .02em; text-decoration: none; font-size: 1.15rem; line-height: 1.15; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand .bk { display: inline-flex; flex-direction: column; gap: 4px; }
.brand .ln { display: flex; align-items: center; height: 8px; }
.brand .wv { flex: none; width: 22px; height: 8px; fill: none; stroke: var(--amber); stroke-width: 2; stroke-linecap: round; }
.brand .ln i:first-of-type { flex: 1; height: 2px; margin-left: -1px; background: var(--green); border-radius: 1px; }
.brand .ln i:last-of-type { flex: none; width: 7px; height: 7px; margin-left: 3px; border-radius: 50%; background: var(--pink); }
.brand .sub { font-family: var(--mono); font-size: .8rem; font-weight: 500; letter-spacing: 0; color: var(--muted); padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 360px) { .brand .sub { display: none; } }

footer { border-top: 1px solid var(--line); padding: 32px 0 40px; color: var(--muted); font-size: .9rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
footer a { color: var(--cyan); text-decoration: none; }

/* Shared */
.head { padding: 72px 0 32px; }
.head .kicker { font-family: var(--mono); font-size: .85rem; color: var(--cyan); }
.head h1 { margin: 12px 0 0; font-size: clamp(2.1rem, 5.2vw, 3.4rem); line-height: 1.08; letter-spacing: -.035em; font-weight: 800; }
.head p { margin: 16px 0 0; color: var(--muted); font-size: 1.12rem; max-width: 60ch; }
@media (max-width: 700px) { .head { padding: 44px 0 22px; } }
.btn { display: inline-block; padding: 11px 22px; border-radius: 10px; text-decoration: none; cursor: pointer; border: 2px solid var(--green); color: var(--green); font: inherit; font-weight: 500; background: rgba(74,222,128,.06); transition: background .2s, box-shadow .2s; }
.btn:hover { background: rgba(74,222,128,.12); box-shadow: 0 0 22px -4px rgba(74,222,128,.5); }
.btn.ghost { border-color: var(--line); color: var(--text); background: none; }
.btn.ghost:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: none; }
.btn.small { padding: 7px 14px; font-size: .9rem; border-width: 1px; }
.panel { position: relative; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
@media (max-width: 560px) { .panel { padding: 16px 14px; } }
.cta { margin: 56px 0 72px; padding: 26px; border-radius: 10px; border: 1px solid rgba(236,72,153,.45); background: linear-gradient(135deg, rgba(236,72,153,.10), rgba(91,207,230,.04)); display: flex; justify-content: space-between; align-items: center; gap: 18px 32px; flex-wrap: wrap; }
.cta h2 { margin: 0; font-size: 1.3rem; letter-spacing: -.02em; }
.cta p { margin: 6px 0 0; color: var(--muted); max-width: 52ch; }
.toast { position: fixed; left: 50%; top: 82px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; z-index: 20; padding: 10px 16px; border-radius: 8px; background: #0F161E; border: 1px solid rgba(74,222,128,.55); color: var(--green); font-size: .92rem; font-weight: 500; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Landing */
.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin: 0; padding: 0; list-style: none; }
@media (max-width: 1000px) { .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .game-grid { grid-template-columns: minmax(0, 1fr); } }
.game-card a { display: flex; flex-direction: column; height: 100%; padding: 26px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); text-decoration: none; transition: border-color .2s, box-shadow .2s; }
.game-card a:hover { border-color: rgba(91,207,230,.6); box-shadow: 0 0 30px -12px var(--cyan); }
.game-card .tag { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.game-card h2 { margin: 10px 0 0; font-size: 1.5rem; letter-spacing: -.02em; }
.game-card a:hover h2 { color: var(--green); }
.game-card p { margin: 8px 0 0; color: var(--muted); flex: 1; }
.game-card .best { margin-top: 18px; font-family: var(--mono); font-size: .82rem; color: var(--muted); }
.game-card .go { margin-top: 14px; font-family: var(--mono); font-size: .85rem; font-weight: 500; color: var(--cyan); }
.preview { margin-top: 18px; height: 110px; border-radius: 8px; background: #0F161E; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.preview svg { width: 100%; height: 100%; }
.pv-code { font-family: var(--mono); font-size: .8rem; line-height: 1.7; color: #CFD8E0; padding: 10px 14px; width: 100%; }
.pv-code span { display: block; padding: 0 6px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-code .hit { background: rgba(247,200,115,.16); box-shadow: inset 2px 0 0 var(--amber); }

/* Game chrome shared by both games */
.hud { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 0 0 14px; font-family: var(--mono); font-size: .86rem; color: var(--muted); }
.hud b { color: var(--text); font-weight: 500; }
.hud .sp { flex: 1; }
.msg { min-height: 1.6em; margin: 12px 0 0; font-size: .95rem; }
.msg.ok { color: var(--green); } .msg.bad { color: #FBDDA6; }
.overlay { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 20px; border-radius: 10px; background: rgba(15,22,30,.92); text-align: center; }
.overlay .card { max-width: 440px; }
.overlay h2 { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }
.overlay p { margin: 10px 0 0; color: var(--muted); }
.overlay .acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.stars { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.stars svg { width: 30px; height: 30px; fill: #3A4756; }
.stars svg.on { fill: var(--green); }
