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

html, body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

/* ===== LOADING ===== */
.loading-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100vh; gap: 2rem;
}
.loading-title { font-size: 4rem; font-weight: 900; letter-spacing: 0.3em; color: #f0c040; }
.loading-cards { display: flex; gap: 0.5rem; }
.loading-card {
    width: 50px; height: 70px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.3);
    background: white; display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 900;
    animation: cardBounce 1.2s infinite ease-in-out;
}
.loading-card:nth-child(2) { animation-delay: 0.1s; }
.loading-card:nth-child(3) { animation-delay: 0.2s; }
.loading-card:nth-child(4) { animation-delay: 0.3s; }
.loading-card:nth-child(5) { animation-delay: 0.4s; }
.loading-card:nth-child(6) { animation-delay: 0.5s; }
@keyframes cardBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* ===== BUTTONS ===== */
button { cursor: pointer; border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 600; transition: all 0.15s; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, #f0c040, #e8a020);
    color: #1a1a2e; padding: 0.6rem 1.5rem; border: 1px solid transparent;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(240,192,64,0.4); }
.btn-secondary {
    background: rgba(255,255,255,0.1); color: #e0e0e0;
    padding: 0.6rem 1.5rem; border: 1px solid rgba(255,255,255,0.2);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.btn-join {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white; padding: 0.4rem 1rem; font-size: 0.85rem;
}
.btn-join:hover:not(:disabled) { transform: translateY(-1px); }
.btn-discard {
    background: linear-gradient(135deg, #e53935, #b71c1c);
    color: white; padding: 0.7rem 2rem; font-size: 1rem; margin-top: 0.5rem;
}
.btn-discard:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(229,57,53,0.4); }
.btn-refresh {
    background: transparent; color: #aaa; font-size: 1.2rem; padding: 0.2rem 0.5rem;
    border-radius: 50%;
}
.btn-refresh:hover { color: #f0c040; transform: rotate(180deg); }
.btn-start {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240,192,64,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(240,192,64,0); }
}

/* ===== INPUTS ===== */
.name-input {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px; color: #e0e0e0; padding: 0.5rem 1rem; font-size: 1rem;
    outline: none; transition: border-color 0.2s;
    width: 100%; 
    box-sizing: border-box;
}
.name-input:focus { border-color: #f0c040; }
.name-input::placeholder { color: #666; }

/* ===== LOBBY ===== */
.lobby {
    max-width: 700px; margin: 0 auto; padding: 2rem 1rem;
    display: flex; flex-direction: column; gap: 1.5rem;
}
.lobby-header { text-align: center; }
.game-title {
    font-family: 'Nunito Sans', 'Segoe UI', system-ui, sans-serif;
    font-size: clamp(2rem, 9vw, 4rem); font-weight: 900; letter-spacing: 0.2em;
    background: linear-gradient(135deg, #f0c040, #ff6b35);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.mirror-k { display: inline-block; transform: scaleX(-1); margin-left: -0.24em; }
.game-subtitle { color: #888; font-size: 1.1rem; margin-top: 0.3rem; }
.player-name-section {
    display: flex; align-items: center; gap: 1rem;
    background: rgba(255,255,255,0.05); border-radius: 12px; padding: 1rem 1.5rem;
}
.player-name-section label { font-weight: 600; white-space: nowrap; }
.player-name-section .name-input { flex: 1; min-width: 0; }
.lobby-actions { display: flex; gap: 1rem; }
.create-form {
    display: flex; gap: 0.8rem; align-items: center;
    background: rgba(255,255,255,0.05); border-radius: 12px; padding: 1rem 1.5rem;
    flex-wrap: wrap;
}
.create-form .name-input { flex: 1; min-width: 200px; }
.games-section { display: flex; flex-direction: column; gap: 1rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; }
.section-header h2 { font-size: 1.2rem; font-weight: 600; color: #bbb; }
.games-list { display: flex; flex-direction: column; gap: 0.7rem; }
.game-card {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px; padding: 1rem 1.5rem;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    transition: border-color 0.2s;
}
.game-card:hover { border-color: rgba(240,192,64,0.3); }
.game-info { flex: 1; display: flex; flex-direction: column; gap: 0.2rem; }
.game-name { font-weight: 700; font-size: 1rem; }
.game-creator { font-size: 0.8rem; color: #888; }
.game-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; }
.player-count { font-size: 0.85rem; color: #aaa; }
.game-status { font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.6rem; border-radius: 20px; }
.game-status.waiting { background: rgba(76,175,80,0.2); color: #81C784; }
.game-status.playing { background: rgba(33,150,243,0.2); color: #64B5F6; }
.game-status.finished { background: rgba(158,158,158,0.2); color: #9E9E9E; }
.empty-list { color: #666; text-align: center; padding: 2rem; }
.loading { color: #888; text-align: center; padding: 2rem; }
.error-msg {
    background: rgba(229,57,53,0.15); border: 1px solid rgba(229,57,53,0.3);
    border-radius: 8px; padding: 0.6rem 1rem; color: #EF9A9A; font-size: 0.9rem;
}

/* ===== GAME ROOM ===== */
.game-room {
    max-width: 900px; margin: 0 auto; padding: 1rem;
    display: flex; flex-direction: column; gap: 1rem; min-height: 100vh;
}
.game-header {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: rgba(255,255,255,0.05); border-radius: 12px; padding: 0.8rem 1.2rem;
}
.game-title-small { font-size: 1.2rem; font-weight: 700; flex: 1; }
.round-badge {
    background: rgba(240,192,64,0.15); color: #f0c040;
    padding: 0.2rem 0.8rem; border-radius: 20px; font-size: 0.85rem; font-weight: 600;
}

/* ===== DECK ===== */
.deck-view { display: flex; align-items: center; gap: 0.8rem; }
.deck-stack { position: relative; width: 50px; height: 70px; }
.deck-card-back {
    position: absolute; width: 44px; height: 62px; border-radius: 6px;
    background: repeating-linear-gradient(
        45deg, #16213e 0px, #16213e 4px, #1a1a2e 4px, #1a1a2e 8px
    );
    border: 1.5px solid #3a3a5c;
}
.deck-count { font-size: 0.85rem; color: #aaa; white-space: nowrap; }

/* ===== WAITING ROOM ===== */
.waiting-room {
    background: rgba(255,255,255,0.05); border-radius: 16px;
    padding: 2rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.waiting-room h2 { font-size: 1.5rem; font-weight: 700; }
.players-waiting { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; max-width: 300px; }
.waiting-player {
    display: flex; align-items: center; gap: 0.8rem;
    background: rgba(255,255,255,0.05); border-radius: 8px; padding: 0.5rem 1rem;
}
.player-dot { color: #4CAF50; }
.waiting-info { color: #888; font-size: 0.9rem; }
.waiting-msg { color: #888; font-style: italic; }
.waiting-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; align-items: center; }
.waiting-actions button { padding: 0.6rem 1.5rem; font-size: 0.9rem; height: 3rem; }
.player-tag { font-size: 0.72rem; color: #888; }
.tag-bot { background: rgba(240,192,64,0.15); color: #f0c040; border-radius: 4px; padding: 1px 6px; }
.player-medals { display: flex; gap: 0.4rem; align-items: center; margin-left: auto; }
.player-medals span { font-size: 0.78rem; white-space: nowrap; }

/* ===== OTHER PLAYERS ===== */
.other-players {
    display: flex; gap: 1rem; flex-wrap: wrap;
    background: rgba(255,255,255,0.03); border-radius: 12px; padding: 1rem;
}
.other-player {
    background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.08);
    border-radius: 10px; padding: 0.8rem; min-width: 140px;
    display: flex; flex-direction: column; gap: 0.5rem;
    transition: border-color 0.2s, background 0.2s;
}
.other-player.active-turn {
    border-color: #f0c040;
    background: rgba(240,192,64,0.10);
    box-shadow: 0 0 0 3px rgba(240,192,64,0.18);
    animation: turn-pulse 1.6s ease-in-out infinite;
}
@keyframes turn-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(240,192,64,0.18); }
    50%       { box-shadow: 0 0 0 6px rgba(240,192,64,0.06); }
}
.other-player-header { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.other-player-name { font-weight: 600; font-size: 0.9rem; }
.turn-badge {
    background: #f0c040; color: #1a1a2e; border-radius: 20px;
    padding: 0.1rem 0.5rem; font-size: 0.7rem; font-weight: 700;
    display: flex; align-items: center; gap: 3px;
}
.ready-badge {
    background: rgba(76,175,80,0.2); color: #81C784; border-radius: 20px;
    padding: 0.1rem 0.5rem; font-size: 0.7rem; font-weight: 700;
}
.other-player-cards { display: flex; gap: 3px; flex-wrap: wrap; }
.discard-info { font-size: 0.75rem; color: #888; }

/* ===== MY AREA ===== */
.my-area {
    background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 1.2rem; display: flex; flex-direction: column; gap: 1rem;
    transition: border-color 0.2s, background 0.2s;
}
.my-area.active-turn {
    border-color: #f0c040;
    background: rgba(240,192,64,0.08);
    box-shadow: 0 0 0 3px rgba(240,192,64,0.18);
    animation: turn-pulse 1.6s ease-in-out infinite;
}
.my-area-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.my-name { font-weight: 700; font-size: 1.1rem; }
.turn-indicator { padding: 0.25rem 0.8rem; border-radius: 20px; font-size: 0.85rem; font-weight: 700; }
.turn-indicator.my-turn { background: rgba(240,192,64,0.2); color: #f0c040; animation: pulse 1.5s infinite; }
.turn-indicator.waiting-turn { background: rgba(255,255,255,0.08); color: #aaa; }
.turn-indicator.revealing { background: rgba(33,150,243,0.2); color: #64B5F6; }
.turn-countdown { display: flex; align-items: center; gap: 0.4rem; }
.countdown-secs { font-size: 0.8rem; color: #aaa; min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.countdown-bar { width: 72px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.countdown-fill { height: 100%; border-radius: 2px; transition: width 0.25s linear, background 1s; }
.countdown-ok      { background: #43A047; }
.countdown-warn    { background: #f0c040; }
.countdown-danger  { background: #e53935; }

/* ===== HAND ===== */
.hand-view { display: flex; flex-direction: column; gap: 1rem; }
.hand-cards { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.discard-controls { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.discard-hint { font-size: 0.85rem; color: #aaa; }

/* ===== CARD ===== */
.card {
    width: 70px; height: 100px; border-radius: 10px;
    background: white; border: 2px solid #ddd;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 5px; cursor: pointer; user-select: none;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.5);
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative; overflow: hidden;
}
.card:hover:not(.face-down) { transform: translateY(-6px); box-shadow: 2px 8px 16px rgba(0,0,0,0.6); }
.card.selected {
    transform: translateY(-12px) scale(1.05);
    box-shadow: 0 12px 24px rgba(240,192,64,0.5);
    border-color: #f0c040 !important;
}
.card.dragging { opacity: 0.5; transform: scale(0.95); }
.card.face-down { background: #16213e; border-color: #3a3a5c; cursor: default; }
.card.face-down:hover { transform: none; }
.card.dealing {
    animation: deal-in 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    animation-delay: calc(var(--deal-i, 0) * 0.1s);
}
@keyframes deal-in {
    0%   { opacity: 0; transform: translateY(70px) scale(0.65) rotate(-5deg); }
    65%  { opacity: 1; transform: translateY(-7px) scale(1.04) rotate(1deg); }
    100% { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

.card-corner { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.card-corner.rotated { align-items: flex-end; transform: rotate(180deg); align-self: flex-end; }
.card-letter { font-size: 1rem; font-weight: 900; line-height: 1; }
.card-figure-center {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.card-figure { font-size: 3.5rem; line-height: 1; }
.card-back-pattern {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        45deg, #16213e 0px, #16213e 4px, #1e1e3a 4px, #1e1e3a 8px
    );
    border-radius: 8px;
}
.card-back-pattern::after {
    content: 'T'; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem; font-weight: 900; color: rgba(240,192,64,0.3);
}

/* Card colors */
.color-red    .card-letter, .color-red    .card-figure { color: #e53935; }
.color-green  .card-letter, .color-green  .card-figure { color: #43A047; }
.color-blue   .card-letter, .color-blue   .card-figure { color: #1E88E5; }
.color-black  .card-letter, .color-black  .card-figure { color: #212121; }
.color-magenta .card-letter, .color-magenta .card-figure { color: #9C27B0; }
.color-cyan   .card-letter, .color-cyan   .card-figure { color: #00ACC1; }
.color-orange .card-letter, .color-orange .card-figure { color: #F57C00; }
.color-brown  .card-letter, .color-brown  .card-figure { color: #795548; }

/* Color tinted card backgrounds */
.color-red    { background: linear-gradient(160deg, #fff8f8, #fff); border-color: #ffcdd2; }
.color-green  { background: linear-gradient(160deg, #f8fff8, #fff); border-color: #c8e6c9; }
.color-blue   { background: linear-gradient(160deg, #f8f8ff, #fff); border-color: #bbdefb; }
.color-black  { background: linear-gradient(160deg, #f5f5f5, #fff); border-color: #bdbdbd; }
.color-magenta { background: linear-gradient(160deg, #fdf4ff, #fff); border-color: #e1bee7; }
.color-cyan   { background: linear-gradient(160deg, #f0ffff, #fff); border-color: #b2ebf2; }
.color-orange { background: linear-gradient(160deg, #fff7f0, #fff); border-color: #ffe0b2; }
.color-brown  { background: linear-gradient(160deg, #faf5f2, #fff); border-color: #d7ccc8; }

/* ===== RESULTS ===== */
.results-view {
    display: flex; flex-direction: column; gap: 1.5rem;
    max-width: 860px; margin: 0 auto; padding: 1rem;
}
.results-header { text-align: center; }
.results-header h2 { font-size: 1.8rem; font-weight: 700; }
.round-label { color: #888; margin-top: 0.3rem; }
.results-list { display: flex; flex-direction: column; gap: 0.8rem; }

.result-entry {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px; padding: 1rem 1.2rem;
    display: flex; flex-direction: column; gap: 0.7rem;
}
.result-entry.my-result { border-color: rgba(240,192,64,0.4); background: rgba(240,192,64,0.04); }
.result-entry.rank-1 { border-color: rgba(240,192,64,0.55); }

.result-player-header {
    display: flex; align-items: center; gap: 0.7rem;
}
.rank-medal { font-size: 1.5rem; line-height: 1; }
.result-player-name { font-weight: 700; font-size: 1rem; }

/* --- Cards row --- */
.result-cards-row {
    display: flex; gap: 5px; flex-wrap: wrap; align-items: flex-end;
    padding-bottom: 4px;
}

/* Slot wrapper for each card */
.rc-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; }

/* Grouped card: colored outline + underline bar */
.rc-slot.rc-grouped .card {
    outline: 2.5px solid var(--gc);
    outline-offset: 2px;
    box-shadow: 0 0 8px color-mix(in srgb, var(--gc) 40%, transparent),
                2px 3px 8px rgba(0,0,0,0.5);
}
.rc-slot.rc-grouped::after {
    content: '';
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: var(--gc);
}

/* Disable the default hover lift inside results */
.result-entry .card { box-shadow: 1px 2px 5px rgba(0,0,0,0.4); }
.result-entry .card:hover { transform: translateY(-3px) !important; }

/* --- Badges --- */
.result-badges {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
}
.grp-badge {
    display: inline-flex; align-items: center;
    padding: 0.18rem 0.75rem;
    border-radius: 20px;
    border: 1.5px solid var(--gc, #888);
    color: var(--gc, #888);
    background: color-mix(in srgb, var(--gc, #888) 12%, transparent);
    font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.grp-badge.grp-nojugada {
    --gc: #888;
    border-style: dashed;
    font-style: italic;
}
.grp-badge.grp-hand-name {
    --gc: #a78bfa;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}
.grp-badge.grp-hand-name.expandable { cursor: pointer; user-select: none; }
.grp-caret {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.15rem; height: 1.15rem; margin-left: 0.4rem;
    border-radius: 50%;
    background: var(--gc, #a78bfa);
    color: #fff;
    font-size: 0.72rem; line-height: 1; font-style: normal;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--gc, #a78bfa) 30%, transparent);
    transition: transform 0.18s ease;
}
.grp-caret.open { transform: rotate(180deg); }
.my-play-badge {
    display: flex; align-items: center; gap: 0.5rem;
    flex-wrap: wrap; margin: 0.1rem 0 0.6rem;
}
.my-play-label { font-size: 0.78rem; color: #9aa0aa; font-weight: 600; }
.grp-breakdown {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
    flex-basis: 100%; margin-top: 0.35rem;
}

/* Continue */
.continue-section {
    background: rgba(255,255,255,0.05); border-radius: 14px;
    padding: 1.5rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.continue-prompt { font-size: 1.1rem; font-weight: 600; }
.continue-buttons { display: flex; gap: 1rem; }
.waiting-others { color: #888; }

/* ===== MOBILE ===== */
@media (max-width: 480px) {
    .game-room { padding: 0.5rem; }

    /* Cartas más pequeñas */
    .card {
        width: 54px; height: 78px;
        border-radius: 8px; padding: 3px;
    }
    .card-letter { font-size: 0.72rem; }
    .card-figure  { font-size: 3.9rem; }

    /* Mano: una fila sin wrap */
    .hand-cards {
        flex-wrap: nowrap;
        gap: 0.3rem;
        overflow-x: auto;
    }

    /* Resultados: una fila sin wrap */
    .result-cards-row {
        flex-wrap: nowrap;
        gap: 3px;
        overflow-x: auto;
    }
}

/* ===== HELP BUTTON ===== */
.btn-help {
    width: clamp(2rem, 7.5vw, 3.2rem); height: clamp(2rem, 7.5vw, 3.2rem); border-radius: 50%;
    border: 2px solid #f0c040; background: transparent;
    color: #f0c040; font-weight: 900; font-size: clamp(1.1rem, 4.5vw, 1.8rem);
    cursor: pointer; line-height: 1; flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.btn-help:hover { background: #f0c040; color: #1a1a2e; }

.lobby-header { display: flex; flex-direction: column; align-items: center; }
.lobby-title-row { display: flex; align-items: center; gap: 0.5rem; }

.game-header { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.game-header .btn-mute { margin-left: auto; }
.btn-mute {
    background: transparent; border: none; font-size: 1.2rem;
    cursor: pointer; line-height: 1; padding: 0.2rem; opacity: 0.7;
    transition: opacity 0.15s;
}
.btn-mute:hover { opacity: 1; }

/* ===== HELP MODAL ===== */
.help-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.help-modal {
    background: #16213e; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px; padding: 1.5rem;
    max-width: 640px; width: 100%;
    max-height: 90vh; overflow-y: auto;
    position: relative;
    display: flex; flex-direction: column; gap: 1rem;
}
.help-close {
    position: absolute; top: 0.8rem; right: 0.8rem;
    background: transparent; border: none; color: #aaa;
    font-size: 1.2rem; cursor: pointer; line-height: 1; padding: 0.2rem 0.5rem;
}
.help-close:hover { color: #fff; }
.help-title { font-size: 1.4rem; font-weight: 900; color: #f0c040; margin: 0; }

.help-section h3 { font-size: 1rem; font-weight: 700; color: #f0c040; margin: 0 0 0.5rem; }
.help-section p  { margin: 0 0 0.4rem; font-size: 0.92rem; color: #ccc; line-height: 1.5; }

.help-params { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.5rem 0; }
.help-param  { display: flex; align-items: baseline; gap: 0.6rem; font-size: 0.9rem; }
.help-param-name { color: #f0c040; font-weight: 700; min-width: 60px; }
.help-param-vals { color: #ddd; }
.help-figures { font-size: 1.3rem; line-height: 1; }

.help-note { font-size: 0.85rem !important; color: #999 !important; }

.help-steps { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.35rem; }
.help-steps li { font-size: 0.92rem; color: #ccc; line-height: 1.5; }

.help-formula { text-align: center; font-size: 1.05rem; color: #f0c040; margin: 0.5rem 0 0.2rem !important; }
.help-formula-desc { text-align: center; font-size: 0.85rem !important; }

.help-table-wrap { overflow-x: auto; margin: 0.5rem 0; }
.help-table {
    width: 100%; border-collapse: collapse; font-size: 0.88rem;
}
.help-table th, .help-table td {
    padding: 0.4rem 0.7rem; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.help-table th { color: #f0c040; font-weight: 700; background: rgba(255,255,255,0.04); }
.help-table td { color: #ddd; }
.help-table td:first-child { text-align: left; font-weight: 600; color: #eee; }
.help-table tbody tr:hover { background: rgba(255,255,255,0.04); }

.help-hands-table td:nth-child(1) { color: #666; font-size: 0.8rem; min-width: 20px; }
.help-hands-table td:nth-child(2) { font-weight: 600; color: #eee; white-space: nowrap; }
.help-hands-table .pts { color: #f0c040; font-weight: 700; text-align: right; }
.help-hands-table .row-special td { color: #f0c040; font-weight: 700; }
.help-hands-table .row-special td:nth-child(2) { color: #f5d060; }
.prob-cell { text-align: right; font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.prob-rare     { color: #666; }
.prob-uncommon { color: #888; }
.prob-low      { color: #aaa; }
.prob-medium   { color: #c8a040; }
.prob-common   { color: #f0c040; }

/* ===== SUGERENCIAS ===== */
.btn-sug {
    width: clamp(2rem, 7.5vw, 3.2rem); height: clamp(2rem, 7.5vw, 3.2rem); border-radius: 50%;
    border: 2px solid #64B5F6; background: transparent;
    color: #64B5F6; font-size: clamp(1.1rem, 4.5vw, 1.8rem);
    cursor: pointer; line-height: 1; flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.btn-sug:hover { background: #64B5F6; color: #1a1a2e; }

.sug-modal { max-width: 480px; }

.sug-form { display: flex; flex-direction: column; gap: 1rem; }
.sug-field { display: flex; flex-direction: column; gap: 0.4rem; }
.sug-label { font-size: 0.9rem; font-weight: 600; color: #bbb; }

.sug-select {
    width: 100%;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px; color: #e0e0e0; padding: 0.5rem 1rem; font-size: 1rem;
    outline: none; cursor: pointer; transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 1rem center;
}
.sug-select:focus { border-color: #64B5F6; }
.sug-select option { background: #16213e; color: #e0e0e0; }

.sug-form .name-input, .sug-select, .sug-form .sug-textarea { width: 100%; box-sizing: border-box; }

.sug-textarea { resize: vertical; min-height: 100px; font-family: inherit; font-size: 0.95rem; }
.sug-chars { font-size: 0.78rem; color: #666; text-align: right; }

.sug-actions { display: flex; gap: 0.8rem; justify-content: flex-end; margin-top: 0.5rem; }

.sug-success {
    display: flex; flex-direction: column; align-items: center;
    gap: 1rem; padding: 1.5rem 0; text-align: center;
}
.sug-success-icon {
    width: 3.5rem; height: 3.5rem; border-radius: 50%;
    background: rgba(76,175,80,0.2); border: 2px solid #81C784;
    color: #81C784; font-size: 1.8rem; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
}
.sug-success p { color: #ccc; font-size: 1rem; }

/* ===== BLAZOR ERROR ===== */
#blazor-error-ui {
    background: #b71c1c; bottom: 0; display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem;
    position: fixed; width: 100%; z-index: 1000; color: white; font-size: 0.9rem;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ===== SESSION STATS ===== */
.session-stats {
    margin-top: 1.5rem;
    padding: 1rem 1.2rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
}
.session-stats-title {
    margin: 0 0 0.8rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    font-weight: 600;
}
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.stats-table th {
    text-align: center;
    padding: 0.3rem 0.5rem;
    color: #888;
    font-weight: 600;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.stats-table th:first-child { text-align: left; }
.stats-table td {
    text-align: center;
    padding: 0.35rem 0.5rem;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stats-table td:first-child { text-align: left; color: #e0e0e0; }
.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-me td { color: #64b5f6 !important; font-weight: 600; }

/* ===== HELP MINI CARDS (ejemplos visuales) ===== */
.help-mini-card {
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: space-between;
    width: 34px; height: 48px;
    border-radius: 6px; border: 1.5px solid;
    padding: 3px 2px; box-sizing: border-box; flex-shrink: 0;
}
.hmc-lt  { font-size: 0.65rem; font-weight: 900; align-self: flex-start; line-height: 1; }
.hmc-fig { font-size: 1.3rem; line-height: 1; }
.color-red     .hmc-lt, .color-red     .hmc-fig { color: #e53935; }
.color-green   .hmc-lt, .color-green   .hmc-fig { color: #43A047; }
.color-blue    .hmc-lt, .color-blue    .hmc-fig { color: #1E88E5; }
.color-cyan    .hmc-lt, .color-cyan    .hmc-fig { color: #00ACC1; }
.color-magenta .hmc-lt, .color-magenta .hmc-fig { color: #9C27B0; }

.help-examples-row {
    display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0.5rem 0;
}
.help-example {
    display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
}
.help-mini-hand {
    display: flex; align-items: flex-end; gap: 4px;
}
.help-ex-plus { color: #888; font-size: 1.1rem; align-self: center; padding: 0 2px; }
.help-ex-label { font-size: 0.8rem; font-weight: 700; color: #f0c040; }
.help-ex-desc  { font-size: 0.72rem; color: #888; text-align: center; max-width: 130px; }

/* ===== RESPONSIVE RESULTS (mobile improvements) ===== */
.stats-table-wrap { overflow-x: auto; }

@media (max-width: 480px) {
    .result-entry { padding: 0.65rem 0.75rem; }
    .result-player-header { flex-wrap: wrap; gap: 0.4rem; }
    .result-player-name { font-size: 0.9rem; }
    .continue-section { padding: 1rem; }
    .continue-buttons { flex-direction: column; width: 100%; }
    .continue-buttons .btn-primary,
    .continue-buttons .btn-secondary { width: 100%; text-align: center; }
    .session-stats { padding: 0.65rem 0.75rem; }
    .results-header h2 { font-size: 1.4rem; }
}

/* ===== RECONEXIÓN ===== */
.reconnect-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 900;
    padding: 0.45rem 1rem; text-align: center;
    font-size: 0.88rem; font-weight: 600;
    display: flex; align-items: center; justify-content: center; gap: 0.8rem;
}
.reconnect-warn  { background: rgba(200,160,0,0.92); color: #1a1a2e; }
.reconnect-error { background: rgba(183,28,28,0.92); color: #fff; }
.btn-reload {
    padding: 0.15rem 0.7rem; border-radius: 4px;
    border: 1.5px solid currentColor; background: transparent;
    color: inherit; cursor: pointer; font-weight: 700; font-size: 0.82rem;
}
.btn-reload:hover { background: rgba(255,255,255,0.2); }

/* ===== FEEDBACK DE DESCARTE ===== */
.turn-indicator.discarded-ok { color: #81c784; font-weight: 600; font-size: 0.88rem; }

/* ===== EXPLICACIÓN DE RESULTADO (separadores de grupos) ===== */
.grp-sep { color: #666; font-size: 0.85rem; padding: 0 0.15rem; align-self: center; }

/* ===== VISTA DE DESCARTES ===== */
.discard-section {
    display: flex; flex-direction: column; gap: 4px;
}
.discard-section-label {
    font-size: 0.72rem; color: #888; font-weight: 600; letter-spacing: 0.02em;
}
.discard-pile-row {
    display: flex; gap: 3px; flex-wrap: wrap;
}
.discard-pile-row .card {
    width: 32px; height: 46px;
    border-radius: 5px; padding: 2px;
    opacity: 0.45; border-style: dashed;
    cursor: default; pointer-events: none;
    transform: none !important;
}
.discard-badge-result {
    margin-left: auto;
    font-size: 0.72rem; color: #888; font-weight: 600;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px; padding: 0.1rem 0.45rem;
    white-space: nowrap;
}

/* ===== PARTIDA A X VICTORIAS ===== */
.champion-banner {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
    background: linear-gradient(135deg, rgba(255,200,0,0.15) 0%, rgba(255,140,0,0.10) 100%);
    border: 1.5px solid rgba(255,200,0,0.35);
    border-radius: 12px; padding: 1rem 1.5rem;
    margin-bottom: 0.8rem; flex-wrap: wrap; text-align: center;
}
.champion-icon { font-size: 2.2rem; line-height: 1; }
.champion-name { font-size: 1.5rem; font-weight: 800; color: #fcd34d; }
.champion-sub  { font-size: 0.9rem; color: #a0a0a0; width: 100%; margin-top: -0.2rem; }

.target-badge {
    background: rgba(255,200,0,0.12); border: 1px solid rgba(255,200,0,0.3);
    border-radius: 10px; padding: 0.15rem 0.55rem;
    font-size: 0.82rem; font-weight: 700; color: #fcd34d;
    white-space: nowrap;
}

.create-form-row {
    display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.1rem;
}
.create-form-label {
    font-size: 0.88rem; color: #aaa; white-space: nowrap; min-width: 2.5rem;
}
.create-form-select {
    flex: 1; padding: 0.45rem 0.6rem;
    background: #2a2a3e; color: #e8e8f0;
    border: 1.5px solid rgba(255,255,255,0.15); border-radius: 8px;
    font-size: 0.9rem; cursor: pointer;
}
.create-form-select:focus {
    outline: none; border-color: rgba(255,255,255,0.35);
}
.create-form-select option {
    background: #2a2a3e; color: #e8e8f0;
}

.private-toggle {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.9rem; color: #d0d0d8;
    cursor: pointer; user-select: none;
    padding: 0.25rem 0;
}
.private-toggle input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; accent-color: #f0c040;
}

.join-code-row {
    display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem;
    width: 100%;
}
.join-code-row .name-input {
    flex: 1; min-width: 120px;
    letter-spacing: 0.15em; text-align: center; font-weight: 700;
}

.private-code-banner {
    display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    background: linear-gradient(135deg, rgba(240,192,64,0.15), rgba(240,192,64,0.05));
    border: 1.5px solid rgba(240,192,64,0.5); border-radius: 12px;
    padding: 0.75rem 1rem; margin: 0.5rem 0 1rem;
}
.private-code-label { font-size: 0.85rem; color: #fcd34d; font-weight: 700; }
.private-code-value {
    font-size: 2.2rem; font-weight: 900;
    color: #f0c040; letter-spacing: 0.3em;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(240,192,64,0.4);
}
.private-code-hint { font-size: 0.8rem; color: #aaa; }

.game-actions {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
}
.btn-spectate {
    background: rgba(120,160,255,0.12);
    color: #b8c8ff;
    border: 1.5px solid rgba(120,160,255,0.35);
    padding: 0.45rem 0.9rem; border-radius: 8px;
    font-weight: 700; cursor: pointer;
    transition: background 0.15s ease;
}
.btn-spectate:hover:not(:disabled) { background: rgba(120,160,255,0.22); }
.btn-spectate:disabled { opacity: 0.4; cursor: not-allowed; }

.spectator-badge {
    background: rgba(120,160,255,0.18);
    color: #b8c8ff;
    border: 1.5px solid rgba(120,160,255,0.45);
    padding: 0.25rem 0.6rem; border-radius: 999px;
    font-size: 0.82rem; font-weight: 700;
}
.spectator-count {
    background: rgba(255,255,255,0.06);
    color: #cfcfd8;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 0.2rem 0.55rem; border-radius: 999px;
    font-size: 0.82rem; font-weight: 700;
    cursor: help;
}
.btn-leave-spectate {
    margin-left: auto;
}

/* ===== TOOLBAR REACCIONES ===== */
.reaction-toolbar {
    position: sticky; bottom: 0.6rem;
    display: flex; justify-content: center; gap: 0.4rem;
    margin: 0.75rem auto 0.4rem;
    padding: 0.35rem 0.6rem;
    background: rgba(20,20,30,0.85);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 999px;
    width: fit-content;
    backdrop-filter: blur(6px);
    z-index: 5;
}
.reaction-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    width: 38px; height: 38px;
    font-size: 1.25rem; line-height: 1;
    cursor: pointer; padding: 0;
    transition: transform 0.12s ease, background 0.15s ease;
}
.reaction-btn:hover  { background: rgba(255,255,255,0.12); transform: scale(1.15); }
.reaction-btn:active { transform: scale(0.92); }

/* Burbuja flotante que aparece sobre el jugador */
.other-player, .my-area { position: relative; }
.reaction-bubble {
    position: absolute;
    top: -0.6rem; right: 0.6rem;
    font-size: 2.4rem; line-height: 1;
    pointer-events: none; user-select: none;
    z-index: 10;
    animation: reaction-float 2.5s ease-out forwards;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
@keyframes reaction-float {
    0%   { opacity: 0; transform: translateY(10px) scale(0.6); }
    15%  { opacity: 1; transform: translateY(-4px) scale(1.15); }
    30%  { transform: translateY(-10px) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(0.95); }
}

/* ===== FILA INFO (historial + sesión) ===== */
.info-row {
    display: flex; gap: 0.75rem; margin-bottom: 0.75rem;
}
.info-col {
    flex: 1; min-width: 0;
}
.info-col .rhp { margin-bottom: 0; height: 100%; box-sizing: border-box; }

/* ===== HISTORIAL DE RONDA ===== */
.rhp {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px; padding: 0.55rem 0.85rem;
    margin-bottom: 0.75rem;
}
.rhp-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.35rem;
}
.rhp-title { font-size: 0.75rem; color: #888; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.rhp-close {
    background: none; border: none; color: #555; cursor: pointer;
    font-size: 0.8rem; line-height: 1; padding: 0 0.1rem;
    transition: color 0.15s;
}
.rhp-close:hover { color: #ccc; }
.rhp-rows { display: flex; flex-direction: column; gap: 0.2rem; }
.rhp-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; }
.rhp-winner .rhp-name { color: #fcd34d; font-weight: 700; }
.rhp-medal { width: 1.4rem; text-align: center; flex-shrink: 0; }
.rhp-name { flex: 1; font-weight: 500; }
.rhp-hand { color: #777; font-size: 0.76rem; white-space: nowrap; }

/* ===== PANEL DE ESTADÍSTICAS DE SESIÓN (en juego) ===== */
.ssp {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px; padding: 0.55rem 0.85rem;
    height: 100%; box-sizing: border-box;
    display: flex; flex-direction: column; gap: 0.35rem;
}
.ssp-title {
    font-size: 0.75rem; color: #888; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase;
}
.ssp-table {
    width: 100%; border-collapse: collapse; font-size: 0.8rem;
}
.ssp-table th {
    text-align: center; color: #666; font-weight: 600;
    padding: 0.1rem 0.3rem; font-size: 0.72rem;
}
.ssp-table th:first-child { text-align: left; }
.ssp-table td {
    text-align: center; padding: 0.18rem 0.3rem;
    color: #ccc; border-top: 1px solid rgba(255,255,255,0.05);
}
.ssp-table td:first-child { text-align: left; color: #e0e0e0; }
.ssp-table tr.ssp-me td { color: #60a5fa; font-weight: 700; }
.ssp-table tr.ssp-me td:first-child { color: #60a5fa; }
