/* Card color text classes for challenge results dialog - now bigger, blocky, and on its own line */
.card-color-white, .card-color-gray, .card-color-blue, .card-color-green, .card-color-yellow, .card-color-pink {
    display: block;
    margin: 12px auto 8px auto;
    font-family: 'Arial Black', 'Arial Narrow', Arial, sans-serif;
    font-variant: small-caps;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 900;
    font-size: 2.1em;
    line-height: 1.08;
    text-align: center;
    border-radius: 5px;
    padding: 2px 8px 2px 8px;
    box-sizing: border-box;
}
.card-color-white {
    color: #fffdf4 !important;
    text-shadow: 0 1px 2px #2f2618cc, 0 0 2px #fff8, 1px 0 2px #2f261899, -1px 0 2px #2f261899;
}
.card-color-gray {
    color: #bcbcbc !important;
    text-shadow: 0 1px 2px #2f2618cc, 0 0 2px #fff8, 1px 0 2px #2f261899, -1px 0 2px #2f261899;
}
.card-color-blue {
    color: #2a6fd6 !important;
    text-shadow: 0 1px 2px #2f2618cc, 0 0 2px #fff8, 1px 0 2px #2f261899, -1px 0 2px #2f261899;
}
.card-color-green {
    color: #43d943 !important;
    text-shadow:
        0 1px 2px #2f2618cc,
        0 0 2px #fff8,
        1px 0 2px #2f261899,
        -1px 0 2px #2f261899,
        0 0 2px #fff,
        0 1.5px 4px #fff;
}
.card-color-yellow {
    color: #ffe14a !important;
    text-shadow: 0 1px 2px #2f2618cc, 0 0 2px #fff8, 1px 0 2px #2f261899, -1px 0 2px #2f261899;
}
.card-color-pink {
    color: #ea739a !important;
    text-shadow: 0 1px 2px #2f2618cc, 0 0 2px #fff8, 1px 0 2px #2f261899, -1px 0 2px #2f261899;
}
/* Ensures color card names are readable on any background */
.card-color-text {
    text-shadow:
        0 1px 2px #2f2618cc,
        0 0 2px #fff8,
        1px 0 2px #2f261899,
        -1px 0 2px #2f261899;
    font-weight: 900;
    padding: 0 2px;
    border-radius: 3px;
    /* color is set inline or by other classes */
}
/* Dialog and spinner headers: all-caps, blocky, sans-serif */
.spinner-header,
.dialog-card .dialog-header,
.challenge-context {
    font-family: 'Arial Black', 'Arial Narrow', Arial, sans-serif;
    font-variant: small-caps;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 900;
    font-size: 1.13em;
    text-align: center;
    color: #2f2618;
    background: transparent;
    border: none;
    padding: 0;
}
/* Discarded card visual below player hand */
.discarded-card-visual {
    position: relative;
    width: 38px;
    height: 54px;
    margin: 8px auto 0 auto;
    display: block;
    z-index: 10;
}
.discarded-card-visual img {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.13);
}
.discarded-card-visual .discard-x {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}
.discarded-card-visual .discard-x svg {
    width: 90%;
    height: 90%;
    display: block;
    opacity: 0.5;
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 4px #fff6);
}

/* Good sir, changed to absolute to match JS and avoid breaking other animations */
.flying-discard-card {
    position: absolute;
    aspect-ratio: 5 / 7;
    border: 1.5px solid #ea739a;
    border-radius: 4px;
    background: linear-gradient(180deg, #fff9e9 0%, #e7d6b0 100%);
    box-shadow: 0 8px 16px rgba(45, 28, 11, 0.32);
    pointer-events: none;
    opacity: 0.98;
    z-index: 2002;
    transition:
        opacity 0.9s cubic-bezier(0.4,0.2,0.2,1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}
.flying-discard-card img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.13);
}
.flying-discard-card .discard-x {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}
.flying-discard-card .discard-x svg {
    width: 90%;
    height: 90%;
    display: block;
    opacity: 0.5;
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 4px #fff6);
}
/* Spinner card styled like results dialog card */
.spinner-card {
    background: #fffbe8 !important;
    border-radius: 18px;
    box-shadow: 0 6px 12px rgba(0,0,0,1.00 );
    padding: 32px 24px 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-width: 340px;
    min-height: 440px;
    padding-top: 8px;
    padding-bottom: 32px;
    overflow: hidden;
    max-width: 96vw;
    max-height: 96vh;
    opacity: 1 !important;
}

