:root {
  color-scheme: dark;
  --bg: #10131a;
  --panel: #181d29;
  --panel-2: #202738;
  --text: #eef2ff;
  --muted: #aeb8cc;
  --accent: #ff375f;
  --ok: #33d17a;
  --bad: #ff6b6b;
  --line: #30384d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #26304a 0, var(--bg) 45%);
  color: var(--text);
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.panel {
  background: rgba(24, 29, 41, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 48px);
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  margin-top: 10px;
  font-size: 13px;
}

.row {
  display: flex;
  gap: 10px;
}

input,
select,
button {
  border-radius: 12px;
  border: 1px solid var(--line);
  font: inherit;
  color: var(--text);
}

input,
select {
  width: 100%;
  background: #111722;
  padding: 12px 14px;
  outline: none;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: transparent;
  padding: 12px 16px;
  font-weight: 700;
  white-space: nowrap;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.status {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.status.ok {
  color: var(--ok);
}

.status.bad {
  color: var(--bad);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.rooms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.rooms.empty {
  display: block;
  color: var(--muted);
}

.room-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: #111722;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.room-card p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.host-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.game-list-wrap,
.host-tools .hint {
  grid-column: 1 / -1;
}

.game-list-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  background: #111722;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.game-list.empty {
  display: block;
  color: var(--muted);
}

.game-item {
  display: grid;
  gap: 4px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  background: #1c2433;
  border-color: var(--line);
  font-weight: 500;
  padding: 10px 12px;
}

.game-item.selected {
  border-color: #b06cff;
  background: #2a2144;
  color: #fff;
}

.game-item.unsupported {
  cursor: not-allowed;
  opacity: 0.5;
  background: #181c25;
}

.game-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.game-error {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  color: var(--bad);
  text-align: center;
}

.nes-screen {
  width: min(768px, 100%);
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.nes-screen canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.controls span {
  background: #111722;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
}

.hidden {
  display: none !important;
}

code {
  color: #ffd166;
}

@media (max-width: 760px) {
  .hero,
  .grid,
  .row,
  .host-tools {
    grid-template-columns: 1fr;
    display: grid;
  }
}
