/* UNO 游戏样式
   ============== */

/* 基础变量 */
:root {
    --uno-red: #E8413C;
    --uno-yellow: #F5C518;
    --uno-green: #2DC653;
    --uno-blue: #0072BC;
    --uno-wild: #333;
    --card-width: 80px;
    --card-height: 120px;
    --card-radius: 10px;
    --card-font: 'Arial Black', 'Arial', sans-serif;
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    color: #fff;
    min-height: 100vh;
    overflow: hidden;
}

/* 通用按钮 */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--uno-green);
    color: #fff;
}

.btn-primary:hover {
    background: #25a747;
}

.btn-secondary {
    background: var(--uno-blue);
    color: #fff;
}

.btn-secondary:hover {
    background: #0062a7;
}

.btn-danger {
    background: var(--uno-red);
    color: #fff;
}

.btn-danger:hover {
    background: #c73330;
}

.btn-small {
    padding: 6px 16px;
    font-size: 14px;
}

.btn-action {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
}

.btn-action:hover {
    background: rgba(255,255,255,0.25);
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-uno {
    background: var(--uno-red);
    color: #fff;
    font-size: 20px;
    font-weight: 900;
    padding: 12px 32px;
    animation: unoPulse 0.8s infinite;
}

@keyframes unoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.btn-solo {
    background: linear-gradient(135deg, var(--uno-red), var(--uno-yellow));
    color: #fff;
    font-size: 18px;
    padding: 16px 40px;
    border-radius: 12px;
    font-weight: 700;
}

.btn-solo:hover {
    background: linear-gradient(135deg, #c73330, #d4a812);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(232, 65, 60, 0.4);
}

.btn-local {
    background: linear-gradient(135deg, var(--uno-green), var(--uno-blue));
    color: #fff;
    font-size: 18px;
    padding: 16px 40px;
    border-radius: 12px;
    font-weight: 700;
}

.btn-local:hover {
    background: linear-gradient(135deg, #25a747, #0062a7);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 114, 188, 0.4);
}

.solo-section {
    margin-bottom: 30px;
    text-align: center;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============ 同屏多人设置界面 ============ */
.local-setup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: auto;
    padding: 40px 20px;
}

.local-setup-container h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.setup-hint {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 24px;
    text-align: center;
}

#local-player-inputs {
    width: 100%;
    margin-bottom: 16px;
}

.local-player-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.local-player-row .player-num {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    min-width: 60px;
}

.local-player-row input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    outline: none;
}

.local-player-row input:focus {
    border-color: var(--uno-green);
}

.local-player-row .remove-player-btn {
    padding: 8px 12px;
    background: rgba(232, 65, 60, 0.3);
    border: none;
    border-radius: 6px;
    color: var(--uno-red);
    cursor: pointer;
    font-size: 14px;
}

.setup-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ============ 回合切换遮罩 ============ */
.shield-content {
    background: rgba(26, 26, 46, 0.98);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    border: 3px solid rgba(255,255,255,0.2);
}

.shield-content h3 {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 16px;
}

.shield-content p {
    font-size: 16px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 8px;
}

.shield-hint {
    font-size: 13px;
    color: rgba(255,255,255,0.4);
    margin-bottom: 24px;
}

.hidden {
    display: none !important;
}

/* ============ 界面切换 ============ */
.screen {
    display: none;
    position: absolute;
    inset: 0;
}

.screen.active {
    display: flex;
}

/* ============ 大厅界面 ============ */
.lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 700px;
    margin: auto;
    padding: 40px 20px;
}

.game-title {
    font-size: 72px;
    font-weight: 900;
    letter-spacing: 8px;
    margin-bottom: 8px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.uno-letter {
    display: inline-block;
    padding: 0 4px;
}

.u-letter { color: var(--uno-red); }
.n-letter { color: var(--uno-yellow); }
.o-letter { color: var(--uno-green); }

.game-subtitle {
    font-size: 18px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 40px;
}

.lobby-actions {
    display: flex;
    gap: 30px;
    width: 100%;
    align-items: stretch;
}

.lobby-section {
    flex: 1;
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 24px;
}

.lobby-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.lobby-divider {
    width: 1px;
    background: rgba(255,255,255,0.15);
    align-self: stretch;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 6px;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--uno-blue);
}

