:root {
    --bg: #f4ead6;
    --panel: rgba(255, 251, 243, 0.86);
    --panel-border: rgba(123, 92, 43, 0.18);
    --text: #2f2417;
    --muted: #6d5a3f;
    --accent: #b66e2f;
    --accent-dark: #894e1d;
    --shadow: 0 22px 50px rgba(93, 65, 33, 0.14);
    --radius: 28px;
    --font-display: "Trebuchet MS", "Avenir Next", sans-serif;
    --font-body: "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 218, 154, 0.85), transparent 28%),
        radial-gradient(circle at bottom right, rgba(219, 143, 66, 0.25), transparent 22%),
        linear-gradient(135deg, #efe4cf 0%, #f7f1e6 45%, #e7dac1 100%);
}

[hidden] {
    display: none !important;
}

button,
input,
select {
    font: inherit;
}

.page-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 8px 0 32px;
}

.room-shell {
    padding-top: 2px;
}

.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 18px;
}

.hero-panel {
    padding: 18px 20px;
}

.hero-content {
    max-width: 44rem;
}

.hero h1,
.room-header h1 {
    font-family: var(--font-display);
    line-height: 0.92;
}

.hero h1 {
    margin: 4px 0 8px;
    font-size: clamp(2rem, 4vw, 3.4rem);
}

.hero-copy {
    max-width: 36rem;
    margin: 0;
    font-size: 0.98rem;
    color: var(--muted);
    white-space: nowrap;
}

.hero-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.hero-card {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hero-card.compact {
    min-width: 240px;
    gap: 10px;
}

.status-chip {
    display: inline-flex;
    width: fit-content;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(182, 110, 47, 0.14);
    color: var(--accent-dark);
    font-weight: 700;
}

.secondary-chip {
    background: rgba(130, 96, 58, 0.1);
    color: var(--muted);
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.72rem;
    color: var(--accent-dark);
}

.layout-grid,
.room-layout {
    display: grid;
    grid-template-columns: 272px 1fr;
    gap: 14px;
}

.panel {
    padding: 16px;
}

.board-panel {
    min-height: 760px;
}

.panel-header,
.seat-card-top,
.room-card-top,
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stack {
    display: grid;
    gap: 16px;
}

label span,
.subtle,
.room-card p,
.seat-card p {
    color: var(--muted);
}

label {
    display: grid;
    gap: 8px;
}

input,
select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(127, 101, 72, 0.24);
    background: rgba(255, 255, 255, 0.7);
}

.primary-button,
.secondary-button,
.piece-pill,
.text-link {
    border: none;
    border-radius: 16px;
    padding: 12px 18px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent) 0%, #d68f4f 100%);
    color: #fffdf8;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(182, 110, 47, 0.24);
}

.secondary-button,
.piece-pill {
    background: rgba(130, 96, 58, 0.1);
    color: var(--text);
}

.text-link {
    background: transparent;
    color: var(--accent-dark);
    padding-left: 0;
    text-decoration: none;
}

.primary-button:hover,
.secondary-button:hover,
.piece-pill:not(:disabled):hover,
.text-link:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.piece-pill:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.room-list,
.seat-list {
    display: grid;
    gap: 10px;
}

.room-card,
.seat-card {
    padding: 12px 13px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(127, 101, 72, 0.16);
}

.room-card h3,
.seat-card h3 {
    margin: 0 0 2px;
    font-size: 1rem;
}

.room-badge {
    min-width: 56px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(182, 110, 47, 0.12);
    text-align: center;
    font-weight: 700;
}

.room-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
    padding: 6px 10px;
    min-height: 0;
}

.room-header-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
}

.room-header .eyebrow {
    font-size: 0.6rem;
    letter-spacing: 0.11em;
}

.room-header h1 {
    margin: 0;
    font-size: clamp(1.1rem, 1.8vw, 1.65rem);
    line-height: 0.9;
}

.room-header #room-status-copy {
    margin: 0;
    font-size: 0.76rem;
}

.start-roll-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(240, 210, 41, 0.22) 0%, rgba(214, 143, 79, 0.18) 100%);
    border: 1px solid rgba(182, 110, 47, 0.22);
    color: var(--accent-dark);
    font-size: 0.88rem;
    font-weight: 700;
}

.room-action-card {
    min-width: 0;
    padding: 6px 8px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    box-shadow: 0 8px 18px rgba(93, 65, 33, 0.07);
}

.room-action-card .primary-button,
.room-action-card .secondary-button {
    width: auto;
    min-width: 148px;
    padding: 7px 14px;
    border-radius: 13px;
}

.room-action-card .status-chip {
    padding: 4px 10px;
    font-size: 0.76rem;
    white-space: nowrap;
}

.is-my-turn .board-panel {
    box-shadow: 0 0 0 3px rgba(46, 159, 107, 0.5), 0 20px 36px rgba(46, 159, 107, 0.16);
    border-color: rgba(46, 159, 107, 0.55);
}

.is-start-roll .room-header,
.is-start-roll .board-panel {
    box-shadow: 0 0 0 2px rgba(214, 143, 79, 0.2), var(--shadow);
}

