:root {
  --bg: #0b1020;
  --surface: #121a2f;
  --surface-2: #1a2440;
  --border: #2a3555;
  --text: #e8edf7;
  --muted: #8b9bbf;
  --accent: #6ee7b7;
  --accent-2: #38bdf8;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #152041 0%, var(--bg) 45%);
  color: var(--text);
  min-height: 100vh;
}

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

.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #041018;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hero {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(110, 231, 183, 0.08));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.hero h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

.hero-meta {
  margin-top: 0.85rem !important;
  color: var(--accent) !important;
  font-weight: 600;
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.5rem 0 1rem;
}

.quick-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.quick-tag.active,
.quick-tag:hover {
  border-color: rgba(110, 231, 183, 0.5);
  color: var(--text);
  background: rgba(110, 231, 183, 0.12);
}

.result-count {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.thumb-icon {
  font-size: 2rem;
  opacity: 0.9;
}

.card-thumb[data-tone],
.thumb-icon[data-tone="brain"] { color: #a5b4fc; }
.thumb-icon[data-tone="logic"] { color: #7c6cff; }
.thumb-icon[data-tone="strategy"] { color: #ff6b8a; }
.thumb-icon[data-tone="memory"] { color: #38bdf8; }
.thumb-icon[data-tone="math"] { color: #ffc857; }
.thumb-icon[data-tone="word"] { color: #3ee0b8; }
.thumb-icon[data-tone="spatial"] { color: #fb923c; }
.thumb-icon[data-tone="visual"] { color: #f472b6; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

input, select, textarea, button {
  font: inherit;
}

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(56, 189, 248, 0.35);
  border-color: var(--accent-2);
}

button, .btn {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-2), #2563eb);
  color: white;
  font-weight: 600;
}

button.secondary, .btn.secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

button.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(110, 231, 183, 0.45);
}

.card-thumb {
  height: 140px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 2rem;
}

.card-body { padding: 1rem; }

.card-body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.card-body p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  min-height: 2.8em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.panel h3 { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-grid label.full { grid-column: 1 / -1; }

.status {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  display: none;
}

.status.show { display: block; }
.status.ok { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.status.error { background: rgba(248, 113, 113, 0.15); color: #fecaca; }

.play-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(11, 16, 32, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.play-frame-wrap {
  background: #000;
  min-height: calc(100vh - 64px);
}

.play-frame {
  width: 100%;
  height: calc(100vh - 64px);
  border: 0;
  display: block;
}

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .card-actions { flex-direction: column; }
}

/* QA Dashboard */
.qa-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.metric-small {
  font-size: 0.78rem;
  font-weight: 500;
  word-break: break-all;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.pass { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.badge.warn { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge.fail { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }

.pass-text { color: #6ee7b7; }
.warn-text { color: #fcd34d; }
.fail-text { color: #fca5a5; }

.qa-table-wrap { overflow-x: auto; }

.qa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.qa-table th,
.qa-table td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.qa-table th { color: var(--muted); font-weight: 600; }

.qa-game {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.65rem;
  background: var(--surface-2);
}

.qa-game summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  list-style: none;
}

.qa-game summary::-webkit-details-marker { display: none; }

.qa-game-stats {
  color: var(--muted);
  font-size: 0.88rem;
  margin-left: auto;
}

.qa-checks { padding: 0 1rem 0.85rem; }

.qa-check {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.45rem 0;
  border-top: 1px solid rgba(255,255,255,0.04);
  font-size: 0.9rem;
}

.qa-check-name { font-weight: 600; }
.qa-check-msg { color: var(--muted); }

@media (max-width: 720px) {
  .qa-check { grid-template-columns: 1fr; }
  .qa-game-stats { margin-left: 0; width: 100%; }
}