.input-group select option {
    background: #1a1a2e;
    color: #fff;
}

.status-message {
    margin-top: 20px;
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255,255,255,0.1);
}

.status-message.error {
    background: rgba(232, 65, 60, 0.2);
    border: 1px solid var(--uno-red);
}

.status-message.success {
    background: rgba(45, 198, 83, 0.2);
    border: 1px solid var(--uno-green);
}

/* ============ 等待界面 ============ */
.waiting-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    margin: auto;
    padding: 40px 20px;
}

.waiting-container h2 {
    font-size: 28px;
    margin-bottom: 30px;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.room-info p {
    font-size: 16px;
    color: rgba(255,255,255,0.7);
}

.room-code-display {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--uno-yellow);
    background: rgba(0,0,0,0.3);
    padding: 12px 24px;
    border-radius: 8px;
    border: 2px solid var(--uno-yellow);
}

.player-list {
    width: 100%;
    margin-bottom: 30px;
}

.player-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    margin-bottom: 8px;
}

.player-item .player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--uno-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    margin-right: 12px;
}

.player-item .player-name {
    font-size: 16px;
}

.player-item .host-badge {
    font-size: 12px;
    color: var(--uno-yellow);
    margin-left: 8px;
}

.player-item .player-status {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-left: auto;
}

/* ============ 游戏界面 ============ */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
    position: relative;
}

/* 其他玩家区域 */
.other-players {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 10px 0;
    min-height: 130px;
}

.other-player-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    min-width: 100px;
    transition: all 0.3s;
}

.other-player-card.active-player {
    background: rgba(245, 197, 24, 0.2);
    border: 2px solid var(--uno-yellow);
    transform: scale(1.05);
}

.other-player-card .op-name {
    font-size: 14px;
    font-weight: 600;
}

.other-player-card .op-cards {
    display: flex;
    gap: 3px;
}

.other-player-card .mini-card-back {
    width: 18px;
    height: 28px;
    background: #333;
    border-radius: 3px;
    border: 1px solid var(--uno-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    color: var(--uno-yellow);
    font-weight: 900;
}

.other-player-card .op-card-count {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
}

.other-player-card .op-uno-badge {
    font-size: 11px;
    color: var(--uno-red);
    font-weight: 900;
}

/* 出牌区域 */
.play-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 20px 0;
    flex: 1;
    max-height: 200px;
}

.draw-pile {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.draw-pile:hover {
    transform: scale(1.05);
}

.pile-card {
    box-shadow: 3px 3px 0 #222, 6px 6px 0 #1a1a2e;
}

.pile-count {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.discard-pile {
    position: relative;
    min-width: var(--card-width);
    min-height: var(--card-height);
}

.game-direction {
    font-size: 24px;
    color: rgba(255,255,255,0.5);
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.current-color-indicator {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 0 12px currentColor;
}

.game-status {
    text-align: center;
    font-size: 18px;
    padding: 8px;
    min-height: 40px;
    font-weight: 600;
}

.game-status .turn-indicator {
    color: var(--uno-yellow);
}

/* ============ 卡牌样式 ============ */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--card-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--card-font);
    font-weight: 900;
    font-size: 28px;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    user-select: none;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.card.playable {
    border: 3px solid rgba(255,255,255,0.8);
    animation: cardGlow 1.5s infinite;
}

@keyframes cardGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255,255,255,0.3); }
    50% { box-shadow: 0 0 20px rgba(255,255,255,0.6); }
}

.card.not-playable {
    opacity: 0.6;
    cursor: not-allowed;
}

.card.not-playable:hover {
    transform: none;
    box-shadow: none;
}

/* 颜色 */
.card-red {
    background: var(--uno-red);
    color: #fff;
}

.card-yellow {
    background: var(--uno-yellow);
    color: #333;
}

.card-green {
    background: var(--uno-green);
    color: #fff;
}

.card-blue {
    background: var(--uno-blue);
    color: #fff;
}

.card-wild {
    background: linear-gradient(135deg, var(--uno-red) 25%, var(--uno-yellow) 25%, var(--uno-yellow) 50%, var(--uno-green) 50%, var(--uno-green) 75%, var(--uno-blue) 75%);
    color: #fff;
}

