:root {
  --bg: #edf1ec;
  --panel: rgba(255, 252, 246, 0.97);
  --panel-strong: #fffaf0;
  --ink: #111820;
  --muted: #5d6670;
  --line: #d8d2c7;
  --gold: #f2b632;
  --gold-dark: #745000;
  --green: #237552;
  --red: #b33846;
  --blue: #2866a8;
  --orange: #c96f17;
  --purple: #7b4bb2;
  --teal: #247f86;
  --shadow: 0 24px 68px rgba(21, 24, 22, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(17, 24, 32, 0.18), rgba(237, 241, 236, 0.92) 38%, rgba(237, 241, 236, 0.76)),
    url("data/the commons.jpg") center / cover fixed;
}

button {
  font: inherit;
}

button:disabled {
  opacity: 0.44;
  cursor: not-allowed;
}

.app-shell {
  width: min(1260px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
}

.stage-panel,
.status-panel {
  border: 1px solid rgba(68, 56, 38, 0.18);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stage-panel {
  min-height: calc(100vh - 56px);
  padding: 28px;
  display: flex;
  flex-direction: column;
}

.status-panel {
  align-self: start;
  position: sticky;
  top: 28px;
  padding: 24px;
}

.topbar,
.progress-row,
.status-heading,
.scenario-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.eyebrow,
.mini-label,
.scenario-kicker {
  margin: 0 0 7px;
  color: var(--gold-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.35rem, 6vw, 5.3rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.55rem;
  line-height: 1.18;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.icon-button,
.secondary-button {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
}

.icon-button {
  width: 70px;
}

.menu-view,
.game-view,
.result-view {
  margin-top: 34px;
}

.menu-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 22px;
  align-items: stretch;
}

.menu-copy {
  max-width: 760px;
}

.menu-copy h2 {
  max-width: 830px;
  font-size: clamp(1.8rem, 3.6vw, 3.35rem);
}

.menu-copy p,
.result-view p,
.scenario-detail {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.62;
}

.start-card,
.loadout-panel,
.scenario-card {
  border: 1px solid var(--line);
  background: #fff;
}

.start-card {
  padding: 18px;
}

.system-list {
  display: grid;
  gap: 8px;
}

.system-list span,
.achievement-list span,
.week-pill,
.score-badge,
#difficultyBadge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff2c4;
  color: var(--gold-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

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

.profile-card,
.choice-button,
.primary-button {
  border: 1px solid var(--line);
  cursor: pointer;
}

.profile-card {
  min-height: 148px;
  padding: 16px;
  background: #fff;
  text-align: left;
}

.profile-card span,
.choice-button span {
  display: block;
  margin-bottom: 8px;
  font-weight: 900;
}

.profile-card strong,
.choice-button strong,
.profile-card small {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.profile-card small {
  margin-top: 12px;
  color: var(--gold-dark);
  font-weight: 900;
}

.profile-card.active,
.choice-button:hover,
.profile-card:hover,
.icon-button:hover,
.secondary-button:hover {
  border-color: var(--gold-dark);
}

.profile-card.active {
  background: #fff3c7;
}

.loadout-panel {
  margin: 18px 0 20px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1fr);
  gap: 22px;
  align-items: center;
}

.loadout-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.loadout-bars {
  display: grid;
  gap: 8px;
}

.mini-bar {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mini-bar div {
  height: 8px;
  overflow: hidden;
  background: #e8ded0;
}

.mini-bar i {
  display: block;
  height: 100%;
}

.primary-button {
  min-height: 50px;
  padding: 0 20px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.semester-track {
  margin: 16px 0 20px;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 5px;
}

.semester-track span {
  height: 9px;
  background: #e2d7c6;
}

.semester-track span.done {
  background: var(--green);
}

.semester-track span.current {
  background: var(--gold);
}

.scene-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(360px, 1fr);
  gap: 20px;
  align-items: stretch;
}

.scene-media {
  min-height: 490px;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.scene-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.scene-media figcaption {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 8px 10px;
  background: rgba(18, 25, 34, 0.84);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.scenario-card {
  min-height: 490px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

#scenarioText {
  margin-bottom: 10px;
  font-size: clamp(1.5rem, 2.6vw, 2.35rem);
}

#difficultyBadge {
  min-width: 104px;
  padding: 0 10px;
}

.choices {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.choice-button {
  min-height: 100px;
  padding: 16px;
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
}

.choice-effects {
  margin-top: 10px;
  color: var(--gold-dark);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.35;
}

.alert-stack {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.alert {
  padding: 10px;
  background: #edf8ef;
  color: #1c6042;
  border: 1px solid rgba(35, 117, 82, 0.18);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.alert.danger {
  background: #fff0f0;
  color: #8e2530;
  border-color: rgba(179, 56, 70, 0.2);
}

.meters {
  margin: 22px 0 26px;
  display: grid;
  gap: 14px;
}

.meter {
  display: grid;
  gap: 7px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.meter-track {
  height: 11px;
  overflow: hidden;
  background: #e8ded0;
}

.meter-fill {
  height: 100%;
  transition: width 180ms ease;
}

.red { background: var(--red); }
.orange { background: var(--orange); }
.blue { background: var(--blue); }
.green { background: var(--green); }
.purple { background: var(--purple); }
.teal { background: var(--teal); }
.gold { background: var(--gold); }

.score-badge {
  width: 50px;
  min-height: 50px;
  flex: 0 0 auto;
  font-size: 1rem;
}

.notes-panel {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.notes-panel + .notes-panel {
  margin-top: 18px;
}

.notes-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.notes-panel li + li {
  margin-top: 8px;
}

.achievement-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.achievement-list span {
  padding: 0 9px;
}

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

.result-view {
  max-width: 880px;
}

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

.result-stat,
.ending-panel {
  background: #fff;
  border: 1px solid var(--line);
}

.result-stat {
  min-height: 92px;
  padding: 14px;
}

.result-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.result-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.9rem;
}

.ending-panel {
  margin-bottom: 22px;
  padding: 18px;
}

.ending-panel ul {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.hidden {
  display: none;
}

@media (max-width: 1020px) {
  body {
    background-attachment: scroll;
  }

  .app-shell {
    width: min(100% - 22px, 780px);
    grid-template-columns: 1fr;
    padding: 16px 0;
  }

  .stage-panel {
    min-height: auto;
    padding: 20px;
  }

  .status-panel {
    position: static;
  }

  .menu-grid,
  .scene-grid,
  .loadout-panel {
    grid-template-columns: 1fr;
  }

  .profile-picker,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-media,
  .scenario-card {
    min-height: 340px;
  }
}

@media (max-width: 620px) {
  .topbar,
  .progress-row,
  .status-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .profile-picker,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .mini-bar {
    grid-template-columns: 70px minmax(0, 1fr) 32px;
  }
}
