:root {
  --bg: #f7f1e8;
  --paper: rgba(255, 250, 244, 0.86);
  --ink: #1f2a37;
  --muted: #5f6775;
  --line: rgba(31, 42, 55, 0.12);
  --accent: #bf5b2c;
  --accent-2: #1f6e6b;
  --accent-3: #8b2e4c;
  --accent-4: #6e53b7;
  --shadow: 0 24px 60px rgba(60, 44, 28, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(191, 91, 44, 0.14), transparent 34%),
    radial-gradient(circle at top right, rgba(31, 110, 107, 0.16), transparent 28%),
    linear-gradient(180deg, #fbf6ee 0%, #f4ecdf 100%);
}

h1,
h2,
h3,
.module-tile h2,
.game-matrix .corner,
.game-matrix .axis-label {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  letter-spacing: 0.01em;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero,
.module-header,
.home-notes article,
.control-panel,
.chart-card,
.feedback-panel {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  padding: 40px;
  border-radius: 34px;
  margin-bottom: 24px;
}

.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 10px;
}

.hero h1,
.module-header h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.hero-copy,
.module-header p,
.feedback-panel p,
.home-notes p,
.control-panel p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

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

.module-tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 220px;
  padding: 24px;
  border-radius: 28px;
  text-decoration: none;
  color: white;
  box-shadow: var(--shadow);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.module-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 34px 60px rgba(30, 24, 18, 0.2);
}

.tile-ppc {
  background: linear-gradient(145deg, #bb5c2b, #f19b45);
}

.tile-sd {
  background: linear-gradient(145deg, #166d68, #4cb7ab);
}

.tile-game {
  background: linear-gradient(145deg, #7b2951, #d15f83);
}

.tile-ext {
  background: linear-gradient(145deg, #4d3e86, #9582ec);
}

.module-tag {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.module-tile h2 {
  margin: 0;
  font-size: 2rem;
}

.module-tile p {
  margin: 0;
  line-height: 1.65;
}

.tile-footer {
  margin-top: auto;
  font-weight: 700;
}

.home-notes {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.home-notes article {
  padding: 22px;
  border-radius: var(--radius);
}

.home-notes h3,
.feedback-panel h2,
.control-panel h2 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.module-header {
  display: flex;
  align-items: flex-start;
  gap: 22px;
  padding: 28px 30px;
  border-radius: 28px;
  margin-bottom: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  height: fit-content;
  padding: 12px 14px;
  border-radius: 999px;
  text-decoration: none;
  background: rgba(31, 42, 55, 0.06);
  font-weight: 600;
}

.module-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 20px;
}

.control-panel {
  padding: 24px;
  border-radius: var(--radius);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.control span {
  font-weight: 700;
}

.control input,
.control select,
.matrix-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: inherit;
}

.control strong {
  color: var(--accent);
}

.reset-button {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--accent), #e8844d);
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

.chart-panel {
  min-width: 0;
}

.chart-card {
  padding: 18px 18px 10px;
  border-radius: var(--radius);
}

.chart-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.chart-meta.multi {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.feedback-panel {
  margin-top: 20px;
  padding: 22px 24px;
  border-radius: var(--radius);
}

.axis {
  stroke: rgba(31, 42, 55, 0.6);
  stroke-width: 2;
}

.grid-line {
  stroke: rgba(31, 42, 55, 0.08);
  stroke-width: 1;
}

.curve {
  fill: none;
  stroke-width: 4;
}

.curve-demand {
  stroke: var(--accent-3);
}

.curve-supply,
.curve-mpc {
  stroke: var(--accent-2);
}

.curve-msc,
.curve-msb {
  stroke: var(--accent);
}

.curve-ppc {
  stroke: var(--accent);
}

.point-marker,
.equilibrium-point,
.social-point {
  stroke: white;
  stroke-width: 2;
}

.point-marker {
  fill: var(--accent-4);
}

.equilibrium-point {
  fill: var(--accent-3);
}

.social-point {
  fill: var(--accent);
}

.label {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.small-label {
  fill: var(--muted);
  font-size: 12px;
}

.zone-fill-cs {
  fill: rgba(209, 95, 131, 0.22);
}

.zone-fill-ps {
  fill: rgba(76, 183, 171, 0.24);
}

.zone-fill-dwl {
  fill: rgba(73, 67, 58, 0.18);
}

.zone-fill-ext {
  fill: rgba(191, 91, 44, 0.18);
}

.dashed {
  stroke-dasharray: 6 6;
}

.matrix-editor {
  margin-top: 18px;
}

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

.matrix-input label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.game-matrix {
  display: grid;
  grid-template-columns: 110px repeat(2, minmax(140px, 1fr));
  grid-template-rows: 72px repeat(2, minmax(138px, 1fr));
  gap: 8px;
  min-height: 360px;
}

.game-matrix > div {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  padding: 14px;
}

.game-matrix .corner {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  color: var(--muted);
}

.game-matrix .axis-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.game-matrix .cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.game-matrix .cell.nash {
  outline: 3px solid rgba(191, 91, 44, 0.45);
  background: rgba(255, 239, 228, 0.95);
}

.payoff-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
}

.payoff-name {
  width: 22px;
  color: var(--muted);
}

.payoff-value.underlined {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 5px;
}

.cell-label {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

@media (max-width: 980px) {
  .tile-grid,
  .home-notes,
  .module-shell {
    grid-template-columns: 1fr;
  }

  .chart-meta.multi {
    grid-template-columns: 1fr;
  }

  .game-matrix {
    grid-template-columns: 88px repeat(2, minmax(100px, 1fr));
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding: 12px 0 30px;
  }

  .hero,
  .module-header,
  .control-panel,
  .chart-card,
  .feedback-panel,
  .home-notes article {
    border-radius: 20px;
  }

  .hero,
  .module-header,
  .control-panel,
  .feedback-panel {
    padding: 20px;
  }

  .module-header {
    flex-direction: column;
  }

  .module-tile h2 {
    font-size: 1.65rem;
  }
}
