* { box-sizing: border-box; }

:root {
    --pig-bg: #0f172a;
    --pig-text: #e5e7eb;
    --pig-muted: #94a3b8;
    --pig-panel: #111827;
    --pig-panel-2: #1f2937;
    --pig-line: rgba(255,255,255,0.10);
}

.container {
    max-width: 1400px;
    margin: auto;
}

.combo-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.combo-chip {
    background: rgba(250, 204, 21, 0.18);
    border: 1px solid rgba(250, 204, 21, 0.35);
    color: #fde68a;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.top-bar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
    margin-bottom: 0;
}

.panel {
    background: linear-gradient(180deg, var(--pig-panel) 0%, var(--pig-panel-2) 100%);
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--pig-line);
    box-shadow: 0 10px 30px rgba(0,0,0,0.22);
}

.status-panel { flex: 2; }

.score-panel {
    flex: 1;
    min-width: 250px;
}

.score-panel ul {
    margin: 10px 0 0;
    padding-left: 18px;
}

.board {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section {
    background: linear-gradient(180deg, var(--pig-panel) 0%, var(--pig-panel-2) 100%);
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--pig-line);
    box-shadow: 0 10px 30px rgba(0,0,0,0.16);
}

.card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card {
    background: transparent;
    border-radius: 10px;
    padding: 0;
    border: 2px solid transparent;
    overflow: hidden;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        opacity 0.15s ease,
        border-color 0.15s ease,
        filter 0.15s ease;
}

.card.tiny-card {
    width: 44px;
}

.card.medium-card {
    width: 64px;
}

.card.playable {
    border-color: rgba(96, 165, 250, 0.35);
    cursor: pointer;
}

.card.playable:hover,
.card.playable:active,
.card.playable:focus-within {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.22);
    transform: translateY(-2px) scale(1.02);
}

.card.choice-card {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.card.choice-card:hover {
    transform: translateY(-2px);
}

.card.active-source {
    transform: translateY(-4px);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18);
}

.card.match-target {
    border-color: #facc15;
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.35);
    transform: translateY(-2px);
}

.card.table-react {
    animation: tableReact 0.18s ease 2;
}

@keyframes tableReact {
    0% { transform: translateX(0) translateY(-2px) scale(1); }
    25% { transform: translateX(-4px) translateY(-2px) scale(1.03); }
    50% { transform: translateX(4px) translateY(-2px) scale(1.04); }
    100% { transform: translateX(0) translateY(-2px) scale(1); }
}

.card-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.card-meta {
    margin-top: 4px;
    font-size: 10px;
    color: #e5e7eb;
    text-align: center;
    word-break: keep-all;
}

.play-button,
.choice-button,
.primary-button {
    margin-top: 8px;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 999px;
    color: #f8f5e9;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.2px;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.play-button:hover,
.choice-button:hover,
.primary-button:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.play-button {
    background: linear-gradient(180deg, #2f5d3a, #21442a);
}

.choice-button {
    background: linear-gradient(180deg, #8a3f24, #6a2f1a);
}

.primary-button {
    background: linear-gradient(180deg, #7c5a1b, #5b4112);
    width: auto;
    padding: 10px 14px;
}

.hero-action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.hero-action-button {
    min-width: 220px;
    padding: 16px 22px;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.2px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.22);
}

.hero-action-button.cpu {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
}

.hero-action-button.person {
    background: linear-gradient(180deg, #16a34a, #15803d);
}

.secondary-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.captured-count {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.capture-group-title {
    margin-bottom: 10px;
    font-weight: 700;
}

.hidden-hand {
    width: 48px;
}

.hidden-hand img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.card-submit {
    all: unset;
    display: block;
    width: 100%;
    cursor: pointer;
}

.last-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--pig-line);
    padding: 12px;
    border-radius: 12px;
    margin-top: 10px;
    line-height: 1.5;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: var(--pig-text);
    vertical-align: middle;
}

.status-badge.warning {
    border-color: rgba(250, 204, 21, 0.35);
    background: rgba(250, 204, 21, 0.14);
    color: #fde68a;
}

.status-badge.danger {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.14);
    color: #fecaca;
}

.status-badge.muted {
    border-color: rgba(148, 163, 184, 0.28);
    background: rgba(148, 163, 184, 0.10);
    color: #cbd5e1;
}

.status-badge.success {
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.14);
    color: #bbf7d0;
}

.status-badge.info {
    border-color: rgba(96, 165, 250, 0.35);
    background: rgba(96, 165, 250, 0.14);
    color: #bfdbfe;
}

.choice-panel {
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.14), rgba(120, 53, 15, 0.18));
    margin-bottom: 20px;
}

.action-toast {
    position: sticky;
    top: 12px;
    z-index: 30;
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.18), rgba(30, 41, 59, 0.24));
    color: #dbeafe;
    box-shadow: 0 10px 24px rgba(0,0,0,0.16);
    transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease, margin 0.35s ease, padding 0.35s ease;
    opacity: 1;
    max-height: 120px;
    overflow: hidden;
}

