:root {
    color-scheme: light;
    --ink: #182a24;
    --forest: #173d32;
    --forest-soft: #285448;
    --leaf: #dce9e0;
    --leaf-deep: #c7dbce;
    --paper: #f8f9f4;
    --white: #ffffff;
    --line: #c8d5cc;
    --muted: #66776f;
    --coral: #e5684e;
    --coral-dark: #b94a36;
    --gold: #f2c95d;
    --shadow: 0 16px 42px rgb(24 42 36 / 10%);
    font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background-color: #eaf0eb;
    background-image: linear-gradient(rgb(23 61 50 / 3%) 1px, transparent 1px), linear-gradient(90deg, rgb(23 61 50 / 3%) 1px, transparent 1px);
    background-size: 32px 32px;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

.app-shell {
    width: min(1180px, calc(100% - 48px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 26px 0 44px;
}

.site-head,
.game-topline,
.panel-heading,
.turn-heading,
.score-summary,
.invite-row,
.game-actions,
.room-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-head {
    min-height: 42px;
    margin-bottom: 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--forest);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    grid-template: repeat(2, 1fr) / repeat(2, 1fr);
    align-items: center;
    justify-items: center;
    padding: 8px;
    border-radius: 10px 10px 10px 3px;
    background: var(--coral);
    transform: rotate(-4deg);
}

.brand-mark i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--white);
}

.brand-mark i:last-child {
    grid-column: 2;
}

.brand-name {
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 20px;
    font-weight: 700;
}

.private-label,
.room-status,
.turn-pill,
.roll-count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--forest);
    background: rgb(248 249 244 / 80%);
    font-size: 12px;
    font-weight: 700;
}

.private-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--coral);
}

.entry-grid {
    display: grid;
    min-height: 490px;
    grid-template-columns: minmax(0, 1.08fr) minmax(330px, .92fr);
    overflow: hidden;
    border: 1px solid var(--forest);
    border-radius: 8px;
    background: var(--forest);
    box-shadow: var(--shadow);
    animation: settle-in 420ms ease-out both;
}

.entry-story {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 490px;
    padding: clamp(30px, 6vw, 70px);
    overflow: hidden;
    color: var(--paper);
    background: var(--forest);
}

.entry-story::after {
    position: absolute;
    right: -84px;
    bottom: -110px;
    width: 300px;
    height: 300px;
    border: 1px solid rgb(248 249 244 / 15%);
    border-radius: 50%;
    content: "";
    box-shadow: 0 0 0 22px rgb(248 249 244 / 4%), 0 0 0 54px rgb(248 249 244 / 4%);
    pointer-events: none;
}

.eyebrow {
    margin: 0 0 22px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.entry-story h1,
.game-title h1 {
    max-width: 580px;
    margin: 0;
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: clamp(42px, 5vw, 68px);
    font-weight: 700;
    line-height: 1.02;
}

.entry-story h1 span {
    color: var(--gold);
    font-style: italic;
}

.entry-copy {
    max-width: 390px;
    margin: 23px 0 0;
    color: #d2e0d6;
    font-size: 16px;
    line-height: 1.65;
}

.dice-still-life {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-top: 45px;
}

.mini-die {
    display: grid;
    width: 54px;
    aspect-ratio: 1;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    align-items: center;
    justify-items: center;
    padding: 10px;
    border-radius: 11px 11px 11px 3px;
    background: var(--paper);
    box-shadow: 0 6px 15px rgb(0 0 0 / 18%);
    transform: rotate(-8deg);
}

.mini-die:nth-child(2) {
    background: var(--gold);
    transform: translateY(-9px) rotate(7deg);
}

.mini-die:nth-child(3) {
    transform: rotate(4deg);
}

.mini-die i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--forest);
}

.mini-die i.hidden {
    visibility: hidden;
}

.entry-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 5vw, 58px);
    background: var(--paper);
}

.entry-form {
    width: min(100%, 360px);
}

