:root {
    --primary: #c0392b;
    --secondary: #2c3e50;
    --accent: #f1c40f;
    --glass: rgba(255, 255, 255, 0.1);
    --glass-heavy: rgba(255, 255, 255, 0.2);
    --text: #ffffff;
    --table-green: #1b5e20;
    --table-border: #4caf50;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #0a0a0a;
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
    padding: 20px;
    background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
}

.screen.active {
    display: flex;
}

/* Landing Screen */
#landing-screen {
    justify-content: center;
    align-items: center;
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    letter-spacing: 4px;
    background: linear-gradient(45deg, #f1c40f, #e67e22);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.input-group {
    margin-bottom: 20px;
}

input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border 0.3s;
}

input:focus {
    border-color: var(--accent);
}

button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

button:active {
    transform: scale(0.95);
}

.primary-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(45deg, #c0392b, #e74c3c);
    color: white;
    font-size: 1.1rem;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.4);
}

.secondary-btn {
    width: 100%;
    padding: 12px;
    background: var(--glass-heavy);
    color: white;
}

/* Room Screen */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 0 0 16px 16px;
    font-size: 0.9rem;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#room-display-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--accent);
}

#personal-score-display {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

#personal-score-display:hover {
    background: rgba(255, 255, 255, 0.2);
}

.action-btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
}

#pot-display-table {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--accent);
    z-index: 5;
    pointer-events: none;
}

.top-left-area {
    display: flex;
    align-items: center;
    min-width: 100px;
}

#table-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 40px 0;
}

#poker-table {
    width: 85vw;
    height: 85vw;
    max-width: 500px;
    max-height: 500px;
    background: var(--table-green);
    border: 8px solid #2e7d32;
    border-radius: 50%;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.8);
    position: relative;
}

.table-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

#status-msg {
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Players on table */
#players-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.player-token {
    position: absolute;
    width: 70px;
    height: 70px;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.avatar {
    width: 50px;
    height: 50px;
    background: #444;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.player-token.active .avatar {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent);
}

.player-token.waiting .avatar {
    opacity: 0.5;
}

.player-token.folded .avatar {
    background: #333;
    filter: grayscale(1);
}

.player-token.lost .avatar {
    border-color: #f44336;
}

.status-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    color: white;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    background: #e74c3c;
    /* Default red */
    border: 1px solid white;
}

.status-badge.folded {
    background: #e74c3c;
}

.status-badge.lost {
    background: #2c3e50;
    opacity: 0.9;
}

.nickname {
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    white-space: nowrap;
}

.chips {
    font-size: 0.6rem;
    color: var(--accent);
}

.status-label {
    position: absolute;
    bottom: -15px;
    font-size: 0.6rem;
    color: var(--accent);
    text-transform: uppercase;
}

/* 倒计时闹钟样式 */
.turn-timer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

.turn-timer.low-time {
    background: #f44336;
    color: #fff;
    animation: shake 0.2s infinite;
}

@keyframes shake {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }

    25% {
        transform: translateX(-50%) rotate(5deg);
    }

    50% {
        transform: translateX(-50%) rotate(0deg);
    }

    75% {
        transform: translateX(-50%) rotate(-5deg);
    }

    100% {
        transform: translateX(-50%) rotate(0deg);
    }
}

/* Controls */
@media (max-width: 600px) {
    .glass-card {
        padding: 20px;
        width: 90%;
    }

    /* 移动端圆桌上移，腾出空间给聊天框 */
    #table-container {
        align-items: flex-start;
        padding-top: 20px;
        /* transform: scale(0.85) translateY(-40px); */
        transform: scale(1.0) translateY(50px);
    }

    #players-container {
        transform: scale(0.85);
    }

    /* 移动端聊天框缩窄 */
    #chat-container {
        width: 180px;
        bottom: 85px;
        left: 10px;
    }

    /* 准备与开始按钮 移到右侧竖向排列 */
    .bottom-bar {
        justify-content: center;
        bottom: 15px;
    }

    #ready-btn,
    #start-game-btn {
        position: fixed;
        right: 15px;
        bottom: 85px;
        flex-direction: column;
        display: flex;
        gap: 10px;
        z-index: 70;
    }

    #start-game-btn {
        bottom: 140px;
        /* 开始按钮放在准备按钮上方 */
    }

    .action-btn {
        padding: 10px;
        font-size: 0.8rem;
    }
}

.bottom-bar {
    position: absolute;
    bottom: 20px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.action-btn {
    padding: 12px 15px;
    font-size: 0.9rem;
    min-width: 60px;
    background: var(--glass-heavy);
    color: white;
}

.action-btn.danger {
    background: #c0392b;
}

.action-btn.success {
    background: #27ae60;
}

.action-btn.warning {
    background: #f39c12;
}

.action-btn:disabled {
    opacity: 0.3 !important;
    filter: grayscale(1);
    pointer-events: none;
    transform: none !important;
}

/* Chat Styles */
#chat-container {
    position: absolute;
    bottom: 80px;
    left: 20px;
    width: 260px;
    max-height: 200px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    z-index: 60;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s;
}

#chat-container.collapsed {
    max-height: 34px;
    width: 100px;
}

#chat-header {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.6);
}

#chat-toggle-btn {
    font-size: 0.7rem;
    color: var(--accent);
}

#chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s;
}

#chat-container.collapsed #chat-body {
    opacity: 0;
    pointer-events: none;
}

#chat-container.collapsed .chat-title {
    display: none;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.chat-msg {
    animation: fadeInSlide 0.3s ease-out;
    word-break: break-all;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-sender {
    font-weight: bold;
    color: var(--accent);
    margin-right: 5px;
}

.msg-time {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-left: 5px;
}

.msg-text {
    color: #eee;
}

.chat-input-wrapper {
    display: flex;
    /* padding: 6px; */
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 0.8rem;
    padding: 5px 8px;
    outline: none;
}

#send-chat-btn {
    background: var(--accent);
    border: none;
    border-radius: 4px;
    color: #1a1a1a;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 10px;
    cursor: pointer;
    transition: transform 0.1s;
}

#send-chat-btn:active {
    transform: scale(0.95);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.rules-body {
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
    margin: 20px 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.rules-body li {
    margin-bottom: 5px;
}

/* Cards */
.hand-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 110;
    justify-content: center;
    align-items: center;
}

.hand-overlay.active {
    display: flex;
}

.hand-container {
    text-align: center;
}

.cards-row {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.card {
    width: 80px;
    height: 120px;
    background: white;
    border-radius: 10px;
    color: black;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    font-size: 1.5rem;
    font-weight: bold;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    position: relative;
}

.card .suit {
    font-size: 2rem;
    align-self: center;
}

.card.red {
    color: #d32f2f;
}

/* Animations */
@keyframes deal {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.card {
    animation: deal 0.5s ease-out;
}