@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&display=swap");

:root {
  --bg: #f2f8ff;
  --panel: #ffffff;
  --text: #17324a;
  --muted: #5f758a;
  --human: #1f8f5f;
  --human-soft: #e9f9f1;
  --ai: #1569d6;
  --ai-soft: #eaf2ff;
}

* {
  box-sizing: border-box;
  font-family: "Manrope", sans-serif;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 65%);
  color: var(--text);
}

#wrapper {
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(320px, 440px) minmax(460px, 1fr) minmax(420px, 1fr);
}

#content, #sidebar, #labcard {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(21, 50, 74, 0.12);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

h1 {
  margin: 0;
  font-size: 2.8rem;
}

.subtitle {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 1.4rem;
}

form {
  font-size: 1.4rem;
}

.mode-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.mode-pill {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-pill input {
  display: none;
}

.mode-human {
  background: var(--human-soft);
  color: var(--human);
}

.mode-ai {
  background: var(--ai-soft);
  color: var(--ai);
}

.mode-pill.active.mode-human {
  border-color: var(--human);
}

.mode-pill.active.mode-ai {
  border-color: var(--ai);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.lab-section {
  margin-bottom: 0;
  padding: 0;
  border-radius: 12px;
  background: transparent;
}

.lab-section h2 {
  margin-bottom: 10px;
}

.lab-section .field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.viz-wrap {
  margin-top: 8px;
}

#qtable-canvas {
  width: 100%;
  height: auto;
  border: 1px solid #c6d5e4;
  border-radius: 8px;
  background: #fff;
}

#reward-canvas {
  width: 100%;
  height: auto;
  border: 1px solid #c6d5e4;
  border-radius: 8px;
  background: #fff;
}

h3 {
  margin: 8px 0;
  font-size: 1.4rem;
}

.stats-card {
  border-radius: 12px;
  padding: 12px;
}

.human-card {
  background: var(--human-soft);
}

.ai-card {
  background: var(--ai-soft);
}

h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
}

.number {
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: #274560;
  font-weight: 700;
}

.field-group {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.inline-options {
  display: flex;
  gap: 16px;
}

input[type="range"], select, input[type="button"] {
  width: 100%;
}

input, select {
  border: 1px solid #d8e2ea;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 1.4rem;
}

.button-row {
  margin-top: 8px;
}

input[type="button"] {
  background: #143652;
  color: #fff;
  border: none;
  cursor: pointer;
}

.hint {
  margin: 12px 0 0;
  font-size: 1.2rem;
  color: var(--muted);
}

#labcard .hint {
  font-size: 1.1rem;
  line-height: 1.4;
}

@media (max-width: 980px) {
  #wrapper {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  #content, #sidebar, #labcard {
    padding: 14px;
  }

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

@media (max-width: 560px) {
  h1 {
    font-size: 2.2rem;
  }

  .mode-section {
    grid-template-columns: 1fr;
  }

  .field-group {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .inline-options {
    gap: 10px;
  }
}
