:root {
    --ink: #070910;
    --navy: #0d1422;
    --panel: rgba(12, 18, 32, 0.62);
    --panel-strong: rgba(8, 12, 22, 0.82);
    --line: rgba(212, 176, 106, 0.28);
    --line-strong: rgba(212, 176, 106, 0.55);
    --gold: #d4b06a;
    --gold-bright: #f3ddae;
    --cream: #f6f1e8;
    --muted: #9aa4b8;
    --teal: #7ecdc8;
    --danger: #e07a7a;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --font-display: "Cinzel", serif;
    --font-body: "Outfit", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--ink);
    color: var(--cream);
    margin: 0;
    overflow: hidden;
    letter-spacing: 0.01em;
}

#splash-screen,
#game-container,
#game-board,
.hand,
#message-area {
    overflow: hidden;
}

.atmosphere {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 60% at 15% 10%, rgba(212, 176, 106, 0.12), transparent 55%),
        radial-gradient(ellipse 70% 50% at 90% 85%, rgba(110, 170, 200, 0.08), transparent 50%),
        radial-gradient(circle at 50% 50%, #121a2c 0%, var(--ink) 72%);
}

.atmosphere::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image: url("img/logo.png");
    background-repeat: no-repeat;
    background-position: 110% 120%;
    background-size: min(55vw, 640px);
    filter: grayscale(0.2) brightness(0.35);
    mask-image: radial-gradient(circle at 80% 90%, black 0%, transparent 68%);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--gold);
}

/* --- SPLASH --- */
#splash-screen {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(20px, 3vw, 40px);
    width: 100vw;
    height: 100vh;
    padding: clamp(16px, 3vh, 32px) clamp(16px, 4vw, 56px);
    overflow: hidden;
}

#splash-left,
#splash-right {
    width: min(46%, 560px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#splash-left { text-align: center; }

#splash-logo {
    width: min(150px, 28vw);
    margin: 4px auto 10px;
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.45));
}

#splash-left h1 {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 3.6vw, 2.8rem);
    font-weight: 500;
    color: var(--gold-bright);
    margin: 0;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#splash-left h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: var(--cream);
    margin: 10px 0 0;
    opacity: 0.9;
}

#splash-left .subtitle {
    font-size: 0.92rem;
    font-weight: 300;
    margin: 8px 0 22px;
    color: var(--muted);
    font-style: italic;
}

.splash-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

#splash-left input {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 14px 18px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.03);
    color: var(--cream);
    text-align: center;
    width: min(280px, 80%);
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

#splash-left input::placeholder { color: var(--muted); }
#splash-left input:focus {
    border-color: var(--gold);
    background: rgba(212, 176, 106, 0.06);
}

#start-game-button,
#check-quinta-button,
#continue-game-button,
#restart-game-button {
    font-family: var(--font-display);
    font-size: 0.92rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 16px 28px;
    border-radius: 999px;
    border: 1px solid var(--gold);
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    color: #1a1408;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

#start-game-button:hover,
#check-quinta-button:hover:not(:disabled),
#continue-game-button:hover,
#restart-game-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.instructions {
    background: var(--panel);
    padding: 22px 24px 20px;
    border-radius: 24px;
    border: 1px solid var(--line);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.instructions-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.zaldor-portrait {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
}

.instructions h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--gold-bright);
    margin: 0;
}

.instructions h4 {
    font-family: var(--font-display);
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 22px 0 8px;
}

.instructions p {
    font-size: 0.86rem;
    line-height: 1.45;
    color: var(--muted);
    font-weight: 300;
    margin: 0 0 12px;
}

.instructions p strong { color: var(--cream); font-weight: 500; }

.rules-link-splash {
    display: inline-flex;
    margin-top: 12px;
    color: var(--gold-bright);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 4px;
}

.rules-link-splash:hover { color: var(--cream); }

/* --- AYUDA MEMORIA COBOE --- */
.coboe-guide {
    color: var(--cream);
}