.is-start-roll #turn-indicator {
    background: linear-gradient(135deg, rgba(240, 210, 41, 0.22) 0%, rgba(214, 143, 79, 0.24) 100%);
    color: var(--accent-dark);
    font-weight: 800;
}

.is-start-roll #roll-button:not([hidden]) {
    background: linear-gradient(135deg, #d9a729 0%, #d68f4f 100%);
    box-shadow: 0 14px 28px rgba(214, 143, 79, 0.3);
}

.is-my-turn #roll-button:not([hidden]) {
    animation: roll-pulse 1.05s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(182, 110, 47, 0.3), 0 12px 24px rgba(182, 110, 47, 0.24);
}

@keyframes roll-pulse {
    0% {
        transform: translateY(0) scale(1);
        box-shadow: 0 0 0 0 rgba(182, 110, 47, 0.32), 0 12px 24px rgba(182, 110, 47, 0.24);
    }

    65% {
        transform: translateY(-1px) scale(1.02);
        box-shadow: 0 0 0 10px rgba(182, 110, 47, 0), 0 16px 30px rgba(182, 110, 47, 0.3);
    }

    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 0 0 0 rgba(182, 110, 47, 0), 0 12px 24px rgba(182, 110, 47, 0.24);
    }
}

@keyframes playable-piece-pulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(182, 110, 47, 0));
    }

    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 10px rgba(182, 110, 47, 0.42));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(182, 110, 47, 0));
    }
}

@keyframes forced-piece-pulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(46, 159, 107, 0));
    }

    55% {
        transform: scale(1.08);
        filter: drop-shadow(0 0 12px rgba(46, 159, 107, 0.5));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 0 rgba(46, 159, 107, 0));
    }
}

@keyframes playable-pill-pulse {
    0% {
        box-shadow: 0 0 0 2px rgba(182, 110, 47, 0.1);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(182, 110, 47, 0.22);
    }

    100% {
        box-shadow: 0 0 0 2px rgba(182, 110, 47, 0.1);
    }
}

@keyframes dice-fly-in {
    0% {
        opacity: 0;
        transform: translate(-50%, 28px) scale(0.35);
        filter: blur(4px);
    }

    24% {
        opacity: 1;
        transform: translate(-50%, 6px) scale(1.34);
        filter: blur(0);
    }

    68% {
        opacity: 1;
        transform: translate(-50%, -6px) scale(1.02);
        filter: blur(0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -18px) scale(0.9);
        filter: blur(1px);
    }
}

.room-footer-nav {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.room-footer-link {
    padding: 4px 0;
    font-size: 0.84rem;
}

.is-fullscreen .page-shell {
    width: min(100vw - 20px, 1720px);
    padding: 8px 0 16px;
}

.is-fullscreen .room-layout {
    grid-template-columns: 250px 1fr;
    gap: 12px;
}

.is-fullscreen .panel {
    padding: 12px;
}

.is-fullscreen .board-panel {
    padding-top: 8px;
}

.is-fullscreen .board-root {
    min-height: calc(100vh - 180px);
}

.is-fullscreen .board-svg {
    max-height: calc(100vh - 210px);
    margin: 0 auto;
}

.is-fullscreen .seat-list .seat-card {
    padding: 8px 9px;
}

.is-fullscreen .piece-pill {
    padding: 6px 7px;
    font-size: 0.72rem;
}

.board-panel {
    padding-top: 10px;
}

.board-panel .panel-header {
    gap: 8px;
    margin-bottom: 0;
}

.vote-kick-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 0 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(208, 130, 45, 0.1);
    border: 1px solid rgba(208, 130, 45, 0.22);
}

.vote-kick-copy {
    font-size: 0.84rem;
    color: var(--text);
}

.board-header-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.dice-flash {
    position: absolute;
    left: 50%;
    top: 84px;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    margin-left: -46px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff9db 0%, #ffd84e 42%, #d39a10 100%);
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(112, 70, 6, 0.45);
    box-shadow: 0 18px 34px rgba(211, 154, 16, 0.32);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 22px) scale(0.38);
}

.dice-flash.is-active {
    animation: dice-fly-in 0.74s cubic-bezier(0.2, 0.84, 0.2, 1) both;
}

.dice-flash.color-red {
    background: radial-gradient(circle at 35% 35%, #ffe3e3 0%, #ef6b6b 42%, #b83232 100%);
}

.dice-flash.color-blue {
    background: radial-gradient(circle at 35% 35%, #e2efff 0%, #4f8ff0 42%, #235bb6 100%);
}

.dice-flash.color-green {
    background: radial-gradient(circle at 35% 35%, #e0f7ea 0%, #46b77c 42%, #1f7b50 100%);
}

.dice-flash.color-yellow {
    background: radial-gradient(circle at 35% 35%, #fff9db 0%, #ffd84e 42%, #d39a10 100%);
}

.my-color-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(130, 96, 58, 0.1);
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.my-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}

.board-root {
    position: relative;
    min-height: 0;
}

.board-svg {
    width: 100%;
    height: auto;
    display: block;
}

.board-piece {
    transition: transform 0.16s ease, filter 0.16s ease;
    transform-box: fill-box;
    transform-origin: center;
    will-change: transform, filter;
}

.board-piece.is-clickable {
    cursor: pointer;
    filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.55));
}

.board-piece.is-clickable:hover {
    transform: scale(1.045);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.85));
}

