/* game.css */
:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.6);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #e6edf3;
    --text-secondary: #848d97;

    --primary-color: #2f81f7;
    --secondary-color: #238636;
    --warning-color: #d29922;
    --danger-color: #f85149;
    --info-color: #a371f7;

    --glow-primary: rgba(47, 129, 247, 0.4);
    --glow-secondary: rgba(35, 134, 54, 0.4);
    --glow-warning: rgba(210, 153, 34, 0.4);

    font-family: 'Noto Sans TC', sans-serif;
}

body.dark-theme {
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: radial-gradient(circle at 50% 10%, #1f2937, #0d1117 80%);
}

#particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: url('https://www.transparenttextures.com/patterns/stardust.png');
    opacity: 0.3;
}

h1,
h2,
h3,
h4 {
    font-family: 'Orbitron', 'Play', sans-serif;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Glassmorphism */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    color: #fff;
    outline: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
}

.btn-primary:hover {
    background: #388bfd;
    box-shadow: 0 0 15px var(--glow-primary);
}

.btn-secondary {
    background: var(--secondary-color);
}

.btn-secondary:hover {
    background: #2ea043;
    box-shadow: 0 0 15px var(--glow-secondary);
}

.btn-warning {
    background: var(--warning-color);
    color: #000;
}

.btn-warning:hover {
    background: #e3b341;
    box-shadow: 0 0 15px var(--glow-warning);
}

.btn-success {
    background: #2ea043;
    color: white;
}

.btn-success:hover {
    background: #238636;
    box-shadow: 0 0 15px var(--glow-secondary);
}

.btn-danger {
    background: var(--danger-color);
}

.btn-info {
    background: var(--info-color);
}

.hidden {
    display: none !important;
}