.entry-form h2,
.lobby-heading h2,
.score-heading h2 {
    margin: 0;
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 30px;
    line-height: 1.15;
}

.form-intro {
    margin: 10px 0 27px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 800;
}

.text-input {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--ink);
    background: var(--white);
}

.primary-button,
.secondary-button,
.quiet-button {
    min-height: 46px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.primary-button {
    color: var(--white);
    background: var(--coral);
}

.primary-button:hover:not(:disabled) {
    background: var(--coral-dark);
    transform: translateY(-1px);
}

.secondary-button {
    color: var(--white);
    background: var(--forest);
}

.secondary-button:hover:not(:disabled) {
    background: var(--forest-soft);
    transform: translateY(-1px);
}

.quiet-button {
    min-height: 38px;
    padding: 0 12px;
    border-color: var(--line);
    color: var(--forest);
    background: transparent;
}

.quiet-button:hover:not(:disabled) {
    border-color: var(--forest);
    background: var(--leaf);
}

.entry-form .primary-button,
.entry-form .secondary-button {
    width: 100%;
    margin-top: 14px;
}

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

.notice {
    min-height: 22px;
    margin: 12px 0 0;
    color: var(--coral-dark);
    font-size: 13px;
    line-height: 1.45;
}

.game-view {
    animation: settle-in 360ms ease-out both;
}

.game-topline {
    margin-bottom: 23px;
}

.game-title h1 {
    font-size: 36px;
}

.game-title p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.room-status {
    background: var(--paper);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(260px, .78fr) minmax(0, 1.55fr);
    align-items: start;
    gap: 20px;
}

.play-column,
.score-column {
    min-width: 0;
}

.play-panel,
.lobby-panel {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--paper);
    box-shadow: 0 7px 22px rgb(24 42 36 / 5%);
}

.play-panel {
    position: sticky;
    top: 18px;
}

.panel-kicker {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.turn-heading h2 {
    margin: 0;
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 25px;
    line-height: 1.15;
}

.turn-pill {
    min-height: 27px;
    padding: 5px 9px;
    color: var(--forest);
    background: var(--leaf);
    font-size: 11px;
    white-space: nowrap;
}

.dice-tray {
    display: grid;
    grid-template-columns: repeat(5, minmax(38px, 1fr));
    gap: 8px;
    margin: 25px 0 18px;
}

.die-button {
    display: grid;
    width: 100%;
    aspect-ratio: 1;
    grid-template: repeat(3, 1fr) / repeat(3, 1fr);
    align-items: center;
    justify-items: center;
    padding: 9px;
    border: 1px solid #d5ded6;
    border-radius: 9px 9px 9px 3px;
    background: var(--white);
    box-shadow: 0 3px 0 #d9e1db;
    cursor: pointer;
    transition: transform 130ms ease, background-color 130ms ease, box-shadow 130ms ease;
}

.die-button:hover:not(:disabled) {
    transform: translateY(-2px);
}

.die-button.held {
    border-color: var(--forest);
    background: var(--gold);
    box-shadow: 0 3px 0 #d1ad4f;
    transform: translateY(-4px) rotate(-3deg);
}

.die-button i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--forest);
}

.die-button i.hidden {
    visibility: hidden;
}

.roll-count {
    min-height: 25px;
    padding: 4px 9px;
    color: var(--muted);
    background: transparent;
    font-size: 11px;
}

.game-actions {
    margin-top: 16px;
}

.game-actions .primary-button {
    flex: 1;
}

