/* ======== Reset & Base ======== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0d1117;
    color: #e6edf3;
    min-height: 100vh;
    line-height: 1.5;
}

/* ======== Lobby ======== */
.lobby-container {
    max-width: 480px;
    margin: 80px auto;
    padding: 36px 32px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 16px;
    text-align: center;
}

.lobby-container h1 {
    font-size: 2.4rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.subtitle { color: #8b949e; margin-bottom: 28px; font-size: 14px; }

.add-player-form {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.add-player-form input,
.add-player-form select {
    padding: 10px 12px;
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #0d1117;
    color: #e6edf3;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.add-player-form input:focus,
.add-player-form select:focus {
    border-color: #58a6ff;
}

.add-player-form input { flex: 1; min-width: 0; }
.add-player-form select { width: 155px; flex-shrink: 0; }

.player-list { margin-bottom: 20px; }

.player-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 8px;
    margin-bottom: 6px;
}

.player-name { flex: 1; font-weight: 500; font-size: 14px; }

.player-type {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 10px;
}

.type-human { background: #1f6feb; color: #fff; }
.type-bot { background: #8957e5; color: #fff; }

.remove-btn {
    background: none;
    border: none;
    color: #484f58;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.remove-btn:hover { color: #f85149; }

.lobby-actions { margin-top: 22px; }

.lobby-msg { color: #8b949e; font-size: 13px; margin-top: 8px; }

.error-msg { color: #f85149; margin-top: 12px; font-size: 13px; min-height: 18px; }

/* ======== Buttons ======== */
button, .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

button:hover, .btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: 0.35; cursor: not-allowed; transform: none; filter: none; }

.btn-primary, #add-btn, #start-btn { background: #ff6b6b; color: #fff; }
.btn-secondary { background: #30363d; color: #e6edf3; }
.btn-muted { background: #21262d; color: #8b949e; }
.btn-cambio { background: #da3633; color: #fff; font-size: 15px; }

/* ======== Game Layout ======== */
.game-body { background: #0a0f14; }

.game-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 16px 20px 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.game-title {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.turn-indicator {
    font-size: 13px;
    padding: 5px 14px;
    border-radius: 20px;
    font-weight: 600;
}
.turn-indicator.your-turn { background: #238636; color: #fff; }
.turn-indicator.waiting { background: #161b22; color: #8b949e; border: 1px solid #30363d; }

.cambio-banner {
    text-align: center;
    padding: 8px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, rgba(218, 54, 51, 0.15), rgba(218, 54, 51, 0.05));
    border: 1px solid rgba(218, 54, 51, 0.4);
    border-radius: 8px;
    color: #f85149;
    font-weight: 600;
    font-size: 13px;
}

/* ======== Opponents ======== */
.opponents-area {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    margin-bottom: 16px;
    padding: 16px;
    background: #111820;
    border: 1px solid #1c2531;
    border-radius: 12px;
}

.opponent { text-align: center; }

.opponent-name {
    font-size: 13px;
    font-weight: 600;
    color: #c9d1d9;
    margin-bottom: 8px;
}

.opp-card-count {
    color: #484f58;
    font-weight: 400;
    font-size: 11px;
}

.opp-hand-grid {
    display: grid;
    grid-template-columns: repeat(2, 48px);
    gap: 4px;
    justify-content: center;
}

/* ======== Table Center ======== */
.table-center {
    display: flex;
    justify-content: center;
    gap: 48px;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 20px 0;
}

.pile-group { text-align: center; }

.pile-label {
    font-size: 11px;
    color: #484f58;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* ======== Cards ======== */
.card {
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
}

/* Standard size (player hand, table piles) */
.card {
    width: 72px;
    height: 100px;
}

/* Small size (opponent hands, game over) */
.card-sm {
    width: 48px;
    height: 68px;
}

.card-back {
    background: linear-gradient(145deg, #1c3a5f, #162d4a);
    border: 2px solid #264d73;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.card-back::before {
    content: '';
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(88, 166, 255, 0.15);
    border-radius: 4px;
}

.deck-card { cursor: default; }

.deck-count {
    font-size: 22px;
    color: #58a6ff;
    z-index: 1;
}

.card-face {
    background: #f5f5f0;
    border: 2px solid #d0d0c8;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.card-face.suit-red { color: #cc3333; border-color: #e8b0b0; }
.card-face.suit-black { color: #1a1a2e; border-color: #b8b8b0; }

.card-rank {
    font-size: 19px;
    line-height: 1;
}

.card-suit-icon {
    font-size: 22px;
    line-height: 1;
    margin-top: 1px;
}

.card-sm .card-rank { font-size: 13px; }
.card-sm .card-suit-icon { font-size: 16px; }

.discard-card {
    border-style: solid;
}

.discard-card.empty {
    background: rgba(255,255,255,0.03);
    border: 2px dashed #30363d;
}

.empty-label {
    color: #484f58;
    font-size: 12px;
    font-weight: 400;
}

.card-pos-label {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 12px;
    color: #e6edf3;
    font-weight: 700;
}

.card-face .card-pos-label { color: #394150; }

.card-eye {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 12px;
    line-height: 1;
    opacity: 0.85;
    filter: drop-shadow(0 0 2px rgba(248, 81, 73, 0.6));
}

/* ======== Your Hand (2x2 grid) ======== */
.your-section {
    text-align: center;
    margin-bottom: 14px;
}

.your-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #484f58;
    font-weight: 600;
    margin-bottom: 8px;
}

.hand-grid {
    display: grid;
    grid-template-columns: repeat(2, 72px);
    gap: 8px;
    justify-content: center;
}

/* ======== Clickable Cards ======== */
.card-clickable {
    cursor: pointer !important;
    box-shadow: 0 0 0 3px #58a6ff, 0 0 16px rgba(88, 166, 255, 0.25) !important;
    animation: pulse-blue 1.8s ease-in-out infinite;
}

.card-clickable:hover {
    transform: translateY(-5px) scale(1.04) !important;
    box-shadow: 0 0 0 3px #58a6ff, 0 8px 24px rgba(88, 166, 255, 0.35) !important;
}

.card-stickable {
    cursor: pointer !important;
    box-shadow: 0 0 0 3px #3fb950, 0 0 16px rgba(63, 185, 80, 0.25) !important;
    animation: pulse-green 1.8s ease-in-out infinite;
}

.card-stickable:hover {
    transform: translateY(-5px) scale(1.04) !important;
    box-shadow: 0 0 0 3px #3fb950, 0 8px 24px rgba(63, 185, 80, 0.35) !important;
}

.card-selected {
    transform: translateY(-8px) scale(1.06) !important;
    box-shadow: 0 0 0 4px #f0883e, 0 8px 24px rgba(240, 136, 62, 0.4) !important;
    animation: none !important;
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 3px #58a6ff, 0 0 12px rgba(88, 166, 255, 0.2); }
    50% { box-shadow: 0 0 0 5px rgba(88, 166, 255, 0.5), 0 0 20px rgba(88, 166, 255, 0.15); }
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 3px #3fb950, 0 0 12px rgba(63, 185, 80, 0.2); }
    50% { box-shadow: 0 0 0 5px rgba(63, 185, 80, 0.5), 0 0 20px rgba(63, 185, 80, 0.15); }
}

/* ======== Prompt Area ======== */
.prompt-area {
    background: #161b22;
    border: 1px solid #30363d;
    border-left: 4px solid #58a6ff;
    border-radius: 8px;
    padding: 18px 22px;
    margin-bottom: 14px;
}

.prompt-text {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.prompt-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.prompt-hint {
    font-size: 12px;
    color: #8b949e;
    font-style: italic;
    width: 100%;
    margin-top: 4px;
}

.highlight {
    color: #f0883e;
    font-weight: 700;
    font-size: 1.05em;
}

/* Prompt card display (drawn card / peeked card) */
.prompt-card-area {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.prompt-card {
    display: inline-flex !important;
    width: 72px !important;
    height: 100px !important;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(240, 136, 62, 0.35), 0 4px 12px rgba(0,0,0,0.3);
    animation: card-glow 2s ease-in-out infinite;
}

.prompt-card-desc {
    font-size: 14px;
    color: #e6edf3;
    line-height: 1.5;
}

@keyframes card-glow {
    0%, 100% { box-shadow: 0 0 16px rgba(240, 136, 62, 0.3), 0 4px 12px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 28px rgba(240, 136, 62, 0.5), 0 4px 12px rgba(0,0,0,0.3); }
}

.hidden { display: none !important; }

/* ======== Game Log ======== */
.log-section {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 8px;
    overflow: hidden;
}

.log-title {
    padding: 8px 14px;
    background: #0d1117;
    font-size: 11px;
    font-weight: 600;
    color: #484f58;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.game-log {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 14px;
}

.log-help {
    margin: 0;
    padding: 8px 14px;
    color: #aeb8c4;
    font-size: 12px;
    line-height: 1.5;
}

.log-entry {
    font-size: 12px;
    color: #8b949e;
    padding: 3px 0;
    border-bottom: 1px solid #0d1117;
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* ======== Game Over ======== */
.game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.game-over-panel {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 16px;
    padding: 36px;
    text-align: center;
    max-width: 600px;
    width: 92%;
    max-height: 88vh;
    overflow-y: auto;
}

.go-title {
    font-size: 1.8rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.go-winner {
    font-size: 1.4rem;
    font-weight: 700;
    color: #3fb950;
    margin-bottom: 4px;
}

.go-meta {
    font-size: 13px;
    color: #8b949e;
    margin-bottom: 20px;
}

.go-hands { text-align: left; margin-bottom: 20px; }

.go-player {
    padding: 12px 14px;
    margin-bottom: 6px;
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 8px;
}

.go-winner-row {
    border-color: #238636;
    background: rgba(35, 134, 54, 0.08);
}

.go-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.go-pname { font-weight: 600; font-size: 14px; }
.go-pscore { color: #8b949e; font-size: 13px; font-weight: 600; }
.go-winner-row .go-pscore { color: #3fb950; }

.go-cards {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.go-score-breakdown {
    margin-top: 6px;
    font-size: 11px;
    color: #8b949e;
    line-height: 1.4;
}

.go-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}

/* ======== Scrollbar ======== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

.rules-summary { margin: 8px 0 16px; color: #aeb8c4; font-size: 13px; line-height: 1.6; }
.rules-summary summary { cursor: pointer; }
.game-title small { font-size: 12px; color: #aeb8c4; }
