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

:root {
    --bg: #f5fff8;
    --bg-2: #ebf9ef;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-solid: #ffffff;
    --green-950: #063d1d;
    --green-900: #0a4f27;
    --green-800: #0d6b32;
    --green-700: #13833d;
    --green-600: #1aa34a;
    --green-500: #29b95a;
    --green-400: #53cf78;
    --green-300: #8be3a5;
    --green-200: #bdeecb;
    --green-100: #dcf8e4;
    --green-50: #f0fcf3;
    --lime: #8be84d;
    --amber: #ffbd3d;
    --danger: #e34858;
    --text: #143422;
    --muted: #64806d;
    --muted-2: #9ab0a1;
    --line: rgba(19, 131, 61, 0.14);
    --line-strong: rgba(19, 131, 61, 0.32);
    --shadow: 0 24px 70px rgba(13, 107, 50, 0.10);
    --radius: 24px;
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Space Grotesk', 'Segoe UI', Tahoma, sans-serif;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
    overscroll-behavior-x: none;
}

button,
select {
    font: inherit;
}

button,
.celda,
select {
    -webkit-tap-highlight-color: transparent;
}

#particles-bg {
    position: fixed;
    inset: 0;
    z-index: -5;
    overflow: hidden;
    background:
        radial-gradient(circle at 12% 16%, rgba(83, 207, 120, 0.22), transparent 25%),
        radial-gradient(circle at 88% 11%, rgba(139, 232, 77, 0.18), transparent 24%),
        radial-gradient(circle at 70% 88%, rgba(41, 185, 90, 0.13), transparent 28%),
        linear-gradient(145deg, #ffffff 0%, #f2fff6 48%, #e9f8ed 100%);
}

#particles-bg::before,
#particles-bg::after {
    content: '';
    position: absolute;
    inset: -10%;
    background-image:
        radial-gradient(circle, rgba(19, 131, 61, 0.24) 0 1px, transparent 1.5px),
        radial-gradient(circle, rgba(83, 207, 120, 0.20) 0 1px, transparent 1.7px);
    background-size: 78px 78px, 118px 118px;
    background-position: 0 0, 31px 35px;
    opacity: 0.35;
    animation: particleDrift 26s linear infinite;
}

#particles-bg::after {
    opacity: 0.18;
    transform: scale(1.12);
    animation-duration: 38s;
}