.coboe-kicker {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 6px;
}

.coboe-cycle ol,
.coboe-cycle-inline {
    list-style: none;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 0;
    margin: 0 0 12px;
}

.suit-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
}

.suit-mark {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.suit-chip.copas { color: #e08b8b; }
.suit-chip.copas .suit-mark { background: #c45c5c; }
.suit-chip.bastos { color: #8fbf93; }
.suit-chip.bastos .suit-mark { background: #5a9a62; }
.suit-chip.oros { color: var(--gold-bright); }
.suit-chip.oros .suit-mark { background: var(--gold); }
.suit-chip.espadas { color: #9eb3c9; }
.suit-chip.espadas .suit-mark { background: #7a93b0; }

.suit-chip:not(:last-child)::after {
    content: "→";
    margin-left: 7px;
    color: var(--gold);
    opacity: 0.55;
    font-size: 0.7em;
}

.coboe-seq { margin-bottom: 8px; }

.mini-seq {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mini-seq img {
    height: 54px;
    width: auto;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.coboe-guide--board {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 6px;
    opacity: 0.88;
    flex-wrap: wrap;
}

.coboe-cycle-inline { margin: 0; flex-shrink: 0; }
.coboe-cycle-inline .suit-chip {
    padding: 3px 7px;
    font-size: 0.64rem;
}

.coboe-mini-rows {
    display: flex;
    gap: 10px;
    min-width: 0;
}

.coboe-guide--board .coboe-seq {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.coboe-guide--board .coboe-seq span {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
}

.coboe-guide--board .mini-seq img { height: 32px; }

.zone-head { flex-shrink: 0; }

/* --- MODAL --- */
#example-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 12, 0.78);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

#example-modal {
    background: var(--navy);
    padding: 36px 32px 28px;
    border-radius: 24px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 680px;
    width: 100%;
    position: relative;
}

#example-modal .close-button {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 2rem;
    color: var(--gold);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}

#example-modal-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--gold-bright);
    margin: 0 0 22px;
    font-weight: 500;
}

#example-modal-cards {
    justify-content: center;
    align-content: center;
    flex-wrap: wrap;
    min-height: 150px;
    max-height: 70vh;
    background: transparent;
    border: none;
    padding: 0;
    container-type: normal;
}

#example-modal-cards .card {
    height: 120px;
    width: auto;
    margin: 4px;
}

.example-modal-score {
    width: 100%;
    text-align: center;
    font-size: 1rem;
    color: var(--gold);
    margin-top: 18px;
    letter-spacing: 0.04em;
}

/* --- JUEGO --- */
#game-container {
    display: none;
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
}

#game-board {
    display: flex;
    gap: 12px;
    width: 100%;
    height: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.game-column {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#player-column { width: 54%; }
#table-column { width: 18%; justify-content: space-between; gap: 12px; }
#info-column { width: 28%; }

.board-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.board-mark {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.score-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: stretch;
    width: 100%;
}

.score-area {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px 10px 8px;
    border-radius: 14px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.score-area.opponent { text-align: right; }

.score-kicker {
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.score-name {
    font-family: var(--font-display);
    font-size: 0.82rem;
    color: var(--cream);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--gold-bright);
    line-height: 1.1;
}

.score-goal {
    align-self: center;
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    color: var(--gold);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 8px;
}

.zone {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.zone-quinta { margin-top: 8px; }

h2 {
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 6px;
}

.hand {
    --card-gap: 6px;
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 14px;
    border: 1px solid var(--line);
    overflow: hidden;
    padding: 8px 10px;
    gap: var(--card-gap);
    container-type: size;
}

#player-hand .card {
    flex: 0 0 auto;
    margin: 0;
    width: auto;
    height: min(100cqb, calc((100cqi - 7 * var(--card-gap)) / 8 / 0.652));
    aspect-ratio: 167 / 256;
    object-fit: contain;
}

#quinta-area .card {
    flex: 0 0 auto;
    margin: 0;
    width: auto;
    height: min(100cqb, calc((100cqi - 6 * var(--card-gap)) / 7 / 0.652));
    aspect-ratio: 167 / 256;
    object-fit: contain;
}

#quinta-area {
    border-color: var(--line-strong);
    background: rgba(212, 176, 106, 0.05);
}

.opponent-quinta-title { color: var(--danger); }

.pile-well {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
    flex: 1;
    min-height: 0;
}

#deck, #discard-pile { width: 100%; display: flex; justify-content: center; }
#discard-pile { min-height: 0; flex: 1; background: transparent; border: none; padding: 0; align-items: center; }
#discard-pile .card { pointer-events: none; }

#discard-pile-area.pozo-bloqueado {
    border-color: var(--danger);
    box-shadow: inset 0 0 0 1px rgba(224, 122, 122, 0.35);
}

#deck .card,
#discard-pile .card {
    height: min(168px, 26vh);
    width: auto;
    margin: 0;
}

.table-controls { width: 100%; }

#check-quinta-button,
#continue-game-button,
#restart-game-button {
    width: 100%;
    padding: 11px 10px;
    margin: 0;
    font-size: 0.78rem;
}

#continue-game-button,
#restart-game-button { display: none; }

button:disabled {
    background: transparent;
    color: var(--muted);
    border-color: rgba(154, 164, 184, 0.35);
    cursor: not-allowed;
    filter: none;
    transform: none;
}

.title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

#rules-link {
    display: grid;
    place-items: center;
    color: var(--gold);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    text-decoration: none;
    font-size: 0.8rem;
    font-family: var(--font-display);
}