.turn-hint {
    min-height: 36px;
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.lobby-panel {
    margin-top: 15px;
}

.lobby-heading h2,
.score-heading h2 {
    font-size: 22px;
}

.lobby-heading p,
.score-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.player-list {
    display: grid;
    gap: 8px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 7px 9px;
    border-radius: 4px;
    background: var(--leaf);
    font-size: 13px;
    font-weight: 700;
}

.player-initial {
    display: grid;
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    place-items: center;
    border-radius: 50%;
    color: var(--white);
    background: var(--forest-soft);
    font-size: 11px;
}

.host-tag {
    margin-left: auto;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.invite-box {
    margin-top: 15px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.invite-box label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.invite-row {
    gap: 8px;
}

.invite-input {
    min-width: 0;
    min-height: 38px;
    flex: 1;
    padding: 0 9px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--forest);
    background: var(--white);
    font-size: 11px;
    text-overflow: ellipsis;
}

.room-footer {
    margin-top: 14px;
}

.score-panel {
    padding: 20px 20px 13px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--paper);
    box-shadow: 0 7px 22px rgb(24 42 36 / 5%);
}

.score-heading {
    margin-bottom: 16px;
}

.score-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.score-table {
    width: 100%;
    min-width: 450px;
    border-collapse: collapse;
    font-size: 12px;
    text-align: center;
}

.score-table th,
.score-table td {
    height: 34px;
    padding: 4px 7px;
    border-bottom: 1px solid #e2e8e2;
}

.score-table thead th {
    position: sticky;
    top: 0;
    color: var(--muted);
    background: var(--paper);
    font-size: 11px;
    font-weight: 800;
}

.score-table thead th:first-child,
.score-table tbody th {
    width: 150px;
    text-align: left;
}

.score-table tbody th {
    color: #35483f;
    font-size: 12px;
    font-weight: 700;
}

.score-table .group-row th {
    height: 30px;
    padding-top: 10px;
    border-bottom: 0;
    color: var(--forest);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.score-table .group-row td {
    border-bottom: 0;
}

.score-table .you-column {
    color: var(--forest);
    background: rgb(220 233 224 / 45%);
}

.score-choice {
    width: 38px;
    min-height: 28px;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--coral-dark);
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 900;
}

.score-choice:hover {
    border-color: var(--coral);
    background: #fff0e9;
}

.score-choice.zero-score {
    color: var(--muted);
}

.score-total-row th,
.score-total-row td {
    height: 43px;
    border-top: 2px solid var(--forest);
    border-bottom: 0;
    color: var(--forest);
    font-size: 14px;
    font-weight: 900;
}

.score-subtotal {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 600;
}

.player-column-name {
    display: block;
    max-width: 116px;
    overflow: hidden;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-column-name.active-player::after {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 5px;
    border-radius: 50%;
    background: var(--coral);
    content: "";
    vertical-align: 1px;
}

.finished-banner {
    margin: 0 0 18px;
    padding: 15px 18px;
    border-radius: 6px;
    color: var(--forest);
    background: var(--gold);
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 20px;
    font-weight: 700;
}

.loading-message {
    padding: 40px 0;
    color: var(--forest);
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-size: 24px;
}

@keyframes settle-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 860px) {
    .game-layout {
        grid-template-columns: minmax(250px, .8fr) minmax(0, 1.2fr);
        gap: 13px;
    }

    .play-panel,
    .lobby-panel {
        padding: 17px;
    }

    .score-panel {
        padding: 17px 14px 11px;
    }
}

@media (max-width: 700px) {
    .app-shell {
        width: min(100% - 28px, 540px);
        padding-top: 16px;
    }

    .site-head {
        margin-bottom: 17px;
    }

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

    .entry-story {
        min-height: 350px;
        padding: 34px 26px 28px;
    }

    .entry-story h1 {
        font-size: 46px;
    }

    .entry-copy {
        max-width: 330px;
        font-size: 14px;
    }

    .dice-still-life {
        margin-top: 28px;
    }

    .mini-die {
        width: 43px;
        padding: 8px;
    }

    .entry-form-side {
        padding: 30px 25px;
    }

    .game-topline {
        align-items: flex-start;
    }

    .game-title h1 {
        font-size: 30px;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .play-panel {
        position: static;
    }

    .dice-tray {
        gap: 10px;
    }

    .score-panel {
        padding: 16px 10px 9px;
    }

    .score-heading {
        padding: 0 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}