.ambient-grid {
    position: fixed;
    inset: 0;
    z-index: -4;
    pointer-events: none;
    opacity: 0.35;
    background-image:
        linear-gradient(rgba(19, 131, 61, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(19, 131, 61, 0.07) 1px, transparent 1px);
    background-size: 54px 54px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 15%, #000 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, #000 15%, #000 85%, transparent 100%);
}

.orb {
    position: fixed;
    z-index: -3;
    border-radius: 50%;
    filter: blur(75px);
    pointer-events: none;
}

.orb-a {
    width: 360px;
    height: 360px;
    left: -130px;
    top: 38%;
    background: rgba(83, 207, 120, 0.15);
}

.orb-b {
    width: 420px;
    height: 420px;
    right: -160px;
    top: 24%;
    background: rgba(139, 232, 77, 0.11);
}

@keyframes particleDrift {
    to { transform: translate3d(78px, 78px, 0); }
}

@keyframes pulse {
    50% { opacity: 0.38; transform: scale(0.72); }
}

@keyframes scan {
    0%, 100% { transform: translateY(-150%); opacity: 0; }
    12%, 82% { opacity: 0.65; }
    50% { transform: translateY(1350%); }
}

@keyframes floatIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes vibrar {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slotAparecer {
    0% { opacity: 0; transform: scale(0.65) translateY(7px); }
    70% { transform: scale(1.04) translateY(-2px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes successPulse {
    50% { box-shadow: 0 0 0 8px rgba(41, 185, 90, 0.06), 0 12px 30px rgba(13, 107, 50, 0.12); }
}

.container {
    position: relative;
    z-index: 1;
    width: min(1460px, calc(100% - 48px));
    margin: 0 auto;
    padding: 30px 0 42px;
}

.hero-header {
    text-align: center;
    padding: 14px 20px 32px;
}

.system-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 18px;
    padding: 8px 14px;
    border: 1px solid rgba(19, 131, 61, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    box-shadow: 0 8px 28px rgba(13, 107, 50, 0.06), inset 0 1px 0 #fff;
    color: var(--green-700);
    font: 700 10px/1 'Orbitron', sans-serif;
    letter-spacing: 1.6px;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green-500);
    box-shadow: 0 0 0 4px rgba(41, 185, 90, 0.10), 0 0 14px rgba(41, 185, 90, 0.42);
    animation: pulse 1.6s ease-in-out infinite;
}

.eyebrow {
    margin-bottom: 10px;
    color: var(--muted);
    font: 700 10px/1.2 'Orbitron', sans-serif;
    letter-spacing: 4px;
}

.hero-header h1 {
    color: #82a08c;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.35rem, 3vw, 2.7rem);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.hero-header h1.highlight {
    margin-top: 4px;
    font-size: clamp(2.15rem, 5.7vw, 5rem);
    font-weight: 800;
    letter-spacing: 0.07em;
    background: linear-gradient(90deg, var(--green-900), var(--green-600) 48%, #62c742 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 8px 16px rgba(13, 107, 50, 0.10));
}

.subtitle {
    max-width: 820px;
    margin: 17px auto 0;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.6;
    letter-spacing: 1.7px;
    text-transform: uppercase;
}

.hero-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 540px;
    margin: 21px auto 0;
    color: var(--green-700);
    font: 700 9px 'Orbitron', sans-serif;
}

.hero-line span {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(19, 131, 61, 0.35));
}

.hero-line span:last-child {
    transform: scaleX(-1);
}

.hero-line i {
    font-style: normal;
}

.game-container {
    display: grid;
    grid-template-columns: minmax(500px, 0.94fr) minmax(0, 1.06fr);
    gap: 22px;
    align-items: stretch;
}

.panel-shell {
    position: relative;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.94), rgba(248, 255, 250, 0.86));
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: hidden;
}

.panel-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(120deg, rgba(83, 207, 120, 0.08), transparent 18%, transparent 72%, rgba(139, 232, 77, 0.07));
}

.panel-shell::after {
    content: '';
    position: absolute;
    top: 0;
    left: 22px;
    right: 22px;
    height: 2px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--green-500), transparent);
    opacity: 0.52;
}

.sopa-wrapper,
.relacionar-wrapper {
    height: clamp(570px, 64vh, 640px);
    min-height: 570px;
}

.sopa-wrapper {
    display: flex;
    flex-direction: column;
    padding: 18px;
}

.relacionar-wrapper {
    display: flex;
    flex-direction: column;
}

.panel-topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.sopa-wrapper .panel-topbar {
    padding: 2px 4px 15px;
}

.relacionar-header {
    flex-shrink: 0;
    padding: 20px 22px 17px;
    border-bottom: 1px solid rgba(19, 131, 61, 0.10);
}

.panel-kicker {
    display: block;
    margin-bottom: 6px;
    color: var(--muted-2);
    font: 700 9px 'Orbitron', sans-serif;
    letter-spacing: 2.4px;
}

.panel-topbar h2,
.panel-topbar h3,
.baul-header h3 {
    color: var(--green-950);
    font: 800 0.82rem 'Orbitron', sans-serif;
    letter-spacing: 2.1px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--green-700);
    font: 700 9px 'Orbitron', sans-serif;
    letter-spacing: 1px;
    white-space: nowrap;
}

.status-badge b {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green-500);
    box-shadow: 0 0 0 4px rgba(41, 185, 90, 0.10), 0 0 12px rgba(41, 185, 90, 0.32);
}

.sopa-container {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border: 1px solid rgba(19, 131, 61, 0.13);
    border-radius: 18px;
    background:
        linear-gradient(rgba(19, 131, 61, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(19, 131, 61, 0.045) 1px, transparent 1px),
        linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(239, 252, 243, 0.92));
    background-size: 23px 23px, 23px 23px, auto;
    box-shadow: inset 0 0 45px rgba(13, 107, 50, 0.035);
    overflow: hidden;
    touch-action: none;
}

.sopa-container::after {
    content: '';
    position: absolute;
    z-index: 0;
    left: 0;
    right: 0;
    height: 44px;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, rgba(83, 207, 120, 0.12), transparent);
    animation: scan 9s linear infinite;
}

