:root {
    --color-bg: #e9f1ea;
    --color-surface: #ffffff;
    --color-text: #1d2621;
    --color-muted: #5d6b63;
    --color-border: #cfdcd2;
    --color-primary: #1b7a43;
    --color-primary-dark: #145c33;
    --color-danger: #b3261e;
    --color-danger-bg: #fbe9e7;
    --color-success-bg: #e3f4e8;
    --radius: 8px;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.08), 0 4px 12px rgb(0 0 0 / 0.04);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

a {
    color: var(--color-primary);
}

h1 {
    margin-top: 0;
    font-size: 1.6rem;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--color-primary);
    color: #fff;
}

.site-header a {
    color: #fff;
}

.brand {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.05em;
    text-decoration: none;
    text-transform: uppercase;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-nav__user {
    font-weight: 600;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card--narrow {
    max-width: 420px;
    margin-inline: auto;
}

.hero {
    text-align: center;
    padding-block: 3rem;
}

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

.flash {
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: var(--color-success-bg);
}

.flash--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

/* Forms: works for hand-written forms and Symfony's default form theme */
.form > div,
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.form-row--inline {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.form label {
    font-weight: 600;
}

.form input[type="email"],
.form input[type="text"],
.form input[type="password"],
.form select {
    font: inherit;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.form input:focus,
.form select:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.form ul {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--color-danger);
    font-size: 0.9rem;
}

.form .help-text {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.button {
    display: inline-block;
    font: inherit;
    font-weight: 600;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 6px;
    background: var(--color-primary);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    background: var(--color-primary-dark);
}

.button--secondary {
    background: transparent;
    color: var(--color-primary);
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

.button--secondary:hover {
    background: var(--color-success-bg);
}

.button--small {
    padding: 0.3rem 0.75rem;
    font-size: 0.9rem;
}

.site-header .button--small {
    background: #fff;
    color: var(--color-primary);
}

h2 {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
}

.card > h2:first-child {
    margin-top: 0;
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button--danger {
    background: var(--color-danger);
}

.button--danger:hover {
    background: #8c1d17;
}

.button--danger-outline {
    background: transparent;
    color: var(--color-danger);
    box-shadow: inset 0 0 0 2px var(--color-danger);
}

.button--danger-outline:hover {
    background: var(--color-danger-bg);
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--color-primary);
    color: #fff;
}

.badge--muted,
.badge--finished {
    background: var(--color-border);
    color: var(--color-text);
}

.badge--ordering,
.badge--playing {
    background: #ea580c;
}

/* Tables of games on the home page */
.game-table {
    width: 100%;
    border-collapse: collapse;
}

.game-table th,
.game-table td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.game-table th {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.home-actions h1 {
    margin-bottom: 0.25rem;
}

.home-actions__buttons {
    display: flex;
    gap: 0.5rem;
}

/* Tokens */
.token {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
}

.token svg {
    width: 100%;
    height: 100%;
}

.token--large {
    width: 3rem;
    height: 3rem;
}

.token--empty {
    border: 2px dashed currentColor;
    border-radius: 50%;
    font-weight: 700;
}

/* Lobby */
.lobby {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.lobby .card {
    margin-bottom: 0;
}

@media (max-width: 800px) {
    .lobby {
        grid-template-columns: 1fr;
    }
}

.lobby__header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
}

.lobby__header h1 {
    margin-bottom: 0.25rem;
}

.lobby__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.game-code {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: var(--color-bg);
}

.game-code__label {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.game-code__value {
    font-family: ui-monospace, monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.15em;
}

.player-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.player-list__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem;
    border-radius: 6px;
}

.player-list__item--me {
    background: var(--color-success-bg);
}

.player-list__name {
    font-weight: 700;
}

.player-list__action {
    margin-left: auto;
}

.token-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: 0.5rem;
}

.token-picker__option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    font: inherit;
    font-size: 0.85rem;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}

.token-picker__option:hover:not(:disabled) {
    border-color: var(--color-primary);
}

.token-picker__option--selected {
    border-color: var(--color-primary);
    background: var(--color-success-bg);
    font-weight: 700;
}

.token-picker__option:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.form--compact > div {
    margin-bottom: 0.75rem;
}

.form [type="checkbox"],
.form [type="radio"] {
    margin-right: 0.35rem;
}

.form label.required::after {
    content: "";
}

.badge--danger {
    background: var(--color-danger);
}

/* Game: board plus player panel */
.page:has(.game) {
    max-width: 1400px;
}

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

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

/*
 * The board frame holds the board, the detail card and the centre panel.
 * On wide screens the centre panel sits over the board's empty middle; on
 * phones it drops below the board.
 */
.board-frame {
    container-type: inline-size;
    position: relative;
    width: min(100%, 92vh);
    margin: 0 auto;
}

.board {
    display: grid;
    grid-template-columns: 1.6fr repeat(9, 1fr) 1.6fr;
    grid-template-rows: 1.6fr repeat(9, 1fr) 1.6fr;
    width: 100%;
    aspect-ratio: 1;
    background: #cde6d0;
    border: 2px solid #1d2621;
    box-shadow: var(--shadow);
}

.space {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    min-width: 0;
    padding: 0.3cqw 0.2cqw;
    border: 1px solid #1d2621;
    background: #f4faf4;
    text-align: center;
    font-size: 1.15cqw;
    line-height: 1.15;
}

.space__band {
    position: relative;
    flex: 0 0 22%;
    align-self: stretch;
    margin: -0.3cqw -0.2cqw 0.2cqw;
    border-bottom: 1px solid #1d2621;
}

.space--top .space__band {
    order: 9;
    margin: 0.2cqw -0.2cqw -0.3cqw;
    border-top: 1px solid #1d2621;
    border-bottom: none;
}

.space--left,
.space--right {
    flex-direction: row;
}

.space--left .space__band,
.space--right .space__band {
    flex-basis: 22%;
    margin: -0.3cqw 0.3cqw -0.3cqw -0.2cqw;
    border-bottom: none;
    border-right: 1px solid #1d2621;
}

.space--left .space__band {
    order: 9;
    margin: -0.3cqw -0.2cqw -0.3cqw 0.3cqw;
    border-right: none;
    border-left: 1px solid #1d2621;
}

.space__lock {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.3cqw;
}

.space__name {
    font-weight: 700;
    hyphens: auto;
    overflow-wrap: break-word;
}

.space__price {
    color: var(--color-muted);
}

.space--corner {
    justify-content: center;
    font-size: 1.5cqw;
}

.space--mortgaged {
    background: repeating-linear-gradient(45deg, #f4faf4, #f4faf4 4px, #e2e2e2 4px, #e2e2e2 8px);
}

.space--owned {
    box-shadow: inset 0 0 0 0.45cqw var(--owner-colour);
}

.space__tokens {
    position: absolute;
    inset: 15% 0 0;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    pointer-events: none;
}

.space__tokens .token {
    width: 3cqw;
    height: 3cqw;
    filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}

.board__centre {
    /* The corners are 1.6 of the 12.2 units across: the middle starts 13.1% in */
    position: absolute;
    inset: 13.2%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1cqw;
    min-height: 0;
    padding: 2cqw;
    font-size: max(0.8rem, 1.5cqw);
}

.board__title {
    padding: 0.3cqw 3cqw;
    background: var(--color-danger);
    color: #fff;
    font-size: 4cqw;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transform: rotate(-8deg);
}

.dice {
    display: flex;
    gap: 1cqw;
    min-height: 6cqw;
}

.die {
    font-size: 6cqw;
    line-height: 1;
}

.dice--rolling .die {
    animation: dice-roll 0.6s ease-out;
}

.dice--rolling .die:nth-child(2) {
    animation-delay: 0.05s;
}

@keyframes dice-roll {
    0% { transform: rotate(0) scale(0.6); }
    40% { transform: rotate(200deg) scale(1.15); }
    100% { transform: rotate(360deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .dice--rolling .die {
        animation: none;
    }
}

.pot {
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: #fff7d6;
}

.turn-panel {
    width: min(100%, 34rem);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.turn-panel__status {
    margin: 0 0 0.5rem;
}

.turn-panel__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.game-log {
    flex: 1;
    width: min(100%, 34rem);
    min-height: 0;
    margin: 0;
    padding: 0.5rem 0.75rem;
    overflow-y: auto;
    list-style: none;
    border-radius: var(--radius);
    background: rgb(255 255 255 / 0.7);
    font-size: 0.85em;
}

.game-log__entry {
    padding: 0.1rem 0;
    border-bottom: 1px solid var(--color-border);
}

.game-log__entry:first-child {
    font-weight: 700;
}

.game__side {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.player-card {
    padding: 0.75rem;
    border-left: 5px solid var(--player-colour);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow);
}

.player-card--current {
    outline: 2px solid var(--player-colour);
}

.player-card__header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.player-card__name {
    font-weight: 700;
    color: var(--player-colour);
}

.player-card__cash {
    margin-left: auto;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.player-card p {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
}

.deeds {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}

.deed {
    padding: 0.1rem 0.4rem;
    border-top: 4px solid var(--deed-colour);
    border-radius: 3px;
    background: var(--color-bg);
    font-size: 0.75rem;
}

.deed--mortgaged {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Buildings in a property's colour band */
.buildings {
    position: absolute;
    inset: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.2cqw;
}

.house,
.hotel {
    display: inline-block;
    width: 1cqw;
    height: 1cqw;
    border: 1px solid #fff;
    border-radius: 2px;
    background: #15803d;
}

.hotel {
    width: 2.2cqw;
    background: #b3261e;
}

/* The card drawn most recently */
.drawn-card {
    max-width: 28rem;
    padding: 0.5rem 0.9rem;
    border: 2px solid currentColor;
    border-radius: var(--radius);
    background: #fff;
    text-align: center;
}

.drawn-card--chance {
    color: #c2410c;
}

.drawn-card--community-chest {
    color: #1d4ed8;
}

.drawn-card__deck {
    display: block;
    font-size: 0.75em;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auction__custom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0.6rem 0;
}

.auction__custom input {
    width: 6rem;
    font: inherit;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

/* Managing your properties */
.manage {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

.manage summary {
    cursor: pointer;
    font-weight: 700;
}

.manage__table {
    width: 100%;
    margin-top: 0.4rem;
    border-collapse: collapse;
}

.manage__table td {
    padding: 0.3rem 0.2rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.manage__swatch {
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
}

.manage__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem;
}

.manage__actions .button--small {
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
}

.bank {
    font-size: 0.85rem;
    text-align: center;
}

.player-card__actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.player-card__actions .button--small {
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
}

.out-players {
    font-size: 0.85rem;
}

.winner {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
}

/* Trades */
.trades {
    padding: 0.75rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow);
    font-size: 0.85rem;
}

.trades h2 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.trade {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--color-primary);
    border-radius: 4px;
    background: var(--color-bg);
}

.trade p {
    margin: 0 0 0.35rem;
}

.trade--blocked {
    border-left-color: var(--color-danger);
}

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

.trade__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.trade-form {
    margin-top: 0.5rem;
}

.trade-form summary {
    cursor: pointer;
    font-weight: 700;
}

.trade-form__sides {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.trade-form fieldset {
    min-width: 0;
    margin: 0;
    padding: 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.trade-form legend {
    font-weight: 700;
}

/* Expanded choice widgets put every checkbox and label in one div: one per row */
.trade-form fieldset > div[id] {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.15rem 0.35rem;
}

.trade-form fieldset > div[id] label {
    font-weight: 400;
}

.trade-form fieldset > div[id] input {
    margin: 0;
}

.trade-form .form-row,
.trade-form fieldset > div:has(input[type="number"]) {
    margin-top: 0.4rem;
}

.trade-form input[type="number"] {
    width: 6rem;
}

/* Admin */
.admin-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow);
}

.admin-nav a[aria-current="page"] {
    font-weight: 700;
    text-decoration: none;
}

.admin-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.admin-filter label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.admin-filter select,
.admin-filter input {
    font: inherit;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.admin-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.admin-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1rem;
    margin: 0;
}

.admin-facts dt {
    font-weight: 700;
}

.admin-facts dd {
    margin: 0;
}

.admin-decks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1.5rem;
    font-size: 0.85rem;
}

.admin-decks h3 {
    margin: 0 0 0.25rem;
}

.admin-decks h4 {
    margin: 0.75rem 0 0.25rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.admin-decks ol {
    margin: 0;
    padding-left: 1.5rem;
}

.admin-log {
    font-size: 0.85rem;
}

.admin-log td:first-child {
    white-space: nowrap;
}

.admin-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 800px) {
    .admin-columns {
        grid-template-columns: 1fr;
    }
}

.card--danger {
    border-top: 4px solid var(--color-danger);
}

.pager {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.game-table code {
    font-size: 0.95em;
}

/* Space detail card */
.space {
    cursor: help;
}

.space:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: -3px;
    z-index: 1;
}

.space-card {
    position: absolute;
    z-index: 10;
    width: min(16rem, 90%);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
    font-size: 0.85rem;
    pointer-events: none;
}

.space-card__title {
    margin: -0.6rem -0.75rem 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 0.6rem solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 800;
    text-align: center;
}

.space-card p {
    margin: 0.35rem 0 0;
}

.space-card table {
    width: 100%;
    border-collapse: collapse;
}

.space-card td {
    padding: 0.1rem 0;
}

.space-card td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.space-card__owner {
    font-weight: 700;
}

/* Tokens: the current player's pulses gently */
.space__token {
    display: inline-flex;
}

.space__token--current .token {
    animation: token-pulse 1.4s ease-in-out infinite;
}

@keyframes token-pulse {
    50% { transform: scale(1.25); }
}

@media (prefers-reduced-motion: reduce) {
    .space__token--current .token {
        animation: none;
        outline: 2px solid currentColor;
        border-radius: 50%;
    }
}

/* When it's the viewer's turn to act */
.turn-panel--mine {
    box-shadow: 0 0 0 3px var(--color-primary), var(--shadow);
}

/* Phones: the middle of the board moves below it, and spaces show colour,
   ownership and tokens only. Tap a space for its details. */
@media (max-width: 700px) {
    .page:has(.game) {
        padding-inline: 0.5rem;
    }

    .board-frame {
        width: 100%;
    }

    .board__centre {
        position: static;
        padding: 1rem 0 0;
        font-size: 0.95rem;
    }

    .board__title {
        display: none;
    }

    .die {
        font-size: 3rem;
    }

    .game-log {
        max-height: 14rem;
    }

    .space:not(.space--corner) .space__name,
    .space:not(.space--corner) .space__price {
        display: none;
    }

    .space--corner .space__name {
        font-size: 2.2cqw;
    }

    .space__tokens .token {
        width: 4.5cqw;
        height: 4.5cqw;
    }

    .space-card {
        pointer-events: auto;
    }
}

@media (max-width: 500px) {
    .site-header {
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
        padding: 0.6rem 0.75rem;
    }

    .site-nav {
        gap: 0.75rem;
        font-size: 0.9rem;
    }

    .site-nav a {
        white-space: nowrap;
    }
}
