:root {
    --paper: #f5f0e6;
    --ink: #181411;
    --accent: #f05d23;
    --accent-deep: #b33a14;
    --mint: #7abf8e;
    --mud: #75563a;
    --sand: #ddc39a;
    --panel: rgba(255, 249, 239, 0.9);
    --line: rgba(24, 20, 17, 0.12);
    --shadow: 0 18px 45px rgba(24, 20, 17, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink);
    background: radial-gradient(circle at top left, rgba(240, 93, 35, 0.24), transparent 30%), linear-gradient(135deg, #f6ead4 0%, #c4b08f 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 36px 36px;
    pointer-events: none;
    opacity: 0.45;
}

.topbar,
.page-shell {
    position: relative;
    z-index: 1;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1.5rem 2rem 0;
}

.brand {
    color: var(--ink);
    text-decoration: none;
    font-size: 1.8rem;
    font-weight: 700;
}

.tagline,
.muted,
.list-item p,
.panel p {
    color: rgba(24, 20, 17, 0.72);
}

.page-shell {
    padding: 1.5rem 2rem 2rem;
}

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

.hero-card {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 2rem;
    padding: 2rem;
    align-items: center;
}

.login-card h1 {
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    line-height: 0.95;
    margin: 0.4rem 0 1rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
    color: var(--accent-deep);
    margin: 0;
}

.lead {
    font-size: 1.1rem;
    max-width: 34rem;
}

.hero-splash {
    display: block;
    width: min(100%, 520px);
    margin-top: 1.2rem;
    border-radius: 18px;
    border: 1px solid rgba(24, 20, 17, 0.12);
    box-shadow: 0 14px 28px rgba(24, 20, 17, 0.18);
}

.stack-form {
    display: grid;
    gap: 0.8rem;
}

.compact-form {
    margin-top: 0.8rem;
}

input,
select,
button,
.link-button {
    border-radius: 16px;
    border: 1px solid rgba(24, 20, 17, 0.15);
    font: inherit;
}

input,
select {
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.8);
    width: 100%;
}

button,
.link-button {
    background: var(--accent);
    color: white;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 140ms ease, background 140ms ease;
}

.row-actions form {
    margin: 0;
}

button:hover,
.link-button:hover {
    transform: translateY(-1px);
    background: var(--accent-deep);
}

.ghost-button {
    background: transparent;
    color: var(--ink);
}

.grid {
    display: grid;
    gap: 1.2rem;
}

.two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1.2rem;
}

.game-layout {
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    align-items: start;
}

.board-panel,
.sidebar-panel {
    min-width: 0;
}

.panel {
    padding: 1.35rem;
}

.panel-heading,
.split-row,
.row-actions,
.topbar-actions,
.split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.list-block,
.player-stack,
.log-list {
    display: grid;
    gap: 0.8rem;
}

.list-item,
.player-card,
.tile-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0.9rem;
    background: rgba(255, 255, 255, 0.55);
}

.list-item.stretch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.6rem;
}

.chip,
.handle-pill,
.roll-chip {
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    background: rgba(24, 20, 17, 0.08);
    font-size: 0.9rem;
}

.bot {
    background: rgba(122, 191, 142, 0.25);
}

.stale-chip {
    background: rgba(240, 93, 35, 0.18);
    border: 1px solid rgba(240, 93, 35, 0.24);
}

.active-chip,
.current-player,
.tile-card.current {
    border-color: rgba(240, 93, 35, 0.55);
    box-shadow: inset 0 0 0 1px rgba(240, 93, 35, 0.2);
}

.bankrupt {
    opacity: 0.55;
}

.notice {
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 16px;
}

.notice.error {
    background: rgba(179, 58, 20, 0.12);
    color: #70210c;
}

.notice.success {
    background: rgba(122, 191, 142, 0.16);
    color: #214f2e;
}

.move-notice {
    background: rgba(240, 93, 35, 0.12);
    color: #6b2810;
}

.board-grid {
    display: grid;
    grid-template-columns: repeat(13, minmax(0, 1fr));
    grid-template-rows: repeat(13, minmax(0, 1fr));
    gap: 0.45rem;
    aspect-ratio: 1;
    min-height: 840px;
    padding: 0.45rem;
    background: linear-gradient(145deg, rgba(117, 86, 58, 0.16), rgba(221, 195, 154, 0.35));
    border-radius: 24px;
    overflow: auto;
    position: relative;
}

.board-center-art {
    grid-column: 2 / 13;
    grid-row: 2 / 13;
    border-radius: 26px;
    overflow: hidden;
    position: relative;
    min-height: 0;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(24, 20, 17, 0.08);
}

.board-center-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.92) contrast(1.02);
}

.board-center-copy {
    position: absolute;
    left: 1.25rem;
    bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border-radius: 18px;
    background: rgba(245, 240, 230, 0.82);
    backdrop-filter: blur(8px);
}

