:root {
    --bg-primary: #07131f;
    --bg-secondary: #0e2032;
    --panel-glass: rgba(15, 34, 52, 0.72);
    --panel-border: rgba(120, 183, 255, 0.18);
    --accent: #4dd0e1;
    --accent-strong: #00bcd4;
    --text-primary: #e6f4ff;
    --text-muted: rgba(230, 244, 255, 0.65);
    --danger: #ff8373;
    --success: #4be6b9;
    --card-wan: linear-gradient(135deg, #32202b 0%, #552233 100%);
    --card-tiao: linear-gradient(135deg, #1f3d2b 0%, #2b6842 100%);
    --card-bing: linear-gradient(135deg, #1d2e52 0%, #284c7a 100%);
    --card-honor: linear-gradient(135deg, #3d2c1d 0%, #70471f 100%);
    --card-flower: linear-gradient(135deg, #351c4a 0%, #5a2581 100%);
    --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.35);
    --radius-large: 22px;
    --radius-medium: 16px;
    --radius-small: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Microsoft YaHei', 'Inter', 'Helvetica Neue', sans-serif;
    background: radial-gradient(circle at 10% 20%, rgba(29, 71, 103, 0.65) 0%, rgba(7, 19, 31, 0.95) 58%),
        linear-gradient(180deg, #050910 0%, #0a1523 100%);
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('data:image/svg+xml,%3Csvg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" fill-opacity="0.05" stroke="%23ffffff" stroke-width="0.5"%3E%3Cpath d="M0 50h200M0 150h200M50 0v200M150 0v200"/%3E%3C/g%3E%3C/svg%3E');
    mix-blend-mode: overlay;
    pointer-events: none;
    opacity: 0.6;
    z-index: -2;
}

.app-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 32px 48px 48px;
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 28px 32px;
    background: linear-gradient(135deg, rgba(14, 46, 68, 0.95), rgba(8, 23, 38, 0.85));
    border-radius: var(--radius-large);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 24px;
    z-index: 10;
    backdrop-filter: blur(14px);
}

.title-group h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: 0.6px;
}

.title-group .subtitle {
    margin: 8px 0 0;
    font-size: 15px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 12px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(640px, 38%) minmax(880px, 1fr);
    gap: 36px;
    margin-top: 32px;
}

.panel {
    background: var(--panel-glass);
    border-radius: var(--radius-large);
    border: 1px solid var(--panel-border);
    padding: 28px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
}

.panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(77, 208, 225, 0.18), transparent 55%);
    pointer-events: none;
}

.panel-header {
    margin-bottom: 24px;
}

.panel-header h2 {
    margin: 0;
    font-size: 22px;
}

.panel-subtitle {
    margin: 8px 0 0;
    font-size: 14px;
    color: var(--text-muted);
}

.table-wrapper {
    border-radius: var(--radius-medium);
    overflow: hidden;
    border: 1px solid rgba(120, 183, 255, 0.12);
    backdrop-filter: blur(4px);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(9, 22, 34, 0.65);
}

thead {
    background: rgba(12, 36, 55, 0.7);
}

thead th {
    padding: 14px 16px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(230, 244, 255, 0.85);
}

tbody td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(120, 183, 255, 0.08);
}

.room-cell-main {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.room-cell-sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(77, 208, 225, 0.08);
}

button {
    padding: 10px 20px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #04131f;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 188, 212, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(0, 188, 212, 0.45);
}

button:active {
    transform: translateY(0);
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(10, 46, 70, 0.92), rgba(5, 15, 24, 0.98));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(10px);
}

.login-card {
    width: min(420px, 86vw);
    background: rgba(9, 26, 40, 0.92);
    border-radius: var(--radius-large);
    padding: 40px 38px;
    border: 1px solid rgba(120, 183, 255, 0.25);
    box-shadow: 0 28px 50px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.login-brand h2 {
    margin: 0;
    font-size: 24px;
}

.login-brand p {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--text-muted);
}

.login-card label {
    font-size: 14px;
    margin-bottom: 6px;
    display: block;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-small);
    border: 1px solid rgba(120, 183, 255, 0.28);
    background: rgba(8, 22, 34, 0.85);
    color: var(--text-primary);
    font-size: 15px;
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(77, 208, 225, 0.25);
}

