/* ============================================
   ICATHI 4.0 — Juego de Cartas: Relaciona
   Colores: #3d5a96 | #e8755c | #d05a7e | #691b31
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    --blue:      #3d5a96;
    --blue-dk:   #2e4575;
    --blue-lt:   #5a7ab8;
    --coral:     #e8755c;
    --pink:      #d05a7e;
    --vino:      #691b31;
    --white:     #ffffff;
    --gray:      #f4f6fa;
    --text:      #2d3a50;
    --text-lt:   #6b7a92;
    --success:   #28a745;
    --error:     #dc3545;
    --warning:   #ffc107;
    --header-h:  52px;
    --radius:    12px;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Nunito', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #3d5a96 0%, #e8755c 50%, #d05a7e 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
}

/* ── HEADER ─────────────────────────────────── */
.quiz-header {
    height: var(--header-h);
    min-height: var(--header-h);
    flex-shrink: 0;
    background-color: #3d5a96;
    background-image:
        linear-gradient(90deg, #e8755c  0px,    #e8755c  60px,   transparent  60px),
        linear-gradient(90deg, #d05a7e  90px,   #d05a7e  150px,  transparent  150px),
        linear-gradient(90deg, #3d5a96  170px,  #3d5a96  260px,  transparent  260px),
        linear-gradient(90deg, #e8755c  290px,  #e8755c  330px,  transparent  330px),
        linear-gradient(90deg, #ffffff  350px,  #ffffff  370px,  transparent  370px),
        linear-gradient(90deg, #d05a7e  400px,  #d05a7e  480px,  transparent  480px),
        linear-gradient(90deg, #3d5a96  510px,  #3d5a96  600px,  transparent  600px),
        linear-gradient(90deg, #e8755c  630px,  #e8755c  680px,  transparent  680px),
        linear-gradient(90deg, #d05a7e  710px,  #d05a7e  760px,  transparent  760px),
        linear-gradient(90deg, #3d5a96  790px,  #3d5a96  870px,  transparent  870px),
        linear-gradient(90deg, #e8755c  900px,  #e8755c  940px,  transparent  940px),
        linear-gradient(90deg, #ffffff  970px,  #ffffff  990px,  transparent  990px);
    background-size: 100% 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.30);
    position: relative;
    overflow: hidden;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--coral), var(--pink));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(208,90,126,0.4);
}

.header-title strong {
    font-size: 14px;
    font-weight: 800;
    color: var(--white);
    display: block;
    line-height: 1.1;
}

.header-title span {
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    font-weight: 500;
}

.header-right {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
}

.score-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #000000;
}

.score-pill .star {
    color: var(--warning);
    font-size: 14px;
}

/* ── PROGRESS BAR ─────────────────────────── */
.progress-section {
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
    backdrop-filter: blur(6px);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    min-width: 40px;
}

.progress-track {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.20);
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--coral), var(--pink));
    transition: width 0.4s ease;
}

.progress-pct {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.90);
    min-width: 32px;
    text-align: right;
}

/* ── MAIN CONTENT ─────────────────────────── */
.quiz-main {
    flex: 1;
    overflow: hidden;
    padding: 6px 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── WELCOME CARD ─────────────────────────── */
.welcome-card {
    max-width: 520px;
    width: 100%;
    background: rgba(255,255,255,0.95);
    border-radius: var(--radius);
    padding: 24px 24px 20px;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0,0,0,0.16);
    border: 1px solid rgba(255,255,255,0.50);
    backdrop-filter: blur(6px);
    animation: fadeUp 0.35s ease;
    margin: auto;
}

.welcome-icon {
    font-size: 40px;
    margin-bottom: 4px;
    display: block;
}

.welcome-card h1 {
    color: var(--blue);
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.welcome-card .subtitle {
    color: var(--vino);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.welcome-card p {
    color: var(--text-lt);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 6px;
}

.welcome-card .rules {
    text-align: left;
    background: var(--gray);
    border-radius: 10px;
    padding: 12px 16px;
    margin: 10px 0 14px;
}

.welcome-card .rules li {
    list-style: none;
    padding: 4px 0;
    font-size: 12.5px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.welcome-card .rules li::before {
    content: '';
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--coral);
}

/* ── BUTTONS ─────────────────────────────────── */
.btn-primary {
    display: inline-block;
    padding: 10px 28px;
    border: none;
    border-radius: 24px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
    background: linear-gradient(135deg, var(--pink), var(--coral));
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: 0 3px 12px rgba(208,90,126,0.35);
}

.btn-primary:hover {
    transform: scale(1.04);
    box-shadow: 0 5px 18px rgba(208,90,126,0.50);
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-secondary {
    display: inline-block;
    padding: 8px 22px;
    border: 2px solid var(--blue);
    border-radius: 24px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--blue);
    background: transparent;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover {
    background: var(--blue);
    color: var(--white);
}

/* ── BOARD HEADER ──────────────────────────── */
.board-header {
    width: 100%;
    max-width: none;
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
    margin-bottom: 5px;
    flex-shrink: 0;
}

.board-col-title {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.92);
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(0,0,0,0.15);
    backdrop-filter: blur(4px);
}

/* ── BOARD ──────────────────────────────────── */
.board {
    width: 100%;
    max-width: none;
    display: flex;
    gap: 5px;
    flex: 1;
    align-items: stretch;
    min-height: 0;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

.column-spacer {
    width: 20px;
    flex-shrink: 0;
    position: relative;
}

.column-spacer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 8%;
    bottom: 8%;
    width: 2px;
    background: rgba(255,255,255,0.20);
    transform: translateX(-50%);
    border-radius: 2px;
}

/* ── CARDS ──────────────────────────────────── */
.card {
    background: rgba(255,255,255,0.95);
    border: 1.5px solid #dde0e8;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 10.5px;
    line-height: 1.3;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex: 1;
}

.card-left {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.card-left:active {
    cursor: grabbing;
}

.card-left:hover:not(.card-matched) {
    border-color: var(--blue);
    box-shadow: 0 2px 10px rgba(61,90,150,0.12);
}

.card-right {
    cursor: default;
    border-left: 3px solid var(--pink);
}

.card-right:hover:not(.card-matched) {
    border-color: var(--pink);
    box-shadow: 0 2px 10px rgba(208,90,126,0.10);
}

.card-number {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--blue-lt));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 1px;
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-drag-hint {
    color: var(--text-lt);
    font-size: 12px;
    letter-spacing: 1px;
    opacity: 0.35;
    flex-shrink: 0;
    align-self: center;
}

.card-check {
    color: var(--success);
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
    align-self: center;
}

/* ── Card states ────────────────────────────── */
.card-matched {
    background: rgba(40,167,69,0.08);
    border-color: var(--success);
    cursor: default;
    opacity: 0.75;
}

.card-matched .card-number {
    background: var(--success);
}

.card-matched .card-drag-hint {
    display: none;
}

.card-matched:hover {
    border-color: var(--success) !important;
    box-shadow: none !important;
}

.card-left.selected {
    border-color: var(--blue);
    background: rgba(61,90,150,0.06);
    box-shadow: 0 0 0 2px rgba(61,90,150,0.2);
}

.card-wrong {
    border-color: var(--error) !important;
    background: rgba(220,53,69,0.06) !important;
}

.card-right.drag-over {
    border-color: var(--blue);
    background: rgba(61,90,150,0.08);
    box-shadow: 0 0 0 2px rgba(61,90,150,0.18);
}

/* ── Animations ─────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.card.shake {
    animation: shake 0.35s ease;
}

@keyframes correctFlash {
    0% { box-shadow: 0 0 0 0 rgba(40,167,69,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(40,167,69,0.12); }
    100% { box-shadow: 0 0 0 0 rgba(40,167,69,0); }
}

.card-correct-flash {
    animation: correctFlash 0.5s ease;
}

/* ── Board Status ───────────────────────────── */
.board-status {
    width: 100%;
    min-height: 22px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.25s;
    flex-shrink: 0;
}

.board-status.visible {
    opacity: 1;
}

.status-correct { color: var(--success); }
.status-wrong   { color: var(--error); }

/* ── RESULTS CARD ─────────────────────────── */
.results-card {
    max-width: 480px;
    width: 100%;
    background: rgba(255,255,255,0.97);
    border-radius: var(--radius);
    padding: 24px 24px 20px;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0,0,0,0.16);
    border: 1px solid rgba(255,255,255,0.50);
    animation: fadeUp 0.35s ease;
    margin: auto;
}

.results-card .big-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 4px;
}

.results-card h2 {
    color: var(--blue);
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
}

.results-card .results-sub {
    color: var(--vino);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 10px 0 12px;
}

.score-item { text-align: center; }

.score-item .num {
    font-size: 28px;
    font-weight: 800;
    display: block;
}

.score-item .num.green { color: var(--success); }
.score-item .num.red   { color: var(--error); }
.score-item .num.blue  { color: var(--blue); }

.score-item .label {
    font-size: 11px;
    color: var(--text-lt);
    font-weight: 600;
}

.stars-row {
    font-size: 24px;
    margin: 6px 0 12px;
    letter-spacing: 3px;
}

.stars-row .star-filled { color: var(--warning); }
.stars-row .star-empty  { color: #ddd; }

.results-message {
    background: var(--gray);
    border-radius: 10px;
    padding: 12px 16px;
    margin: 10px 0 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
}

.results-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
    :root { --header-h: 46px; }
    .quiz-header { padding: 0 12px; }
    .bot-avatar { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
    .header-title strong { font-size: 13px; }
    .header-title span  { font-size: 10px; }
    .score-pill { font-size: 11px; padding: 3px 8px; }
    .score-pill .star { font-size: 12px; }
    .progress-section { padding: 4px 12px; }
    .quiz-main { padding: 4px 6px 2px; }

    .board { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
    .column-spacer { display: none; }

    .card { font-size: 9.5px; padding: 5px 6px; border-radius: 6px; gap: 4px; }
    .card-number { width: 16px; height: 16px; min-width: 16px; font-size: 8px; }
    .card-drag-hint { font-size: 10px; }
    .card-check { font-size: 12px; }

    .board-header { margin-bottom: 3px; }
    .board-col-title { font-size: 10px; padding: 3px 8px; }
    .board-status { font-size: 11px; min-height: 18px; }

    .welcome-card, .results-card { padding: 18px 16px 16px; }
    .welcome-card h1 { font-size: 17px; }
    .welcome-icon { font-size: 32px; }
    .results-card .big-icon { font-size: 36px; }
    .results-card h2 { font-size: 18px; }
    .score-item .num { font-size: 22px; }
    .stars-row { font-size: 20px; }
}

@media (max-width: 480px) {
    .board { gap: 3px; }
    .card { font-size: 8.5px; padding: 4px 5px; border-width: 1px; }
    .card-number { width: 14px; height: 14px; min-width: 14px; font-size: 7px; }
    .column { gap: 3px; }
    .board-col-title { font-size: 9px; padding: 2px 6px; }
    .progress-section { padding: 3px 8px; gap: 4px; }
    .progress-label { font-size: 10px; min-width: 30px; }
    .progress-pct { font-size: 10px; min-width: 24px; }
    .btn-primary { padding: 8px 20px; font-size: 12px; }
    .btn-secondary { padding: 6px 16px; font-size: 11px; }
}