.sopa {
    position: relative;
    z-index: 1;
    border-collapse: separate;
    border-spacing: 5px;
    table-layout: fixed;
}

.celda {
    width: 46px;
    height: 46px;
    padding: 0;
    text-align: center;
    vertical-align: middle;
    border: 1px solid rgba(19, 131, 61, 0.12);
    border-radius: 9px;
    background: linear-gradient(145deg, #ffffff, #f0faf3);
    color: #6f9078;
    box-shadow: 0 4px 12px rgba(13, 107, 50, 0.045), inset 0 1px 0 #fff;
    font: 800 17px 'Orbitron', 'Courier New', monospace;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.16s ease, color 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.celda:hover:not(.resaltada):not(.seleccionada):not(.usada) {
    transform: translateY(-2px) scale(1.045);
    color: var(--green-900);
    border-color: rgba(19, 131, 61, 0.35);
    background: #f7fff9;
    box-shadow: 0 8px 18px rgba(13, 107, 50, 0.10);
}

.celda.seleccionada {
    color: #ffffff;
    border-color: var(--green-600);
    background: linear-gradient(135deg, var(--green-500), var(--green-700));
    transform: scale(1.07);
    box-shadow: 0 0 0 3px rgba(41, 185, 90, 0.11), 0 8px 20px rgba(13, 107, 50, 0.22);
}

.celda.resaltada {
    color: #714900;
    border-color: #f0b235;
    background: linear-gradient(135deg, #fff4bd, #ffd66a);
    box-shadow: 0 8px 20px rgba(255, 189, 61, 0.20);
    transform: scale(1.03);
    cursor: default;
}

.celda.incorrecta {
    animation: vibrar 0.45s ease;
    color: #ffffff !important;
    background: linear-gradient(135deg, #f36b78, #d93f50) !important;
    border-color: var(--danger) !important;
    box-shadow: 0 8px 20px rgba(227, 72, 88, 0.20) !important;
}

.celda.usada {
    opacity: 0.22;
    filter: grayscale(1);
    cursor: default;
}

.sopa-info {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px 4px 0;
    color: var(--muted);
    text-align: center;
}

.info-icon {
    flex: 0 0 22px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1px solid rgba(19, 131, 61, 0.17);
    border-radius: 6px;
    color: var(--green-700);
    background: rgba(255, 255, 255, 0.72);
    font-size: 12px;
}

.sopa-info .info-text {
    font-size: 10px;
    line-height: 1.4;
    letter-spacing: 1.35px;
    text-transform: uppercase;
}

.progreso-relacion {
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--green-950);
    font: 800 1.35rem 'Orbitron', sans-serif;
}

.progreso-relacion span {
    color: var(--green-600);
}

.progreso-relacion small {
    color: var(--muted-2);
    font-size: 0.55rem;
    letter-spacing: 1px;
}

.relacionar-container {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(19, 131, 61, 0.28) transparent;
}

.relacionar-container::-webkit-scrollbar {
    width: 5px;
}

.relacionar-container::-webkit-scrollbar-track {
    background: transparent;
}

.relacionar-container::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--green-400), var(--green-700));
    border-radius: 10px;
}

.relacionar-items {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.relacion-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 61px;
    padding: 11px 12px 11px 16px;
    border: 1px solid rgba(19, 131, 61, 0.10);
    border-radius: 13px;
    background: linear-gradient(110deg, rgba(255, 255, 255, 0.96), rgba(242, 252, 245, 0.90));
    box-shadow: 0 7px 22px rgba(13, 107, 50, 0.045);
    transition: 0.24s ease;
    animation: floatIn 0.32s ease both;
}

.relacion-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 13px;
    bottom: 13px;
    width: 3px;
    border-radius: 3px;
    background: linear-gradient(var(--green-400), var(--green-700));
    opacity: 0.65;
}

.relacion-item:hover {
    border-color: rgba(19, 131, 61, 0.20);
    background: #ffffff;
    transform: translateX(2px);
    box-shadow: 0 10px 26px rgba(13, 107, 50, 0.075);
}

