:root {
  color-scheme: dark;
  --bg: #101215;
  --panel: #181c22;
  --line: #303743;
  --text: #edf1f6;
  --muted: #9aa4b2;
  --accent: #2dd4bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  color: var(--text);
  font-weight: 800;
  font-size: 20px;
}

nav {
  display: flex;
  gap: 12px;
  align-items: center;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  padding: 28px 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

h1, h2, p {
  margin-top: 0;
}

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

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

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.game-card, .panel, .auth-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
}

.game-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.game-title {
  font-weight: 800;
  font-size: 17px;
}

button, input, textarea {
  font: inherit;
  color: var(--text);
  background: #11151b;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
}

button {
  cursor: pointer;
}

button.primary, .button-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #06211d;
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

input, textarea {
  width: 100%;
}

textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.45;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(420px, 100%);
}

.auth-card .brand {
  display: inline-block;
  margin-bottom: 22px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}

.wide {
  grid-column: 1 / -1;
}

pre {
  margin: 14px 0 0;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 340px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0f13;
}

.dev-shell {
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 300px minmax(360px, 1fr) 420px;
  overflow: hidden;
}

.sidebar, .preview-pane, .agent-pane {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.sidebar {
  padding: 14px;
  overflow: auto;
}

.compact-create {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 8px;
  margin-bottom: 16px;
}

.tight {
  margin-bottom: 10px;
}

.game-list {
  display: grid;
  gap: 10px;
}

.game-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

.game-row.active {
  border-color: var(--accent);
}

.game-row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.preview-pane, .agent-pane {
  display: flex;
  flex-direction: column;
}

.pane-head {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.pane-head h2, .pane-head p {
  margin: 0;
}

#previewFrame {
  flex: 1;
  width: 100%;
  border: 0;
  background: white;
}

.hidden {
  display: none;
}

.chat-log {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
  white-space: pre-wrap;
}

.message.user {
  border-color: #3d6f68;
}

.agent-input {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: var(--panel);
}

.agent-input textarea {
  min-height: 126px;
  margin-bottom: 10px;
}

@media (max-width: 820px) {
  .topbar, .section-title, .dashboard-grid {
    display: block;
  }

  nav {
    margin-top: 10px;
  }

  .topbar {
    height: auto;
    padding: 14px;
  }

  .dev-shell {
    height: auto;
    display: block;
  }

  .preview-pane, .agent-pane {
    min-height: 420px;
  }
}
