/* 基础样式设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, #eff4fb 0%, #f8fafc 45%, #eef2f7 100%);
    color: #0f172a;
    min-height: 100vh;
    overflow: hidden;
}

:root {
    --layout-gap: 18px;
    --matrix-cell-size: 50px;
    --road-column-width: 37px;
    --road-column-height: 210px;
    --road-grid-height: 222px;
    --road-row-size: 35px;
    --road-token-size: 31px;
    --road-side-cell-size: 19px;
    --road-side-token-size: 13px;
    --road-side-grid-height: 114px;
}

.container {
    width: 100%;
    max-width: 1680px;
    min-width: 0;
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px;
    display: grid;
    grid-template-columns: minmax(0, 1.62fr) minmax(360px, 0.98fr);
    gap: var(--layout-gap);
    align-items: start;
}

.workspace-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(214, 223, 235, 0.95);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(10px);
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.panel-eyebrow {
    color: #64748b;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.panel-title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
}

.panel-subtitle {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.35;
}

.status-overview {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-pill-neutral {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.round-pill {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #dbe3ee;
}

.status-pill-ready {
    background: #ecfdf3;
    color: #027a48;
    border-color: #abefc6;
}

.status-pill-running {
    background: #fff7e6;
    color: #b54708;
    border-color: #fedf89;
}

.status-pill-paused {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.status-pill-stopped {
    background: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.status-message-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-message {
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    font-size: 14px;
    line-height: 1.6;
}

.status-helper {
    color: #475569;
    font-size: 13px;
    line-height: 1.5;
}

/* 主内容布局 */
.status-overview,
.dealing-area,
.road-map,
.control-area {
    grid-column: 1;
    min-width: 0;
}

/* 右侧矩阵表格 */
.matrix-table {
    grid-column: 2;
    grid-row: 1 / span 4;
    min-width: 0;
    padding: 14px;
    height: calc(100vh - 36px);
    overflow-x: auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 18px;
}

.matrix-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.matrix-title {
    font-size: 1.2em;
    font-weight: 700;
    text-align: left;
}

