:root {
    --cg-panel: rgba(11, 21, 18, 0.9);
    --cg-line: rgba(157, 208, 172, 0.18);
    --cg-accent: #d9c27d;
    --cg-accent-2: #7fd1a0;
    --cg-soft: #96a89d;
    --cg-felt: radial-gradient(circle at 50% 45%, rgba(72, 118, 86, 0.9) 0%, rgba(22, 55, 38, 0.96) 55%, rgba(11, 25, 18, 1) 100%);
}

.cg-shell {
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr;
}

.cg-shell.room-shell {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
    gap: 0;
}

.cg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--cg-line);
    padding: 12px 20px;
    grid-column: 1 / -1;
    grid-row: 1;
}

.room-settings {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--cg-line);
    padding: 10px 20px;
    display: grid;
    grid-template-columns: auto 1fr repeat(auto-fit, minmax(140px, auto));
    gap: 12px;
    align-items: center;
}

#gameInfo {
    grid-column: 1 / -1;
    margin-bottom: 0;
}

#gameTypeRow,
#hostControls,
#entryControls {
    display: contents;
}

.button-row {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.cg-game-area {
    display: grid;
    /* 左(メンバー)と右(チャット)を220pxに固定し、中央を広く確保 */
    grid-template-columns: 220px minmax(320px, 1fr) 220px;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
    grid-column: 1 / -1;
    grid-row: 4;
    min-height: 0;
    flex: 1;
}

.cg-hero,
.panel {
    border: 1px solid var(--cg-line);
    border-radius: 12px;
    background: var(--cg-panel);
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.cg-hero {
    background:
        radial-gradient(circle at top, rgba(217, 194, 125, 0.12), transparent 30%),
        linear-gradient(180deg, rgba(17, 34, 26, 0.95), rgba(10, 20, 15, 0.95));
}

.lead,
.micro-copy {
    color: var(--cg-soft);
}

.room-list {
    display: grid;
    gap: 12px;
}

.seat-hand,
.hand-cards {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap; /* 2列にならないよう折り返し禁止 */
    overflow-x: auto;  /* はみ出た場合は横スクロールで対応 */
    overflow-y: hidden;
    min-height: 0;
    padding-bottom: 4px; /* スクロールバー用の余裕 */
}

.member-list,
.chat-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.room-card,
.member-card {
    border: 1px solid var(--cg-line);
    border-radius: 16px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
}

.chat-item {
    padding: 6px 0;
    font-size: 12px;
    line-height: 1.5;
}

.chat-item.system {
    color: rgba(150, 168, 157, 0.7);
    border: none;
    background: transparent;
    padding: 3px 0;
}

.chat-item.user {
    border: 1px solid rgba(217, 194, 125, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
    background: rgba(217, 194, 125, 0.04);
}

.chat-item.user strong {
    color: var(--cg-accent);
    display: block;
    font-size: 11px;
}

.chat-item.user small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
}

.badge {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(217, 194, 125, 0.14);
    color: var(--cg-accent);
    font-size: 12px;
}

.member-card {
    opacity: 1;
    transition: transform 0.2s, border-color 0.2s;
}

.member-card.deal-pulse {
    animation: member-deal-pulse 520ms ease;
}

.member-card-backs {
    position: relative;
    height: 38px;
    margin-top: 8px;
}

.mini-card-back {
    position: absolute;
    left: calc(var(--i, 0) * 13px);
    top: calc(var(--i, 0) * 1px);
    width: 24px;
    height: 34px;
    border-radius: 5px;
    border: 1px solid rgba(217, 194, 125, 0.55);
    background: #102018 url("/static/cards/back@2x.png") center / cover no-repeat;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.28);
}

.member-reveal-cards {
    display: flex;
    gap: 5px;
    align-items: center;
    min-height: 46px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.mini-card-flip {
    position: relative;
    width: 28px;
    height: 40px;
    border-radius: 5px;
    transform-style: preserve-3d;
    animation: reveal-card-flip 560ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    animation-delay: var(--delay, 0ms);
    transform: rotateY(180deg);
}

.mini-card-face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 5px;
    border: 1px solid rgba(217, 194, 125, 0.45);
    backface-visibility: hidden;
    background: #102018;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.28);
}

.mini-card-front img {
    width: 100%;
    height: 100%;
    display: block;
}

.mini-card-back-face {
    background: #102018 url("/static/cards/back@2x.png") center / cover no-repeat;
    transform: rotateY(180deg);
}

.mini-card-count {
    position: absolute;
    left: 82px;
    top: 8px;
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(217, 194, 125, 0.12);
    color: var(--cg-accent);
    font-size: 11px;
    text-align: center;
}

.member-card-fly {
    position: fixed;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 9999;
    animation: discard-fly 620ms cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.member-card.inactive {
    opacity: 0.5;
}

.member-card.current-player {
    border-color: var(--cg-accent-2);
    background: rgba(127, 209, 160, 0.08);
    transform: scale(1.01);
}

input,
select,
button {
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
}

button {
    cursor: pointer;
}

.primary-btn {
    background: linear-gradient(135deg, var(--cg-accent), var(--cg-accent-2));
    color: #102018;
    font-weight: 700;
}

.ghost-btn,
.ghost-link,
.danger-btn {
    background: rgba(255, 255, 255, 0.04);
}

.danger-btn {
    border-color: rgba(242, 125, 125, 0.28);
    color: #ffc0c0;
}

.ghost-link {
    padding: 8px 10px;
    border-radius: 10px;
}

.join-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 7, 5, 0.78);
    backdrop-filter: blur(8px);
    z-index: 30;
}

.hidden {
    display: none !important;
}

.join-card {
    width: min(92vw, 420px);
    padding: 24px;
    border-radius: 22px;
    background: #0b1712;
    border: 1px solid var(--cg-line);
    display: grid;
    gap: 12px;
}

.table-panel {
    padding: 0;
    border: none;
    background: transparent;
    height: 100%;
    overflow: hidden;
}

.table-surface {
    position: relative;
    height: 100%;
    border-radius: 12px;
    border: 1px solid var(--cg-line);
    background: var(--cg-felt);
    overflow: hidden;
    padding: 20px;
}

.table-center {
    position: absolute;
    left: 50%;
    top: 25%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
}

.table-mats {
    position: absolute;
    left: 50%;
    top: 60%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 40px;
    z-index: 2;
}

.deck-pile,
.discard-pile {
    width: 88px;
    height: 128px;
    border-radius: 14px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: rgba(4, 12, 8, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    color: rgba(245, 235, 199, 0.6);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.5);
}

.deck-pile {
    border: 2px solid var(--cg-accent);
    background: #102018 url("/static/cards/back@2x.png") center / cover no-repeat;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    transform: translateY(calc((52 - var(--deck-left, 52)) * 0.08px));
    transition: transform 260ms ease, opacity 260ms ease, filter 260ms ease;
}

.deck-pile.low {
    opacity: 0.78;
    filter: saturate(0.85);
}

.deck-pile.empty {
    opacity: 0.3;
    background-image: none;
}

.deck-pile::after {
    content: '';
    position: absolute;
    inset: calc(7px + var(--deck-thin, 0px)) 5px 5px;
    border-radius: 9px;
    border: 1px solid rgba(217, 194, 125, 0.18);
    box-shadow:
        0 calc(-1px * var(--deck-layer-1, 1)) 0 rgba(245, 235, 199, 0.22),
        0 calc(-3px * var(--deck-layer-2, 1)) 0 rgba(245, 235, 199, 0.14),
        0 calc(-5px * var(--deck-layer-3, 1)) 0 rgba(245, 235, 199, 0.08);
    pointer-events: none;
}

.deck-pile::before {
    content: '';
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(217, 194, 125, 0.25);
    border-radius: 9px;
    pointer-events: none;
}

.deck-pile span:not(.deck-count),
.discard-pile span {
    position: relative;
    z-index: 1;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(4, 12, 8, 0.62);
}

.discard-stack-card {
    position: absolute;
    left: 18px;
    top: 20px;
    width: 52px;
    height: 74px;
    border-radius: 8px;
    border: 1px solid rgba(217, 194, 125, 0.45);
    background: #102018 url("/static/cards/back@2x.png") center / cover no-repeat;
    box-shadow: 0 7px 13px rgba(0, 0, 0, 0.32);
    transform: translate(calc(var(--i, 0) * 2px), calc(var(--i, 0) * -2px)) rotate(var(--rot, 0deg));
}

.discard-pile.has-cards {
    border-style: solid;
    border-color: rgba(217, 194, 125, 0.5);
}

.discard-pile.has-cards > span {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
}

.deck-count {
    position: absolute;
    top: -24px;
    font-size: 11px;
    color: var(--cg-accent);
    background: rgba(11, 21, 18, 0.8);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--cg-line);
}