.board-piece.is-playable-move {
    animation: playable-piece-pulse 1.05s ease-in-out infinite;
}

.board-piece.is-forced-move {
    animation: forced-piece-pulse 0.95s ease-in-out infinite;
}

.board-piece.is-my-piece .piece-core {
    stroke: #fff7cf;
    stroke-width: 6;
    filter: drop-shadow(0 0 6px rgba(255, 245, 184, 0.55));
}

.piece-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
}

.piece-pill {
    text-align: left;
    padding: 7px 8px;
    border-radius: 10px;
    font-size: 0.76rem;
    line-height: 1.1;
}

.piece-pill.is-clickable {
    background: rgba(182, 110, 47, 0.18);
    border: 1px solid rgba(182, 110, 47, 0.28);
}

.piece-pill.is-playable-move {
    box-shadow: 0 0 0 2px rgba(182, 110, 47, 0.12);
    animation: playable-pill-pulse 1.05s ease-in-out infinite;
}

.piece-pill.is-forced-move {
    background: rgba(46, 159, 107, 0.18);
    border: 1px solid rgba(46, 159, 107, 0.42);
    box-shadow: 0 0 0 2px rgba(46, 159, 107, 0.14);
}

.seat-card.is-me {
    outline: 2px solid rgba(182, 110, 47, 0.45);
}

.seat-card.is-turn {
    box-shadow: inset 0 0 0 2px rgba(182, 110, 47, 0.38);
}

.seat-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: currentColor;
}

.seat-card p {
    margin: 0;
    font-size: 0.74rem;
}

.seat-card-top {
    gap: 6px;
    align-items: flex-start;
}

.seat-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.place-badge {
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(182, 110, 47, 0.14);
    color: var(--accent-dark);
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.panel-header .subtle {
    font-size: 0.75rem;
}

.seat-list .seat-card {
    padding: 10px 10px 9px;
    border-radius: 16px;
}

.seat-list .seat-card h3 {
    font-size: 0.9rem;
}

.color-red {
    color: #d64a4a;
}

.color-green {
    color: #2e9f6b;
}

.color-yellow {
    color: #d9a729;
}

.color-blue {
    color: #3478d8;
}

.message-box {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(130, 96, 58, 0.08);
    color: var(--text);
    font-size: 0.9rem;
}

.message-box.is-kicked {
    background: rgba(205, 61, 61, 0.12);
    border: 1px solid rgba(205, 61, 61, 0.28);
    color: #842b2b;
    font-weight: 700;
}

.log-panel {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(127, 101, 72, 0.14);
}

.log-header h3 {
    margin: 0;
}

.move-log {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.log-entry,
.log-empty {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(130, 96, 58, 0.08);
    color: var(--text);
    font-size: 0.85rem;
}

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

.empty-state {
    padding: 24px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
    text-align: center;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: 340px;
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(40, 29, 16, 0.92);
    color: #fff;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.24);
}

.toast.is-error {
    background: rgba(164, 40, 40, 0.94);
}

@media (max-width: 980px) {
    .hero,
    .layout-grid,
    .room-layout,
    .room-header {
        grid-template-columns: 1fr;
        display: grid;
    }

    .page-shell {
        width: min(100% - 20px, 1200px);
    }

    .room-shell {
        padding-top: 4px;
    }

    .room-layout > .board-panel {
        order: 1;
    }

    .room-layout > .panel:first-child {
        order: 2;
    }

    .board-panel {
        min-height: auto;
    }

    .piece-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .board-header-meta {
        width: 100%;
        justify-content: space-between;
    }

    .dice-flash {
        top: 74px;
        width: 84px;
        height: 84px;
        margin-left: -42px;
        font-size: 2.1rem;
    }

    .board-piece.is-forced-move {
        animation-duration: 0.82s;
    }

    .my-color-indicator {
        padding: 6px 10px;
        font-size: 0.82rem;
        background: rgba(46, 159, 107, 0.14);
    }

    .board-piece.is-my-piece .piece-core {
        stroke: #fff4a8;
        stroke-width: 7;
        filter: drop-shadow(0 0 10px rgba(255, 235, 120, 0.8));
    }

    .piece-pill.is-forced-move {
        box-shadow: 0 0 0 2px rgba(46, 159, 107, 0.2);
    }

    .vote-kick-panel {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .hero h1,
    .room-header h1 {
        font-size: 2.1rem;
    }

    .panel,
    .hero-card {
        padding: 16px;
    }

    .room-header {
        padding: 10px 12px;
        gap: 8px;
    }

    .room-action-card {
        min-width: 0;
        width: 100%;
        justify-content: space-between;
    }

    .room-action-card .primary-button,
    .room-action-card .secondary-button {
        min-width: 0;
        width: 100%;
    }

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

    .status-chip {
        font-size: 0.9rem;
    }
}
