:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #647071;
  --line: #d9dfdc;
  --paper: #fffdf8;
  --panel: #ffffff;
  --cream: #f6efe2;
  --mint: #d9eee5;
  --clay: #c86f50;
  --leaf: #2d7d61;
  --blue: #356fa8;
  --gold: #d59f30;
  --danger: #b94a48;
  --shadow: 0 14px 40px rgba(38, 45, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(217, 238, 229, 0.72), rgba(246, 239, 226, 0.82)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0 18px, rgba(255, 255, 255, 0.2) 18px 36px);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

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

.topbar,
.dashboard,
.game-grid,
.lower-grid,
.panel-heading,
.value-row {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--leaf);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 4rem;
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.day-pill,
.metric,
.panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.day-pill {
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 800;
}

.dashboard {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric {
  min-height: 86px;
  border-radius: 8px;
  padding: 16px;
}

.metric span,
.market-signals span,
.control-block label,
.ledger small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
}

.game-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.85fr);
  align-items: stretch;
}

.lower-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  margin-top: 16px;
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

.panel-heading {
  grid-template-columns: 1fr auto;
  align-items: start;
  margin-bottom: 14px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.demand-dot {
  background: var(--blue);
}

.supply-dot {
  background: var(--clay);
}

.controls-panel {
  display: flex;
  flex-direction: column;
}

.balance-stage {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 254, 250, 0.97), rgba(246, 249, 247, 0.94)),
    repeating-linear-gradient(0deg, rgba(45, 125, 97, 0.06) 0 1px, transparent 1px 42px);
  padding: 26px;
}

.scale-copy {
  max-width: 390px;
}

.scale-copy h3 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.12;
  letter-spacing: 0;
}

.scale {
  position: absolute;
  left: 54px;
  right: 54px;
  bottom: 32px;
  min-height: 350px;
}

.scale-beam {
  --tilt: 0deg;
  --pan-tilt: 0deg;
  position: absolute;
  left: 10%;
  right: 10%;
  top: 142px;
  height: 13px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 239, 218, 0.68), transparent 48%),
    linear-gradient(90deg, #8b4728, #d48b5c 48%, #8b4728);
  box-shadow:
    inset 0 -4px 5px rgba(92, 42, 20, 0.28),
    0 7px 14px rgba(32, 33, 36, 0.14);
  transform-origin: center;
  transform: rotate(var(--tilt));
  transition: transform 240ms ease;
}

.scale-beam::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -32px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, #fff3e4, transparent 22%),
    linear-gradient(145deg, #f0b38d, #a95732);
  border: 7px solid #f7d8c6;
  box-shadow:
    inset 0 -5px 7px rgba(99, 42, 20, 0.18),
    0 5px 10px rgba(32, 33, 36, 0.14);
  transform: translateX(-50%);
  z-index: 3;
}

.scale-beam::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -13px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 20px solid #202124;
  transform: translateX(-50%);
  z-index: 4;
}

.scale-post {
  position: absolute;
  left: 50%;
  top: 152px;
  width: 13px;
  height: 122px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, #8c4729, #dc9666 50%, #8c4729);
  box-shadow: 0 8px 14px rgba(32, 33, 36, 0.14);
  transform: translateX(-50%);
}

.scale-base {
  position: absolute;
  left: 30%;
  right: 30%;
  bottom: 0;
  height: 88px;
  border-radius: 110px 110px 8px 8px;
  background:
    radial-gradient(circle at 50% 32%, #ffd8c0, transparent 38%),
    linear-gradient(180deg, #d98d61, #8c4428);
  box-shadow:
    inset 0 -8px 10px rgba(88, 38, 18, 0.24),
    0 16px 24px rgba(32, 33, 36, 0.16);
}

.pan {
  position: absolute;
  top: -118px;
  width: min(180px, 38%);
  min-height: 118px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 8px 14px 12px;
  text-align: center;
  transform: rotate(var(--pan-tilt));
  transition: transform 240ms ease;
}

.pan::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  height: 74px;
  border: 0;
  border-radius: 0 0 120px 120px / 0 0 82px 82px;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 244, 229, 0.92), transparent 34%),
    linear-gradient(180deg, #c8784d 0%, #9b4729 66%, #6f321e 100%);
  box-shadow:
    inset 0 -16px 24px rgba(82, 34, 16, 0.28),
    0 12px 18px rgba(32, 33, 36, 0.14);
  transform: none;
  z-index: 0;
}