/* Login */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-panel {
    padding: 40px;
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.logo-title {
    font-size: 3rem;
    margin-bottom: 0;
    background: -webkit-linear-gradient(45deg, #f85149, #a371f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.input-group input {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    box-sizing: border-box;
}

.divider {
    margin: 25px 0;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--panel-border);
}

.divider span {
    padding: 0 15px;
}

/* Lobby */
.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-bottom: 30px;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.room-card {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
}

.room-card:hover {
    transform: translateY(-5px);
}

.room-info h4 {
    margin: 0 0 10px 0;
}

.room-info p {
    margin: 5px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    padding: 30px;
    width: 90%;
    max-width: 500px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.form-group label {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    padding: 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: 1px solid var(--panel-border);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}

/* Game Room */
.room-header {
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 85vh;
}

.table-area {
    min-height: 350px;
    background: radial-gradient(ellipse at center, #1b4b36 0%, #0d1e16 100%);
    border-radius: 12px;
    padding: 40px 20px;
    position: relative;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.deck-area {
    position: absolute;
    top: 20px;
    left: 20px;
}

.discard-area {
    position: absolute;
    top: 20px;
    left: 140px;
}

.deck-count {
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-top: 5px;
    text-align: center;
}

.goalposts {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

/* Cards */
.card {
    width: 100px;
    height: 140px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s ease, opacity 0.3s;
}

@keyframes dealCard {
    0% {
        transform: translateY(-200px) rotate(-180deg) scale(0.5);
        opacity: 0;
    }

    100% {
        transform: translateY(0) rotate(0) scale(1);
        opacity: 1;
    }
}

.deal-animation {
    animation: dealCard 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.card-back {
    background-image: url('https://deckofcardsapi.com/static/img/back.png');
    border: 2px solid #fff;
}

.empty-slot {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    box-shadow: none;
    background: transparent;
}

.glow-pulse {
    animation: pulseGlow 2s infinite alternate;
}

@keyframes pulseGlow {
    from {
        box-shadow: 0 0 10px rgba(47, 129, 247, 0.2);
    }

    to {
        box-shadow: 0 0 25px rgba(47, 129, 247, 0.8);
    }
}

.jackpot-info {
    text-align: center;
    margin-top: 30px;
}

.timer-bar {
    width: 250px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 10px auto;
}

.timer-progress {
    height: 100%;
    background: var(--warning-color);
    width: 100%;
    transition: width 1s linear;
}

/* Betting Controls */
.betting-controls {
    padding: 20px;
    text-align: center;
    border-top: 1px solid var(--panel-border);
}

.turn-indicator {
    color: var(--warning-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.slider-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.slider-container input[type=range] {
    width: 60%;
}

.bet-value {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Orbitron';
    color: var(--warning-color);
}

.quick-bets {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.quick-bets .btn {
    padding: 8px 15px;
    font-size: 0.9rem;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Players Area */
.players-area {
    display: flex;
    padding: 15px;
    gap: 15px;
    overflow-x: auto;
    border-top: 1px solid var(--panel-border);
    justify-content: center;
}

.player-card {
    position: relative;
    min-width: 120px;
    padding: 15px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.player-card.active-turn {
    border-color: var(--warning-color);
    box-shadow: 0 0 15px rgba(210, 153, 34, 0.3);
    transform: scale(1.05);
}

.player-card.disconnected {
    opacity: 0.5;
    filter: grayscale(1);
}

.player-card.passed {
    border-color: #6c757d;
    opacity: 0.8;
}

.kick-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.8rem;
    line-height: 24px;
    border-radius: 50%;
    display: block;
    /* always visible now */
    text-align: center;
    border: 2px solid var(--panel-border);
    background: var(--danger-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 10;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    cursor: pointer;
}

/* Make it fully opaque and slightly larger on hover */
.kick-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Animations */
.player-card .nickname {
    font-weight: bold;
}

.player-card .chips {
    color: var(--warning-color);
    font-weight: bold;
    margin-top: 5px;
}

.player-card .status {
    font-size: 0.8rem;
    margin-top: 5px;
    color: var(--text-secondary);
    height: 18px;
}

/* Logs */
.game-log {
    padding: 15px;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.game-log ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.game-log li {
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 5px;
}

/* Responsive adjustments */
@media(max-width: 768px) {
    .goalposts {
        gap: 10px;
        margin-top: 20px;
    }

    .card {
        width: 70px;
        height: 100px;
    }

    .app-container {
        padding: 10px;
    }

    .room-header {
        padding: 10px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .room-header h2 {
        font-size: 1.2rem;
    }

    .table-area {
        padding: 20px 10px;
        min-height: 250px;
    }

    .deck-area {
        position: relative;
        top: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 10px;
    }

    .discard-area {
        position: relative;
        top: 0;
        left: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 10px;
    }

    .players-area {
        justify-content: flex-start;
    }

    .player-card {
        min-width: 100px;
        padding: 10px;
    }

    .action-buttons {
        flex-wrap: wrap;
    }

    .action-buttons .btn {
        flex: 1;
        min-width: 100px;
    }
}

/* ===== Feature 6: Card Animations ===== */
.card-fly {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    /* just below chip */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transform-origin: top left;
}

/* ===== Feature 1: Guess Selection (Two-Step UP/DOWN) ===== */
.step-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.guess-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.guess-btn {
    min-width: 130px;
    border: 3px solid transparent;
    transition: all 0.25s ease;
    font-size: 1rem;
}

.guess-btn.selected {
    border-color: var(--warning-color) !important;
    box-shadow: 0 0 20px var(--glow-warning), 0 0 40px var(--glow-warning);
    transform: scale(1.08);
}

.selected-guess-display {
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    display: inline-block;
}

.mt-10 {
    margin-top: 10px;
}

/* ===== Feature 2: Chip Fly Animation ===== */
.chip-fly {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--warning-color);
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--warning-color);
    border-radius: 20px;
    padding: 4px 12px;
    white-space: nowrap;
    text-shadow: 0 0 8px var(--warning-color);
    box-shadow: 0 0 12px var(--glow-warning);
    transform-origin: center;
}

/* ===== Feature 3: Win Rate in Player Cards ===== */
.win-rate {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-top: 4px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ===== Feature 4: Header Actions ===== */
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ===== Feature 5: Eliminated Player ===== */
.player-card.eliminated {
    opacity: 0.45;
    filter: grayscale(0.8);
    border-color: var(--danger-color) !important;
    box-shadow: 0 0 10px rgba(248, 81, 73, 0.2);
}

.player-card.eliminated .nickname {
    text-decoration: line-through;
    color: var(--danger-color);
}

/* ===== Game Over Leaderboard Modal ===== */
.game-over-modal {
    padding: 40px;
    width: 95%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
}

.game-over-title {
    color: var(--warning-color);
    font-size: 2rem;
    margin-bottom: 20px;
}

.winner-banner {
    background: linear-gradient(135deg, rgba(210, 153, 34, 0.3), rgba(47, 129, 247, 0.2));
    border: 1px solid var(--warning-color);
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 1.2rem;
    margin-bottom: 25px;
    animation: pulseGlow 1.5s infinite alternate;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.leaderboard-table th {
    background: rgba(255, 255, 255, 0.08);
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--panel-border);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.leaderboard-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr.winner-row td {
    color: var(--warning-color);
    font-weight: bold;
    background: rgba(210, 153, 34, 0.1);
    font-size: 1.05rem;
}