:root {
  --radius: 0.75rem; --background: oklch(0.99 0.005 240); --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0); --muted: oklch(0.965 0.005 240); --muted-foreground: oklch(0.52 0 0);
  --accent: oklch(0.95 0.01 240); --border: oklch(0.9 0.005 240); --input: oklch(0.9 0.005 240);
  --emerald: #059669; --emerald-hover: #047857; --emerald-soft: rgba(16, 185, 129, .12);
  --rose: #e11d48;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px -4px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px -12px rgba(0,0,0,.18), 0 4px 8px -4px rgba(0,0,0,.08);
}
[data-theme="dark"] {
  --background: oklch(0.13 0.005 240); --foreground: oklch(0.97 0 0); --card: oklch(0.175 0.006 240);
  --muted: oklch(0.245 0.006 240); --muted-foreground: oklch(0.66 0 0); --accent: oklch(0.27 0.006 240);
  --border: rgba(255,255,255,.09); --input: rgba(255,255,255,.13);
  --emerald: #10b981; --emerald-hover: #059669; --rose: #f43f5e;
  --shadow: 0 1px 2px rgba(0,0,0,.2); --shadow-md: 0 4px 12px -4px rgba(0,0,0,.4);
  --shadow-lg: 0 16px 40px -16px rgba(0,0,0,.6), 0 4px 8px -4px rgba(0,0,0,.3);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
html, body { height: 100%; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--background); color: var(--foreground); line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column; transition: background .2s, color .2s;
}
button, [role="button"], a[href], summary, label[for], .clickable { cursor: pointer }
a { color: inherit; text-decoration: none } img { display: block; max-width: 100% }
input, textarea { font-family: inherit }
.scrollbar-thin { scrollbar-width: thin; scrollbar-color: var(--border) transparent }
.scrollbar-thin::-webkit-scrollbar { height: 8px; width: 8px }
.scrollbar-thin::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent }

.header { position: sticky; top: 0; z-index: 40; width: 100%; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--background) 80%, transparent); backdrop-filter: blur(12px); flex-shrink: 0; }
.header-inner { max-width: 80rem; margin: 0 auto; display: flex; align-items: center; gap: .5rem; height: 4rem; padding: 0 1rem; }
@media(min-width:640px) { .header-inner { gap: 1rem; padding: 0 1.5rem } }
@media(min-width:1024px) { .header-inner { padding: 0 2rem } }
.logo-btn { display: flex; align-items: center; gap: .625rem; padding: .25rem .5rem .25rem .25rem; border-radius: .5rem; border: none; background: none }
.logo-badge { width: 2.25rem; height: 2.25rem; border-radius: .5rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--emerald); overflow: hidden; }
.logo-text { display: none; font-size: 1rem; font-weight: 700; letter-spacing: -.02em; color: var(--foreground) }
@media(min-width:640px) { .logo-text { display: inline } }
.nav { display: flex; align-items: center; gap: .125rem; border: 1px solid var(--border); background: var(--muted); border-radius: .5rem; padding: .125rem; }
.nav-btn { position: relative; display: inline-flex; align-items: center; gap: .375rem; border: none; background: none; border-radius: .375rem; padding: .4375rem .75rem; font-size: .875rem; font-weight: 550; color: var(--muted-foreground); transition: color .15s, background .15s; }
@media(min-width:640px) { .nav-btn { padding: .4375rem .875rem } }
.nav-btn:hover { color: var(--foreground) }
.nav-btn.active { background: var(--card); color: var(--foreground); box-shadow: var(--shadow) }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1rem; height: 1rem; padding: 0 .25rem; border-radius: 99px; background: var(--emerald); color: #fff; font-size: .65rem; font-weight: 700; line-height: 1; }
.search-wrap { position: relative; flex: 1; display: none; align-items: center }
@media(min-width:768px) { .search-wrap { display: flex } }
.search-icon { position: absolute; left: .75rem; width: 1rem; height: 1rem; color: var(--muted-foreground); pointer-events: none }
.search-input { width: 100%; height: 2.5rem; border-radius: .5rem; border: 1px solid var(--border); background: var(--muted); padding: 0 .75rem 0 2.25rem; font-size: .875rem; color: var(--foreground); transition: background .15s; }
.search-input:focus { outline: none; background: var(--card) }
.search-input::placeholder { color: var(--muted-foreground) }
.mobile-search { display: block; border-top: 1px solid var(--border); padding: .625rem 1rem }
@media(min-width:768px) { .mobile-search { display: none } }
.mobile-search .search-wrap { display: flex }
.icon-btn { width: 2.25rem; height: 2.25rem; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: .5rem; border: 1px solid var(--border); background: var(--card); color: var(--foreground); transition: all .15s; }
.icon-btn:hover { background: var(--accent) }
.spacer-flex { flex: 1 }
@media(min-width:768px) { .spacer-flex { display: none } }

