:root {
    --wood-dark: #2C1810;
    --wood-mid: #5C3A21;
    --wood-light: #8B6344;
    --paper: #F5E6C8;
    --paper-light: #FDF8EF;
    --gold: #C9A84C;
    --gold-dark: #A07828;
    --blue-dark: #1B2A4A;
    --blue-mid: #3D5A80;
    --green: #4A7C59;
    --red: #8B3A3A;
    --shadow: rgba(44, 24, 16, .25);
    --radius: 10px;
    --tr: .3s ease;
    --fh: 'Playfair Display', Georgia, serif;
    --fb: 'Lora', 'Times New Roman', serif;
    --bg-body: #2C1810;
    --bg-surface: var(--paper-light);
    --bg-surface2: var(--paper);
    --text1: var(--wood-dark);
    --text2: var(--wood-light);
    --border: rgba(139, 99, 68, .2)
}

body.dark-mode {
    --bg-body: #0a0806;
    --bg-surface: #1a1410;
    --bg-surface2: #241c16;
    --text1: #e8d8c0;
    --text2: #b0a090;
    --paper: #241c16;
    --paper-light: #1a1410;
    --wood-dark: #e8d8c0;
    --wood-mid: #3a2a1e;
    --border: rgba(201, 168, 76, .12);
    --shadow: rgba(0, 0, 0, .4)
}

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

html {
    scroll-behavior: smooth
}

body {
    font-family: var(--fb);
    background: var(--bg-body);
    color: var(--text1);
    min-height: 100vh;
    line-height: 1.6
}

button {
    cursor: pointer;
    font-family: var(--fb);
    border: none
}

input,
textarea {
    font-family: var(--fb)
}

ul {
    list-style: none
}

.hidden {
    display: none !important
}

.view {
    display: none
}

.view.active {
    display: block
}

#main-header {
    background: linear-gradient(180deg, #1a100a, #2C1810);
    border-bottom: 3px solid var(--gold);
    padding: .75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .5)
}

body.dark-mode #main-header {
    background: linear-gradient(180deg, #050403, #0a0806)
}

.header-content {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center
}

.logo {
    display: flex;
    align-items: center;
    gap: .6rem
}

.logo h1 {
    font-family: var(--fh);
    color: var(--gold);
    font-size: 1.4rem;
    letter-spacing: 1px
}

.secret-btn {
    background: none;
    font-size: 1.8rem;
    padding: 4px;
    border-radius: 8px;
    transition: var(--tr);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .3))
}

.secret-btn:hover {
    transform: scale(1.15) rotate(-5deg)
}

.btn-back {
    padding: .45rem .9rem;
    background: rgba(255, 255, 255, .1);
    color: var(--paper);
    border-radius: 8px;
    font-size: .85rem;
    transition: var(--tr)
}

.btn-back:hover {
    background: rgba(255, 255, 255, .2)
}

.hero {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem
}

.hero-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    object-fit: cover;
    animation: float 3s ease-in-out infinite;
    box-shadow: 0 8px 32px rgba(201, 168, 76, .3);
    border: 3px solid var(--gold)
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-10px)
    }
}

.hero-title {
    font-family: var(--fh);
    color: var(--gold);
    font-size: 2rem;
    margin: .5rem 0 .25rem
}

.hero-sub {
    color: var(--text2);
    font-size: .95rem
}

.code-section {
    max-width: 500px;
    margin: 0 auto 2rem;
    padding: 0 1rem
}

.code-section h3 {
    font-family: var(--fh);
    color: var(--gold);
    text-align: center;
    margin-bottom: .75rem;
    font-size: 1.1rem
}

.code-input-row {
    display: flex;
    gap: .5rem
}

.code-input-row input {
    flex: 1;
    padding: .7rem .9rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    font-size: .9rem;
    color: var(--text1)
}

.code-input-row input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, .2)
}

.games-section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem 2rem
}

.section-heading {
    font-family: var(--fh);
    color: var(--gold);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    text-shadow: 0 1px 8px rgba(201, 168, 76, .3)
}

body.dark-mode .section-heading {
    color: var(--gold)
}

.game-category {
    margin-bottom: 1.5rem
}

.category-title {
    font-family: var(--fh);
    color: var(--gold);
    font-size: 1rem;
    margin-bottom: .75rem;
    padding-bottom: .4rem;
    border-bottom: 2px solid rgba(201, 168, 76, .2)
}

.game-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem
}

.game-card {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 1.2rem;
    text-align: center;
    border: 2px solid transparent;
    transition: var(--tr);
    box-shadow: 0 3px 12px var(--shadow)
}

.game-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold);
    box-shadow: 0 6px 24px rgba(201, 168, 76, .25)
}

.game-card.disabled {
    opacity: .4;
    pointer-events: none
}

.card-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: .3rem
}

.game-card h5 {
    font-family: var(--fh);
    color: var(--text1);
    margin-bottom: .2rem;
    font-size: 1rem
}

.game-card p {
    font-size: .8rem;
    color: var(--text2)
}

.editor-container {
    background: var(--bg-surface);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 24px var(--shadow);
    border: 1px solid var(--border);
    max-width: 900px;
    margin: 1rem auto
}

.editor-tabs {
    display: flex;
    background: var(--wood-mid)
}

body.dark-mode .editor-tabs {
    background: #1a1410;
    border-bottom: 2px solid var(--gold-dark)
}

.tab-btn {
    flex: 1;
    padding: .8rem .5rem;
    color: var(--paper);
    font-size: .9rem;
    background: transparent;
    transition: var(--tr);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px
}

