:root {
    --background: #f5f7fb;
    --surface: rgba(255, 255, 255, 0.85);
    --text-main: #11152b;
    --text-muted: #000000;
    --accent: #2d5cff;
    --success: #16b887;
    --error: #f5535d;
    --border: #dfe3f5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background) url("assets/Images/Fondo%20TKE.jpg") center/cover no-repeat fixed;
    color: var(--text-main);
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.password-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 21, 43, 0.48);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    z-index: 120;
}

.password-content {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border-radius: 24px;
    padding: 40px 44px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 26px 56px rgba(17, 21, 43, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.35);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.password-content h2 {
    margin: 0;
    font-size: 1.6rem;
}

.password-content p {
    margin: 0 0 8px 0;
    color: var(--text-muted);
}

.password-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: block;
    margin-bottom: 10px;
}

#password-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1.5px solid rgba(112, 0, 189, 0.35);
    font-size: 1.05rem;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}

#password-input:focus {
    border-color: #7000bd;
    box-shadow: 0 0 0 4px rgba(112, 0, 189, 0.15);
    outline: none;
}

.password-error {
    margin: 0;
    font-size: 0.9rem;
    color: var(--error);
}

.password-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 30px;
}

#password-submit {
    background: #7000bd;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#password-submit:hover {
    transform: translateY(-2px);
}

#password-submit:active {
    transform: translateY(0);
}

.button-secondary {
    background: rgba(255, 255, 255, 0.65);
    color: var(--text-main);
    border: 1.5px solid rgba(112, 0, 189, 0.18);
    border-radius: 999px;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, border 0.15s ease, transform 0.15s ease;
}

.button-secondary:hover {
    color: #7000bd;
    border-color: rgba(112, 0, 189, 0.35);
    transform: translateY(-2px);
}

.start-screen {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    padding: 32px;
    z-index: 110;
}

.start-content {
    background: var(--surface);
    border-radius: 28px;
    padding: 48px 56px;
    /* max-width: 520px; */
    width: 100%;
    text-align: center;
    /*box-shadow: 0 28px 60px rgba(24, 45, 120, 0.16);*/
    border: 1px solid var(--border);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 24px;
    position: relative;
    padding-bottom: 140px;
}

.instructions-content {
    align-items: center;
    justify-content: center;
    text-align: left;
    gap: 32px;
    padding-bottom: 140px;
}

.instructions-body {
    width: clamp(320px, 70%, 720px);
    align-self: center;
    margin-left: clamp(0px, 8vw, 120px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.instructions-body h1 {
    margin: 0;
}

.instructions-body p {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text-muted);
}

.instructions-list {
    margin: 0;
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
}

.instructions-content #instructions-start-button {
    align-self: center;
}

.start-content h1 {
    margin: 0;
    font-size: 2.6rem;
}

.start-content p {
    margin: 0;
    color: var(--text-muted);
    font-size: 1.1rem;
}

#start-button,
#instructions-start-button,
#completion-continue-button {
    background: #7000BD;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 14px 36px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
    /*box-shadow: 0 18px 34px rgba(45, 92, 255, 0.28);*/
}

#start-button:hover:not(:disabled),
#instructions-start-button:hover:not(:disabled),
#completion-continue-button:hover:not(:disabled) {
    transform: translateY(-2px);
}

#start-button:active:not(:disabled),
#instructions-start-button:active:not(:disabled),
#completion-continue-button:active:not(:disabled) {
    transform: translateY(0);
}

#start-button:disabled,
#instructions-start-button:disabled,
#completion-continue-button:disabled {
    cursor: progress;
    opacity: 0.7;
}

.start-logo {
    position: absolute;
    bottom: 32px;
    left: 32px;
    width: 160px;
    display: flex;
    justify-content: flex-start;
}

.start-logo img {
    width: 100%;
    height: auto;
}

.game {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 56px;
    gap: 32px;
    position: relative;
}

.branding h1 {
    margin: 0;
    font-size: 2.6rem;
}

.tagline {
    margin: 8px 0 0 0;
    color: var(--text-muted);
    font-size: 1.05rem;
}


.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.78);
    border-radius: 24px;
    padding: 28px 32px;
    box-shadow: 0 20px 40px rgba(17, 21, 43, 0.14);
    backdrop-filter: blur(12px);
}

.scoreboard {
    display: flex;
    gap: 28px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.score-card {
    display: flex;
    flex-direction: column;
    text-align: right;
    min-width: 120px;
}

.score-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.28em;
    color: var(--text-muted);
}

.score-value {
    font-size: 2.1rem;
    font-weight: 700;
}