.main { flex: 1 0 auto; min-height: 0; display: flex; flex-direction: column; }
.container { max-width: 80rem; margin: 0 auto; padding: 2rem 1rem; width: 100%; }
@media(min-width:640px) { .container { padding: 2.5rem 1.5rem } }
@media(min-width:1024px) { .container { padding: 2.5rem 2rem } }
.section-title { margin-bottom: 1rem }
.eyebrow { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground) }
.section-title h2 { margin-top: .375rem; font-size: 1.25rem; font-weight: 800; letter-spacing: -.025em }

.hero { position: relative; overflow: hidden; border-radius: 1rem; border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-md); margin-bottom: 2.5rem; }
.hero-grid { display: grid; grid-template-columns: 1fr }
@media(min-width:768px) { .hero-grid { grid-template-columns: 1fr 1fr } }
.hero-img-wrap { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--muted) }
@media(min-width:768px) { .hero-img-wrap { aspect-ratio: auto; min-height: 360px } }
.hero-img-wrap img { width: 100%; height: 100%; object-fit: cover }
.hero-badge { position: absolute; left: .75rem; top: .75rem; border-radius: .375rem; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.6); padding: .25rem .625rem; font-size: .75rem; font-weight: 600; color: #fff; backdrop-filter: blur(6px); display: inline-flex; align-items: center; }
.hero-body { display: flex; flex-direction: column; justify-content: center; gap: 1rem; padding: 1.75rem 1.5rem }
@media(min-width:640px) { .hero-body { padding: 2.25rem } }
.hero-eyebrow { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--emerald) }
.hero-body h2 { font-size: 1.625rem; font-weight: 800; letter-spacing: -.025em; line-height: 1.15 }
.hero-body p.desc { color: var(--muted-foreground); max-width: 60ch; line-height: 1.6 }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding-top: .5rem }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; white-space: nowrap; border-radius: .5rem; font-size: .875rem; font-weight: 550; padding: .5rem 1rem; border: none; transition: background .15s, color .15s, transform .1s, box-shadow .15s; height: 2.25rem; }
.btn:active { transform: translateY(1px) }
.btn-sm { height: 2rem; padding: .375rem .75rem; font-size: .875rem }
.btn-lg { height: 2.625rem; padding: .5rem 1.5rem; font-size: .95rem; font-weight: 600; border-radius: .625rem }
.btn-primary { background: var(--emerald); color: #fff } .btn-primary:hover { background: var(--emerald-hover) }
.btn-outline { border: 1px solid var(--border); background: var(--card); color: var(--foreground) } .btn-outline:hover { background: var(--accent) }
.btn-ghost { background: none; color: var(--muted-foreground) } .btn-ghost:hover { background: var(--accent); color: var(--foreground) }
.btn-emerald { background: var(--emerald); color: #fff; box-shadow: var(--shadow-md) } .btn-emerald:hover { background: var(--emerald-hover) }
.muted-sm { font-size: .875rem; color: var(--muted-foreground) }

.grid-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem }
@media(min-width:640px) { .grid-header { flex-direction: row; align-items: flex-end; justify-content: space-between } }
.grid-header h2 { font-size: 1.375rem; font-weight: 800; letter-spacing: -.025em }
.grid-header p { margin-top: .25rem; font-size: .875rem; color: var(--muted-foreground) }
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem }
.chip { flex-shrink: 0; border-radius: 99px; border: 1px solid var(--border); background: var(--card); padding: .4375rem .9375rem; font-size: .875rem; font-weight: 550; color: var(--muted-foreground); transition: all .15s; }
.chip:hover { color: var(--foreground) }
.chip.active { background: var(--foreground); border-color: var(--foreground); color: var(--background) }

