:root {
    --ink: #1a1f2b;
    --ink-soft: #4a5168;
    --ink-mute: #7a8199;
    --paper: #f7f6f1;
    --paper-card: #ffffff;
    --line: #d9d6ca;
    --line-strong: #b6b1a0;
    --accent: #2b5f84;
    --accent-ink: #ffffff;
    --accent-soft: #dce8f1;
    --danger: #9a2a2a;
    --good: #2d6a4f;
    --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 4px 16px rgba(20, 20, 30, 0.06);

    --decide: #c96e4a;
    --influence: #c79c3e;
    --contribute: #4d8a53;
    --engage: #4f77a8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--accent-soft);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

button {
    font: inherit;
    cursor: pointer;
    background: var(--paper-card);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 6px 12px;
}
button:hover { background: #fafaf6; }
button.primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
}
button.primary:hover { background: #224f70; }
button.linklike {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0 2px;
    text-decoration: underline;
}

/* ----- Landing page ----- */
.site-header {
    padding: 32px 24px 8px;
    max-width: 960px;
    margin: 0 auto;
}
.site-header h1 { margin: 0; font-size: 28px; }
.tagline { margin: 4px 0 0; color: var(--ink-soft); }

.landing {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 24px 48px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.landing .card.muted { grid-column: 1 / -1; }
@media (max-width: 720px) {
    .landing { grid-template-columns: 1fr; }
}

.card {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.card.muted { background: transparent; box-shadow: none; }
.card h2 { margin: 0 0 12px; font-size: 18px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.stack input, .stack select, .stack textarea {
    font: inherit;
    color: var(--ink);
    background: var(--paper-card);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 8px 10px;
}
.stack input:focus, .stack select:focus, .stack textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: var(--accent);
}
.hint { font-size: 13px; color: var(--ink-mute); margin: 10px 0 0; }

/* ----- Event & team lists on event landing ----- */
.team-list, .event-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.team-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf7;
}
.team-row:hover { border-color: var(--line-strong); }
.team-row-main { flex: 1; min-width: 0; }
.team-row-name { font-weight: 600; }
.team-row-meta { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }
.team-row form { margin: 0; }
.event-list li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.event-list li:last-child { border-bottom: none; }
.event-list .hint { display: inline; margin-left: 8px; }

/* Anchor styled as a primary button */
a.button-link {
    display: inline-block;
    background: var(--accent);
    color: var(--accent-ink);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 6px 12px;
    font: inherit;
    text-decoration: none;
    white-space: nowrap;
}
a.button-link:hover { background: #224f70; text-decoration: none; }

/* ----- Site nav ----- */
.site-nav {
    background: #1a1f2b;
    color: #e7e3d7;
    border-bottom: 3px solid var(--accent);
}
.site-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.site-nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fffdf7;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    font-size: 16px;
}
.site-nav-brand:hover { text-decoration: none; color: #fff; }
.site-nav-brand .brand-mark { width: 22px; height: 22px; display: inline-block; }

.site-nav-links {
    margin-left: auto;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.site-nav-links a {
    color: #c9c5b6;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 120ms ease, color 120ms ease;
}
.site-nav-links a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fffdf7;
    text-decoration: none;
}
.site-nav-links a.is-current {
    background: var(--accent);
    color: #fffdf7;
}
.site-nav-links .ext-mark {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 1px;
}

.site-nav-crumb {
    max-width: 1400px;
    margin: 0 auto;
    padding: 6px 24px 8px;
    font-size: 13px;
    color: #a6a18f;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.site-nav-crumb a {
    color: #dcd7c6;
    text-decoration: none;
}
.site-nav-crumb a:hover { color: #fffdf7; text-decoration: underline; }
.site-nav-crumb .crumb-sep { color: #6d6a5e; }
.site-nav-crumb .crumb-current { color: #fffdf7; font-weight: 600; }

@media (max-width: 560px) {
    .site-nav-inner { padding: 8px 14px; gap: 8px; }
    .site-nav-crumb { padding: 6px 14px 8px; }
    .site-nav-brand .brand-name { display: none; }
}
.error {
    max-width: 960px;
    margin: 0 auto 16px;
    padding: 10px 14px;
    background: #fde2e2;
    color: var(--danger);
    border: 1px solid #f1b6b6;
    border-radius: 8px;
}

/* ----- Board header ----- */
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 20px 24px 12px;
    max-width: 1400px;
    margin: 0 auto;
    border-bottom: 1px solid var(--line);
}
.board-header h1 { margin: 0; font-size: 22px; }
.board-header .sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }

/* ----- The 4x4 board ----- */
.board-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px 32px;
}
.dice-board {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}
.dice-board th, .dice-board td {
    border: 1px solid var(--line);
    vertical-align: top;
    padding: 0;
}
.dice-board thead th {
    background: var(--paper);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--line-strong);
}
.dice-board .col-head { width: 22%; }
.dice-board .corner {
    width: 12%;
    font-size: 11px;
    color: var(--ink-mute);
    position: relative;
    background: var(--paper);
}
.corner-where, .corner-how { display: block; }
.corner-where { text-align: left; }
.corner-how { text-align: right; }
.col-label { font-weight: 700; letter-spacing: 0.04em; }
.dice-board thead th:nth-child(2) .col-label { color: var(--decide); }
.dice-board thead th:nth-child(3) .col-label { color: var(--influence); }
.dice-board thead th:nth-child(4) .col-label { color: var(--contribute); }
.dice-board thead th:nth-child(5) .col-label { color: var(--engage); }
.col-sub { font-size: 11px; color: var(--ink-mute); font-weight: 400; margin-top: 2px; }

.row-head {
    background: var(--paper);
    padding: 10px 12px;
    text-align: left;
    border-right: 2px solid var(--line-strong);
    width: 12%;
}
.row-label { font-weight: 700; letter-spacing: 0.04em; }
.row-sub { font-size: 11px; color: var(--ink-mute); font-weight: 400; margin-top: 2px; }

.cell {
    background: var(--paper-card);
    padding: 8px 10px 10px;
    min-height: 160px;
    position: relative;
}
.cell-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--line);
    padding-bottom: 4px;
}
.cell-title {
    font-size: 11px;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.cell-info {
    border-radius: 50%;
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    background: transparent;
    color: var(--ink-mute);
    border-color: var(--line);
}
.cell-info:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.cell-count {
    font-size: 10px;
    color: var(--ink-mute);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    padding: 1px 5px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}
.cell-count.near-cap { color: #9c6a1c; border-color: #e0c48a; background: #fdf3db; }
.cell-count.at-cap { color: var(--danger); border-color: #e2b0b0; background: #fde2e2; font-weight: 600; }

.cell-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 60px;
}
.item {
    background: #fffdf7;
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    cursor: default;
    position: relative;
}
.item.mine { border-left-color: var(--accent); cursor: pointer; }
.item.mine:hover { background: var(--accent-soft); }
.item.admin-edit { border-left-color: var(--danger); border-left-style: dashed; }
.item.admin-edit:hover { background: #fde2e2; }
.item-title { font-weight: 600; color: var(--ink); }
.item-desc { font-size: 12px; color: var(--ink-soft); margin-top: 2px; white-space: pre-wrap; }
.item-nick { font-size: 11px; color: var(--ink-mute); margin-top: 4px; }

.cell-add {
    margin-top: 8px;
    font-size: 12px;
    width: 100%;
    padding: 5px 8px;
    color: var(--ink-soft);
    border-style: dashed;
    background: transparent;
}
.cell-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.cell.full .cell-add { opacity: 0.5; pointer-events: none; }

/* ----- Modals ----- */
dialog.modal {
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 480px;
    width: calc(100vw - 32px);
}
dialog.modal::backdrop { background: rgba(20, 20, 30, 0.35); }
dialog.modal form { margin: 0; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal .modal-cell { color: var(--ink-mute); font-size: 13px; margin: 0 0 12px; }
.modal .modal-nick { font-size: 12px; color: var(--ink-mute); margin: 0; }
.modal .modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
.modal .spacer { flex: 1; }
#item-delete { color: var(--danger); border-color: #e2b0b0; }
#item-delete:hover { background: #fde2e2; }

.modal-move {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}
.modal-move[hidden] { display: none; }
.modal-move label { font-size: 12px; min-width: 0; }
.modal-move select { width: 100%; min-width: 0; }
@media (max-width: 480px) {
    .modal-move { grid-template-columns: 1fr; }
}

.def-body h3 { margin: 0 0 10px; font-size: 16px; }
.def-body p { margin: 6px 0; font-size: 13px; color: var(--ink-soft); }
.def-body ul { margin: 8px 0; padding-left: 20px; font-size: 13px; }
.def-body .def-example { color: var(--ink-mute); font-size: 12px; }

/* ----- Gallery ----- */
.gallery-wrap {
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px 24px 48px;
}
.gallery-wrap h1 { margin: 0 0 4px; font-size: 22px; }
.gallery-wrap .sub { color: var(--ink-soft); margin: 0 0 20px; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
    gap: 20px;
}
.gallery-team {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.gallery-team h2 { margin: 0 0 8px; font-size: 16px; }
.gallery-team .gtable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: 11px;
}
.gallery-team .gtable th, .gallery-team .gtable td {
    border: 1px solid var(--line);
    padding: 4px 6px;
    vertical-align: top;
}
.gallery-team .gtable thead th { background: var(--paper); text-align: left; font-size: 10px; }
.gallery-team .gtable .row-head-g { background: var(--paper); font-weight: 700; font-size: 10px; width: 14%; }
.gallery-team .gtable .gcell { min-height: 40px; }
.gallery-team .gitem {
    background: #fffdf7;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 2px 4px;
    margin-bottom: 3px;
    font-size: 11px;
}
.gallery-team .gitem .gtitle { font-weight: 600; }
.gallery-team .gitem .gnick { color: var(--ink-mute); font-size: 10px; }

/* ----- Admin ----- */
.admin-wrap {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 24px 48px;
}
.admin-wrap h1 { margin: 0 0 16px; }
.admin-wrap section { margin-bottom: 28px; }
.admin-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-wrap th, .admin-wrap td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-wrap form.inline { display: inline; }
.admin-wrap .actions form { display: inline-block; margin-right: 6px; }
.flash {
    background: #e8f5e9;
    color: var(--good);
    border: 1px solid #b7d9ba;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}