.definition-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    border: 1.5px solid rgba(45, 92, 255, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 18px 36px rgba(17, 21, 43, 0.12);
    backdrop-filter: blur(6px);
}

.definition-label {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.24em;
    color: var(--text-muted);
}

.definition-text {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.5;
}

.board {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 48px;
    align-items: start;
}

.words-area,
.matched-area {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.94) 8%, rgba(255, 255, 255, 0.7) 92%);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 18px 32px rgba(17, 21, 43, 0.12);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.words-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.instructions {
    margin: 0;
    color: var(--text-muted);
}

.word-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.list-item {
    border-radius: 14px;
    padding: 14px 18px;
    text-align: center;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    transition: border 0.12s ease, transform 0.12s ease, background 0.12s ease;
    backdrop-filter: blur(4px);
}

.list-item:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
}

.list-item.disabled {
    cursor: default;
    opacity: 0.35;
    transform: none;
    pointer-events: none;
}

.text-answer-item {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    cursor: default;
}

.text-answer-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    width: min(100%, 420px);
}

.text-answer-input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1.5px solid rgba(112, 0, 189, 0.35);
    font-size: 1.05rem;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}

.text-answer-input:focus {
    outline: none;
    border-color: #7000bd;
    box-shadow: 0 0 0 4px rgba(112, 0, 189, 0.15);
}

.text-answer-input:disabled {
    opacity: 0.65;
    background: rgba(255, 255, 255, 0.6);
}

.text-answer-submit {
    background: #7000bd;
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 14px 28px rgba(112, 0, 189, 0.28);
}

.text-answer-submit:hover:not(:disabled) {
    transform: translateY(-2px);
}

.text-answer-submit:active:not(:disabled) {
    transform: translateY(0);
}

.text-answer-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.game-logo {
    align-self: flex-start;
    margin-top: 0;
    margin-left: -32px;
    width: 180px;
    pointer-events: none;
}

.game-logo img {
    width: 100%;
    height: auto;
}

.game-logo-overlay {
    position: absolute;
    bottom: 32px;
    left: 56px;
    width: 180px;
    pointer-events: none;
}

.game-logo-overlay img {
    width: 100%;
    height: auto;
}

.matched-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.matched-area h2 {
    margin: 0;
    font-size: 1.4rem;
}

.matched-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 900px) {
    .matched-list {
        grid-template-columns: 1fr;
    }
}

.matched-item {
    /* border: 1.5px solid rgba(45, 92, 255, 0.18); */
    border-radius: 14px;
    padding: 12px 16px;
    /* background: rgba(255, 255, 255, 0.74); */
    /* box-shadow: 0 12px 22px rgba(17, 21, 43, 0.1); */
    backdrop-filter: blur(4px);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matched-item strong {
    display: block;
    margin-bottom: 4px;
}

.matched-item.empty {
    text-align: center;
    border-style: dashed;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.58);
}

.overlay {
    position: fixed;
    inset: 0;
    background: var(--background) url("assets/Images/Fondo%20TKE.jpg") center/cover no-repeat fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: var(--surface);
    border-radius: 24px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 24px 48px rgba(24, 45, 120, 0.14);
    border: 1px solid var(--border);
}

.overlay-content h2 {
    margin: 0 0 16px 0;
    font-size: 2rem;
}

.overlay-content p {
    margin: 10px 0;
    font-size: 1.05rem;
}

.overlay-actions {
    margin-top: 28px;
}

#restart-button {
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 999px;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-shadow: 0 14px 28px rgba(45, 92, 255, 0.28);
}

#restart-button:hover {
    transform: translateY(-2px);
}

#restart-button:active {
    transform: translateY(0);
}

@media (max-width: 900px) {
    .scoreboard {
        gap: 20px;
    }

    .board {
        grid-template-columns: 1fr;
    }

    .matched-area {
        order: 2;
    }

    .word-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .game-logo {
        margin-left: -16px;
        width: 160px;
    }
}

@media (max-width: 600px) {
    .game {
        padding: 32px;
        gap: 24px;
    }

    .start-content {
        padding: 36px 28px;
    }

    .start-content h1 {
        font-size: 2.2rem;
    }

    .scoreboard {
        width: 100%;
        justify-content: flex-start;
    }

    .score-card {
        text-align: left;
    }

    .score-value {
        font-size: 1.8rem;
    }

    .definition-text {
        font-size: 1.4rem;
    }

    .word-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .start-content {
        padding: 32px 24px 120px;
    }

    .start-logo {
        bottom: 24px;
        left: 24px;
        width: 140px;
    }

    .game-logo {
        margin: 0;
        width: 150px;
        align-self: center;
    }
}