.tab-btn:hover {
    background: rgba(255, 255, 255, .08)
}

.tab-btn.active {
    background: var(--bg-surface);
    color: var(--text1);
    border-bottom-color: var(--gold);
    font-weight: 600
}

.tab-content {
    display: none;
    padding: 1.5rem 1rem
}

.tab-content.active {
    display: block
}

.input-section h2 {
    font-family: var(--fh);
    color: var(--text1);
    margin-bottom: .3rem;
    font-size: 1.3rem
}

.section-desc {
    color: var(--text2);
    margin-bottom: 1rem;
    font-size: .9rem
}

.input-row {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap
}

.input-row input,
.quiz-form input {
    flex: 1;
    min-width: 140px;
    padding: .7rem .8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface2);
    font-size: .9rem;
    color: var(--text1);
    transition: var(--tr)
}

.input-row input:focus,
.quiz-form input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, .15)
}

.pair-arrow {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    color: var(--gold-dark);
    font-weight: bold
}

.quiz-form {
    margin-bottom: 1rem
}

.quiz-form input {
    display: block;
    width: 100%;
    margin-bottom: .6rem
}

.quiz-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .5rem;
    margin-bottom: .75rem
}

.btn-primary {
    padding: .65rem 1.2rem;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: #2C1810;
    border-radius: 8px;
    font-weight: 600;
    font-size: .9rem;
    transition: var(--tr);
    box-shadow: 0 2px 8px rgba(160, 120, 40, .3)
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(160, 120, 40, .4)
}

.btn-full {
    width: 100%
}

.actions-bar {
    display: flex;
    gap: .6rem;
    margin-top: .75rem;
    flex-wrap: wrap
}

.btn-save {
    padding: .6rem 1.1rem;
    background: linear-gradient(135deg, var(--green), #5a9a6a);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--tr)
}

.btn-save:hover {
    filter: brightness(1.1)
}

.btn-clear {
    padding: .6rem 1.1rem;
    background: transparent;
    color: var(--red);
    border: 2px solid var(--red);
    border-radius: 8px;
    font-weight: 500;
    transition: var(--tr)
}

.btn-clear:hover {
    background: var(--red);
    color: white
}

.items-list {
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: .4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, .3)
}

body.dark-mode .items-list {
    background: rgba(255, 255, 255, .03)
}

.items-list:empty::before {
    content: '📖 Aún no hay elementos.';
    display: block;
    padding: 1.5rem;
    text-align: center;
    color: var(--text2);
    font-style: italic
}

.items-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .6rem .8rem;
    border-bottom: 1px solid var(--border);
    animation: fadeIn .3s ease
}

.items-list li:last-child {
    border-bottom: none
}

.items-list li .item-text {
    flex: 1;
    font-size: .9rem
}

.pair-sep {
    color: var(--gold-dark);
    margin: 0 .4rem;
    font-weight: bold
}

.btn-delete {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(139, 58, 58, .1);
    color: var(--red);
    font-size: .9rem;
    transition: var(--tr);
    display: flex;
    align-items: center;
    justify-content: center
}

.btn-delete:hover {
    background: var(--red);
    color: white
}

.export-section {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 1.5rem;
    background: var(--bg-surface);
    border-radius: 14px;
    text-align: center;
    border: 2px dashed var(--border)
}

.export-section h3 {
    font-family: var(--fh);
    color: var(--text1);
    margin-bottom: .4rem
}

.export-section>p {
    color: var(--text2);
    margin-bottom: 1rem;
    font-size: .9rem
}

.btn-export {
    padding: .7rem 1.5rem;
    background: linear-gradient(135deg, var(--blue-dark), var(--blue-mid));
    color: white;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--tr);
    box-shadow: 0 3px 12px rgba(27, 42, 74, .3)
}

.btn-export:hover {
    transform: translateY(-2px)
}

.export-display {
    margin-top: 1rem
}

.export-display textarea {
    width: 100%;
    padding: .8rem;
    background: #1a100a;
    color: var(--gold);
    font-family: 'Courier New', monospace;
    font-size: .8rem;
    border: 1px solid var(--gold-dark);
    border-radius: 8px;
    resize: none;
    margin-bottom: .5rem
}

.btn-copy {
    padding: .5rem 1rem;
    background: var(--gold);
    color: #2C1810;
    border-radius: 6px;
    font-weight: 600;
    font-size: .85rem
}

.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .6rem 1rem;
    background: linear-gradient(135deg, #1a100a, #2C1810);
    border-radius: 10px;
    margin: 0 auto 1rem;
    max-width: 1100px;
    border: 1px solid rgba(201, 168, 76, .15)
}

body.dark-mode .game-hud {
    background: linear-gradient(135deg, #050403, #0d0a08)
}

.hud-item {
    padding: .3rem .7rem;
    background: rgba(201, 168, 76, .12);
    color: var(--gold);
    border-radius: 16px;
    font-size: .85rem;
    border: 1px solid rgba(201, 168, 76, .2)
}

.hud-title {
    font-family: var(--fh);
    color: var(--gold);
    font-size: 1.1rem;
    text-align: center
}

#game-container {
    background: var(--bg-surface);
    border-radius: 14px;
    padding: 1.5rem 1rem;
    min-height: 300px;
    box-shadow: 0 6px 24px var(--shadow);
    border: 1px solid var(--border);
    max-width: 1100px;
    margin: 0 auto
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}