.login-actions {
    display: flex;
    justify-content: flex-end;
}

.login-error {
    margin: 0;
    color: var(--danger);
    font-size: 13px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 28px;
}

.detail-card {
    background: rgba(6, 20, 32, 0.82);
    border-radius: var(--radius-medium);
    border: 1px solid rgba(120, 183, 255, 0.12);
    padding: 24px;
    box-shadow: inset 0 0 0 1px rgba(120, 183, 255, 0.05);
}

.detail-card .detail-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 16px;
}

.detail-card h3 {
    margin: 0;
    font-size: 18px;
}

.detail-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.table-wrapper table#playerTable{
    background: transparent;
}

#playerTable tbody tr.highlight {
    background: rgba(77, 208, 225, 0.12);
}

#roomTable th,
#roomTable td,
#playerTable th,
#playerTable td {
    white-space: nowrap;
}

.card-wall {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
    min-height: 120px;
}

.player-section .table-wrapper {
    overflow-x: auto;
}

.card-tile {
    width: 70px;
    height: 98px;
    border-radius: 14px;
    padding: 10px 9px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    color: #fefefe;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0));
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card-tile::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(255, 255, 255, 0.18);
    mix-blend-mode: overlay;
    pointer-events: none;
}

.card-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.55);
}

.card-rank {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 1px;
}

.card-suit {
    font-size: 13px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    opacity: 0.82;
}

.card-caption {
    display: inline-flex;
    align-self: flex-end;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
}

.card-wan {
    background: var(--card-wan);
    border-color: rgba(255, 128, 128, 0.45);
    color: #ffb4b4;
}

.card-tiao {
    background: var(--card-tiao);
    border-color: rgba(113, 214, 168, 0.45);
    color: #82ffce;
}

.card-bing {
    background: var(--card-bing);
    border-color: rgba(135, 185, 255, 0.45);
    color: #a8d6ff;
}

.card-honor {
    background: var(--card-honor);
    border-color: rgba(255, 193, 112, 0.45);
    color: #ffd59b;
}

.card-flower {
    background: var(--card-flower);
    border-color: rgba(216, 153, 255, 0.45);
    color: #f0c9ff;
}

.card-new {
    box-shadow: 0 0 0 3px rgba(77, 208, 225, 0.35), 0 12px 26px rgba(0, 0, 0, 0.55);
}

.hand-section {
    grid-column: span 2;
}

.meld-section {
    grid-column: span 2;
}

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

.meld-item {
    background: rgba(9, 28, 45, 0.82);
    border-radius: var(--radius-small);
    padding: 14px 16px;
    border: 1px solid rgba(120, 183, 255, 0.1);
}

.meld-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.meld-cards {
    display: flex;
    gap: 10px;
}

.meld-tag {
    font-size: 12px;
    color: var(--text-muted);
}

.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
}

.timeline-list li {
    padding: 10px 14px;
    border-radius: var(--radius-small);
    background: rgba(12, 34, 52, 0.65);
    border: 1px solid rgba(120, 183, 255, 0.12);
    font-size: 13px;
}

.timeline-list li strong {
    color: var(--accent);
    margin-right: 6px;
}

.empty-placeholder {
    font-size: 14px;
    color: var(--text-muted);
    padding: 12px 0;
    text-align: center;
}

.timeline-list .empty-placeholder {
    background: rgba(12, 34, 52, 0.5);
    border-radius: var(--radius-small);
    border: 1px dashed rgba(120, 183, 255, 0.2);
}

@media (max-width: 1360px) {
    .layout {
        grid-template-columns: minmax(100%, 1fr);
    }

    .detail-grid {
        grid-template-columns: minmax(100%, 1fr);
    }

    .hand-section,
    .meld-section {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .app-shell {
        padding: 24px 18px 40px;
    }

    .app-header {
        flex-direction: column;
        gap: 18px;
        align-items: flex-start;
        position: static;
    }

    .layout {
        margin-top: 24px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .card-wall {
        justify-content: center;
    }
}