.game-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; align-items: start; }
@media(min-width:640px) { .game-grid { grid-template-columns: repeat(2, 1fr) } }
@media(min-width:1024px) { .game-grid { grid-template-columns: repeat(3, 1fr) } }
@media(min-width:1280px) { .game-grid { grid-template-columns: repeat(4, 1fr) } }

.game-card { position: relative; display: flex; flex-direction: column; overflow: hidden; border-radius: .75rem; border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-thumb { position: relative; aspect-ratio: 16/9; width: 100%; overflow: hidden; background-color: var(--muted); border: none; padding: 0; display: flex; align-items: center; justify-content: center; }
.card-thumb::before { content: ""; position: absolute; width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--emerald); border-radius: 50%; animation: spin 1s linear infinite; opacity: 0.6; z-index: 0; }
.card-thumb.img-failed::before { display: none; }
.card-thumb.img-failed::after { content: "No Preview"; font-size: 0.875rem; color: var(--muted-foreground); z-index: 1; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; position: relative; z-index: 1; }
.game-card:hover .card-thumb img { transform: scale(1.04) }
.card-genre { position: absolute; left: .625rem; top: .625rem; border-radius: .375rem; border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.55); padding: .125rem .5rem; font-size: .7rem; font-weight: 500; color: #fff; backdrop-filter: blur(4px); z-index: 2; }
.card-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .2s; z-index: 2; }
.game-card:hover .card-play { opacity: 1 }
.card-play span { display: inline-flex; align-items: center; gap: .375rem; border-radius: 99px; background: var(--emerald); padding: .5rem 1.25rem; font-size: .875rem; font-weight: 600; color: #fff; box-shadow: var(--shadow-lg); }
.fav-btn { position: absolute; right: .625rem; top: .625rem; z-index: 5; width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 99px; border: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.45); color: rgba(255,255,255,.9); backdrop-filter: blur(4px); transition: all .15s; }
.fav-btn:hover { background: rgba(0,0,0,.65) }
.fav-btn.active { background: var(--rose); color: #fff; }
.card-body { display: flex; flex-direction: column; gap: .375rem; padding: 1rem; flex: 1 }
.card-body h3 { font-size: .95rem; font-weight: 650; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.card-body p { font-size: .875rem; color: var(--muted-foreground); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5 }
.game-card.bio-expanded .card-body p { -webkit-line-clamp: 999; }
.card-more-btn { margin-top: auto; padding-top: .5rem; align-self: flex-start; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; border-radius: 1rem; border: 1px dashed var(--border); background: var(--muted); padding: 4rem 1.5rem; text-align: center; }
.empty h3 { font-size: 1.125rem; font-weight: 700 }
.empty p { font-size: .875rem; color: var(--muted-foreground); max-width: 28rem; line-height: 1.6 }

.recent-row { display: flex; gap: 1rem; overflow-x: auto; padding: 0 .25rem .75rem; margin: 0 -.25rem; align-items: flex-start; }
.recent-row .game-card { width: 16rem; flex-shrink: 0; }

.player-wrap { height: calc(100vh - 4rem); display: flex; flex-direction: column; }
.player-bar { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); background: var(--card); padding: .625rem 1rem; }
.player-title { flex: 1; min-width: 0; font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.player-stage { position: relative; flex: 1; background: #09090b }
.player-stage:fullscreen { width: 100vw; height: 100vh; }
.player-frame { width: 100%; height: 100%; border: 0 }
.player-btn { display: inline-flex; align-items: center; gap: .375rem; border: 1px solid var(--border); background: var(--card); border-radius: .375rem; padding: .375rem .5rem; font-size: .875rem; color: var(--foreground); transition: all .15s; }
.player-btn:hover { background: var(--accent) }

.code-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; border-radius: .75rem; border: 1px solid var(--border); background: var(--card); box-shadow: var(--shadow-md); margin: 1rem; }
.code-toolbar { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); background: var(--muted); padding: .5rem .75rem; flex-wrap: wrap }
.code-toolbar-title { display: flex; align-items: center; gap: .5rem; font-size: .875rem; font-weight: 650; color: var(--foreground) }
.code-toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: .25rem }
.code-divider { width: 1px; height: 1.25rem; background: var(--border); margin: 0 .25rem }
.code-body { flex: 1; overflow: hidden; display: flex; flex-direction: row; min-height: 0 }
.code-editors { display: flex; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden }
.code-editors.horizontal { flex-direction: row }
.code-editors.vertical { flex-direction: column }
.editor-panel { display: flex; flex-direction: column; overflow: hidden; min-width: 0; min-height: 0; background: var(--card); flex: 1 1 0 }
.editor-header { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); padding: .375rem .75rem; background: var(--muted) }
.editor-dot { width: .5rem; height: .5rem; border-radius: 99px; flex-shrink: 0 }
.editor-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground) }
.editor-host { position: relative; flex: 1; overflow: hidden; min-height: 0; min-width: 0; background: var(--cm-bg, #fff) }
.editor-host .CodeMirror { position: absolute; inset: 0; height: 100%; font-family: ui-monospace, "SF Mono", Monaco, monospace; font-size: 13px; line-height: 1.6 }
.editor-host>textarea { display: none }
.splitter { flex: 0 0 6px; background: var(--border); position: relative; z-index: 6; transition: background .12s }
.splitter.col { cursor: col-resize } .splitter.row { cursor: row-resize }
.splitter::before { content: ""; position: absolute; inset: -4px }
.splitter:hover, .splitter.dragging { background: var(--emerald) }
.preview-panel { display: flex; flex-direction: column; background: #fff; flex: 1 1 0; min-width: 0; min-height: 0 }
.preview-bar { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid #e4e4e7; background: #f4f4f5; padding: .375rem .75rem }
.preview-dots { display: flex; gap: .375rem }
.preview-dots span { width: .625rem; height: .625rem; border-radius: 99px }
.preview-label { margin-left: .5rem; font-size: .75rem; font-weight: 500; color: #71717a }
.preview-frame { flex: 1; border: none; background: #fff; width: 100%; min-height: 0 }
.CodeMirror { font-family: ui-monospace, "SF Mono", Monaco, monospace !important; font-size: 13px !important; line-height: 1.6 !important; height: 100% }
.CodeMirror-matchingbracket { font-weight: 700; text-decoration: underline; text-decoration-color: var(--emerald) !important }
.CodeMirror-placeholder { opacity: .55; font-style: italic }

.footer { margin-top: auto; border-top: 1px solid var(--border); background: var(--muted); flex-shrink: 0; }
.footer-inner { max-width: 80rem; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.5rem 1rem; font-size: .875rem; color: var(--muted-foreground) }
@media(min-width:640px) { .footer-inner { flex-direction: row; padding: 1.5rem 1.5rem } }
.footer-brand { display: flex; align-items: center; gap: .5rem }
.footer-badge { width: 1.5rem; height: 1.5rem; border-radius: .375rem; display: flex; align-items: center; justify-content: center; background: transparent; color: var(--emerald); overflow: hidden }
.footer-brand strong { color: var(--foreground); font-weight: 600 }
.footer-sep { margin: 0 .375rem; opacity: .5 }
.hidden { display: none !important }
@keyframes spin { to { transform: rotate(360deg) } }
