:root {
  color-scheme: light;
  --ink: #212326;
  --muted: #66717b;
  --paper: #fffaf2;
  --panel: #ffffff;
  --line: #d9d1c3;
  --coffee: #7d4b32;
  --mint: #3f8d78;
  --plum: #6e4a7e;
  --amber: #d98b32;
  --bad: #b64a3b;
  --good: #2f7f5f;
  --shadow: 0 18px 50px rgba(59, 42, 24, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(63, 141, 120, 0.16), transparent 32%),
    linear-gradient(300deg, rgba(217, 139, 50, 0.18), transparent 35%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.top-nav {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.top-nav a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  padding: 9px 12px;
  border-radius: 8px;
}

.hero {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.lede {
  max-width: 720px;
  color: #4b4f52;
  font-size: 1.08rem;
  line-height: 1.55;
}

.game-panel,
.rules {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.game-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.status-row > div,
.target-card,
.meter-bank,
.beat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 12px;
}

.status-row strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.brief {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.brief h2 {
  margin: 4px 0 6px;
  font-size: 1.7rem;
}

.brief p,
.beat-note,
.rules li {
  color: #535b61;
  line-height: 1.45;
}

.stats,
.meters {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: 72px 1fr 46px;
  gap: 10px;
  align-items: center;
}

.track {
  height: 12px;
  border-radius: 999px;
  background: #ece5d8;
  overflow: hidden;
  border: 1px solid #ddd3c3;
}

.fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 160ms ease;
}

.fill.cozy {
  background: var(--coffee);
}

.fill.focus {
  background: var(--mint);
}

.fill.spark {
  background: var(--plum);
}

.stat-row strong {
  text-align: right;
}

.mixer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.meter-bank h3,
.beat-panel h3,
.section-head h3 {
  font-size: 1rem;
}

.beats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0 8px;
}

.beat {
  min-height: 68px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f5efe3;
  display: grid;
  place-items: center;
  position: relative;
}

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

.beat span {
  position: absolute;
  bottom: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.beat.ok {
  background: rgba(63, 141, 120, 0.16);
  border-color: rgba(63, 141, 120, 0.45);
}

.beat.clip {
  background: rgba(182, 74, 59, 0.14);
  border-color: rgba(182, 74, 59, 0.55);
}

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

#fitLabel {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

.loop-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 8px;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.loop-card:hover {
  transform: translateY(-1px);
}

.loop-card.selected {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(217, 139, 50, 0.22);
}

.loop-card:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.loop-title {
  font-weight: 850;
  font-size: 1.04rem;
}

.loop-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  background: #efe7da;
  padding: 4px 7px;
  font-size: 0.8rem;
  font-weight: 750;
}

.pattern {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.tick {
  height: 10px;
  border-radius: 999px;
  background: #dfd5c5;
}

.tick.on {
  background: var(--coffee);
}

.message {
  min-height: 28px;
  color: #3c4246;
  font-weight: 750;
}

.message.win {
  color: var(--good);
}

.message.warn {
  color: var(--bad);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.controls button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 800;
}

.controls button:nth-child(2) {
  background: #6a7178;
}

.controls button:disabled {
  background: #b9b2a8;
  cursor: not-allowed;
}

.rules {
  margin-top: 18px;
  padding: 18px;
}

.rules h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.rules ul {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 18px, 1120px);
    padding-top: 12px;
  }

  .top-nav {
    justify-content: stretch;
  }

  .top-nav a {
    flex: 1;
    text-align: center;
  }

  .status-row,
  .brief,
  .mixer,
  .loop-shelf {
    grid-template-columns: 1fr;
  }

  .loop-card {
    min-height: 118px;
  }
}

@media (max-width: 430px) {
  .game-panel,
  .rules {
    padding: 14px;
  }

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

  .status-row > div:last-child {
    grid-column: 1 / -1;
  }

  .stat-row {
    grid-template-columns: 64px 1fr 38px;
  }
}
