:root {
  color-scheme: light;
  --ink: #1d2520;
  --muted: #657067;
  --paper: #f7f8f4;
  --surface: #ffffff;
  --line: #d9ded5;
  --green: #14795d;
  --green-dark: #0d5644;
  --coral: #cc5d4a;
  --gold: #b8860b;
  --plum: #6f4a7f;
  --aqua: #c7ebe1;
  --shadow: 0 18px 60px rgba(29, 37, 32, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(20, 121, 93, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(204, 93, 74, 0.12), transparent 30%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

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

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 16px 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.topbar h1,
.panel h2,
.dialog-card h2 {
  margin: 0;
}

.brand-line {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 3.65rem;
  line-height: 0.95;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  margin-bottom: 4px;
  border: 1px solid rgba(20, 121, 93, 0.28);
  border-radius: 999px;
  background: #e7f7ef;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions,
.control-row,
.dialog-actions,
.row-heading {
  display: flex;
  align-items: center;
}

.top-actions,
.control-row,
.dialog-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.sidebar-controls {
  margin-top: 12px;
}

.sidebar-controls .primary-button,
.sidebar-controls .secondary-button {
  flex: 1 1 140px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.board-panel,
.panel,
.dialog-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.board-panel {
  padding: 14px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.status-strip div,
.metric {
  min-width: 0;
  padding: 10px;
  background: #f1f5ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-strip span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-strip strong,
.metric strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  font-size: 1.05rem;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(48px, 1fr));
  grid-template-rows: repeat(7, minmax(48px, 1fr));
  gap: 6px;
  aspect-ratio: 1;
  width: min(100%, 660px, calc(100vh - 170px));
  min-width: 0;
  margin: 0 auto;
}

.board-center {
  grid-column: 3 / 6;
  grid-row: 3 / 6;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #eaf7f1);
}

.center-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.8rem;
  line-height: 1;
}

.center-card p {
  margin: 0;
  color: var(--muted);
}

.tile {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tile small {
  color: var(--muted);
  font-weight: 800;
}

.tile span {
  overflow-wrap: anywhere;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.1;
}

.tile[data-kind="payday"] {
  border-color: rgba(20, 121, 93, 0.48);
  background: #e7f7ef;
}

.tile[data-kind="opportunity"] {
  border-color: rgba(184, 134, 11, 0.45);
  background: #fff8df;
}

.tile[data-kind="market"] {
  border-color: rgba(111, 74, 127, 0.42);
  background: #f7eefb;
}

.tile[data-kind="expense"],
.tile[data-kind="downsized"] {
  border-color: rgba(204, 93, 74, 0.45);
  background: #fff0ec;
}

.tile.is-active {
  outline: 4px solid var(--green);
  outline-offset: -4px;
}

.tile.is-active::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(204, 93, 74, 0.18);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button {
  padding: 0 18px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 28px rgba(20, 121, 93, 0.24);
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.ghost-button:not(:disabled):hover,
.icon-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.secondary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button,
.ghost-button {
  padding: 0 16px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.25rem;
}

.sidebar {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 14px;
}

.panel-heading {
  margin-bottom: 10px;
}

.row-heading {
  justify-content: space-between;
  gap: 12px;
}

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

.freedom-track {
  height: 12px;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 999px;
  background: #e3e8df;
}

.freedom-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--green));
  transition: width 250ms ease;
}

.asset-list,
.log-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

.asset-list li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.asset-list strong,
.asset-list span {
  display: block;
}

.asset-list span,
.log-list li {
  color: var(--muted);
  font-size: 0.86rem;
}

.log-list {
  display: grid;
  max-height: 150px;
  overflow: auto;
  gap: 8px;
}

.log-list li {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.game-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  background: transparent;
}

.game-dialog::backdrop {
  background: rgba(29, 37, 32, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: 22px;
}

.dialog-copy {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

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

.career-card {
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.career-card strong,
.career-card span {
  display: block;
}

.career-card span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.event-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.event-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.event-numbers div,
.statement-grid section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

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

.event-numbers strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.statement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.statement-grid h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

dl {
  margin: 0;
}

.statement-grid div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.statement-grid div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

@media (max-width: 1040px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

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

  .sidebar .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 2.5rem;
  }

  .status-strip,
  .metric-grid,
  .career-grid,
  .event-numbers,
  .statement-grid,
  .sidebar {
    grid-template-columns: 1fr;
  }

  .board-panel {
    padding: 12px;
  }

  .board-grid {
    grid-template-columns: repeat(7, minmax(38px, 1fr));
    grid-template-rows: repeat(7, minmax(38px, 1fr));
    gap: 5px;
  }

  .tile {
    padding: 6px;
  }

  .tile small {
    font-size: 0.58rem;
  }

  .tile span {
    font-size: 0.58rem;
  }

  .board-center {
    padding: 10px;
  }

  .center-card p {
    display: none;
  }

  .center-card strong {
    font-size: 1.2rem;
  }
}