/* 卡牌内部 */
.card-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60%;
    height: 55%;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    font-size: inherit;
    line-height: 1;
}

.card-wild .card-inner {
    background: rgba(255,255,255,0.3);
}

.card-label {
    font-size: 32px;
    line-height: 1;
}

.card-small-label {
    position: absolute;
    font-size: 12px;
    top: 6px;
    left: 8px;
}

.card-small-label-bottom {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 12px;
    transform: rotate(180deg);
}

/* 牌背 */
.card-back {
    background: #333;
    border: 3px solid var(--uno-red);
    color: var(--uno-yellow);
    cursor: default;
}

.card-back-design {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70%;
    height: 60%;
    border-radius: 50%;
    background: var(--uno-red);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #fff;
}

.card-back:hover {
    transform: none;
}

/* ============ 手牌区域 ============ */
.my-hand-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    min-height: 160px;
}

.my-player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.my-player-info .my-name {
    font-size: 16px;
    font-weight: 600;
}

.my-player-info .my-turn-badge {
    font-size: 13px;
    color: var(--uno-yellow);
    background: rgba(245, 197, 24, 0.2);
    padding: 3px 10px;
    border-radius: 4px;
}

.my-player-info .my-uno-label {
    font-size: 13px;
    color: var(--uno-red);
    font-weight: 900;
}

.my-hand {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100vw;
    padding: 10px 20px;
    gap: -5px;
}

.my-hand .card {
    margin-left: -15px;
    transition: transform 0.15s, margin-left 0.15s;
}

.my-hand .card:first-child {
    margin-left: 0;
}

.my-hand .card:hover {
    transform: translateY(-15px) scale(1.1);
    margin-left: 5px;
    margin-right: 5px;
    z-index: 10;
}

.my-hand .card.selected {
    transform: translateY(-20px) scale(1.15);
    border: 3px solid #fff;
    margin-left: 5px;
    margin-right: 5px;
    z-index: 20;
}

.my-actions {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

/* ============ 颜色选择弹窗 ============ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: rgba(26, 26, 46, 0.95);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
}

.modal-content h3 {
    font-size: 24px;
    margin-bottom: 20px;
}

.color-options {
    display: flex;
    gap: 16px;
}

.color-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.3);
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    transition: all 0.2s;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #fff;
    box-shadow: 0 0 20px currentColor;
}

.color-red { background: var(--uno-red); color: #fff; }
.color-yellow { background: var(--uno-yellow); color: #333; }
.color-green { background: var(--uno-green); color: #fff; }
.color-blue { background: var(--uno-blue); color: #fff; }

/* ============ 游戏结束界面 ============ */
.gameover-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
    margin: auto;
    padding: 40px 20px;
}

.gameover-container h2 {
    font-size: 36px;
    margin-bottom: 30px;
}

.winner-info {
    font-size: 24px;
    color: var(--uno-yellow);
    margin-bottom: 20px;
    font-weight: 700;
}

.final-scores {
    width: 100%;
    margin-bottom: 30px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 8px;
    margin-bottom: 8px;
}

.score-item.winner-score {
    background: rgba(245, 197, 24, 0.15);
    border: 1px solid var(--uno-yellow);
}

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

/* ============ 动画 ============ */
.card-play-animation {
    animation: cardPlay 0.5s ease-out;
}

@keyframes cardPlay {
    0% {
        transform: translateY(100px) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translateY(0) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.card-draw-animation {
    animation: cardDraw 0.4s ease-out;
}

@keyframes cardDraw {
    0% {
        transform: translateX(-100px) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 8px;
    font-size: 16px;
    z-index: 200;
    animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s;
}

@keyframes toastIn {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* 响应式 */
@media (max-width: 600px) {
    :root {
        --card-width: 60px;
        --card-height: 90px;
        --card-radius: 8px;
    }

    .game-title {
        font-size: 48px;
    }

    .lobby-actions {
        flex-direction: column;
    }

    .lobby-divider {
        width: 100%;
        height: 1px;
    }

    .card-label {
        font-size: 24px;
    }

    .other-player-card {
        min-width: 70px;
        padding: 6px;
    }

    .my-hand .card {
        margin-left: -20px;
    }

    .color-btn {
        width: 50px;
        height: 50px;
        font-size: 14px;
    }
}