.matrix-subtitle {
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

.matrix-toolbar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.matrix-selection {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
}

.matrix-shortcuts {
    font-size: 12px;
    color: #64748b;
}

.matrix-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.matrix-status {
    width: 100%;
    min-height: 56px;
    padding: 12px 14px;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #dbe3ee;
    color: #334155;
    font-size: 12px;
    line-height: 1.6;
}

.matrix-grid {
    display: grid;
    grid-template-columns: repeat(11, var(--matrix-cell-size));
    grid-template-rows: repeat(11, var(--matrix-cell-size));
    gap: 0;
    background: white;
    padding: 0;
    border: 1px solid #d6deeb;
    border-radius: 14px;
    overflow: hidden;
    width: calc(var(--matrix-cell-size) * 11);
    min-width: calc(var(--matrix-cell-size) * 11);
    height: calc(var(--matrix-cell-size) * 11);
    min-height: calc(var(--matrix-cell-size) * 11);
    margin: 0 auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.matrix-cell {
    width: var(--matrix-cell-size);
    height: var(--matrix-cell-size);
    background: white;
    border-right: 1px solid #dbe3ee;
    border-bottom: 1px solid #dbe3ee;
    font-size: 12px;
    user-select: none;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.matrix-cell.editable {
    cursor: text;
    caret-color: black;
    min-height: 100%;
    overflow: hidden;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-cell.editable > div {
    width: 100%;
    min-height: var(--matrix-cell-size);
    text-align: center;
    padding: 0 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    white-space: pre-wrap;
}

.matrix-cell.editable > div:empty {
    height: var(--matrix-cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-cell.editable > div:empty::before {
    content: '\200B';
    display: inline;
    vertical-align: middle;
}

.matrix-cell.editable::before {
    display: none;
}

.matrix-cell.fixed {
    background: white;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}

.matrix-cell.center-column {
    background: #fff1f1;
    font-size: 18px;
}

.matrix-cell.bottom-row {
    background: #f5f9ff;
    font-size: 18px;
}

.matrix-cell:focus {
    outline: none;
}

.matrix-cell.editable > div:focus {
    outline: none;
}

.matrix-cell.editable:focus-within {
    background-color: #f8fafc;
}

.matrix-cell.editable:hover {
    background: #f8fafc;
}

.matrix-cell.editable.is-selected {
    background: #fff7d6;
    box-shadow: inset 0 0 0 2px #f59e0b;
    transform: scale(0.98);
}

/* 调整现有组件的样式 */
.dealing-area {
    padding: 12px 20px 16px;
    position: relative;
    height: 294px;
}

.dealing-header {
    margin-bottom: 4px;
}

.dealing-meta-compact {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.round-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.9em;
    font-weight: 700;
    white-space: nowrap;
}


.table {
    width: 100%;
    height: calc(100% - 58px);
    background: radial-gradient(circle at 50% 10%, #228554 0%, #1b6c43 45%, #14532d 100%);
    border-radius: 22px 22px 120px 120px;
    position: relative;
    padding: 22px 20px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.banker-side, .player-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
}

.side-label {
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.05em;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin-bottom: -6px;
}

.banker-area, .player-area {
    display: flex;
    justify-content: center;
    margin: 0;
    margin-top: 25px;
}

.card-slot {
    width: 56px;
    height: 80px;
    border: 2px dashed rgba(255, 255, 255, 0.26);
    border-radius: 10px;
    margin: 0 8px;
    background: rgba(255, 255, 255, 0.12);
    position: relative;
}

.card-placeholder {
    width: 100%;
    height: 100%;
}

.deck-area {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.deck {
    width: 56px;
    height: 80px;
    background: white;
    border-radius: 6px;
    margin: 8px auto;
    position: relative;
    box-shadow: 
        -1px 1px 2px rgba(0, 0, 0, 0.1),
        -2px 2px 2px rgba(0, 0, 0, 0.1),
        -3px 3px 2px rgba(0, 0, 0, 0.1),
        -4px 4px 2px rgba(0, 0, 0, 0.1),
        -5px 5px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 添加黑桃A样式 */
.deck::after {
    content: 'A♠';
    position: absolute;
    font-size: 26px;
    color: black;
    font-weight: bold;
    z-index: 1;
}

/* 左标记 */
.deck::before {
    content: 'A\A♠';
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 10px;
    white-space: pre;
    color: black;
    z-index: 1;
}

/* 叠牌效果现在移到新的伪元素 */
.deck .card-stack-effect::before,
.deck .card-stack-effect::after {
    content: '';
    position: absolute;
    background: white;
    border-radius: 8px;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.deck .card-stack-effect::before {
    bottom: -2px;
    right: 2px;
    box-shadow: 
        -1px 1px 2px rgba(0, 0, 0, 0.1),
        -2px 2px 2px rgba(0, 0, 0, 0.1),
        -3px 3px 2px rgba(0, 0, 0, 0.1);
}

.deck .card-stack-effect::after {
    bottom: -4px;
    right: 4px;
    box-shadow: 
        -1px 1px 2px rgba(0, 0, 0, 0.1),
        -2px 2px 2px rgba(0, 0, 0, 0.1),
        -3px 3px 2px rgba(0, 0, 0, 0.1);
}

.deck-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: white;
    margin-bottom: 10px;
    font-size: 0.85em;
    font-weight: 700;
}

/* 路单记录区样式 */
.road-map {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.road-map-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.road-summary {
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: #1e293b;
    font-size: 12px;
    line-height: 1.45;
    border: 1px solid #e2e8f0;
}

.road-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    color: #4a5568;
    font-size: 11px;
}

.road-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.road-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-banker {
    background: #d84c4c;
}

.legend-player {
    background: #3a83e8;
}

.legend-tie {
    background: #1fa971;
}

.legend-pair {
    background: linear-gradient(135deg, #d84c4c 0 50%, #3a83e8 50% 100%);
}

.legend-derived-red {
    background: #d84c4c;
}

.legend-derived-blue {
    background: #3a83e8;
}

.road-map-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: var(--road-grid-height);
    padding: 8px 8px 10px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    background-color: white;
    border: 1px solid #e6edf5;
    border-radius: 10px;
}

.road-grid-surface {
    position: relative;
    min-height: 100%;
    height: 100%;
    background-color: #fff;
    background-image:
        linear-gradient(to right, #edf2f7 1px, transparent 1px),
        linear-gradient(to bottom, #edf2f7 1px, transparent 1px);
    background-size: var(--road-column-width) 100%, 100% var(--road-row-size);
    background-position: 0 0, 0 0;
}

.road-grid-content {
    position: absolute;
    inset: 0 auto 0 0;
    display: flex;
    height: 100%;
}

.road-column {
    display: flex;
    flex-direction: column;
    width: var(--road-column-width);
    height: var(--road-column-height);
    flex-shrink: 0;
    position: relative;
    overflow: visible;
    isolation: isolate;
}

.road-cell {
    width: var(--road-column-width);
    height: var(--road-row-size);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.road-item {
    width: var(--road-token-size);
    height: var(--road-token-size);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 700;
    margin: 0;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 0.9em;
    position: relative;
    z-index: 4;
    overflow: visible;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.92);
}

.road-item .points {
    line-height: 1;
    font-size: 13px;
    letter-spacing: -0.2px;
}

.road-corner-label {
    position: absolute;
    left: 5px;
    top: 4px;
    font-size: 8px;
    line-height: 1;
    font-weight: 700;
    opacity: 0.9;
}

.road-badge {
    position: absolute;
    z-index: 5;
    font-size: 9px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 700;
}

.tie-badge {
    right: -4px;
    top: -1px;
    background: #1fa971;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.pair-flag {
    position: absolute;
    z-index: 6;
    bottom: -2px;
    font-size: 8px;
    line-height: 1;
    padding: 2px 3px;
    border-radius: 999px;
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.banker-pair-flag {
    left: -2px;
    background: #d84c4c;
}

.player-pair-flag {
    right: -2px;
    background: #3a83e8;
}

.road-item.banker {
    background: radial-gradient(circle at 35% 30%, #f38a8a, #d84c4c 65%);
}

.road-item.player {
    background: radial-gradient(circle at 35% 30%, #86b8ff, #3a83e8 65%);
}

.road-item.tie {
    background-color: #2ecc71;
}

.road-item.horizontal {
    position: absolute;
    margin-left: -1px;
    z-index: 1;
}

/* 滚动条样式 */
.road-map-grid::-webkit-scrollbar {
    height: 8px;
}

.road-map-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.road-map-grid::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.road-map-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.placeholder {
    display: none;
}

.side-road-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
}

.side-road-panel {
    min-width: 0;
    width: 100%;
    overflow: hidden;
    border: 1px solid #e6edf5;
    border-radius: 12px;
    padding: 6px;
    background: linear-gradient(180deg, #fbfdff 0%, #f8fbff 100%);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-road-title {
    font-size: 11px;
    font-weight: 700;
    color: #4a5568;
}

.side-road-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: var(--road-side-grid-height);
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    padding: 0;
    background: #fff;
}

.side-road-grid-surface {
    position: relative;
    min-height: 100%;
    height: 100%;
    background-color: #fff;
    background-image:
        linear-gradient(to right, #edf2f7 1px, transparent 1px),
        linear-gradient(to bottom, #edf2f7 1px, transparent 1px);
    background-size: 20px 100%, 100% var(--road-side-cell-size);
    background-position: 0 0, 0 0;
}

.side-road-grid-content {
    position: absolute;
    inset: 0 auto 0 0;
    display: flex;
    height: 100%;
}

.side-road-column {
    display: flex;
    flex-direction: column;
    width: var(--road-side-cell-size);
    height: var(--road-side-grid-height);
    flex-shrink: 0;
}

.side-road-cell {
    width: var(--road-side-cell-size);
    height: var(--road-side-cell-size);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: transparent;
}

.side-road-item,
.side-road-placeholder {
    width: var(--road-side-token-size);
    height: var(--road-side-token-size);
    margin: 0;
    border-radius: 50%;
    flex-shrink: 0;
}

.side-road-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--road-side-token-size) * 0.95);
    font-weight: 800;
    line-height: 1;
    color: #fff;
    position: relative;
}

.side-road-placeholder {
    display: none;
}

.side-road-item.red {
    background: radial-gradient(circle at 35% 30%, #f38a8a, #d84c4c 70%);
}

.side-road-item.blue {
    background: radial-gradient(circle at 35% 30%, #86b8ff, #3a83e8 70%);
}

.side-road-item.cockroach-mark {
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: transparent;
    overflow: visible;
}

.side-road-item.cockroach-mark::before {
    content: '';
    position: absolute;
    width: 2px;
    height: calc(var(--road-side-token-size) * 1.05);
    border-radius: 999px;
    transform: rotate(35deg);
    transform-origin: center;
}

.side-road-item.cockroach-mark.red::before {
    background: #d84c4c;
}

.side-road-item.cockroach-mark.blue::before {
    background: #3a83e8;
}

.side-road-grid::-webkit-scrollbar {
    height: 6px;
}

.side-road-grid::-webkit-scrollbar-thumb {
    background: #b7c4d6;
    border-radius: 999px;
}

/* 操作区样式 */
.control-area {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: space-between;
    min-height: 132px;
}

.main-controls {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    min-width: 126px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
    transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.btn-primary {
    background-color: #ff6b6b;
    color: white;
}

.btn-secondary {
    background-color: #4dabf7;
    color: white;
}

.btn-success {
    background-color: #2ecc71;
    color: white;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
}

.btn-success:hover {
    background-color: #27ae60;
}

.btn-ghost {
    min-width: auto;
    height: 34px;
    margin: 0;
    padding: 0 12px;
    background: #f8fafc;
    color: #1e293b;
    border: 1px solid #dbe3ee;
    font-size: 13px;
}

.btn-ghost:hover {
    background: #eef2f7;
}

.btn-danger-ghost {
    color: #b42318;
    border-color: #f3c0ba;
    background: #fff5f4;
}

.btn-danger-ghost:hover {
    background: #fee4e2;
}

.btn.is-running {
    background-color: #f39c12;
}

.control-notes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.quick-rule {
    color: #475569;
    font-size: 0.9em;
    line-height: 1.5;
}

.mode-note {
    color: #0f172a;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
}

/* 添加加载状态样式 */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* 添加禁用状态样式 */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 添加工具提示样式 */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
}

/* 卡牌的样式 */
.card {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card-corner {
    position: absolute;
    top: 5px;
    left: 6px;
    font-size: 14px;
    line-height: 1;
    font-weight: 700;
}

/* 卡牌数值的样式 */
.card-value {
    font-size: 32px;
    font-weight: bold;
    position: relative;
    z-index: 1;
}

.card.hearts .card-corner,
.card.diamonds .card-corner {
    color: red;
}

.card.clubs .card-corner,
.card.spades .card-corner {
    color: black;
}

/* 隐藏滚动条但保持功能 */
.road-map-grid::-webkit-scrollbar {
    display: none;
}

@media (max-width: 1280px) {
    body {
        overflow: auto;
    }

    .container {
        grid-template-columns: 1fr;
        min-height: 100vh;
    }

    .status-overview,
    .dealing-area,
    .matrix-table,
    .road-map,
    .control-area {
        grid-column: 1;
        grid-row: auto;
        width: 100%;
    }

    .matrix-table {
        position: static;
        height: auto;
        align-items: stretch;
    }
}

@media (max-width: 900px) {
    :root {
        --layout-gap: 12px;
        --matrix-cell-size: 36px;
        --road-grid-height: 234px;
        --road-side-cell-size: 20px;
        --road-side-token-size: 14px;
        --road-side-grid-height: 120px;
    }

    .container {
        padding: 12px;
    }

    .panel-heading,
    .matrix-header,
    .matrix-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-eyebrow,
    .status-helper {
        display: none;
    }

    .status-overview,
    .dealing-area,
    .road-map,
    .control-area,
    .matrix-table {
        border-radius: 16px;
    }

    .status-overview {
        padding: 10px 12px;
        gap: 8px;
    }

    .status-overview .panel-heading {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .status-pills {
        justify-content: flex-start;
        gap: 6px;
    }

    .round-pill {
        order: -1;
        display: inline-flex;
    }

    .status-pill {
        min-height: 24px;
        padding: 0 8px;
        font-size: 10px;
    }

    .status-message-wrap {
        gap: 4px;
    }

    .status-message {
        padding: 8px 10px;
        font-size: 12px;
        line-height: 1.4;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .status-helper,
    .panel-subtitle,
    .matrix-shortcuts,
    .quick-rule,
    .mode-note {
        font-size: 12px;
    }

    .dealing-area {
        padding: 10px 14px 12px;
        height: auto;
    }

    .dealing-header {
        margin-bottom: 4px;
    }

    .dealing-meta-compact {
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
    }

    .round-number {
        min-height: 26px;
        padding: 0 8px;
        font-size: 11px;
    }

    .table {
        height: auto;
        min-height: 236px;
        border-radius: 18px 18px 60px 60px;
        padding: 44px 12px 54px;
        gap: 8px;
    }

    .banker-side,
    .player-side {
        padding: 0 4px;
    }

    .side-label {
        font-size: 0.92em;
        margin-bottom: -2px;
    }

    .banker-area,
    .player-area {
        margin-top: 16px;
    }

    .card-slot,
    .deck {
        width: 44px;
        height: 64px;
    }

    .card-slot {
        margin: 0 3px;
    }

    .deck::after {
        font-size: 20px;
    }

    .deck::before {
        font-size: 8px;
    }

    .deck-area {
        top: 10px;
    }

    .deck-count {
        min-height: 28px;
        padding: 0 10px;
        margin-bottom: 8px;
        font-size: 12px;
    }

    .road-map {
        padding: 14px;
        gap: 10px;
    }

    .road-summary {
        min-height: 38px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .road-map-grid {
        padding: 8px 0;
        scroll-padding-right: 12px;
    }

    .road-item {
        margin: 2px;
    }

    .road-item .points {
        font-size: 12px;
    }

    .side-road-section {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        overflow: visible;
        padding: 2px 0 4px;
    }

    .side-road-panel {
        min-width: 0;
        width: 100%;
        padding: 5px;
    }

    .control-area {
        padding: 14px;
        min-height: 0;
        gap: 12px;
    }

    .main-controls {
        gap: 10px;
    }

    .btn {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
        height: 40px;
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 10px;
    }

    .main-controls .btn:first-child {
        flex-basis: 100%;
    }

    .btn-ghost {
        height: 32px;
        padding: 0 10px;
        font-size: 12px;
    }

    .matrix-table {
        padding: 14px;
        gap: 10px;
    }

    .matrix-title {
        font-size: 1.05rem;
    }

    .matrix-toolbar,
    .matrix-status {
        padding: 10px 12px;
    }

    .matrix-grid {
        margin: 0 auto;
    }
}

@media (max-width: 600px) {
    :root {
        --matrix-cell-size: min(8.6vw, 34px);
        --road-column-width: 39px;
        --road-column-height: 216px;
        --road-row-size: 36px;
        --road-token-size: 33px;
        --road-side-cell-size: 16px;
        --road-side-token-size: 9px;
        --road-side-grid-height: 96px;
    }

    .container {
        padding: 10px;
    }

    .panel-title,
    .matrix-title {
        font-size: 1rem;
    }

    .status-overview,
    .dealing-area,
    .road-map,
    .control-area,
    .matrix-table {
        padding-left: 12px;
        padding-right: 12px;
    }

    .table {
        min-height: 184px;
        padding: 8px 10px 56px;
    }

    .card-slot,
    .deck {
        width: 40px;
        height: 58px;
    }

    .card-corner {
        top: 4px;
        left: 5px;
        font-size: 11px;
    }

    .card-value {
        font-size: 28px;
    }

    .road-legend {
        gap: 6px 10px;
        font-size: 11px;
    }

    .side-road-section {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .matrix-header {
        gap: 8px;
    }

    .matrix-subtitle {
        font-size: 11px;
        line-height: 1.35;
    }

    .matrix-toolbar,
    .matrix-status {
        padding: 8px 10px;
    }

    .matrix-shortcuts {
        font-size: 11px;
        line-height: 1.35;
    }

    .matrix-actions {
        justify-content: stretch;
        gap: 6px;
    }

    .matrix-actions .btn-ghost {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        height: 28px;
        font-size: 11px;
        padding: 0 8px;
    }

    .matrix-actions .btn-danger-ghost {
        flex-basis: 100%;
    }
}