.pan::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 26px;
  height: 32px;
  border-radius: 0 0 4px 4px;
  background:
    linear-gradient(90deg, #8a4327, #d78b5c 50%, #8a4327);
  transform: translateX(-50%);
  z-index: 1;
}

.pan-demand {
  left: 0;
}

.pan-supply {
  right: 0;
}

.pan span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  position: relative;
  z-index: 3;
}

.pan strong {
  display: block;
  margin: 4px 0 8px;
  font-size: 1.45rem;
  position: relative;
  z-index: 3;
}

.loaf-stack {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: min(92px, 100%);
  margin: 0 auto;
  padding: 4px 0 12px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  z-index: 3;
}

.loaf-stack::before {
  display: none;
}

.loaf-stack::after {
  display: none;
}

.loaf {
  display: block;
  position: relative;
  z-index: 2;
  height: 15px;
  border: 1px solid rgba(105, 66, 36, 0.28);
  border-radius: 9px 9px 5px 5px;
  background:
    linear-gradient(180deg, #e5ad61, #b87335);
  box-shadow: inset 0 -2px 3px rgba(80, 43, 18, 0.16);
}

.curve-panel canvas {
  width: 100%;
  aspect-ratio: 1.46;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffefa, #f8fbf8);
}

.curve-stats {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.control-block {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.value-row {
  grid-template-columns: 1fr 76px;
  align-items: center;
  margin-top: 9px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--leaf);
}

output {
  min-width: 74px;
  border-radius: 8px;
  background: var(--mint);
  padding: 8px 10px;
  text-align: center;
  font-weight: 900;
}

.market-signals {
  display: grid;
  gap: 10px;
  margin: 10px 0 12px;
}

.market-signals div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.market-signals strong {
  text-align: right;
}

.news-strip {
  margin-bottom: 16px;
  border: 1px solid #cbd8d1;
  border-radius: 8px;
  background: #f7fbf7;
  padding: 14px;
}

.news-strip h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.news-strip p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.primary-action,
.secondary-action {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 900;
}

.primary-action {
  background: var(--ink);
  color: #ffffff;
}

.primary-action:hover {
  background: #39403d;
}

.secondary-action {
  margin-top: 10px;
  background: #ece8dd;
  color: var(--ink);
}

.report {
  display: grid;
  gap: 10px;
  min-height: 148px;
  color: var(--muted);
}

.feedback-layout {
  display: grid;
  gap: 12px;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.62fr) minmax(280px, 1fr);
  gap: 12px;
  align-items: stretch;
}

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

.report-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--paper);
}

.report-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.report-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.2rem;
}

.cost-box {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf4;
  padding: 12px;
  color: var(--ink);
  font-size: 0.9rem;
}

.cost-box span {
  color: var(--muted);
}

.ledger-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  padding: 12px;
}

.ledger-wrap h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0;
}

.ledger {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.ledger li {
  display: grid;
  grid-template-columns: 84px 82px 56px;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.bar-label {
  display: grid;
  gap: 1px;
}

.bar-label strong,
.bar-label span {
  display: block;
}

.bar-label span {
  font-size: 0.82rem;
  font-weight: 900;
}

.profit-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e8e4;
}

.profit-bar i {
  display: block;
  height: 100%;
  min-width: 6px;
  border-radius: inherit;
  background: var(--leaf);
}

.loss-day .profit-bar i {
  background: var(--danger);
}

.empty-ledger {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.positive {
  color: var(--leaf);
}

.negative {
  color: var(--danger);
}

@media (max-width: 860px) {
  .topbar,
  .dashboard,
  .game-grid,
  .lower-grid,
  .result-layout,
  .curve-stats,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  .day-pill {
    width: fit-content;
  }

  h1 {
    font-size: 2.8rem;
  }

  .balance-stage {
    min-height: 520px;
  }

  .scale {
    left: 24px;
    right: 24px;
    bottom: 40px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }

  .panel,
  .metric {
    padding: 14px;
  }

  .panel-heading {
    grid-template-columns: 1fr;
  }

  .value-row {
    grid-template-columns: 1fr;
  }

  output {
    width: 100%;
  }

  h1 {
    font-size: 2.1rem;
  }

  .metric strong {
    font-size: 1.45rem;
  }
}
