:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #111111;
  --muted: #666666;
  --border: #e5e5e5;
  --accent: #111111;
  --radius: 12px;
  --header-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

#search-input {
  flex: 1;
  max-width: 360px;
  margin-left: auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--bg);
}

#search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.categories-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.categories-bar::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s, color 0.15s;
}

.category-pill:hover {
  color: var(--text);
}

.category-pill.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

@media (min-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

.game-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.game-card-thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--border);
  position: relative;
}

.game-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--text);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.game-card-info {
  padding: 0.65rem 0.75rem;
}

.game-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-card-category {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: capitalize;
  margin-top: 0.15rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

.game-toolbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.back-btn {
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
}

.back-btn:hover {
  color: var(--text);
}

.game-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fullscreen-btn {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.fullscreen-btn:hover {
  background: var(--bg);
}

.game-player-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

body.playing .site-footer {
  display: none;
}

body.playing #game-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: calc(100vh - var(--header-h));
}

body.playing .game-toolbar {
  max-width: none;
  flex-shrink: 0;
}

body.playing .game-player-wrap {
  max-width: none;
  width: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body.playing .game-frame-container {
  flex: 1;
  width: 100%;
  min-height: calc(100vh - var(--header-h) - 52px);
  display: flex;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

body.playing .game-frame-container iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - var(--header-h) - 52px);
  border: none;
}

body.playing .game-description,
body.playing .related-section {
  max-width: 1200px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

body.playing .game-description {
  flex-shrink: 0;
  padding-top: 1rem;
}

body.playing .related-section {
  flex-shrink: 0;
  padding-bottom: 2rem;
}

.game-frame-container {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  width: 100%;
}

.game-frame-container iframe {
  display: block;
  width: 100%;
  height: 75vh;
  min-height: 520px;
  border: none;
}

.game-frame-container:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border: none;
  border-radius: 0;
  display: flex;
  background: #000;
}

.game-frame-container:fullscreen iframe {
  width: 100%;
  height: 100%;
  min-height: 100%;
  flex: 1;
}

.game-description {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: pre-line;
}

.related-section {
  margin-top: 2rem;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--text);
}

.site-footer code {
  font-size: 0.85em;
  background: var(--border);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
