/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-gradient: radial-gradient(circle, #1a4223 0%, #0b1a0e 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-width: 90px;
    --card-height: 135px;
    --gold: #d4af37;
    --gold-glow: 0 0 15px rgba(212, 175, 55, 0.6);
    --primary: #2a7a3e;
    --primary-hover: #369c50;
    --danger: #9c2e2e;
    --danger-hover: #b83d3d;
    --text-light: #f5f5f5;
    --text-dark: #222222;
    --panel-bg: rgba(10, 25, 12, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background: var(--bg-gradient);
    color: var(--text-light);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header & Controls */
header {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--glass-border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

header h1 {
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: 2px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

header h1 span {
    color: var(--gold);
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.3);
}

.header-buttons {
    display: flex;
    gap: 12px;
}

button.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

button.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Standout styles for the tutorial/rules button */
button#btn-rules {
    background: linear-gradient(135deg, var(--gold) 0%, #b78a07 100%);
    color: #0b150c;
    border: 1px solid #ffe875;
    text-shadow: none;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
    font-weight: 700;
}

button#btn-rules:hover {
    background: linear-gradient(135deg, #ffd343 0%, var(--gold) 100%);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
    transform: translateY(-2px);
}

/* Beautiful blue highlight style for the Home link */
.header-buttons a.btn-home-link {
    background: rgba(41, 128, 185, 0.25);
    border-color: rgba(52, 152, 219, 0.5);
    color: #5dade2;
    transition: all 0.2s ease;
}

.header-buttons a.btn-home-link:hover {
    background: rgba(41, 128, 185, 0.4);
    border-color: #5dade2;
    color: #fff;
    transform: translateY(-2px);
}

/* Beautiful light-red highlight style for the PDF link */
.header-buttons a.btn-pdf-download {
    background: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.4);
    color: #ff8a8a;
    transition: all 0.2s ease;
}

.header-buttons a.btn-pdf-download:hover {
    background: rgba(231, 76, 60, 0.35);
    border-color: #ff7675;
    color: #fff;
    transform: translateY(-2px);
}


/* Main Game Layout */
.game-container {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 61px);
    overflow: hidden;
}

/* Sidebar Scoreboard */
.sidebar {
    background: var(--panel-bg);
    border-right: 1px solid var(--glass-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(12px);
    overflow-y: auto;
}

.score-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    flex-shrink: 0; /* evita que flex comprima los paneles — permite scroll en sidebar */
}

.score-panel h3 {
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.score-row:last-child {
    margin-bottom: 0;
}

.score-label {
    font-weight: 400;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.score-val {
    font-weight: 800;
    font-size: 1.4rem;
}

.score-val.player {
    color: #4cd964;
}

.score-val.cpu {
    color: #ff3b30;
}

/* China Markers (Malas/Buenas visual bar) */
.china-track {
    margin-top: 10px;
}

.china-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.china-dots {
    display: grid;
    grid-template-columns: repeat(25, 1fr);
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 4px;
}

.china-dot {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    transition: background-color 0.3s ease;
}

.china-dot.active-p1 {
    background: #4cd964;
    box-shadow: 0 0 5px rgba(76, 217, 100, 0.7);
}

.china-dot.active-p2 {
    background: #ff3b30;
    box-shadow: 0 0 5px rgba(255, 59, 48, 0.7);
}

/* Game Logs */
.log-panel {
    flex-shrink: 0;
    min-height: 220px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.log-panel h4 {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.log-messages {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 5px;
}

.log-msg {
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}

.log-msg.system { color: var(--gold); font-weight: 600; }
.log-msg.player { color: #4cd964; }
.log-msg.cpu { color: #ff9f0a; }
.log-msg.action { color: #5ac8fa; }

/* Game Board */
.board {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    padding: 24px;
    gap: 16px;
    position: relative;
    overflow: hidden;
    height: 100%;
}

/* Player/CPU Zones */
.zone {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.zone-label {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Card layout wrapper */
.cards-hand {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* Play Field (Center) */
.play-field {
    border: 2px dashed rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    background: rgba(0, 0, 0, 0.15);
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 20px;
    padding: 20px;
    align-items: center;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.guia-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 20px;
    height: 100%;
}

.guia-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

.baza-area {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    position: relative;
}

.played-cards-slots {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex: 1;
}

.played-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 160px;
    justify-content: center;
}

.played-slot-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

.slot-card-container {
    width: var(--card-width);
    height: var(--card-height);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action Controls Panel */
.controls-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 700px;
    z-index: 5;
    margin: 0 auto;
}

.status-bar {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--glass-border);
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
    backdrop-filter: blur(5px);
    text-align: center;
    min-width: 250px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 16px;
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    width: 100%;
}

button.btn-action {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button.btn-action:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

button.btn-action:active:not(:disabled) {
    transform: translateY(0);
}

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

button.btn-action.bid-envite {
    background: linear-gradient(135deg, #1d6e3c 0%, #15502c 100%);
    border-color: #2da15a;
}
button.btn-action.bid-envite:hover:not(:disabled) {
    background: linear-gradient(135deg, #238549 0%, #175e33 100%);
}

button.btn-action.bid-truque {
    background: linear-gradient(135deg, #a3843b 0%, #7e6328 100%);
    border-color: #c4a14c;
}
button.btn-action.bid-truque:hover:not(:disabled) {
    background: linear-gradient(135deg, #be9c47 0%, #8d702d 100%);
}

button.btn-action.bid-accept {
    background: linear-gradient(135deg, #2a5eb8 0%, #1d438a 100%);
    border-color: #3b76e1;
}
button.btn-action.bid-accept:hover:not(:disabled) {
    background: linear-gradient(135deg, #3770d6 0%, #204b9c 100%);
}

button.btn-action.bid-decline {
    background: linear-gradient(135deg, #b03838 0%, #852626 100%);
    border-color: #cc4545;
}
button.btn-action.bid-decline:hover:not(:disabled) {
    background: linear-gradient(135deg, #c74444 0%, #942b2b 100%);
}

/* Spanish Deck Card Styling */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px;
    border: 2px solid #ffffff;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-12px) rotate(1deg);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
}

.card:focus {
    outline: none;
    transform: translateY(-12px) rotate(1deg);
    border-color: var(--gold);
    box-shadow: var(--gold-glow);
}

.card.selected {
    transform: translateY(-20px);
    border-color: var(--gold);
    box-shadow: var(--gold-glow);
}

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

.card.disabled:hover {
    transform: none;
}

.card.guia-card {
    border-color: var(--gold);
    box-shadow: var(--gold-glow);
}

.card.guia-card::after {
    content: '★ GUÍA';
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 8px;
    font-weight: 800;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.8);
    padding: 1px 3px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

/* Card Content Details */
.card-pinta-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-dark);
    z-index: 2;
}

.card-corner.top {
    align-self: flex-start;
}

.card-corner.bottom {
    align-self: flex-end;
    transform: rotate(180deg);
}

.card-corner-suit {
    width: 14px;
    height: 14px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-corner-suit svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Global Tooltip for Cards */
.global-tooltip {
    position: fixed;
    background: rgba(15, 30, 15, 0.95);
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    border: 1px solid #d4af37;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    transform: translateX(-50%) translateY(10px);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
}

.global-tooltip.active {
    opacity: 1;
    transform: translateX(-50%) translateY(-100%);
}

/* Card Corner Text Colors by Suit */
.card-corner.suit-oro { color: #b78a07 !important; }
.card-corner.suit-copa { color: #c0392b !important; }
.card-corner.suit-espada { color: #2c3e50 !important; }
.card-corner.suit-basto { color: #1e6b37 !important; }

.card-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    z-index: 2;
    overflow: hidden;
}

/* Card center grid layout for Spanish deck pips */
.card-grid-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px;
    position: relative;
}

.grid-1 svg { width: 56px; height: 56px; }

.grid-2 {
    flex-direction: column;
    justify-content: space-around;
}
.grid-2 svg { width: 38px; height: 38px; }

.grid-3 {
    flex-direction: column;
    justify-content: space-around;
}
.grid-3 svg { width: 30px; height: 30px; }

.grid-4 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px 8px;
    padding: 4px;
    justify-items: center;
    align-items: center;
    width: 100%;
    height: 100%;
}
.grid-4 svg { width: 30px; height: 30px; }

.grid-5 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px 8px;
    padding: 4px;
    justify-items: center;
    align-items: center;
    position: relative;
    width: 100%;
    height: 100%;
}
.grid-5 svg { width: 26px; height: 26px; }

.grid-6 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px 6px;
    padding: 4px 6px;
    justify-items: center;
    align-items: center;
    width: 100%;
    height: 100%;
}
.grid-6 svg { width: 24px; height: 24px; }

.grid-7 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px 6px;
    padding: 4px 6px;
    justify-items: center;
    align-items: center;
    position: relative;
    width: 100%;
    height: 100%;
}
.grid-7 svg { width: 22px; height: 22px; }

.center-pip-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3;
}
.grid-5 .center-pip-wrapper svg { width: 26px; height: 26px; }
.grid-7 .center-pip-wrapper { top: 38%; }
.grid-7 .center-pip-wrapper svg { width: 22px; height: 22px; }

/* Figures for 10, 11, 12 */
.figure-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
}
.figure-svg {
    width: 100%;
    height: 100%;
    max-height: 85px;
}
.figure-suit-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border: 1.5px solid var(--gold);
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
}
.figure-suit-badge svg {
    width: 100%;
    height: 100%;
}

/* Card Back (Facedown) */
.card.back {
    background: linear-gradient(135deg, #1d438a 0%, #0d1e3f 100%);
    border: 3px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: default;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.card.back::before {
    content: '';
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 5px;
    right: 5px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-image: 
        radial-gradient(var(--gold) 15%, transparent 16%),
        radial-gradient(var(--gold) 15%, transparent 16%);
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px;
    opacity: 0.25;
    border-radius: 6px;
    z-index: 1;
}

.card.back::after {
    content: '';
    position: absolute;
    width: 48px;
    height: 48px;
    background-image: url('https://www.moratalla-murcia.com/moratalla/uploads/theme/logo2.jpg');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    border: 2px solid var(--gold);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), var(--gold-glow);
    background-color: #ffffff;
    z-index: 2;
}

.card.back:hover {
    transform: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.card.taped {
    background: linear-gradient(135deg, #444 0%, #222 100%);
    border: 3px solid #ffffff;
}
.card.taped > * {
    display: none !important;
}
.card.taped::before {
    content: 'TAPADA';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 10px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
}
.card.taped:hover {
    transform: none;
}

/* SVG Suits Colors */
.suit-oro { fill: #d4af37; stroke: #8d702d; stroke-width: 1; }
.suit-copa { fill: #c42727; stroke: #7c1616; stroke-dasharray: none; }
.suit-espada { fill: #4a7ebb; stroke: #2a4c75; }
.suit-basto { fill: #8a5a2b; stroke: #4f3318; }

/* Pass & Play privacy screen overlay */
.privacy-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 15, 6, 0.95);
    backdrop-filter: blur(15px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.privacy-screen.active {
    opacity: 1;
    pointer-events: auto;
}

.privacy-screen h2 {
    font-size: 1.8rem;
    color: var(--gold);
    font-weight: 800;
}

.privacy-screen p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
}

button.btn-reveal {
    background: linear-gradient(135deg, var(--gold) 0%, #8d702d 100%);
    border: 1px solid #ffe89e;
    color: #111;
    font-size: 1.1rem;
    font-weight: 800;
    padding: 12px 28px;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
    transition: all 0.2s ease;
}

button.btn-reveal:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
}

/* Modals (Rules, Game Over) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(135deg, #102413 0%, #050d06 100%);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--gold);
}

.close-btn {
    font-size: 1.8rem;
    color: rgba(255,255,255,0.4);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-light);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
}

.modal-body h3 {
    color: var(--gold);
    margin-top: 20px;
    margin-bottom: 8px;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body li {
    margin-bottom: 6px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(0,0,0,0.2);
}

/* Specific styling for game over */
.game-over-body {
    text-align: center;
    padding: 40px 24px;
}

.game-over-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.game-over-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--gold);
    margin-bottom: 10px;
}

.game-over-desc {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 30px;
}

/* General Layout Adjustments & Responsiveness */
@media (max-width: 900px) {
    :root {
        --card-width: 70px;
        --card-height: 105px;
    }
    
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(100vh - 61px);
        height: calc(100dvh - 61px);
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
        height: auto;
        padding: 8px;
        gap: 8px;
        justify-content: space-between;
        overflow-y: visible;
    }
    
    .sidebar .score-panel {
        flex: 1 1 180px;
        padding: 8px;
        margin-bottom: 0;
    }
    
    /* Ocultamos las pistas de puntos visuales en móvil para ahorrar espacio, pero mantenemos el log */
    .sidebar .china-track {
        display: none;
    }
    
    .sidebar .log-panel {
        flex: 1 1 100%;
        min-height: 150px;
        max-height: 200px;
        margin-top: 5px;
    }
    
    .board {
        padding: 8px;
        gap: 8px;
        grid-template-rows: auto 1fr auto auto;
        height: auto;
        overflow: visible;
    }
    
    .play-field {
        grid-template-columns: 100px 1fr;
        padding: 10px;
        gap: 10px;
    }
    
    .guia-area {
        padding-right: 10px;
    }
    
    .played-slot {
        min-height: 110px;
    }
    
    .controls-area {
        gap: 6px;
    }
    
    .status-bar {
        padding: 4px 16px;
        font-size: 0.85rem;
        min-width: 180px;
    }
    
    .action-buttons {
        padding: 6px;
        gap: 6px;
    }
    
    button.btn-action {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .card-corner {
        font-size: 0.9rem;
    }
    
    .card-center svg {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 600px) {
    :root {
        --card-width: 55px;
        --card-height: 82px;
    }
    
    .sidebar .score-panel {
        flex: 1 1 100%;
        font-size: 0.85rem;
    }
    
    .play-field {
        grid-template-columns: 75px 1fr;
        gap: 6px;
        padding: 6px;
    }
    
    .guia-area {
        padding-right: 6px;
    }
    
    .played-slot {
        min-height: 90px;
    }
    
    .card-corner {
        font-size: 0.8rem;
    }
    
    .card-center svg {
        width: 24px;
        height: 24px;
    }
    
    button.btn-action {
        padding: 6px 10px;
        font-size: 0.75rem;
        border-radius: 6px;
    }
}

/* Responsive Header Buttons & Custom Envido Selector */
.btn-text-short {
    display: none;
}
.btn-text {
    display: inline;
}

@media (max-width: 768px) {
    header {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 12px !important;
        gap: 6px !important;
    }
    header h1 {
        font-size: 1.1rem !important;
        margin: 0 !important;
    }
    .header-buttons {
        width: auto !important;
        gap: 4px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
    }
    .header-buttons a,
    .header-buttons button {
        font-size: 0.75rem !important;
        padding: 5px 8px !important;
        flex: 0 0 auto !important;
        min-width: auto !important;
        white-space: nowrap !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 600px) {
    header h1 {
        display: none !important;
    }
    header {
        justify-content: center !important;
        padding: 4px 6px !important;
    }
    .header-buttons {
        width: 100% !important;
        justify-content: space-between !important;
    }
    .header-buttons a,
    .header-buttons button {
        padding: 4px 5px !important;
        font-size: 0.7rem !important;
    }
    .btn-text {
        display: none !important;
    }
    .btn-text-short {
        display: inline !important;
    }
    .btn-home-link .btn-text {
        display: none !important;
    }
    .btn-home-link img {
        margin-right: 0 !important;
    }
}

/* Replay Modal Custom Styling */
.replay-modal-content {
    max-width: 900px !important;
    max-height: 90vh !important;
    display: flex;
    flex-direction: column;
    background: rgba(18, 30, 23, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6) !important;
    border-radius: 20px;
    padding: 20px !important;
}

.replay-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.replay-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 10px;
}

.hand-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
}

.hand-selector-container label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ccc;
}

.hand-selector-container select {
    background: transparent;
    border: none;
    color: #fff;
    font-weight: bold;
    outline: none;
    cursor: pointer;
}

.replay-modal-body {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Replay Board Styling */
.replay-board {
    background: rgba(0, 0, 0, 0.25);
    border: 1px dashed rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 400px;
}

.replay-player-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.replay-zone-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.replay-cards-hand {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.replay-center-zone {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 15px;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 15px 0;
    margin: 10px 0;
}

.replay-guia-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border-right: 1px solid rgba(255,255,255,0.08);
    padding-right: 15px;
}

.replay-table-slots {
    display: flex;
    justify-content: space-around;
}

.replay-played-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.replay-slot-title {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
}

.replay-card-slot {
    width: 60px;
    height: 90px;
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Replay Side Panel */
.replay-side-panel {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    height: 400px;
}

.replay-side-panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 8px;
}

.replay-logs {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 5px;
}

.replay-log-item {
    font-size: 0.8rem;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255,255,255,0.03);
    border-left: 3px solid #ccc;
    color: #ddd;
    transition: all 0.2s;
    cursor: pointer;
}

.replay-log-item.active {
    background: rgba(116, 185, 255, 0.15);
    border-left-color: #74b9ff;
    color: #fff;
    font-weight: 600;
}

.replay-score-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold);
    text-align: center;
}

/* Footer Controls */
.replay-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
    margin-top: 10px;
}

.replay-controls {
    display: flex;
    gap: 8px;
}

.btn-replay {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-replay:hover {
    background: rgba(255,255,255,0.18);
    transform: scale(1.05);
}

.btn-replay.btn-play {
    background: var(--gold);
    color: #121e17;
    border: none;
}

.btn-replay.btn-play:hover {
    background: #ffe875;
}

.replay-speed {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #aaa;
}

.replay-speed select {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    outline: none;
}

.btn-close-replay {
    background: #d63031;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-replay:hover {
    background: #ff7675;
}

.replay-board .card {
    width: 60px !important;
    height: 90px !important;
    border-radius: 6px !important;
    font-size: 0.65rem !important;
    padding: 4px !important;
}

.replay-board .card-center svg {
    width: 24px !important;
    height: 24px !important;
}

.replay-board .card.taped {
    background: repeating-linear-gradient(45deg, #2d3436, #2d3436 10px, #222f3e 10px, #222f3e 20px) !important;
}

.replay-board .card.taped > * {
    display: none !important;
}

/* Responsive Replay Modal */
@media (max-width: 768px) {
    .replay-modal-content {
        max-height: 95vh !important;
        padding: 12px !important;
    }
    .replay-modal-body {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .replay-board {
        min-height: 260px;
    }
    .replay-side-panel {
        height: 180px;
    }
    .replay-modal-footer {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding-top: 10px;
        margin-top: 10px;
    }
}

/* =============================================
   ENVIDAR SELECTOR – Premium redesign
   ============================================= */

.envido-selector-container {
    background: linear-gradient(145deg, rgba(10, 40, 20, 0.97), rgba(5, 25, 12, 0.99));
    border: 1px solid #2da15a;
    border-radius: 18px;
    padding: 14px 16px 12px;
    box-shadow: 0 0 30px rgba(45, 161, 90, 0.35), 0 8px 32px rgba(0,0,0,0.6);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: envido-appear 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes envido-appear {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.envido-selector-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.envido-icon {
    font-size: 1.2rem;
    color: #ffe875;
    animation: spin-coin 2s linear infinite;
}

@keyframes spin-coin {
    0%   { transform: rotateY(0deg); }
    50%  { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
}

.envido-selector-title {
    font-size: 1rem;
    font-weight: 800;
    color: #ffe875;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex: 1;
}

.envido-max-badge {
    background: rgba(255,232,117,0.15);
    border: 1px solid rgba(255,232,117,0.35);
    color: #ffe875;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
}

/* Quick-pick chips */
.envido-chip-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.envido-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #1d6e3c, #0f3d20);
    border: 1px solid #2da15a;
    color: #fff;
    border-radius: 12px;
    padding: 6px 10px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.18s;
    min-width: 52px;
    line-height: 1.1;
}

.envido-chip span {
    font-size: 0.55rem;
    font-weight: 500;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 2px;
}

.envido-chip:hover,
.envido-chip.active {
    background: linear-gradient(145deg, #29a356, #17542f);
    border-color: #5fdc93;
    transform: translateY(-2px);
    box-shadow: 0 0 14px rgba(95, 220, 147, 0.5);
}

/* Custom stepper */
.envido-custom-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.envido-stepper {
    background: rgba(45,161,90,0.2);
    border: 1px solid #2da15a;
    color: #5fdc93;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.envido-stepper:hover {
    background: rgba(45,161,90,0.4);
    box-shadow: 0 0 10px rgba(45,161,90,0.5);
    transform: scale(1.1);
}

.envido-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.envido-big-num {
    font-size: 2.2rem;
    font-weight: 900;
    color: #ffe875;
    line-height: 1;
    text-shadow: 0 0 20px rgba(255,232,117,0.6);
}

.envido-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Confirm / Cancel */
.envido-confirm-row {
    display: flex;
    gap: 8px;
}

.btn-envidar {
    flex: 1;
    background: linear-gradient(135deg, #29a356, #17542f);
    border: 1px solid #5fdc93;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-transform: uppercase;
    box-shadow: 0 4px 16px rgba(41,163,86,0.35);
}

.btn-envidar:hover {
    background: linear-gradient(135deg, #34c96a, #1d6e3c);
    box-shadow: 0 6px 24px rgba(41,163,86,0.6);
    transform: translateY(-2px);
}

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

.btn-envido-cancel {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-envido-cancel:hover {
    background: rgba(255,100,100,0.15);
    border-color: rgba(255,100,100,0.35);
    color: #ff7675;
}

/* Cantar button */
button.btn-cantar {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.5), rgba(72, 52, 212, 0.4)) !important;
    border: 1px solid rgba(162, 155, 254, 0.5) !important;
    color: #a29bfe !important;
}

button.btn-cantar:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.7), rgba(72, 52, 212, 0.6)) !important;
    border-color: #a29bfe !important;
    color: #fff !important;
}

/* Responsive tweaks for the envido selector */
@media (max-width: 480px) {
    .envido-chip {
        min-width: 44px;
        font-size: 0.9rem;
        padding: 5px 7px;
    }
    .envido-big-num {
        font-size: 1.8rem;
    }
    .envido-confirm-row {
        flex-direction: column;
    }
}

/* ==========================================
   VOICE PANEL STYLES
   ========================================== */

/* Toggle button (on/off) */
.voice-toggle-btn {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.voice-toggle-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    transform: scale(1.1);
}

.voice-toggle-btn.voice-off {
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.4);
    color: #ff3b30;
}

/* Gender selector pill buttons */
.voice-gender-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.voice-gender-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.voice-gender-btn.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.3), rgba(212, 175, 55, 0.15));
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

/* Special style when "Ninguna" (none/mute) is active */
.voice-gender-btn[data-gender="none"].active {
    background: linear-gradient(135deg, rgba(255, 59, 48, 0.2), rgba(255, 59, 48, 0.08));
    border-color: rgba(255, 59, 48, 0.5);
    color: #ff6b6b;
    box-shadow: 0 0 10px rgba(255, 59, 48, 0.15);
}

/* Volume range slider */
.voice-volume-slider {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

.voice-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
    transition: transform 0.15s;
}

.voice-volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.voice-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.5);
}

/* Test/Probar voice button */
.voice-test-btn {
    width: 100%;
    padding: 8px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.08));
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: var(--gold);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.voice-test-btn:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.35), rgba(212, 175, 55, 0.18));
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
    transform: translateY(-1px);
}

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

/* Cantar button with flash animation */
button.btn-cantar {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.08));
    border-color: rgba(212, 175, 55, 0.4);
    color: var(--gold);
    transition: all 0.2s ease;
}

button.btn-cantar:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.35), rgba(212, 175, 55, 0.18));
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
    color: #ffe875;
}

@keyframes voice-flash-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.8); background: rgba(212,175,55,0.5); }
    50%  { box-shadow: 0 0 0 8px rgba(212, 175, 55, 0); }
    100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.08)); }
}

button.btn-cantar.voice-flash {
    animation: voice-flash-pulse 0.6s ease-out forwards;
}

/* Doble clic - Selección de carta */
.card.selected-for-play {
    transform: translateY(-20px) scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 175, 55, 0.6);
    border-color: #d4af37;
    z-index: 20;
}
