:root {
    color-scheme: dark;
    --background: #111318;
    --panel: #1c2028;
    --panel-light: #252b35;
    --border: #353d49;
    --text: #f4f5f7;
    --muted: #aeb6c4;
    --accent: #d9a441;
    --accent-dark: #a87923;
    --danger: #c94c4c;
    --good: #4ca66c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(217, 164, 65, 0.09), transparent 35rem),
        var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #151920;
    color: var(--text);
    font: inherit;
}

button {
    padding: 0.65rem 1rem;
    cursor: pointer;
}

button:hover {
    border-color: var(--accent);
}

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #17130b;
    font-weight: 700;
}

button.secondary {
    background: var(--panel-light);
}

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

input,
select,
textarea {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem;
}

textarea {
    min-height: 5rem;
    resize: vertical;
}

label {
    color: var(--muted);
    font-size: 0.92rem;
}

hr {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1rem max(1rem, calc((100vw - 1180px) / 2));
    border-bottom: 1px solid var(--border);
    background: rgba(17, 19, 24, 0.92);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1,
.topbar p {
    margin: 0;
}

.topbar h1 {
    color: var(--accent);
    font-size: 1.5rem;
}

.topbar p {
    color: var(--muted);
    font-size: 0.85rem;
}

.topbar nav {
    display: flex;
    gap: 0.5rem;
}

.nav-button.active {
    color: var(--accent);
    border-color: var(--accent);
}

main {
    width: min(1180px, calc(100% - 2rem));
    margin: 1.5rem auto 4rem;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.panel {
    margin-bottom: 1rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(28, 32, 40, 0.95);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.18);
}

.panel h2,
.panel h3,
.panel h4 {
    margin-top: 0;
}

.hidden {
    display: none !important;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    align-items: end;
}

.action-grid {
    grid-template-columns: repeat(4, 1fr);
}

.seat-grid,
.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.player-card {
    display: flex;
    min-height: 7rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--good);
    border-radius: 10px;
    background: var(--panel-light);
}

.player-card.dead {
    opacity: 0.55;
    border-left-color: var(--danger);
    filter: grayscale(0.7);
}

.player-card span {
    color: var(--accent);
}

.player-card small,
.hint,
.empty {
    color: var(--muted);
}

.game-heading,
.section-heading,
.button-row,
.inline-form,
.timer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.game-heading,
.section-heading {
    justify-content: space-between;
}

.inline-form {
    flex-wrap: wrap;
    margin-top: 0.8rem;
}

.inline-form > * {
    flex: 1 1 150px;
}

.button-row {
    margin-top: 1rem;
}

.reveal-card {
    display: grid;
    max-width: 420px;
    gap: 1rem;
    margin: 1rem auto 0;
    padding: 2rem;
    border: 1px solid var(--accent-dark);
    border-radius: 14px;
    text-align: center;
    background: #151920;
}

.reveal-card strong {
    font-size: 1.3rem;
}

.secret {
    padding: 1.2rem;
    border-radius: 8px;
    background: var(--accent);
    color: #18130a;
    font-size: 1.7rem;
    font-weight: 800;
}

.timer {
    flex-wrap: wrap;
}

#timer-display {
    min-width: 7rem;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    font-size: 2.4rem;
    font-weight: 800;
}

.result,
.winner {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-weight: 700;
}

.winner {
    font-size: 1.3rem;
}

.history-game {
    margin-bottom: 0.8rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-light);
}

.history-game summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 700;
}

.identity-list {
    columns: 3 180px;
}

.timeline {
    padding-left: 1.5rem;
}

.timeline li {
    margin-bottom: 0.8rem;
    padding-left: 0.4rem;
}

.timeline time,
.timeline span,
.timeline strong {
    display: block;
}

.timeline time,
.timeline span {
    color: var(--muted);
    font-size: 0.8rem;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 20;
    max-width: min(420px, calc(100% - 2rem));
    padding: 0.9rem 1.2rem;
    border: 1px solid var(--good);
    border-radius: 9px;
    background: #193523;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
}

.toast.error {
    border-color: var(--danger);
    background: #481f1f;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .action-grid {
        grid-template-columns: 1fr 1fr;
    }

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

@media (max-width: 480px) {
    .action-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar nav,
    .topbar nav button {
        width: 100%;
    }

    .topbar nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}