.table-label {
    font-size: 24px;
    font-weight: 700;
    color: #f5ebc7;
}

.table-sub {
    margin-top: 8px;
    color: var(--cg-soft);
}

.poker-card,
.card-wrapper,
.table-card {
    position: relative;
    width: 56px;
    flex-shrink: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.hand-cards .poker-card {
    width: 80px;
}

.hand-cards .card-wrapper {
    width: 80px;
    height: 112px;
    cursor: pointer;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.poker-card img,
.card-wrapper img,
.table-card img {
    width: 100%;
    display: block;
}

.poker-card button {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.poker-card.selected,
.card-wrapper.selected {
    transform: translateY(-11px) rotate(-2.5deg);
    border-color: #f3d34a;
    box-shadow: 0 0 0 2px rgba(243, 211, 74, 0.44), 0 12px 24px rgba(0, 0, 0, 0.34);
    animation: selected-card-wobble 260ms ease;
}

.poker-card .tag {
    position: absolute;
    left: 30px;
    top: 6px;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(100, 100, 100, 0.85);
    font-size: 10px;
    color: #ffffff;
    z-index: 2;
}

.dealt {
    opacity: 0;
    transform: translateY(16px) scale(0.94);
    animation: deal-in 420ms ease forwards;
    animation-delay: var(--delay, 0ms);
}

.discard-fly {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    animation: discard-fly 480ms cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.draw-fly {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    width: var(--fly-w, 56px);
    height: var(--fly-h, 80px);
    border-radius: 10px;
    border: 1px solid rgba(217, 194, 125, 0.45);
    background: #102018 url("/static/cards/back@2x.png") center / cover no-repeat;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.36);
    animation: draw-fly 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.table-cards {
    position: absolute;
    inset: 96px 20px 20px;
    display: grid;
    align-content: end;
    z-index: 3;
}

.reveal-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
    gap: 10px;
    align-items: end;
}

.reveal-seat {
    border: 1px solid rgba(245, 235, 199, 0.18);
    border-radius: 8px;
    padding: 8px;
    background: rgba(4, 12, 8, 0.42);
    min-height: 118px;
}

.reveal-seat.winner {
    border-color: var(--cg-accent);
    box-shadow: 0 0 0 1px rgba(217, 194, 125, 0.18);
}

.reveal-seat strong,
.reveal-seat span {
    display: block;
    font-size: 12px;
    color: #f5ebc7;
}

.reveal-seat span {
    color: var(--cg-soft);
}

.reveal-cards {
    display: flex;
    gap: 4px;
    margin: 6px 0;
}

.table-card-flip {
    position: relative;
    width: 44px;
    height: 62px;
    display: inline-block;
    transform-style: preserve-3d;
    animation: reveal-card-flip 620ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    animation-delay: var(--delay, 0ms);
    transform: rotateY(180deg);
}

.table-card-face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 5px;
    border: 1px solid rgba(217, 194, 125, 0.36);
    backface-visibility: hidden;
    background: #102018;
}

.table-card-front img {
    width: 100%;
    display: block;
}

.table-card-back {
    background: #102018 url("/static/cards/back@2x.png") center / cover no-repeat;
    transform: rotateY(180deg);
}

.chat-log {
    max-height: 280px;
    overflow: auto;
}

.chat-row {
    margin-top: 12px;
}

@keyframes deal-in {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes discard-fly {
    0% {
        opacity: 1;
        transform: translate(var(--from-x), var(--from-y)) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0.15;
        transform: translate(var(--to-x), var(--to-y)) rotate(var(--rot, 8deg)) scale(0.7);
    }
}

@keyframes draw-fly {
    0% {
        opacity: 0.95;
        transform: translate(var(--from-x), var(--from-y)) rotate(0deg) scale(0.78);
    }
    100% {
        opacity: 0.08;
        transform: translate(var(--to-x), var(--to-y)) rotate(var(--rot, -6deg)) scale(1);
    }
}

@keyframes selected-card-wobble {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-11px) rotate(-2.5deg); }
}

@keyframes member-deal-pulse {
    0% { border-color: var(--cg-line); }
    45% { border-color: var(--cg-accent); transform: translateY(-2px); }
    100% { border-color: var(--cg-line); }
}

@keyframes reveal-card-flip {
    0% {
        opacity: 0.85;
        transform: rotateY(180deg) translateY(4px);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) translateY(0);
    }
}


@media (prefers-reduced-motion: reduce) {
    .dealt,
    .discard-fly,
    .draw-fly,
    .member-card-fly,
    .mini-card-flip,
    .table-card-flip,
    .member-card.deal-pulse,
    .poker-card.selected,
    .card-wrapper.selected {
        animation: none !important;
        transition: none !important;
    }
}
/* 勝者を光らせるアニメーション */
@keyframes winnerGlow {
    0% { 
        box-shadow: 0 0 1px #ffd700, inset 0 0 1px #ffd700; 
        border-color: #cca400; 
    }
    100% { 
        box-shadow: 0 0 3px #ffea00, inset 0 0 3px #ffea00; 
        border-color: #ffff00; 
    }
}

.winner-glow {
    animation: winnerGlow 0.8s infinite alternate !important;
    background-color: rgba(255, 215, 0, 0.15) !important;
    position: relative;
    z-index: 10;
    transition: all 0.3s ease;
}

.member-card.winner-glow {
    border-color: #ffca28; /* 金色っぽい枠線 */
    box-shadow: 0 0 3px rgba(255, 202, 40, 0.6); /* じんわり光るエフェクト */
    animation: winner-pulse 1.5s infinite alternate;
}

@keyframes winner-pulse {
    0% { box-shadow: 0 0 1px rgba(255, 202, 40, 0.4); }
    100% { box-shadow: 0 0 3px rgba(255, 202, 40, 0.9); }
}