:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --card: #1f2430;
  --line: #2f3545;
  --text: #e8ecf1;
  --muted: #9da7b6;
  --brand: #61dafb;
  --brand-2: #35b3d4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top, #161b26 0%, var(--bg) 45%);
  color: var(--text);
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(8px);
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.region-nav {
  display: flex;
  gap: 10px;
  padding-bottom: 10px;
}

.region-link {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.region-link.active {
  border-color: var(--brand);
  color: var(--brand);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.lang-switcher {
  display: flex;
  align-items: center;
}

.lang-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #11141a;
  border-radius: 8px;
  padding: 6px 8px;
}

.lang-icon {
  width: 16px;
  height: 16px;
  fill: var(--muted);
}

.lang-select {
  width: auto;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0 18px 0 0;
  min-width: 108px;
  border-radius: 0;
  font-size: 16px;
}

.lang-select:focus {
  outline: none;
}

main.container {
  padding: 24px 0 32px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.hero p {
  margin: 0 0 20px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 220px 170px 180px;
  gap: 12px;
  margin-bottom: 20px;
}

.sticky-toolbar {
  position: sticky;
  top: 108px;
  z-index: 30;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(8px);
}

.region-entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.region-entry {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  font-weight: 600;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbar-field span {
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
}

.game-grid {
  display: grid;
  gap: 16px;
}

.game-grid.view-card {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.game-grid.view-list {
  grid-template-columns: 1fr;
}

.game-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
}

.game-link {
  color: inherit;
  text-decoration: none;
}

.game-grid.view-list .game-link {
  display: grid;
  grid-template-columns: 96px 1fr;
}

.game-cover-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #11151d;
}

.game-grid.view-list .game-cover-wrap {
  aspect-ratio: auto;
  height: 132px;
}

.game-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-cover-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.game-meta {
  padding: 12px;
}

.game-grid.view-list .game-meta {
  padding: 10px;
}

.game-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.game-platform {
  margin: 0;
  color: var(--brand);
  font-size: 0.88rem;
}

.game-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 38px;
}

.game-grid.view-list .game-desc {
  min-height: auto;
}

.view-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.view-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px;
  min-height: 40px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.view-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--muted);
}

.view-btn.active {
  border-color: var(--brand);
}

.view-btn.active svg {
  fill: var(--brand);
}

.pagination-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pager-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  color: var(--muted);
  min-width: 72px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.empty-state {
  margin-top: 16px;
  color: var(--muted);
}

.game-page .back-nav {
  margin-bottom: 16px;
}

.game-head h1 {
  margin: 0 0 8px;
}

.game-head p {
  margin: 0 0 10px;
  color: var(--muted);
}

.emulator-wrapper {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel);
}

.version-selector {
  margin-bottom: 10px;
}

#emulator-container {
  position: relative;
  width: 100%;
  min-height: 320px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.emulator-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  color: var(--text);
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.76);
}

.emulator-start-gate {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.84);
}

.emulator-start-btn {
  border: 1px solid #77c5ff;
  background: #0e5c8c;
  color: #f7fbff;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.emulator-start-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.emulator-start-tip {
  margin: 0;
  color: #c8d8ea;
  font-size: 0.9rem;
}

.emulator-loading.is-hidden {
  display: none;
}

.emulator-start-gate.is-hidden {
  display: none;
}

.controls {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--panel);
}

.controls h2 {
  margin-top: 0;
}

.controls ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.controls-list li {
  line-height: 1.8;
  margin-bottom: 4px;
}

.controls-list kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 0.08em 0.45em;
  margin: 0 0.15em;
  border: 1px solid #566174;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #202838;
  color: #f4f7fc;
  font-size: 0.86em;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  vertical-align: baseline;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 0 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .region-nav {
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .region-entry-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .sticky-toolbar {
    top: 96px;
    padding: 8px;
  }

  .game-grid.view-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .game-grid.view-card .game-meta {
    padding: 8px;
  }

  .game-grid.view-card .game-title {
    font-size: 0.92rem;
  }

  .game-grid.view-card .game-desc {
    font-size: 0.82rem;
    min-height: 0;
  }

  main.container {
    padding-top: 18px;
  }

  .game-page .controls {
    display: none;
  }
}