.spinner-header {
    margin-top: 0;
    margin-bottom: 2px;
    padding: 16px 0 10px 0;
    text-align: center;
    width: 100%;
    font-weight: bold;
    font-size: 1.25em;
    z-index: 2;
    background: transparent;
    border-bottom: 2px solid transparent;
    box-shadow: none;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    position: relative;
}
/* Spinner panel styled like choicePanel */
.spinner-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--card, #fffbe8);
    border-radius: 18px;
    box-shadow: 0 6px 32px rgba(0,0,0,0.13);
    padding: 32px 24px 28px 24px;
    z-index: 998;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 320px;
    min-height: 320px;
    max-width: 96vw;
    max-height: 96vh;
}
.character-card .pawn-name {
    font-size: 13px !important;
}

/* Raise name text for Blabber, Snooper, Doggie Daddy in setup screen */
.character-card[data-character-id="blabber"] .pawn-name {
    bottom: 13% !important;
}
.character-card[data-character-id="snooper"] .pawn-name {
    bottom: 14% !important;
}
.character-card[data-character-id="doggie-daddy"] .pawn-name {
    bottom: 10% !important;
}
.character-card[data-character-id="baba-looey"] .pawn-name {
    bottom: 6% !important;
}
/* Setup screen: restore pawn size and centering in character cards */
.character-card .pawn {
    position: static;
    width: 96px;
    height: 120px;
    transform: none;
    margin: 0 auto;
    display: block;
}
.character-card .pawn-inner {
    width: 100%;
    height: 100%;
}
:root {
    --paper: #efe1be;
    --paper-strong: #e0ca93;
    --ink: #2f2618;
    --ink-soft: #5a4f3a;
    --pink: #ea739a;
    --pink-dark: #b2416f;
    --sky: #d5e6ee;
    --card: rgba(255, 250, 236, 0.92);
    --border: rgba(69, 48, 28, 0.22);
    --shadow: 0 24px 48px rgba(71, 44, 20, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
    color: var(--ink);
    overflow-x: hidden;
    overflow-y: auto;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 30%),
        linear-gradient(180deg, #f4e7c8 0%, #dbc08e 100%);
}

body.in-game {
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

.hidden {
    display: none !important;
}

.page-shell {
    height: 100dvh;
    padding: 8px 8px 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.breadcrumbs {
    flex: 0 0 auto;
    text-align: center;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.breadcrumbs a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid rgba(107, 79, 44, 0.35);
}

.breadcrumbs a:hover {
    border-bottom-color: rgba(107, 79, 44, 0.75);
}

.breadcrumbs span {
    margin: 0 0.45rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 8px;
    flex: 0 0 auto;
}

.eyebrow,
.kicker,
.status-label,
.panel-caption {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: var(--ink-soft);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: clamp(1.55rem, 2.4vw, 2.3rem);
    font-family: Impact, 'Arial Black', Arial, sans-serif;
}

.subtitle {
    margin-bottom: 0;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ghost-button,
.primary-button,
.option-button,
.spinner-button,
.choice-button {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 13px;
    cursor: pointer;
    transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.ghost-button,
.option-button,
.choice-button {
    background: rgba(255, 252, 245, 0.72);
    color: var(--ink);
}

.ghost-button:hover,
.primary-button:hover,
.option-button:hover,
.spinner-button:hover,
.choice-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(74, 48, 24, 0.12);
}

.primary-button,
.spinner-button {
    background: linear-gradient(180deg, #ef4102 0%, #e05014 100%);
    color: #fff9f0;
    font-family: 'Arial Black', 'Arial Narrow', Arial, sans-serif;
    font-size: 1.1em;
    font-variant: normal;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.primary-button:disabled,
.spinner-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.spinner-button {
    padding: 10px 18px 9px;
    border: 2px solid #3b1f0e;
    border-radius: 16px 22px 18px 20px;
    background: linear-gradient(180deg, #ef4102 0%, #e05014 100%);
    color: #fff8dc;
    font-family: 'Arial Black', 'Arial Narrow', Arial, sans-serif;
    font-weight: 900;
    font-size: 1.08em;
    letter-spacing: 0.04em;
    text-shadow: none;
    box-shadow: 0 4px 0 #612210, 0 12px 16px rgba(70, 33, 17, 0.2);
}

.spinner-button:hover:not(:disabled) {
    transform: translateY(-2px) rotate(0deg) scale(1.03);
    box-shadow: 0 6px 0 #612210, 0 14px 20px rgba(70, 33, 17, 0.24);
}

.spinner-button:active:not(:disabled) {
    transform: translateY(2px) rotate(0deg) scale(0.99);
    box-shadow: 0 2px 0 #612210, 0 6px 10px rgba(70, 33, 17, 0.2);
}

.app-layout {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    height: 100vh;
    max-height: 100vh;
    box-sizing: border-box;
}

.setup-panel,
.panel,
.log-panel,
.status-strip,
.choice-panel,
.rules-drawer {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.setup-panel {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.setup-hero-container {
    position: relative;
    width: 100%;
    max-height: 28vh;
    background: linear-gradient(180deg, #ef4102 0%, #e05014 100%);
    border-radius: 28px 28px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.setup-hero {
    display: block;
    max-width: 100%;
    max-height: 28vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

@media (max-height: 820px) {
    .setup-hero-container {
        height: 28vh;
        align-items: flex-start;
    }

    .setup-hero {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        object-fit: cover;
        object-position: top center;
    }
}

.setup-start-btn {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 13px 40px;
    font-family: 'Arial Black', 'Arial Narrow', Arial, sans-serif;
    font-variant: normal;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 900;
    font-size: 1.1em;
    line-height: 1;
    text-shadow: none;
    background: linear-gradient(180deg, #ef4102 0%, #e05014 100%);
    border: 2px solid #6b0a04;
    box-shadow: 0 4px 18px rgba(180, 20, 10, 0.55);
    white-space: nowrap;
}

.setup-start-btn:hover {
    transform: translateX(-50%) translateY(-1px);
}

.setup-content {
    padding: 28px;
    display: grid;
    gap: 28px;
    background: var(--card);
    border-radius: 0 0 28px 28px;
}

.character-select,
.cpu-select {
    display: grid;
    gap: 14px;
}

.setup-heading {
    margin: 0;
    text-align: center;
}

.character-grid,
.cpu-grid,
.pile-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.character-grid {
    justify-content: center;
}

.cpu-grid {
    justify-content: center;
}

.character-card,
.cpu-card {
    border-radius: 22px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 252, 243, 0.95), rgba(237, 220, 180, 0.95));
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    align-items: center;
}

.character-card {
    width: 140px;
}

.cpu-card {
    width: 130px;
}

.character-card.selected,
.cpu-card.selected {
    outline: 4px solid #ef4102;
    outline-offset: 2px;
    border-color: rgba(197, 72, 18, 0.65);
    box-shadow: 0 10px 18px rgba(239, 65, 2, 0.24);
}

.portrait {
    width: 96px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: transparent;
    flex-shrink: 0;
    border: none;
    box-shadow: none;
}

.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}



.game-shell {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1.55fr) minmax(220px, 280px);
    gap: 0px;
    align-items: start;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.board-column {
    display: grid;
    gap: 4px;
    grid-template-rows: 1fr auto;
    min-height: 0;
}

.status-strip {
    border-radius: 20px;
    padding: 9px 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.status-value {
    margin: 2px 0 0;
    font-size: 0.95rem;
}

.board-stage {
    position: relative;
    border-radius: 30px;
    padding: 10px;
    /* background: linear-gradient(180deg, #f6ebcf 0%, #dfc58f, 0% ); */
    border: none;
    /* box-shadow: var(--shadow); */
    min-height: 0;
    max-height: 94vh;
    min-height: 70vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-surface {
    margin-top: 14px;
    position: relative;
    width: min(100%, calc(94vh * 0.919));
    aspect-ratio: 953 / 1037;
}

.board-image {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 20px;
    object-fit: fill;
}

.board-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.pile-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.pile-stack {
    position: absolute;
    width: 9.2%; /* 4.6% * 2 = 9.2%, ~88px on a 953px-wide board */
    min-width: 48px;
    max-width: 104px;
    aspect-ratio: 5 / 7;
    transform: translate(-50%, -50%) rotate(var(--pile-angle, 0deg));
}

.pile-layers {
    position: absolute;
    inset: 0;
}

.pile-layer,
.pile-empty-slot {
    position: absolute;
    inset: 0;
    border-radius: 4px;
}

.pile-layer {
    border: 1px solid rgba(77, 58, 36, 0.7);
    background:
        linear-gradient(180deg, #fff9e9 0%, #e7d6b0 100%);
    transform: translate(
        calc(var(--layer-index) * -0.4px),
        calc(var(--layer-index) * -1.3px)
    );
    box-shadow: 0 1px 1px rgba(68, 48, 24, 0.18);
}

.pile-empty-slot {
    border: 1px dashed rgba(94, 76, 52, 0.62);
    background: rgba(255, 250, 238, 0.25);
    color: rgba(72, 54, 33, 0.82);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: clamp(7px, 0.72vw, 9px);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pile-count {
    position: absolute;
    top: -8px;
    right: -10px;
    min-width: 19px;
    height: 19px;
    border-radius: 999px;
    border: 1px solid rgba(77, 46, 21, 0.55);
    background: linear-gradient(180deg, #fff4d8, #e8c17a);
    color: #3e2915;
    font-size: clamp(9px, 0.88vw, 11px);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(44, 27, 12, 0.28);
}

.pile-stack.is-empty .pile-count {
    background: linear-gradient(180deg, #efe9de, #d5c9b5);
    color: rgba(64, 47, 29, 0.8);
}

.flying-draw-card {
    position: fixed;
    aspect-ratio: 5 / 7;
    transform: translate(-50%, -50%) rotate(-6deg) scale(0.96);
    border: 1px solid rgba(77, 58, 36, 0.7);
    border-radius: 4px;
    background:
        linear-gradient(180deg, rgba(255, 249, 233, 0.98), rgba(231, 214, 176, 0.98));
    box-shadow: 0 8px 16px rgba(45, 28, 11, 0.32);
    pointer-events: none;
    opacity: 0.96;
    z-index: 90;
    transition:
        left 920ms cubic-bezier(0.21, 0.88, 0.27, 0.99),
        top 920ms cubic-bezier(0.21, 0.88, 0.27, 0.99),
        transform 920ms cubic-bezier(0.21, 0.88, 0.27, 0.99),
        opacity 920ms ease;
}

.flying-draw-card.is-flying {
    transform: translate(-50%, -50%) rotate(8deg) scale(0.56);
    opacity: 0.22;
}

.pawn {
    position: absolute;
    width: 11.25%; /* 7.5% * 1.5 = 11.25%, ~108px on a 953px-wide board */
    min-width: 54px;
    max-width: 120px;
    display: block;
    border-radius: 0;
    overflow: visible;
    border: none;
    box-shadow: none;
    background: transparent;
    transform: translate(-50%, -50%);
    transition: left 260ms ease, top 260ms ease, transform 220ms ease;
}

.pawn[data-moving="true"] {
    transform: translate(-50%, calc(-50% - 10px)) scale(1.08);
}

.pawn-inner {
    position: relative;
    width: 100%;
}

.pawn-img {
    width: 100%;
    aspect-ratio: 1 / 1.25;
    object-fit: contain;
    object-position: center;
    background: transparent;
    display: block;
    position: relative;
    transform-origin: center center;
    transition: transform 160ms ease;
}

.pawn--facing-left .pawn-img {
    transform: scaleX(-1);
}

.pawn-name {
    position: absolute;
    bottom: 9%;
    left: 0;
    right: 0;
    text-align: center;
    font-family: 'Arial Black', Impact, 'Arial Narrow', Arial, sans-serif;
    font-size: clamp(6px, 1vw, 12px);
    font-weight: 800;
    color: #111;
    line-height: 1.25;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    text-shadow:
        -1px -1px 0 #fff,
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff,
         0 0 4px rgba(255,255,255,0.9);
    direction: ltr;
    pointer-events: none;
}

.pawn-name--double {
    bottom: 1.5%;
    line-height: 1.05;
    white-space: normal;
}

/* Spinner container and all spinner elements are forced to the top stacking context */
.spinner-dock {
    position: absolute;
    width: min(340px, 48vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    .spinner-assembly {
            margin-top: -30px;
            margin-bottom: 8px;
            max-width: 260px;
            max-height: 260px;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
    }
    .spinner-wheel {
        max-width: 240px;
        max-height: 240px;
        width: 100%;
        height: auto;
    }
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: transform 340ms ease, opacity 340ms ease;
    z-index: 999;
    pointer-events: auto;
}

.spinner-dock--hidden {
    opacity: 0;
    pointer-events: none;
}

/* bottom + right players → bottom-right corner */
.spinner-dock[data-side="bottom"],
.spinner-dock[data-side="right"] {
    right: 10px;
    bottom: 10px;
    transform: translate(120%, 0);
}

/* top + left players → top-right corner */
 .spinner-dock[data-side="top"],
 .spinner-dock[data-side="left"] {
    position: static;
    inset: unset;
    transform: none;
    z-index: auto;
    opacity: 1;
    transition: none;
    margin: 0 auto;
}

.spinner-dock.is-visible[data-side="bottom"],
.spinner-dock.is-visible[data-side="right"],
.spinner-dock.is-visible[data-side="top"],
.spinner-dock.is-visible[data-side="left"] {
           margin-top: 48px;
    opacity: 1;
}

.spinner-dock[data-side="center"] {
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
        max-width: 240px;
        max-height: 240px;
    .spinner-button {
        min-width: 260px;
        display: block;
    }
}

.spinner-wheel {
    width: min(248px, 34vw);
    aspect-ratio: 1;
    position: relative;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #000;
    padding: 1px;
    overflow: hidden;
}

.spinner-assembly {
    position: relative;
    width: min(248px, 34vw);
    aspect-ratio: 1;
    left: 0px;
}

.spinner-face {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 50%;
    user-select: none;
    pointer-events: none;
}

.spinner-pointer {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 96%;
    height: 96%;
    object-fit: contain;
    transform: translate(-50%, -50%) rotate(-135deg);
    transform-origin: 50% 50%;
    pointer-events: none;
    transition: transform 1.45s cubic-bezier(0.18, 0.89, 0.22, 1);
}

.choice-panel {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: min(300px, calc(100% - 24px));
    border-radius: 24px;
    padding: 14px;
    display: grid;
    gap: 10px;
}

.choice-actions {
    display: grid;
    gap: 10px;
}

.choice-sublabel {
    display: block;
    font-size: 0.75rem;
    font-style: italic;
    opacity: 0.72;
    margin-top: 2px;
    pointer-events: none;
}

.choice-note {
    margin: 0;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--ink-soft);
    border-left: 2px solid var(--paper-strong);
    padding-left: 6px;
}

.winner-banner {
    position: absolute;
    inset: 12px;
    border-radius: 26px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 18px;
    background: rgba(65, 34, 15, 0.82);
    color: #fff6e6;
    font-size: clamp(1.4rem, 2.5vw, 2.4rem);
    z-index: 2001;
    box-shadow: 0 0 0 9999px rgba(65,34,15,0.32);
}

.winner-banner .winner-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 0;
    margin: 18px auto 0 auto;
    max-width: 800px;
    width: 100%;
    justify-items: stretch;
    align-items: stretch;
    padding: 0;
}
.winner-banner .winner-card-img {
    width: 100%;
    height: auto;
    object-fit: fill;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    border: none;
    display: block;
    margin: 0;
    padding: 0;
}

.log-panel,
.panel {
    border-radius: 24px;
    padding: 10px;
    min-height: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 8px;
}

.turn-log {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
    max-height: 160px;
    overflow: auto;
    font-size: 0.9rem;
}

.sidebar-left,
.sidebar-right {
    display: grid;
    gap: 80px;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
}

.sidebar-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    min-height: 52px;
}

.sidebar-right-offset {
    min-height: 52px;
}

.player-panel {
    min-height: 0;
    overflow: hidden;
}

.player-card {
    border-radius: 18px;
    border: 1px solid var(--border);
    padding: 9px;
    margin: 8px;
    background: rgba(255, 251, 242, 0.74);
}

.player-card.current-turn {
    outline: 3px solid #ef4102;
    outline-offset: 0;
    box-shadow: 0 0 0 2px rgba(224, 80, 20, 0.32);
}

.player-card-header {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.player-name {
    margin-bottom: 2px;
    font-size: 1rem;
}

.player-meta {
    margin-bottom: 0;
}

.hand-toggle-btn {
    background: none;
    border: none;
    border-bottom: 1px dotted rgba(90, 79, 58, 0.5);
    padding: 0;
    cursor: pointer;
    text-align: left;
    color: var(--ink-soft);
    font-size: 0.85rem;
    line-height: inherit;
    transition: color 120ms ease, border-bottom-color 120ms ease;
}

.hand-toggle-btn:hover {
    color: var(--ink);
    border-bottom-color: rgba(90, 79, 58, 0.9);
    transform: none;
    box-shadow: none;
}

.hand-reveal {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
    gap: 4px;
    padding: 6px 0;
    margin-bottom: 6px;
}

.hand-reveal.is-open {
    display: grid;
}

.hand-card {
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(71, 54, 30, 0.35);
    background: var(--card-swatch, #ccc);
    aspect-ratio: 5 / 7;
}

.hand-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hand-card--missing .hand-card-img {
    display: none;
}

.hand-card-label {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.42);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    text-align: center;
    padding: 3px 2px;
    line-height: 1.2;
    pointer-events: none;
}

.hand-card--missing .hand-card-label {
    display: block;
}

.hand-reveal-empty {
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-style: italic;
    margin: 0;
    padding: 2px 0;
    grid-column: 1 / -1;
}



.player-progress {
    display: grid;
    gap: 6px;
}

.played-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 6px;
    row-gap: 1px;
}

.played-slot {
    min-height: 40px;
    aspect-ratio: 7 / 5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0;
    background: rgba(120, 120, 120, 0.1);
    border: none;
    box-shadow: none;
}

.played-slot--filled {
    background: rgba(255, 251, 242, 0.72);
    border: none;
}

.played-slot-img {
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: fill;
    object-position: center;
    display: block;
    border-radius: 0;
}

.player-meta,
.player-stats,
.pile-card small {
    color: var(--ink-soft);
    font-size: 0.85rem;
}

.player-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.stat-chip {
    border-radius: 14px;
    padding: 10px 8px;
    background: rgba(255, 255, 255, 0.52);
    font-size: 0.98rem;
    text-align: center;
    min-height: 68px;
    display: grid;
    align-content: center;
}

.pile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pile-card {
    border-radius: 18px;
    padding: 9px;
    border: 1px solid var(--border);
    background: rgba(255, 251, 242, 0.76);
}

#playerPanel {
    max-height: 100%;
    overflow: auto;
    padding-right: 4px;
}

.rules-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: min(560px, 100vw);
    height: 100vh;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 260ms ease;
    z-index: 10;
    display: grid;
    grid-template-rows: auto 1fr;
}

.rules-drawer.is-open {
    transform: translateX(0);
}

.rules-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 0;
    align-items: start;
}

.rules-body {
    overflow: auto;
    padding: 20px;
}

.rules-heading {
    display: block;
    font-weight: 700;
    margin: 18px 0 8px;
}

.rules-indent {
    text-indent: 1.6em;
}

.house-rules {
    margin-top: 24px;
    padding: 16px;
    border-radius: 20px;
    background: rgba(234, 115, 154, 0.08);
}

@media (max-width: 1100px) {
    .game-shell {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
    }

    .sidebar-left,
    .sidebar-right {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: none;
    }

    .sidebar-controls,
    .sidebar-right-offset {
        min-height: 0;
    }
}

@media (max-width: 760px) {
    .page-shell {
        padding: 10px 10px 0;
        overflow: auto;
    }

    .topbar,
    .setup-summary,
    .panel-header,
    .rules-header {
        flex-direction: column;
        align-items: stretch;
    }

    .breadcrumbs {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }

    .status-strip,
    .sidebar-left,
    .sidebar-right,
    .player-stats,
    .pile-grid,
    .cpu-grid {
        grid-template-columns: 1fr;
    }

    .board-stage {
        min-height: 42vh;
        padding: 10px;
    }

    .board-overlay {
        inset: 10px;
    }

    .choice-panel {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
    }
}