:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #080b12;
  --bg-band: #0d1320;
  --surface: #111827;
  --surface-strong: #172033;
  --surface-soft: #0f172a;
  --border: #263245;
  --border-strong: #334155;
  --text: #f8fafc;
  --muted: #b6c2d2;
  --faint: #8090a6;
  --primary: #22d3ee;
  --primary-text: #04131a;
  --control: #1e293b;
  --control-text: #e0f2fe;
  --shadow: 0 18px 42px rgba(0, 0, 0, .32);
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { min-height: 44px; cursor: pointer; }

:focus-visible {
  outline: 3px solid #22d3ee;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell { min-height: 100vh; }
.hero-band { background: var(--bg-band); color: var(--text); padding: 18px 16px 24px; border-bottom: 1px solid var(--border); }
.compact-hero { padding-top: 10px; padding-bottom: 10px; }
.top-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; margin-bottom: 20px; }
.compact-hero .top-nav { margin-bottom: 6px; }
.top-nav strong { min-width: 0; font-size: 20px; }
.top-nav span { min-width: 0; color: var(--muted); font-size: 14px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-content { display: grid; gap: 18px; }
.compact-hero .hero-content { gap: 0; }
.eyebrow { color: #5eead4; font-weight: 700; margin: 0 0 8px; }
h1, h2, h3, p { letter-spacing: 0; overflow-wrap: anywhere; }
h1 { font-size: 36px; line-height: 1; margin: 0 0 12px; }
.compact-hero h1 { max-width: 980px; font-size: clamp(22px, 5.2vw, 40px); line-height: 1.15; margin: 0; text-wrap: balance; }
.hero-title { display: block; }
h2 { margin: 0 0 12px; font-size: 22px; }
.hero-description { max-width: 48ch; margin: 8px 0 0; color: var(--muted); font-size: clamp(12px, 3vw, 15px); line-height: 1.5; overflow-wrap: normal; word-break: normal; }
.hero-copy { margin: 0; color: var(--muted); line-height: 1.5; }

.control-bar, .section-block, .detail-view { padding: 16px; }
.home-view .control-bar { padding-top: 12px; padding-bottom: 10px; }
.search-box input { width: 100%; min-height: 48px; border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; color: var(--text); background: var(--surface); }
.home-view .search-box input { min-height: 44px; }
.search-box input::placeholder { color: var(--faint); }
.category-row, .tag-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.category-row::-webkit-scrollbar, .tag-row::-webkit-scrollbar { display: none; }
.chip, .tag-row span { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 8px 12px; white-space: nowrap; }
.chip.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

.game-grid, .mini-row { display: grid; gap: 12px; }
.game-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.mini-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.game-card { display: grid; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.game-card:active { transform: translateY(1px); }
.featured-card { color: var(--text); }
.game-art { min-height: 116px; display: grid; place-items: center; overflow: hidden; background: linear-gradient(135deg, var(--accent), #1e293b); }
.game-art img { width: 100%; height: 100%; min-height: 116px; display: block; object-fit: cover; }
.game-art span { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: rgba(8, 13, 20, .58); color: #fff; font-size: 30px; font-weight: 900; }
.game-card-body { min-width: 0; padding: 12px; }
.game-category { color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.game-card h3 { margin: 6px 0; font-size: 17px; }
.game-card p { margin: 0; color: var(--muted); line-height: 1.4; }

.recent-block { padding-top: 10px; padding-bottom: 8px; }
.recent-block h2 { margin-bottom: 8px; font-size: 16px; }
.recent-list { display: grid; gap: 8px; }
.recent-card { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: rgba(17, 24, 39, .74); }
.recent-card:active { transform: translateY(1px); }
.recent-card .game-art { width: 64px; height: 64px; min-height: 64px; flex: 0 0 64px; border-radius: 6px; }
.recent-card .game-art img { min-height: 64px; }
.recent-card-body { min-width: 0; display: grid; gap: 2px; }
.recent-card-body span { color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.recent-card-body strong { min-width: 0; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-card-body small { color: var(--muted); font-size: 12px; }

.empty-state, .coming-soon, .not-found { padding: 28px 16px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.primary-button, .secondary-button, .control-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 0; border-radius: 8px; padding: 0 16px; font-weight: 800; }
.primary-button { background: var(--primary); color: var(--primary-text); }
.secondary-button, .control-button { background: var(--control); color: var(--control-text); border: 1px solid var(--border-strong); }

.back-link { display: inline-flex; min-height: 44px; align-items: center; font-weight: 800; }
.play-card { display: grid; gap: 14px; margin-bottom: 18px; }
.play-card p { color: var(--muted); line-height: 1.5; margin: 0 0 14px; }
.compact-detail-card { gap: 6px; margin-bottom: 12px; }
.compact-detail-card h1 { max-width: 100%; font-size: clamp(24px, 7vw, 42px); margin: 4px 0 8px; }
.compact-detail-card p { max-width: 680px; margin: 0; }
.game-host { position: relative; isolation: isolate; overflow: hidden; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); padding: 6px; margin-bottom: 18px; box-shadow: var(--shadow); }
.fullscreen-button { position: absolute; z-index: 20; top: 14px; right: 18px; display: grid; place-items: center; width: 46px; min-height: 46px; padding: 0; border: 1px solid rgba(248, 250, 252, .62); border-radius: 8px; color: #f8fafc; background: rgba(3, 6, 12, .86); box-shadow: 0 10px 28px rgba(0, 0, 0, .58), 0 0 18px rgba(34, 211, 238, .22), inset 0 0 18px rgba(255, 255, 255, .08); backdrop-filter: blur(10px); }
.fullscreen-button:active { transform: translateY(1px); }
.fullscreen-icon { width: 20px; height: 20px; display: block; color: currentColor; background:
  linear-gradient(currentColor, currentColor) left top / 9px 2px no-repeat,
  linear-gradient(currentColor, currentColor) left top / 2px 9px no-repeat,
  linear-gradient(currentColor, currentColor) right top / 9px 2px no-repeat,
  linear-gradient(currentColor, currentColor) right top / 2px 9px no-repeat,
  linear-gradient(currentColor, currentColor) left bottom / 9px 2px no-repeat,
  linear-gradient(currentColor, currentColor) left bottom / 2px 9px no-repeat,
  linear-gradient(currentColor, currentColor) right bottom / 9px 2px no-repeat,
  linear-gradient(currentColor, currentColor) right bottom / 2px 9px no-repeat; }
.fullscreen-button[data-fullscreen-active="true"] .fullscreen-icon { transform: scale(.82); }
.game-host:fullscreen { width: 100vw; height: 100vh; padding: 0; border: 0; border-radius: 0; background: #05060b; }
.game-host:fullscreen .game-root { min-height: 100vh; }
.game-host:fullscreen .game-panel { min-height: 100vh; align-content: center; padding: 16px; }
.game-host:fullscreen .game-canvas { max-height: none; }
.game-host:fullscreen .lottery-machine-shell,
.game-host:fullscreen .lottery-machine-frame,
.game-host:fullscreen .ball-fighter-shell,
.game-host:fullscreen .ball-fighter-frame { height: 100vh; border-radius: 0; }
.game-root { min-height: 320px; }
.game-root .inline-soon { padding: 24px 0; border: 0; background: transparent; }
.game-root .inline-soon h3 { margin: 0 0 8px; }
.game-root .inline-soon p { margin: 0; color: var(--muted); line-height: 1.5; }
.lottery-machine-shell { overflow: hidden; border-radius: 8px; border: 1px solid rgba(255, 79, 175, .28); background: #05060b; box-shadow: 0 24px 80px rgba(0, 0, 0, .38); }
.lottery-machine-frame { display: block; width: 100%; height: clamp(640px, 78dvh, 820px); border: 0; background: #05060b; }
.ball-fighter-shell { overflow: hidden; border-radius: 8px; border: 1px solid rgba(255, 59, 47, .34); background: #05060b; box-shadow: 0 24px 80px rgba(0, 0, 0, .38); }
.ball-fighter-frame { display: block; width: 100%; height: clamp(640px, 78dvh, 820px); border: 0; background: #05060b; }
.game-seo-block { padding: 0; margin: 0 0 18px; }
.game-seo-block h2 { margin-bottom: 8px; font-size: 18px; }
.game-seo-block p { max-width: 760px; margin: 0 0 12px; color: var(--muted); line-height: 1.55; }
.game-seo-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.game-seo-list li { border: 1px solid var(--border); border-radius: 999px; padding: 8px 10px; color: var(--control-text); background: var(--surface-soft); font-size: 13px; font-weight: 800; }
.related-block { padding-left: 0; padding-right: 0; }

.game-panel { display: grid; gap: 12px; }
.game-canvas { width: 100%; max-height: 58vh; border-radius: 8px; background: #101827; touch-action: manipulation; }
.game-controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.timing-track { position: relative; height: 72px; border-radius: 8px; background: var(--surface-strong); overflow: hidden; }
.target-zone { position: absolute; left: 43%; width: 14%; top: 0; bottom: 0; background: rgba(34, 197, 94, .45); }
.timing-marker { position: absolute; top: 8px; bottom: 8px; width: 10px; transform: translateX(-50%); border-radius: 999px; background: #f8fafc; }
.timing-readout { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timing-tap { min-height: 72px; font-size: 22px; }

.dungeon-game { --tile-size: min(11vw, 54px); }
.dungeon-hud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dungeon-hud span { min-height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-soft); border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 800; text-align: center; padding: 4px; }
.dungeon-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; width: min(100%, 420px); margin: 0 auto; padding: 8px; border-radius: 8px; background: #111827; }
.dungeon-tile { aspect-ratio: 1; min-width: 0; display: grid; place-items: center; border-radius: 6px; background: #1f2a3d; color: #e5e7eb; font-weight: 900; font-size: 18px; line-height: 1; }
.dungeon-tile.wall { background: #334155; color: #cbd5e1; }
.dungeon-tile.player { background: #14b8a6; color: #042f2e; }
.dungeon-tile.enemy { background: #fb7185; color: #4c0519; }
.dungeon-tile.gem { background: #fde047; color: #422006; }
.dungeon-tile.exit { background: #cbd5e1; color: #334155; }
.dungeon-tile.exit.open { background: #86efac; color: #052e16; }
.dungeon-status { min-height: 44px; margin: 0; display: grid; align-items: center; color: var(--muted); line-height: 1.4; }
.dungeon-pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: ". up ." "left down right"; gap: 8px; }
.dungeon-pad .up { grid-area: up; }
.dungeon-pad .left { grid-area: left; }
.dungeon-pad .right { grid-area: right; }
.dungeon-pad .down { grid-area: down; }

.orbit-game { gap: 12px; }
.orbit-hud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.orbit-hud span { min-height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-soft); border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 800; text-align: center; padding: 4px; }
.orbit-scene { width: 100%; min-height: 220px; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #07111f; touch-action: pan-y; }
.orbit-scene canvas { display: block; width: 100%; height: 100%; }
.orbit-status { min-height: 44px; margin: 0; display: grid; align-items: center; color: var(--muted); line-height: 1.4; }
.orbit-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.game-panel.neon-drift-game { display: grid; gap: 12px; padding: 14px; border: 1px solid rgba(34, 211, 238, 0.28); border-radius: 8px; background: #080b1f; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4); }
.neon-drift-hud { display: grid; grid-template-columns: 1fr 0.8fr 1.2fr; gap: 8px; align-items: center; }
.neon-drift-hud span { min-width: 0; padding: 8px 10px; border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 8px; color: #e0f2fe; background: rgba(15, 23, 42, 0.72); font-size: 0.9rem; line-height: 1.2; text-align: center; }
.neon-drift-scene { width: 100%; aspect-ratio: 4 / 5; min-height: 360px; overflow: hidden; border: 1px solid rgba(168, 85, 247, 0.28); border-radius: 8px; background: radial-gradient(circle at 50% 15%, rgba(34, 211, 238, 0.26), transparent 28%), linear-gradient(180deg, #11143a 0%, #050816 100%); touch-action: none; }
.neon-drift-scene canvas { display: block; width: 100%; height: 100%; }
.neon-drift-game .neon-drift-restart { min-height: 48px; border: 1px solid rgba(34, 211, 238, 0.4); border-radius: 8px; color: #ecfeff; background: rgba(14, 116, 144, 0.24); cursor: pointer; }
.neon-drift-game .neon-drift-restart:focus-visible { outline: 3px solid #22d3ee; outline-offset: 2px; }

@media (min-width: 760px) {
  .hero-band, .control-bar, .section-block, .detail-view { padding-left: max(24px, calc((100vw - 1080px) / 2)); padding-right: max(24px, calc((100vw - 1080px) / 2)); }
  .hero-content { grid-template-columns: minmax(0, 1fr) 360px; align-items: end; }
  .compact-hero .hero-content { grid-template-columns: 1fr; }
  .hero-description { max-width: none; white-space: nowrap; }
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .play-card { grid-template-columns: 280px minmax(0, 1fr); align-items: center; }
  .compact-detail-card { grid-template-columns: 1fr; align-items: start; }
  .related-block { padding-left: 0; padding-right: 0; }
  .dungeon-hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .orbit-hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .orbit-scene { max-height: 520px; }
}

@media (max-width: 760px) {
  .fullscreen-button { right: auto; left: min(calc(100% - 64px), 310px); }
}

@media (max-width: 759px) {
  .hero-description { white-space: normal; }
}

@media (max-width: 430px) {
  .top-nav span { display: none; }
  .game-panel.neon-drift-game { padding: 10px; }
  .neon-drift-hud { grid-template-columns: 1fr; }
  .neon-drift-scene { min-height: 330px; }
}