.action-toast.stop {
    border-color: rgba(250, 204, 21, 0.45);
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.14), rgba(120, 53, 15, 0.18));
    color: #fde68a;
}

.action-toast.hidden {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
}

.result-panel {
    border: 1px solid var(--pig-line);
    background: linear-gradient(180deg, var(--pig-panel) 0%, var(--pig-panel-2) 100%);
    margin-bottom: 20px;
}

.result-panel.win-player1 {
    border-color: rgba(34, 197, 94, 0.6);
    background: rgba(34, 197, 94, 0.14);
}

.result-panel.win-player2 {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.14);
}

.result-panel.win-draw {
    border-color: rgba(250, 204, 21, 0.6);
    background: rgba(250, 204, 21, 0.14);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.result-stat {
    background: rgba(0, 0, 0, 0.18);
    padding: 10px;
    border-radius: 8px;
}

.result-stat-label {
    font-size: 12px;
    opacity: 0.85;
}

.result-stat-value {
    font-size: 20px;
    font-weight: bold;
    margin-top: 4px;
}

.table-area {
    background: radial-gradient(circle at center, #1f7a3d 0%, #14532d 62%, #0f3d22 100%);
    border: 1px solid var(--pig-line);
    border-radius: 28px;
    padding: 24px 28px;
    box-shadow:
        inset 0 10px 28px rgba(0, 0, 0, 0.30),
        0 10px 24px rgba(0, 0, 0, 0.16);
}

.table-center {
    min-height: 220px;
}

.hand-section {
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

.hand-section.inactive {
    opacity: 0.72;
}

.hand-section.active-turn {
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.18);
}

.hand-section.active-turn .section-title {
    color: #bfdbfe;
}

.small-hand .card.medium-card {
    width: 54px;
}

.small-hand .hidden-hand {
    width: 42px;
}

.table-cards .card.medium-card {
    width: 78px;
}

.table-cards .card-meta {
    font-size: 11px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.section-count {
    color: var(--pig-muted);
    font-size: 14px;
    font-weight: 700;
}

.turn-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: transparent;
    flex: 0 0 auto;
}

.active-turn .turn-dot {
    background: #60a5fa;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.55);
}

.details-wrap {
    margin-top: 24px;
    display: grid;
    gap: 12px;
}

.details-toggle {
    width: 100%;
    background: linear-gradient(180deg, var(--pig-panel) 0%, var(--pig-panel-2) 100%);
    color: var(--pig-text);
    border: 1px solid var(--pig-line);
    border-radius: 16px;
    padding: 14px 16px;
    text-align: left;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.details-toggle:hover {
    background: rgba(255,255,255,0.06);
}

.details-panel {
    display: none;
}

.details-panel.open {
    display: block;
}

.mode-banner {
    margin: 14px 0 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 10px 24px rgba(0,0,0,0.16);
}

.mode-banner.account {
    border-color: rgba(245, 158, 11, 0.38);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.16), rgba(120, 53, 15, 0.22));
}

.mode-banner.casual {
    border-color: rgba(96, 165, 250, 0.35);
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.14), rgba(30, 41, 59, 0.22));
}

.mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.03em;
    margin-bottom: 10px;
}

.mode-banner.account .mode-badge {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.mode-banner.casual .mode-badge {
    color: #bfdbfe;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.30);
}

.board-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 20px;
}

.board-sidebar {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: start;
    display: grid;
    gap: 12px;
    position: static;
    top: auto;
}

.compact-panel h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
}

.status-stack {
    display: grid;
    gap: 8px;
    font-size: 14px;
}

.mini-score-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mini-score-box {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--pig-line);
    border-radius: 12px;
    padding: 12px;
}

.mini-score-label {
    font-size: 12px;
    color: var(--pig-muted);
    margin-bottom: 4px;
}

.mini-score-value {
    font-size: 24px;
    font-weight: 800;
    color: #f8fafc;
}

.board-main {
    display: grid;
    gap: 18px;
}

.mat-hand {
    background: linear-gradient(180deg, var(--pig-panel) 0%, var(--pig-panel-2) 100%);
    border: 1px solid var(--pig-line);
    border-radius: 18px;
    padding: 14px 16px;
}

.mat-hand-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 700;
}

.card-row.hand-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.play-mat {
    position: relative;
    min-height: 640px;
    border-radius: 36px;
    padding: 28px;
    background: radial-gradient(circle at center, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.00) 48%), linear-gradient(180deg, #177245 0%, #0f5a36 100%);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: inset 0 18px 40px rgba(0,0,0,0.24), 0 18px 40px rgba(0,0,0,0.18);
}

.table-core {
    position: absolute;
    inset: 26% 18% 24% 18%;
    display: grid;
    align-content: center;
    justify-items: center;
    text-align: center;
}

.table-core-title {
    font-size: 18px;
    font-weight: 800;
    color: #f8fafc;
    margin-bottom: 16px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.table-card-cloud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    max-width: 520px;
}

.capture-zone {
    position: absolute;
    width: 200px;
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 10px;
    backdrop-filter: blur(2px);
}

.capture-zone-top-left {
    top: 22px;
    left: 22px;
}

