:root {
    --bs-body-bg: #f5f5f0;
    --bs-body-color: #253c35;
    --bs-primary: #173e35;
    --bs-primary-rgb: 23, 62, 53;
    --bs-link-color: #225f4e;
    --bs-link-hover-color: #173e35;
    --bs-border-color: #dedfd5;
    --bs-border-radius: .65rem;
}
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
header { background: #fffef9; }
.container { max-width: 1240px; }
.brand { color: #173e35; font-size: 1.85rem; font-weight: 750; letter-spacing: -.09em; }
.brand-dot { color: #ac6a31; }
.eyebrow { color: #5a7065; font-size: .7rem; font-weight: 700; letter-spacing: .14em; }
.app-header { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.view-heading { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; min-width: 0; }
.view-heading[data-view="browser"] { display: block; }
.header-controls { margin-left: auto; }
.view-heading h1 { letter-spacing: -.025em; }
.view-heading h1:focus { outline: none; }
.card { --bs-card-bg: #fffef9; --bs-card-border-color: #dedfd5; box-shadow: 0 3px 12px #173e3504; }
.card-header { background: transparent; padding: 1.15rem; }
.card-body { padding: 1.25rem; }
.btn-primary { --bs-btn-bg: #173e35; --bs-btn-border-color: #173e35; --bs-btn-hover-bg: #285c4d; --bs-btn-hover-border-color: #285c4d; --bs-btn-active-bg: #0d2c24; --bs-btn-active-border-color: #0d2c24; --bs-btn-disabled-bg: #173e35; --bs-btn-disabled-border-color: #173e35; }
.btn-outline-primary { --bs-btn-color: #173e35; --bs-btn-border-color: #173e35; --bs-btn-hover-bg: #173e35; --bs-btn-hover-border-color: #173e35; --bs-btn-active-bg: #173e35; --bs-btn-active-border-color: #173e35; --bs-btn-disabled-color: #173e35; --bs-btn-disabled-border-color: #173e35; }
.form-control:focus, .form-select:focus { border-color: #648b74; box-shadow: 0 0 0 .2rem #648b7425; }
.form-check-input:checked { background-color: #173e35; border-color: #173e35; }
.form-control, .form-select { background-color: #fff; }
.list-group-item { background: transparent; padding: 1rem 1.15rem; }
.list-group-item.active { background: #e8eee4; color: #173e35; border-color: #dedfd5; }
summary { cursor: pointer; }
.turn-card { min-height: 27rem; border-top: 4px solid #648b74; }
.turn-card > .card-body { flex: 1; }
.turn-card > .card-body:has(> #action-form[hidden]):not(:has(.player-results)) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    font-size: 1.5rem;
    overflow-wrap: anywhere;
}
.turn-card > .card-body:has(> #action-form[hidden]):not(:has(.player-results)) > :is(#turn-message, #event-details) {
    margin-bottom: 0 !important;
}
.turn-card > .card-body:has(> #action-form[hidden]):not(:has(.player-results)) > #event-details { font-size: inherit; }
.turn-card > .card-body:has(> #action-form[hidden]) > :is(#turn-message, #event-details):empty { display: none; }
.turn-status { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(min-content, 1fr); align-items: center; gap: .5rem; min-height: 3.5rem; }
.turn-controls, .turn-caption { min-width: 0; overflow-wrap: anywhere; }
#auto-countdown { min-width: 0; overflow: clip; white-space: nowrap; }
#proceed { white-space: nowrap; }
.turn-caption { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .5rem 1rem; text-align: center; }
.turn-mode { justify-self: end; }
#auto-commit-mode {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.625rem;
    height: 2.375rem;
    padding: .125rem;
    font-size: 1.5rem;
    line-height: 1;
}
#auto-countdown-disc { display: inline-block; margin-right: .35rem; color: #648b74; }
.message-log { max-height: 16rem; overflow-y: auto; overflow-wrap: anywhere; }
.message-log-table { width: 100%; border-collapse: collapse; }
.message-log-entry > td { padding: .5rem; vertical-align: top; border-bottom: 1px solid var(--bs-border-color); }
.message-log-date-column, .message-log-player-column, .message-log-title-column { width: 1%; }
.message-log-date, .message-log-player, .message-log-title { white-space: nowrap; }
.message-log-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.message-log-entry:last-child > td { border-bottom: 0; }
.game-layout { display: grid; gap: 1.5rem; }
.game-layout > * { min-width: 0; }
.game-board { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.5rem; }
.game-board > * { min-width: 0; }
.turn-card, .standings-card { grid-column: 1 / -1; }
.calendar-card { align-self: start; }
.economy-facts { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem .75rem; margin: 0; }
.economy-facts dt { font-weight: 400; color: var(--bs-secondary-color); }
.economy-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.calendar-years-section { border-top: 1px solid var(--bs-border-color); margin-top: 1.25rem; padding-top: 1.25rem; }
.calendar-years { display: grid; grid-auto-rows: 3rem; gap: .5rem; font-variant-numeric: tabular-nums; }
.calendar-year-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; min-height: 3rem; }
.calendar-year { display: flex; align-items: center; justify-content: center; height: 3rem; border: 1px solid var(--bs-border-color); border-radius: .35rem; font-size: .8rem; }
.calendar-year.is-past { color: var(--bs-secondary-color); background: rgba(var(--bs-primary-rgb), .04); }
.calendar-year.is-current { color: var(--bs-emphasis-color); background: rgba(var(--bs-primary-rgb), .15); border: 2px solid var(--bs-primary); font-weight: 750; }
.calendar-years:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 3px; }
.market-chart { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.market-chart th { padding: 0 .4rem .75rem; color: #5a7065; font-size: .7rem; text-align: center; }
.market-price { padding: .5rem .6rem; text-align: right; font-size: .85rem; }
.market-slot { width: 6%; height: 2.15rem; border: 1px solid #b8c8b9; text-align: center; color: #9ba99e; }
.market-slot.is-filled { background: #e8eee4; color: #173e35; }
.table { --bs-table-bg: transparent; font-size: .9rem; }
.table th { color: #5a7065; font-size: .75rem; font-weight: 600; }
.table th:first-child, .table td:first-child { padding-left: 1.25rem; }
.table th:last-child, .table td:last-child { padding-right: 1.25rem; }
.table .current-player { --bs-table-bg: #eef2e9; }
.standings-card .table { table-layout: fixed; width: 100%; min-width: 48rem; --standings-holding-width: 3.5rem; --standings-money-width: 8.5rem; }
.standings-player { width: calc(100% - 3 * var(--standings-holding-width) - 3 * var(--standings-money-width)); }
.standings-holding { width: var(--standings-holding-width); }
.standings-money { width: var(--standings-money-width); }
.standings-card .table > tbody > tr > * { overflow: hidden; text-overflow: ellipsis; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-results { container-type: inline-size; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); }
.player-results .table { width: 100%; table-layout: fixed; }
.player-results thead { background: rgba(var(--bs-primary-rgb), .06); }
.player-results .table > :not(caption) > * > * { padding: .65rem .5rem; white-space: normal; overflow-wrap: anywhere; }
.player-results .results-player { color: var(--bs-body-color); font-size: inherit; }
.player-results tbody tr:last-child > * { border-bottom: 0; }
@container (max-width: 44rem) {
    .player-results .table, .player-results tbody { display: block; }
    .player-results thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .player-results tbody tr { display: block; padding: .5rem .75rem; }
    .player-results tbody tr + tr { border-top: 1px solid var(--bs-border-color); }
    .player-results .table > tbody > tr > * { display: block; padding: .3rem 0; border: 0; }
    .player-results .table > tbody > tr > th { padding-bottom: .5rem; }
    .player-results .table > tbody > tr > td { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
    .player-results td::before { content: attr(data-label); text-align: left; color: var(--bs-secondary-color); font-weight: 400; }
}
[hidden] { display: none !important; }
@media (min-width: 992px) and (max-height: 800px) {
    .game-layout { grid-template-columns: minmax(14rem, 1fr) minmax(0, 3fr); align-items: start; }
    .game-board { grid-column: 2; grid-row: 1; }
    .message-log-card { grid-column: 1; grid-row: 1; }
    .message-log { max-height: max(8rem, calc(100dvh - 14rem)); }
}
@media (max-width: 767px) {
    .view-heading { order: 1; flex-basis: 100%; }
    .header-controls { flex: 1; }
    .game-board { grid-template-columns: minmax(0, 1fr); }
    .market-price { padding: .5rem .3rem; }
}
@media (max-width: 575px) {
    .table { font-size: .8rem; }
    .table td, .table th { padding: .7rem .35rem; }
}

/* Classic amber terminal palette, layered over Bootstrap's dark controls. */
[data-theme="classic"] {
    color-scheme: dark;
    --bs-body-bg: #16130e;
    --bs-body-bg-rgb: 22, 19, 14;
    --bs-body-color: #ffc466;
    --bs-body-color-rgb: 255, 196, 102;
    --bs-emphasis-color: #ffdda3;
    --bs-emphasis-color-rgb: 255, 221, 163;
    --bs-secondary-color: #cba566;
    --bs-secondary-color-rgb: 203, 165, 102;
    --bs-tertiary-color: #b38e53;
    --bs-tertiary-bg: #292217;
    --bs-primary: #ffc466;
    --bs-primary-rgb: 255, 196, 102;
    --bs-link-color: #ffc466;
    --bs-link-color-rgb: 255, 196, 102;
    --bs-link-hover-color: #ffdda3;
    --bs-link-hover-color-rgb: 255, 221, 163;
    --bs-border-color: #655031;
    --bs-border-color-translucent: #655031;
    --bs-focus-ring-color: #ffc46640;
}
[data-theme="classic"] body { font-family: var(--bs-font-monospace); }
[data-theme="classic"] header,
[data-theme="classic"] .card { background: #1e1911; --bs-card-bg: #1e1911; --bs-card-border-color: #655031; }
[data-theme="classic"] .brand,
[data-theme="classic"] .brand-dot { color: #ffc466; }
[data-theme="classic"] .eyebrow,
[data-theme="classic"] .market-chart th,
[data-theme="classic"] .table th { color: #cba566; }
[data-theme="classic"] .form-control,
[data-theme="classic"] .form-select { background-color: #16130e; }
[data-theme="classic"] .form-control:focus,
[data-theme="classic"] .form-select:focus { border-color: #ffc466; box-shadow: 0 0 0 .2rem #ffc46625; }
[data-theme="classic"] .form-check-input:checked { background-color: #b87918; border-color: #ffc466; }
[data-theme="classic"] .btn-primary,
[data-theme="classic"] .btn-outline-primary,
[data-theme="classic"] .btn-outline-secondary {
    --bs-btn-color: #ffc466;
    --bs-btn-bg: transparent;
    --bs-btn-border-color: #b38e53;
    --bs-btn-hover-color: #16130e;
    --bs-btn-hover-bg: #ffc466;
    --bs-btn-hover-border-color: #ffc466;
    --bs-btn-active-color: #16130e;
    --bs-btn-active-bg: #ffdda3;
    --bs-btn-active-border-color: #ffdda3;
    --bs-btn-disabled-color: #ffc466;
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-border-color: #655031;
    --bs-btn-focus-shadow-rgb: 255, 196, 102;
}
[data-theme="classic"] .text-bg-light,
[data-theme="classic"] .text-bg-secondary { color: #ffc466 !important; background-color: #382c1a !important; }
[data-theme="classic"] .list-group-item.active,
[data-theme="classic"] .market-slot.is-filled { background: #382c1a; color: #ffdda3; border-color: #655031; }
[data-theme="classic"] .market-slot { color: #b38e53; border-color: #655031; }
[data-theme="classic"] .table .current-player { --bs-table-bg: #382c1a; }
[data-theme="classic"] .turn-card { border-top-color: #ffc466; }
[data-theme="classic"] #auto-countdown-disc { color: #ffc466; }

.action-menu { min-width: 0; }
.amount-controls { display: flex; align-items: center; gap: 1rem; }
.amount-controls .form-control { flex: 0 1 9rem; min-width: 0; }
.amount-controls .form-range { flex: 1; min-width: 0; }
.action-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.action-choice { display: flex; align-items: center; gap: .65rem; padding: .75rem; border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); cursor: pointer; }
.action-choice .form-check-input { flex-shrink: 0; margin: 0; }
.action-choice:has(:checked) { border-color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), .08); }
.action-choice:has(:focus-visible) { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.action-menu:disabled .action-choice, .action-choice:has(:disabled) { opacity: .6; cursor: default; }
@media (max-width: 575px) {
    .turn-card { min-height: 64rem; }
    .action-choices { grid-template-columns: minmax(0, 1fr); }
}

.action-menu:disabled .action-choice.action-echo {
    opacity: 1;
    color: #fff;
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), .3);
    font-weight: 750;
}
[data-theme="classic"] .action-menu:disabled .action-choice.action-echo { color: #16130e; }