.relacion-item .texto {
    flex: 1;
    min-width: 150px;
    color: #536f5d;
    font-size: 0.80rem;
    line-height: 1.4;
}

.relacion-item .espacio {
    display: flex;
    align-items: center;
    gap: 7px;
}

.select-palabra {
    min-width: 118px;
    height: 35px;
    padding: 0 30px 0 10px;
    border: 1px solid rgba(19, 131, 61, 0.17);
    border-radius: 8px;
    outline: none;
    background: #ffffff;
    color: var(--green-800);
    font-weight: 700;
    font-size: 0.68rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.select-palabra:focus {
    border-color: rgba(19, 131, 61, 0.50);
    box-shadow: 0 0 0 3px rgba(41, 185, 90, 0.09);
}

.select-palabra option {
    color: var(--green-900);
    background: #ffffff;
}

.btn-relacionar {
    min-width: 78px;
    height: 35px;
    padding: 0 13px;
    border: 1px solid var(--green-600);
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green-600), var(--green-800));
    color: #ffffff;
    box-shadow: 0 7px 18px rgba(13, 107, 50, 0.15);
    font: 800 0.62rem 'Orbitron', sans-serif;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn-relacionar:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 10px 22px rgba(13, 107, 50, 0.21);
}

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

.btn-relacionar:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.relacion-item.correcta {
    border-color: rgba(41, 185, 90, 0.45);
    background: linear-gradient(110deg, #f5fff7, #e7faec);
    animation: successPulse 0.8s ease;
}

.relacion-item.correcta::before {
    background: var(--green-500);
    opacity: 1;
}

.relacion-item.incorrecta {
    animation: vibrar 0.45s ease;
    border-color: rgba(227, 72, 88, 0.32);
    background: #fff5f6;
}

.relacion-item.incorrecta::before {
    background: var(--danger);
}

.relacion-item.completado {
    opacity: 0.58;
    border-color: rgba(19, 131, 61, 0.09);
    background: #f5faf6;
}

.relacion-item.completado .texto {
    color: #819687;
    text-decoration: line-through;
}

.completado-tag {
    flex: 0 0 auto;
    color: var(--green-600);
    font: 800 0.56rem 'Orbitron', sans-serif;
    letter-spacing: 1.2px;
}

.vacio,
.estado-vacio-final {
    color: var(--muted-2);
    text-align: center;
    padding: 28px 12px;
    font-size: 0.75rem;
    line-height: 1.7;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.loading {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--green-700);
    font: 700 0.72rem 'Orbitron', sans-serif;
    letter-spacing: 1.6px;
}

.loader-ring {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(19, 131, 61, 0.12);
    border-top-color: var(--green-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.baul-container {
    margin-top: 22px;
    padding: 20px 22px 22px;
}

.baul-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.baul-contador {
    display: flex;
    align-items: baseline;
    gap: 5px;
    color: var(--green-600);
    font: 800 1.3rem 'Orbitron', sans-serif;
}

.baul-contador small {
    color: var(--muted-2);
    font-size: 0.55rem;
    letter-spacing: 1px;
}

.baul-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(10, minmax(72px, 1fr));
    gap: 8px;
}

.baul-slot {
    position: relative;
    min-width: 0;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    overflow: hidden;
    border: 1px dashed rgba(19, 131, 61, 0.18);
    border-radius: 11px;
    background: rgba(247, 255, 249, 0.84);
    color: rgba(19, 131, 61, 0.13);
    text-align: center;
    font: 800 0.62rem 'Orbitron', sans-serif;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: 0.3s ease;
}

.baul-slot::after {
    content: attr(data-index);
    position: absolute;
    right: 6px;
    bottom: 4px;
    color: rgba(19, 131, 61, 0.11);
    font: 700 8px 'Orbitron', sans-serif;
}

.baul-slot.ocupado {
    border-style: solid;
    border-color: rgba(19, 131, 61, 0.28);
    background: linear-gradient(135deg, #e7faec, #f9fffa);
    color: var(--green-800);
    box-shadow: 0 8px 18px rgba(13, 107, 50, 0.08);
    animation: slotAparecer 0.45s ease;
}

.baul-slot.ocupado::before {
    content: '';
    position: absolute;
    inset: -80%;
    background: radial-gradient(circle, rgba(83, 207, 120, 0.16), transparent 58%);
    pointer-events: none;
}

.baul-slot.usado {
    opacity: 0.34;
    border-style: solid;
    border-color: rgba(19, 131, 61, 0.10);
    background: #f5faf6;
    color: var(--muted);
    text-decoration: line-through;
}

/* ===== MENSAJE FINAL ===== */
.mensaje-final-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(242, 255, 246, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease;
}

.mensaje-final-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.mensaje-final {
    position: relative;
    width: min(520px, 100%);
    padding: 42px 34px;
    overflow: hidden;
    border: 1px solid rgba(19, 131, 61, 0.18);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 30px 100px rgba(13, 107, 50, 0.18);
    text-align: center;
}

.mensaje-final::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 0%, rgba(83, 207, 120, 0.18), transparent 36%),
        linear-gradient(120deg, transparent, rgba(139, 232, 77, 0.05), transparent);
}

.mensaje-final .icono {
    position: relative;
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border: 1px solid rgba(19, 131, 61, 0.18);
    border-radius: 22px;
    background: linear-gradient(145deg, #ffffff, #e9faee);
    color: var(--green-600);
    box-shadow: 0 10px 30px rgba(13, 107, 50, 0.11);
    font-size: 2rem;
}

.mensaje-final h2 {
    position: relative;
    color: var(--green-900);
    font: 800 clamp(1.45rem, 5vw, 2.25rem) 'Orbitron', sans-serif;
    letter-spacing: 4px;
}

.mensaje-final .linea {
    position: relative;
    width: 90px;
    height: 2px;
    margin: 18px auto;
    background: linear-gradient(90deg, transparent, var(--green-500), transparent);
}

.mensaje-final p {
    position: relative;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.8;
    letter-spacing: 1px;
}

.btn-jugar-de-nuevo {
    position: relative;
    margin-top: 26px;
    padding: 12px 25px;
    border: 1px solid var(--green-600);
    border-radius: 10px;
    background: linear-gradient(135deg, var(--green-600), var(--green-800));
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(13, 107, 50, 0.18);
    font: 800 0.67rem 'Orbitron', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-jugar-de-nuevo:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(13, 107, 50, 0.24);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1180px) {
    .game-container {
        grid-template-columns: minmax(450px, 0.92fr) minmax(0, 1.08fr);
        gap: 18px;
    }

    .sopa-wrapper,
    .relacionar-wrapper {
        height: 570px;
        min-height: 570px;
    }

    .celda {
        width: 42px;
        height: 42px;
        font-size: 15px;
    }

    .sopa {
        border-spacing: 4px;
    }

    .baul-grid {
        grid-template-columns: repeat(5, minmax(100px, 1fr));
    }
}

@media (max-width: 960px) {
    .container {
        width: min(100% - 30px, 900px);
        padding-top: 22px;
    }

    .game-container {
        grid-template-columns: 1fr;
    }

    .sopa-wrapper,
    .relacionar-wrapper {
        width: 100%;
        height: auto;
        min-height: 0;
    }

    .sopa-wrapper {
        min-height: 590px;
    }

    .relacionar-wrapper {
        max-height: 560px;
    }

    .relacionar-container {
        max-height: 480px;
    }

    .celda {
        width: 46px;
        height: 46px;
        font-size: 17px;
    }
}

@media (max-width: 720px) {
    .container {
        width: min(100% - 22px, 680px);
        padding: 16px 0 28px;
    }

    .hero-header {
        padding: 10px 8px 24px;
    }

    .system-chip {
        max-width: 100%;
        font-size: 8px;
        letter-spacing: 1.1px;
    }

    .eyebrow {
        font-size: 8px;
        letter-spacing: 2.2px;
    }

    .subtitle {
        font-size: 0.66rem;
        letter-spacing: 1px;
    }

    .hero-line {
        margin-top: 16px;
    }

    .panel-shell {
        border-radius: 19px;
    }

    .sopa-wrapper {
        min-height: 0;
        padding: 13px;
    }

    .panel-topbar,
    .baul-header {
        align-items: flex-start;
    }

    .sopa-wrapper .panel-topbar {
        padding-bottom: 12px;
    }

    .relacionar-header {
        padding: 16px 15px 13px;
    }

    .panel-topbar h2,
    .panel-topbar h3,
    .baul-header h3 {
        font-size: 0.72rem;
        letter-spacing: 1.5px;
    }

    .status-badge {
        font-size: 7px;
        letter-spacing: 0.7px;
    }

    .sopa-container {
        flex: 0 0 auto;
        width: 100%;
        padding: 11px;
        overflow-x: hidden;
    }

    .sopa {
        width: auto;
        max-width: 100%;
        border-spacing: 3px;
    }

    .celda {
        width: clamp(28px, 8.3vw, 42px);
        height: clamp(28px, 8.3vw, 42px);
        border-radius: 7px;
        font-size: clamp(11px, 3.1vw, 15px);
    }

    .sopa-info {
        padding-top: 11px;
    }

    .sopa-info .info-text {
        font-size: 8px;
        letter-spacing: 0.8px;
    }

    .relacionar-wrapper {
        max-height: none;
    }

    .relacionar-container {
        max-height: 520px;
        padding: 12px;
    }

    .relacion-item {
        align-items: stretch;
        flex-direction: column;
        min-height: 0;
        padding: 12px 12px 12px 15px;
    }

    .relacion-item .texto {
        min-width: 0;
        font-size: 0.78rem;
    }

    .relacion-item .espacio {
        width: 100%;
    }

    .select-palabra {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    .btn-relacionar {
        flex: 0 0 auto;
    }

    .baul-container {
        padding: 17px 14px 16px;
    }

    .baul-header {
        margin-bottom: 13px;
    }

    .baul-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .baul-slot {
        height: 52px;
        font-size: 0.58rem;
    }
}

@media (max-width: 430px) {
    .container {
        width: calc(100% - 14px);
        padding-top: 10px;
    }

    .hero-header h1 {
        font-size: clamp(1rem, 6vw, 1.35rem);
        letter-spacing: 0.12em;
    }

    .hero-header h1.highlight {
        margin-top: 6px;
        font-size: clamp(1.65rem, 10vw, 2.45rem);
        letter-spacing: 0.035em;
    }

    .subtitle {
        margin-top: 12px;
    }

    .status-badge {
        max-width: 90px;
        white-space: normal;
        text-align: right;
        line-height: 1.35;
    }

    .sopa-wrapper {
        padding: 10px;
    }

    .sopa-container {
        padding: 7px;
        border-radius: 14px;
    }

    .sopa {
        border-spacing: 2px;
    }

    .celda {
        width: clamp(23px, 7.7vw, 31px);
        height: clamp(23px, 7.7vw, 31px);
        border-radius: 5px;
        font-size: clamp(9px, 2.8vw, 12px);
    }

    .info-icon {
        display: none;
    }

    .progreso-relacion {
        font-size: 1.05rem;
    }

    .relacionar-container {
        padding: 9px;
    }

    .relacion-item .espacio {
        flex-direction: column;
        align-items: stretch;
    }

    .select-palabra,
    .btn-relacionar {
        width: 100%;
        min-width: 0;
    }

    .baul-header {
        flex-direction: column;
        gap: 8px;
    }

    .baul-contador {
        font-size: 1rem;
    }

    .baul-slot {
        height: 48px;
        font-size: 0.52rem;
    }

    .mensaje-final {
        padding: 32px 18px;
        border-radius: 22px;
    }
}

@media (max-width: 340px) {
    .container {
        width: calc(100% - 8px);
    }

    .sopa-container {
        padding: 5px;
    }

    .sopa {
        border-spacing: 1px;
    }

    .celda {
        width: 25px;
        height: 25px;
        font-size: 9px;
        border-radius: 4px;
    }

    .panel-kicker {
        letter-spacing: 1.5px;
    }

    .panel-topbar h2,
    .panel-topbar h3,
    .baul-header h3 {
        font-size: 0.64rem;
        letter-spacing: 1px;
    }
}

@media (hover: none) {
    .celda:hover:not(.resaltada):not(.seleccionada):not(.usada),
    .relacion-item:hover,
    .btn-relacionar:hover:not(:disabled),
    .btn-jugar-de-nuevo:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}


/* =========================================================
   SOPA 10x10 - AJUSTE TOTAL AL CONTENEDOR
   ========================================================= */
.sopa-container {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

.sopa {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    grid-template-rows: repeat(10, minmax(0, 1fr));
    gap: clamp(2px, 0.45vw, 5px);
    border-spacing: 0 !important;
    table-layout: auto;
}

.celda {
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    font-size: clamp(11px, 1.35vw, 17px);
}

/* Escritorio: la matriz usa toda el área útil sin deformarse */
@media (min-width: 961px) {
    .sopa-container {
        padding: 12px;
    }

    .sopa {
        width: 100%;
        height: 100%;
    }
}

/* Tablet y móvil: cuadrícula completa, siempre dentro del ancho */
@media (max-width: 960px) {
    .sopa-wrapper {
        min-height: 0 !important;
    }

    .sopa-container {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        padding: clamp(6px, 2vw, 12px);
        overflow: hidden;
    }

    .sopa {
        width: 100%;
        height: 100%;
        max-width: none;
    }

    .celda {
        font-size: clamp(10px, 3vw, 16px);
        border-radius: clamp(4px, 1.4vw, 8px);
    }
}

@media (max-width: 430px) {
    .sopa-container {
        padding: 6px;
    }

    .sopa {
        gap: 2px;
    }

    .celda {
        font-size: clamp(9px, 3.1vw, 12px);
        border-radius: 5px;
    }
}

@media (max-width: 340px) {
    .sopa-container {
        padding: 4px;
    }

    .sopa {
        gap: 1px;
    }

    .celda {
        font-size: 9px;
        border-radius: 4px;
    }
}

/* =========================================================
   MATRIZ 15x15 — AJUSTE RESPONSIVE DEFINITIVO
   ========================================================= */
.sopa-container {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    overflow: hidden;
}

.sopa {
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
    min-height: 0;
    display: grid !important;
    grid-template-columns: repeat(15, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(15, minmax(0, 1fr)) !important;
    gap: clamp(1px, 0.18vw, 3px) !important;
    border-spacing: 0 !important;
}

.celda {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    border-radius: clamp(3px, 0.45vw, 7px) !important;
    font-size: clamp(8px, 0.92vw, 13px) !important;
    line-height: 1;
}

/* 8 palabras: que el archivo use mejor el ancho */
.baul-grid {
    grid-template-columns: repeat(8, minmax(80px, 1fr));
}

/* Estado de una palabra ya relacionada: permanece visible y tachada */
.baul-slot.usado {
    opacity: 0.58;
    border-style: solid;
    border-color: rgba(19, 131, 61, 0.18);
    background: linear-gradient(135deg, #f1faf3, #ffffff);
    color: #6f8f78;
    text-decoration-line: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: rgba(13, 107, 50, 0.72);
    text-decoration-skip-ink: none;
    filter: saturate(0.65);
}

.baul-slot.usado::before {
    content: '✓';
    position: absolute;
    top: 5px;
    left: 7px;
    color: var(--green-600);
    font-size: 10px;
    font-weight: 800;
    text-decoration: none;
}

@media (max-width: 1180px) {
    .baul-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .celda { font-size: clamp(8px, 1.15vw, 12px) !important; }
}

@media (max-width: 960px) {
    .sopa-container {
        flex: 0 0 auto !important;
        width: 100%;
        height: auto !important;
        aspect-ratio: 1 / 1;
        padding: clamp(6px, 1.6vw, 12px) !important;
    }

    .sopa {
        width: 100% !important;
        height: 100% !important;
    }

    .celda {
        font-size: clamp(8px, 2.05vw, 13px) !important;
        border-radius: clamp(2px, 0.8vw, 6px) !important;
    }
}

@media (max-width: 720px) {
    .sopa { gap: 2px !important; }
    .celda { font-size: clamp(7px, 2vw, 11px) !important; }
    .baul-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
    .sopa-container { padding: 5px !important; }
    .sopa { gap: 1px !important; }
    .celda {
        font-size: clamp(6.5px, 2.15vw, 9px) !important;
        border-radius: 2px !important;
        border-width: 1px;
    }
}

@media (max-width: 340px) {
    .sopa-container { padding: 3px !important; }
    .sopa { gap: 1px !important; }
    .celda { font-size: 6.5px !important; }
}