.board-center-copy h3 {
    margin: 0.2rem 0 0;
    font-size: 1.4rem;
}

.tile-top {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 700;
    align-items: flex-start;
}

.tile-type {
    color: var(--accent-deep);
}

.tile-card {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 0.35rem;
    padding: 0.45rem;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.tile-avatar-layer {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    width: calc(100% - 0.8rem);
    pointer-events: none;
}

.tile-avatar {
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.62rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(24, 20, 17, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.turn-avatar {
    transform: scale(1.08);
    box-shadow: 0 0 0 2px rgba(240, 93, 35, 0.25), 0 4px 10px rgba(24, 20, 17, 0.18);
}

.tile-accent {
    display: block;
    height: 0.42rem;
    border-radius: 999px;
}

.tile-image-wrap {
    border-radius: 12px;
    overflow: hidden;
    background: rgba(117, 86, 58, 0.08);
    min-height: 3.4rem;
}

.tile-image {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 3.4rem;
    object-fit: cover;
}

.tile-name {
    font-size: 0.82rem;
    line-height: 1.15;
}

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

.compact-heading h3 {
    margin: 0.2rem 0 0;
}

.asset-section {
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.loan-actions,
.asset-list,
.asset-actions {
    display: grid;
    gap: 0.6rem;
}

.asset-list {
    margin-top: 0.9rem;
}

.asset-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.5);
}

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

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

.audio-controls {
    display: grid;
    gap: 0.65rem;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.audio-volume-label {
    margin: 0;
}

.move-avatar-overlay {
    position: absolute;
    width: 1.95rem;
    height: 1.95rem;
    margin-left: -0.975rem;
    margin-top: -0.975rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(24, 20, 17, 0.24);
    border: 2px solid rgba(255, 255, 255, 0.85);
    pointer-events: none;
    z-index: 8;
    transition: left 180ms ease, top 180ms ease;
}

.tile-card .chips {
    margin-top: 0.15rem;
}

.tile-card .chip {
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
}

.log-list {
    max-height: 20rem;
    overflow: auto;
}

.chat-list {
    display: grid;
    gap: 0.7rem;
    max-height: 18rem;
    overflow: auto;
}

.chat-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.75rem 0.85rem;
    background: rgba(255, 255, 255, 0.55);
}

.chat-item p {
    margin: 0.35rem 0;
}

@media (max-width: 900px) {
    .hero-card,
    .two-up,
    .game-layout {
        grid-template-columns: 1fr;
    }

    .topbar,
    .page-shell {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .page-shell {
        padding-top: 1rem;
        padding-bottom: 1.25rem;
    }

    .panel,
    .hero-card {
        padding: 1rem;
        border-radius: 20px;
    }

    .list-item.stretch,
    .row-actions,
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-heading,
    .split,
    .split-row,
    .topbar-actions {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .row-actions > *,
    .row-actions form,
    .row-actions button,
    .row-actions .link-button {
        width: 100%;
    }

    .topbar-actions {
        width: 100%;
    }

    .handle-pill {
        width: 100%;
        text-align: center;
    }

    .board-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .board-grid {
        width: 620px;
        min-width: 620px;
        min-height: 620px;
        gap: 0.3rem;
    }

    .sidebar-panel {
        gap: 0.9rem;
    }

    .player-card,
    .list-item,
    .asset-card,
    .chat-item,
    .tile-card {
        border-radius: 16px;
    }

    .audio-controls,
    .loan-actions,
    .asset-list,
    .asset-actions,
    .trade-form,
    .stack-form {
        gap: 0.7rem;
    }

    .log-list,
    .chat-list {
        max-height: none;
    }

    .tile-name {
        font-size: 0.72rem;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 1rem 1rem 0;
    }

    .brand {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.92rem;
        margin-top: 0.35rem;
    }

    .hero-card {
        gap: 1.25rem;
    }

    .login-card h1 {
        font-size: clamp(1.9rem, 11vw, 3rem);
    }

    .lead {
        font-size: 1rem;
    }

    .panel-heading h1,
    .panel-heading h2,
    .split h1,
    .split h2 {
        margin: 0.2rem 0 0;
    }

    .board-grid {
        width: 520px;
        min-width: 520px;
        min-height: 520px;
    }

    .board-center-copy {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        padding: 0.7rem 0.85rem;
    }

    .board-center-copy h3 {
        font-size: 1.05rem;
    }

    .roll-chip,
    .chip,
    .handle-pill {
        font-size: 0.82rem;
    }

    .tile-avatar {
        width: 1.35rem;
        height: 1.35rem;
        font-size: 0.56rem;
    }

    .tile-card p,
    .chat-item p,
    .asset-card p {
        font-size: 0.78rem;
    }
}