#rules-link:hover {
    background: var(--gold);
    color: #1a1408;
}

#message-area {
    width: 100%;
    flex: 1;
    min-height: 0;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    overflow: hidden;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--cream);
}

#message-area p { margin: 0 0 12px; }
#message-area p:last-child { margin-bottom: 0; }

.zaldor-message {
    color: var(--teal);
    font-style: italic;
    font-weight: 300;
}

.system-message { color: var(--gold-bright); }

.card {
    height: 86px;
    width: auto;
    margin: 3px;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.42);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#player-hand .card:hover,
#quinta-area .card:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 14px 22px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

#scoring-rules {
    margin-top: 8px;
    padding: 8px 12px 6px;
    background: var(--panel-strong);
    border-radius: 14px;
    border: 1px solid var(--line);
    width: 100%;
    flex-shrink: 0;
}

#scoring-rules p {
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-align: left;
    color: var(--gold);
    margin: 0 0 10px;
}

#scoring-rules ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#scoring-rules li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-top: 1px solid rgba(212, 176, 106, 0.12);
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--cream);
}

#scoring-rules li:first-child { border-top: none; }
#scoring-rules li span:last-child { color: var(--gold); font-size: 0.8rem; }
#scoring-rules li:hover { color: var(--gold-bright); }

@media (max-width: 980px) {
    #splash-screen {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    #splash-left,
    #splash-right { width: min(100%, 560px); }

    #splash-logo { width: 88px; }
    #splash-left h1 { font-size: 1.5rem; }
    .mini-seq img { height: 40px; }
    .coboe-guide--board { display: none; }

    #game-board {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .game-column { width: 100%; height: auto; min-height: 0; }

    #player-column { order: 3; flex: 1; }
    #table-column { order: 2; flex-direction: row; flex-wrap: nowrap; height: auto; flex: none; align-items: stretch; }
    #info-column { order: 1; flex: none; max-height: 26vh; }

    #deck-area, #discard-pile-area { flex: 1; }
    .table-controls { flex: 0 0 140px; align-self: center; }

    .card { height: 70px; }
    #player-hand .card,
    #quinta-area .card { height: min(100cqb, 92px); }
    #deck .card, #discard-pile .card { height: 88px; }
    #scoring-rules { display: none; }
}