.capture-zone-bottom-left {
    bottom: 22px;
    left: 22px;
}

.capture-title {
    font-size: 12px;
    font-weight: 700;
    color: #dbeafe;
    margin-bottom: 8px;
}

.capture-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.table-card-cloud .card.medium-card {
    width: 72px;
}

.mat-hand .card.medium-card {
    width: 62px;
}

.capture-row .card.tiny-card {
    width: 42px;
}

.empty-table {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

.mat-captured {
    display: grid;
    gap: 14px;
    align-items: start;
}

.mat-captured-top {
    grid-template-columns: 1fr;
    justify-items: start;
}

.mat-captured-bottom {
    grid-template-columns: 1fr;
    justify-items: start;
    margin-top: 6px;
}

.mat-capture-side {
    min-width: 0;
    overflow: hidden;
}

.mat-captured .mat-capture-side:first-child {
    justify-self: start;
    text-align: left;
}

.mat-captured .mat-capture-side:last-child {
    justify-self: end;
    text-align: right;
}

.mat-captured .mat-capture-side:last-child .mat-capture-groups {
    justify-content: flex-end;
}

.mat-captured .mat-capture-side:last-child .mat-capture-title {
    justify-content: flex-end;
}

.mat-capture-groups {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 0;
    min-height: 52px;
    overflow: visible;
}

.capture-type-group {
    display: inline-flex;
    align-items: flex-start;
    margin-right: 14px;
}

.capture-type-group:empty {
    display: none;
}

.mat-captured .card.tiny-card {
    width: 42px;
    flex: 0 0 auto;
    margin-left: -18px;
}

.mat-captured .card.tiny-card:first-child,
.capture-type-group .card.tiny-card:first-child {
    margin-left: 0;
}

.mat-captured .card-image {
    display: block;
}

.table-cards .card {
    border-radius: 10px;
}

.table-cards.host-turn .card {
    box-shadow: 0 0 0 2px #a855f7;
}

.table-cards.other-turn .card {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

@media (max-width: 1100px) {
    .board-layout {
        grid-template-columns: 1fr;
    }

    .board-sidebar {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        align-items: start;
        position: static;
    }
}

@media (max-width: 900px) {
    .card.tiny-card { width: 34px; }
    .card.medium-card { width: 52px; }
    .hidden-hand { width: 40px; }
    .card-grid { gap: 6px; }
    .card-meta { font-size: 8px; }
    .table-cards .card.medium-card { width: 60px; }
    .small-hand .card.medium-card { width: 44px; }
    .small-hand .hidden-hand { width: 34px; }

    .table-area {
        border-radius: 80px;
        padding: 18px 16px;
    }
}

@media (max-width: 768px) {
    .board {
        gap: 12px;
    }

    .section {
        padding: 10px;
        border-radius: 14px;
    }

    .table-area {
        border-radius: 18px;
        padding: 10px 8px;
    }

    .play-mat {
        min-height: 460px;
        padding: 10px;
        border-radius: 18px;
    }

    .capture-zone {
        width: 150px;
        padding: 8px;
    }

    .table-core {
        inset: 24% 8% 24% 8%;
    }

    .table-card-cloud .card.medium-card {
        width: 56px;
    }

    .mat-hand {
        padding: 10px;
        border-radius: 14px;
    }

    .mat-hand .card.medium-card {
        width: 50px;
    }

    .capture-row .card.tiny-card {
        width: 34px;
    }

    .mat-capture-title,
    .section-title,
    .mat-capture-empty {
        display: none !important;
    }

    .mat-captured {
        gap: 8px;
    }

    .mat-capture-groups {
        min-height: 42px;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: flex-start;
        gap: 8px !important;
    }

    .capture-type-group {
        display: inline-flex !important;
        align-items: flex-start;
        margin-right: 0 !important;
    }

    .capture-type-group:empty {
        display: none !important;
    }

    .capture-type-group .card.tiny-card {
        width: 32px !important;
        flex: 0 0 auto;
        margin-left: -18px !important;
    }

    .capture-type-group .card.tiny-card:first-child {
        margin-left: 0 !important;
    }
}

/* Sticky go/stop and recent action signals */
.action-toast {
  position: sticky;
  top: 12px;
  z-index: 60;
}

.last-action {
  position: sticky;
  top: 64px;
  z-index: 50;
}

/* Keep go/stop signal visible while reading the board */
.action-toast {
  position: sticky !important;
  top: 12px !important;
  z-index: 80 !important;
  overflow: visible !important;
}

.last-action {
  position: sticky;
  top: 64px;
  z-index: 70;
}

/* Reliable floating signal for Go / Stop */
.action-toast[data-action-toast] {
  position: fixed !important;
  top: 16px !important;
  right: 16px !important;
  left: auto !important;
  width: min(360px, calc(100vw - 32px)) !important;
  max-height: none !important;
  overflow: visible !important;
  z-index: 9999 !important;
  margin: 0 !important;
  box-shadow: 0 18px 48px rgba(0,0,0,0.35) !important;
}

@media (max-width: 768px) {
  .action-toast[data-action-toast] {
    top: 12px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
  }
}
