/* ==========================================
   Game Page Styles
   ========================================== */

/* ==========================================
   Variables de tema para game-page
   landing.css define las variables BASE (modo claro).
   Aqui redefinimos para modo oscuro (default) y
   sobrescribimos para modo claro con body.light-theme.
   ========================================== */
.game-page-body {
    /* Modo oscuro = DEFAULT (sin clase) */
    --color-background:      #0f172a;
    --color-foreground:      #f1f5f9;
    --color-card:            #1e293b;
    --color-card-foreground: #f1f5f9;
    --color-border:          rgba(255, 255, 255, 0.10);
    --color-muted:           #1e293b;
    --color-muted-foreground:#94a3b8;
    --color-destructive:     #ef4444;
    --color-surface-2:       #334155;
    /* --color-primary y --color-primary-foreground heredados de landing.css */
}

body.light-theme.game-page-body {
    --color-background:      #f8fafc;
    --color-foreground:      hsl(150, 30%, 12%);
    --color-card:            #ffffff;
    --color-card-foreground: hsl(150, 30%, 12%);
    --color-border:          hsl(140, 15%, 88%);
    --color-muted:           hsl(140, 15%, 95%);
    --color-muted-foreground:hsl(150, 10%, 45%);
    --color-destructive:     #dc2626;
    --color-surface-2:       hsl(140, 20%, 94%);
}

/* Disable text selection for native app feel */
.game-page-body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.game-page-body input,
.game-page-body textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* Game Header */
.game-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--color-primary);
    color: var(--color-primary-foreground);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(6px);
}

.game-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 3.5rem;
    gap: 0.75rem;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    transition: opacity 0.2s;
}

.back-button:hover {
    opacity: 0.8;
}

.game-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.game-logo-icon {
    font-size: 1.5rem;
}

.game-logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: 0.02em;
}

/* Guest User Banner */
.game-guest-banner {
    position: sticky;
    top: 3.5rem;
    z-index: 98;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 0.75rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.4s ease-out;
}

.game-guest-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
}

.guest-banner-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.guest-banner-icon {
    font-size: 1.25rem;
}

.guest-banner-name {
    font-weight: 700;
    color: #fef3c7;
}

.guest-banner-link-btn {
    padding: 0.5rem 1rem;
    background: white;
    color: #d97706;
    border: none;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.guest-banner-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background: #fef3c7;
}

.game-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    min-width: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 2rem;
    padding: 0.25rem 0.65rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

/* Navigation Tabs */
.game-tabs {
    background-color: var(--color-card);
    color: var(--color-foreground);
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 3.5rem;
    z-index: 99;
}

/* Ajuste cuando hay banner de invitado */
.game-guest-banner ~ .game-tabs,
body:has(.game-guest-banner) .game-tabs {
    top: calc(3.5rem + 3.25rem);
}

.tabs-wrapper {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}

.tabs-wrapper::-webkit-scrollbar {
    height: 6px;
}

.tabs-wrapper::-webkit-scrollbar-thumb {
    background: rgba(34, 92, 68, 0.35);
    border-radius: 999px;
}

.tab-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-muted-foreground);
    min-height: 44px;
    scroll-snap-align: start;
}

.tab-button:hover {
    background-color: var(--color-surface-2, var(--color-secondary));
    color: var(--color-foreground);
}

.tab-button.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: linear-gradient(180deg, rgba(34, 92, 68, 0.06) 0%, rgba(34, 92, 68, 0.12) 100%);
}

.tab-icon {
    font-size: 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tab-label {
    font-size: 0.875rem;
}

/* Main Content */
.game-main {
    min-height: calc(100vh - 7rem);
    background: radial-gradient(circle at top, rgba(8, 145, 178, 0.08) 0%, rgba(255, 255, 255, 0) 40%), var(--color-background);
    padding: 2rem 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.section-title-game {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2rem;
    color: var(--color-foreground);
    margin-bottom: 0.5rem;
    text-align: center;
    letter-spacing: 0.015em;
}

.section-description-game {
    color: var(--color-muted-foreground);
    text-align: center;
    margin-bottom: 2rem;
    max-width: 42rem;
    margin-left: auto;
    margin-right: auto;
}

.game-page-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.55);
    padding: 1rem;
}

.game-page-dialog-overlay.active {
    display: flex;
}

.game-page-dialog {
    width: min(520px, 100%);
    background: var(--color-card);
    color: var(--color-card-foreground);
    border: 1px solid var(--color-border);
    border-radius: 0.875rem;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
    padding: 1rem;
}

.game-page-dialog.type-success {
    border-left: 5px solid var(--color-primary);
}

.game-page-dialog.type-error {
    border-left: 5px solid var(--color-destructive, var(--color-primary));
}

.game-page-dialog.type-info {
    border-left: 5px solid var(--color-muted-foreground);
}

.game-page-dialog-title {
    margin: 0 0 0.5rem 0;
    font-family: var(--font-heading);
    font-size: 1.05rem;
}

.game-page-dialog-message {
    color: var(--color-muted-foreground);
    line-height: 1.55;
}

.game-page-dialog-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

.game-page-dialog-btn {
    border: none;
    cursor: pointer;
    border-radius: 0.6rem;
    padding: 0.55rem 1rem;
    font-weight: 700;
    background: var(--color-primary);
    color: var(--color-primary-foreground);
}

/* Selected Defenders Bar */
.selected-defenders {
    background: linear-gradient(135deg, var(--color-water-blue) 0%, var(--color-water-blue-deep) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-card-hover);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

body.light-theme .selected-defenders {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border-color: rgba(255, 255, 255, 0.6);
}

.selected-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.selected-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.75rem;
}

.defender-slot {
    aspect-ratio: 1;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.3s;
    cursor: pointer;
}

.defender-slot.empty {
    opacity: 0.5;
}

.defender-slot.filled {
    background-color: rgba(255, 255, 255, 0.3);
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.8);
}

.defender-slot:hover {
    transform: scale(1.05);
    background-color: rgba(255, 255, 255, 0.3);
}

.defender-slot img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

/* Defenders Grid */
.defenders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.defender-card {
    background-color: var(--color-card);
    color: var(--color-card-foreground);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 2px solid var(--color-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.defender-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-water-blue) 0%, var(--color-water-blue-deep) 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.defender-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.05) 0%, rgba(37, 99, 235, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.defender-card.selected {
    border-color: var(--color-water-blue);
    box-shadow: 0 8px 25px rgba(32, 178, 170, 0.3);
    transform: translateY(-4px);
}

.defender-card.selected::before {
    transform: scaleX(1);
}

.defender-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

body.light-theme .defender-card {
    background: var(--color-card);
    border-color: var(--color-border);
}

body.light-theme .defender-card-title,
body.light-theme .defender-name {
    color: var(--color-foreground);
}

body.light-theme .defender-description,
body.light-theme .defender-detail,
body.light-theme .defender-category {
    color: var(--color-muted-foreground);
}

body.light-theme .defender-cost {
    color: #92400e;
    background: rgba(180, 83, 9, 0.10);
    border-color: rgba(180, 83, 9, 0.25);
}

.defender-card:hover::after,
.defender-card.selected::after {
    opacity: 1;
}

.defender-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.defender-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--color-water-blue-light) 0%, var(--color-water-blue) 100%);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(32, 178, 170, 0.2);
}

.defender-info {
    flex: 1;
}

.defender-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-foreground);
    margin-bottom: 0.25rem;
}

.defender-category {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.category-low-cost {
    background-color: rgba(34, 197, 94, 0.1);
    color: rgb(22, 163, 74);
}

.category-damage {
    background-color: rgba(239, 68, 68, 0.1);
    color: rgb(220, 38, 38);
}

.category-tank {
    background-color: rgba(59, 130, 246, 0.1);
    color: rgb(37, 99, 235);
}

.category-special {
    background-color: rgba(168, 85, 247, 0.1);
    color: rgb(147, 51, 234);
}

.defender-cost {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: #fde68a;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.30);
    border-radius: 9999px;
    padding: 2px 10px;
    line-height: 1.4;
}

.defender-cost::before {
    content: '🪙';
    font-size: 0.85em;
    line-height: 1;
}

.defender-description {
    color: var(--color-muted-foreground);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.defender-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem;
    background-color: var(--color-secondary);
    border-radius: 0.375rem;
    font-size: 0.75rem;
}

.stat-label {
    color: var(--color-muted-foreground);
    font-weight: 600;
}

.stat-value {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-accent);
}

/* Start Game Section */
.start-game-section {
    text-align: center;
    padding: 2rem 0;
}

.start-game-button {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 3rem;
    background: linear-gradient(135deg, var(--color-water-blue) 0%, var(--color-water-blue-deep) 100%);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(32, 178, 170, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.start-game-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
    filter: saturate(0.7);
}

.start-game-button:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 15px 40px rgba(32, 178, 170, 0.5);
}

.start-game-button:active {
    transform: translateY(-2px) scale(1.02);
}

@media (max-width: 1024px) {
    .game-main {
        padding: 1.5rem 0;
    }

    .section-title-game {
        font-size: 1.8rem;
    }
}

.start-icon {
    font-size: 1.5rem;
}

.start-hint {
    margin-top: 0.75rem;
    color: var(--color-muted-foreground);
    font-size: 0.875rem;
}

/* Story Chapters */
.story-chapters {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.story-chapter {
    background-color: var(--color-card, #1e293b);
    color: var(--color-card-foreground, #f1f5f9);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-card);
    border: 2px solid var(--color-border);
    transition: all 0.3s;
    position: relative;
}

.story-chapter.locked {
    opacity: 0.6;
    filter: grayscale(0.5);
}

.story-chapter:not(.locked):hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

.chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.chapter-number {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 2.5rem;
    color: var(--color-water-blue);
    opacity: 0.2;
}

.chapter-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-unlocked {
    background-color: rgba(34, 197, 94, 0.1);
    color: rgb(22, 163, 74);
}

.badge-locked {
    background-color: rgba(156, 163, 175, 0.1);
    color: rgb(107, 114, 128);
}

.chapter-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--color-foreground);
    margin-bottom: 0.75rem;
}

.chapter-description {
    color: var(--color-muted-foreground);
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Boss Info */
.boss-info {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.boss-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.boss-icon {
    font-size: 3rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.boss-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.boss-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 0.25rem;
}

.boss-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 1.5;
    font-style: italic;
}

/* Chapter Levels */
.chapter-levels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.level-badge {
    padding: 0.5rem 1rem;
    background-color: var(--color-secondary);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-foreground);
    transition: all 0.2s;
}

.level-clickable {
    cursor: pointer;
    border: 2px solid transparent;
}

.level-clickable:hover {
    background-color: var(--color-accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(32, 178, 170, 0.3);
}

.boss-level {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.9) 0%, rgba(185, 28, 28, 0.9) 100%);
    color: white;
    font-weight: 700;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.boss-level:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 1) 0%, rgba(220, 38, 38, 1) 100%);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 16px rgba(220, 38, 38, 0.5);
}

/* Chapter Rewards */
.chapter-rewards {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.rewards-title {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-gold);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
}

.rewards-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
}

.rewards-list span {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Tutorial Steps */
.tutorial-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.tutorial-card {
    background-color: var(--color-card, #1e293b);
    color: var(--color-card-foreground, #f1f5f9);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-card);
    border: 2px solid var(--color-border);
    transition: all 0.3s;
}

.tutorial-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

.tutorial-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--color-water-blue) 0%, var(--color-water-blue-deep) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 10px rgba(32, 178, 170, 0.2);
}

.tutorial-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-foreground);
    margin-bottom: 0.75rem;
}

.tutorial-content {
    color: var(--color-muted-foreground);
    line-height: 1.6;
}

/* Shop Filters */
.shop-filters {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.shop-filter-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--color-card, #1e293b);
    border: 2px solid var(--color-border);
    border-radius: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-muted-foreground);
    cursor: pointer;
    transition: all 0.2s;
}

.shop-filter-btn:hover {
    border-color: var(--color-water-blue);
    color: var(--color-water-blue);
}

.shop-filter-btn.active {
    background: linear-gradient(135deg, var(--color-water-blue) 0%, var(--color-water-blue-deep) 100%);
    color: white;
    border-color: var(--color-water-blue);
}

/* Shop Items */
.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.shop-item {
    background-color: var(--color-card, #1e293b);
    color: var(--color-card-foreground, #f1f5f9);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 2px solid var(--color-border);
    transition: all 0.3s;
}

.shop-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-hover);
}

body.light-theme .shop-item,
body.light-theme .upgrade-card,
body.light-theme .achievement-card {
    background: #ffffff;
    color: var(--color-foreground);
    border-color: var(--color-border);
}

body.light-theme .shop-filter-btn {
    background-color: #ffffff;
    color: var(--color-muted-foreground);
}

body.light-theme .shop-item-title,
body.light-theme .shop-item-cost,
body.light-theme .shop-item-description,
body.light-theme .shop-stat-value,
body.light-theme .shop-stat-label {
    color: var(--color-foreground);
}

.shop-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.shop-item-icon {
    font-size: 2.5rem;
}

.shop-item-cost {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-gold);
}

.shop-item-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-foreground);
    margin-bottom: 0.5rem;
}

.shop-item-description {
    color: var(--color-muted-foreground);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.shop-defender-stats {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: var(--color-secondary);
    border-radius: 0.5rem;
}

.shop-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.shop-stat-label {
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
    margin-bottom: 0.25rem;
}

.shop-stat-value {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-accent);
    font-size: 1.125rem;
}

.shop-buy-button {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--color-gold) 0%, hsl(38, 80%, 42%) 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.shop-buy-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(234, 179, 8, 0.3);
}

.shop-buy-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.shop-buy-button.disabled {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.shop-buy-button.insufficient {
    background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%);
}

.shop-item.unlocked {
    border-color: var(--color-success);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.05) 0%, rgba(22, 163, 74, 0.05) 100%);
}

/* ==========================================
   Upgrades Styles
   ========================================== */
.upgrades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.upgrade-card {
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s;
}

.upgrade-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.upgrade-card.maxed {
    border-color: var(--color-gold);
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(202, 138, 4, 0.05) 100%);
}

.upgrade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.upgrade-icon {
    font-size: 2.5rem;
}

.upgrade-level {
    background: var(--color-muted);
    color: var(--color-muted-foreground);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.upgrade-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 0.5rem;
}

.upgrade-description {
    color: var(--color-muted-foreground);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.upgrade-progress {
    width: 100%;
    height: 8px;
    background: var(--color-muted);
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.upgrade-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
    transition: width 0.3s ease;
}

.upgrade-buy-button {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.upgrade-buy-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.upgrade-buy-button.disabled {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    cursor: not-allowed;
}

.upgrade-buy-button.insufficient {
    background: linear-gradient(135deg, #991b1b 0%, #7f1d1d 100%);
    cursor: not-allowed;
}

/* ==========================================
   Achievements Styles
   ========================================== */

.achievement-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.achievement-filter-btn {
    padding: 0.5rem 1.25rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--color-muted-foreground);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.achievement-filter-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
}

.achievement-filter-btn.active {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.achievement-item {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    display: flex;
    gap: 1rem;
    transition: all 0.3s;
    cursor: pointer;
}

.achievement-item.unlocked {
    background: rgba(34, 198, 156, 0.1);
    border-color: rgba(34, 198, 156, 0.25);
}

.achievement-item.unlocked:hover {
    background: rgba(34, 198, 156, 0.15);
    border-color: rgba(34, 198, 156, 0.4);
    transform: translateY(-2px);
}

.achievement-item.locked {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

.achievement-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
    line-height: 1;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 0.375rem;
    font-size: 0.95rem;
}

.achievement-desc {
    font-size: 0.85rem;
    color: var(--color-muted-foreground);
    line-height: 1.4;
}

/* Light theme achievements */
body.light-theme .achievement-filter-btn {
    background: rgba(34, 92, 68, 0.08);
    border-color: rgba(34, 92, 68, 0.2);
    color: hsl(150, 15%, 50%);
}

body.light-theme .achievement-filter-btn.active {
    background: #20b2aa;
    color: white;
    border-color: #20b2aa;
}

body.light-theme .achievement-item {
    background: rgba(34, 92, 68, 0.06);
    border-color: rgba(34, 92, 68, 0.15);
}

body.light-theme .achievement-item.unlocked {
    background: rgba(32, 178, 170, 0.12);
    border-color: rgba(32, 178, 170, 0.3);
}

/* ==========================================
   Upgrade Items
   ========================================== */

.upgrades-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.upgrade-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
}

.upgrade-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(8, 145, 178, 0.15);
}

.upgrade-item-header {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: flex-start;
}

.upgrade-item-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.upgrade-item-info {
    flex: 1;
}

.upgrade-item-name {
    font-weight: 600;
    color: var(--color-foreground);
    font-size: 0.95rem;
}

.upgrade-item-cost {
    font-size: 0.8rem;
    color: var(--color-accent);
    font-weight: 700;
    margin-top: 0.25rem;
}

.upgrade-item-reward {
    font-size: 0.85rem;
    color: var(--color-muted-foreground);
    padding: 0.75rem;
    background: rgba(8, 145, 178, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--color-accent);
    line-height: 1.4;
}

body.light-theme .upgrade-item {
    background: rgba(34, 92, 68, 0.05);
    border-color: rgba(34, 92, 68, 0.15);
}

body.light-theme .upgrade-item:hover {
    background: rgba(34, 92, 68, 0.12);
    border-color: rgba(34, 92, 68, 0.3);
    box-shadow: 0 8px 20px rgba(32, 178, 170, 0.12);
}
   
/* ==========================================
   Historia - Story Section Styles
   ========================================== */
.section-historia {
    padding: 2rem 0;
    background: transparent;
    color: var(--color-foreground);
}

.section-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.section-heading {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 2rem;
    font-family: var(--font-heading);
}

.historia-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2.5rem;
    text-align: left;
    margin-top: 2rem;
}

.historia-lore {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.lore-chapter {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.lore-chapter:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.lore-chapter-num {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-accent);
    min-width: 60px;
    text-align: center;
    line-height: 1;
    font-family: var(--font-heading);
}

.lore-chapter-body h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin: 0 0 0.75rem;
    font-family: var(--font-heading);
}

.lore-chapter-body p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-muted-foreground);
    margin: 0;
}

.historia-visual {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.historia-card {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
}

.historia-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--color-accent);
    font-weight: 700;
    color: var(--color-foreground);
    font-size: 1.05rem;
}

.historia-card-header i {
    font-size: 1.3rem;
    color: var(--color-accent);
}

.historia-mechanics,
.historia-enemies {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.historia-mechanics li,
.historia-enemies li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--color-muted-foreground);
    padding: 0.5rem;
}

.historia-mechanics i {
    font-size: 1.1rem;
    color: var(--color-accent);
    flex-shrink: 0;
}

.enemy-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--color-foreground);
}

.enemy-desc {
    font-size: 0.8rem;
    color: var(--color-muted-foreground);
}

.badge-boss {
    display: inline-block;
    font-size: 0.65rem;
    background: #ef4444;
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-weight: 700;
    text-transform: uppercase;
}

.btn-lore-play {
    margin-top: 1rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--color-accent) 0%, #0891b2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.btn-lore-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(8, 145, 178, 0.3);
}

/* Light theme overrides for historia */
body.light-theme .lore-chapter {
    background: rgba(34, 92, 68, 0.06);
    border: 1px solid rgba(34, 92, 68, 0.15);
}

body.light-theme .lore-chapter:hover {
    background: rgba(34, 92, 68, 0.12);
    border-color: rgba(34, 92, 68, 0.25);
}

body.light-theme .historia-card {
    background: rgba(34, 92, 68, 0.05);
    border: 1px solid rgba(34, 92, 68, 0.15);
}

body.light-theme .historia-card-header {
    border-bottom-color: #20b2aa;
    color: hsl(150, 30%, 12%);
}

body.light-theme .historia-card-header i {
    color: #20b2aa;
}

body.light-theme .lore-chapter-body p {
    color: hsl(150, 15%, 50%);
}

body.light-theme .enemy-info {
    color: hsl(150, 30%, 12%);
}

/* Responsive Historia */
@media (max-width: 768px) {
    .historia-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .section-heading {
        font-size: 1.75rem;
    }
    
    .lore-chapter {
        flex-direction: column;
    }
    
    .lore-chapter-num {
        text-align: left;
    }
}
.achievement-filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    justify-content: center;
}

.achievement-filter-btn {
    padding: 0.5rem 1.25rem;
    background: var(--color-muted);
    color: var(--color-muted-foreground);
    border: 2px solid transparent;
    border-radius: 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.achievement-filter-btn:hover {
    background: var(--color-primary);
    color: var(--color-primary-foreground);
}

.achievement-filter-btn.active {
    background: var(--color-primary);
    color: var(--color-primary-foreground);
    border-color: var(--color-accent);
}

.achievements-grid {
    display: grid;
    gap: 1rem;
    margin-top: 2rem;
}

.achievement-card {
    background: var(--color-card);
    border: 2px solid var(--color-border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
        "icon info"
        "icon points";
    gap: 1rem;
    align-items: start;
    transition: all 0.3s;
    overflow: hidden;
}

.achievement-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.achievement-card.unlocked {
    border-color: var(--color-gold);
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(202, 138, 4, 0.05) 100%);
}

.achievement-icon {
    grid-area: icon;
    font-size: 3rem;
    transition: filter 0.3s;
}

.achievement-icon.locked {
    filter: grayscale(1);
    opacity: 0.5;
}

.achievement-info {
    grid-area: info;
    flex: 1;
    min-width: 0;
}

.achievement-title {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 0.25rem;
}

.achievement-description {
    color: var(--color-muted-foreground);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    overflow-wrap: anywhere;
}

.achievement-progress {
    position: relative;
    width: 100%;
    height: 6px;
    background: var(--color-muted);
    border-radius: 1rem;
    overflow: hidden;
    margin-top: 0.5rem;
}

.achievement-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
    transition: width 0.3s ease;
}

.achievement-progress-text {
    position: absolute;
    top: -20px;
    right: 0;
    font-size: 0.75rem;
    color: var(--color-muted-foreground);
    font-weight: 600;
}

.achievement-points {
    grid-area: points;
    justify-self: start;
    align-self: start;
    background: var(--color-muted);
    color: var(--color-muted-foreground);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 700;
    white-space: nowrap;
}

.achievement-points.earned {
    background: linear-gradient(135deg, var(--color-gold) 0%, hsl(38, 80%, 42%) 100%);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .game-header-content {
        height: auto;
        min-height: 3.5rem;
        padding: 0.5rem 0;
        gap: 0.45rem;
    }

    .back-button {
        font-size: 0.9rem;
        gap: 0.35rem;
    }

    .game-logo-text {
        font-size: 1rem;
    }

    .game-stats {
        gap: 0.35rem;
    }

    .stat-item {
        min-height: 1.9rem;
        padding: 0.2rem 0.5rem;
        font-size: 0.82rem;
    }

    .tabs-wrapper {
        padding: 0.55rem 0.1rem;
        gap: 0.4rem;
    }

    .tab-button {
        padding: 0.62rem 0.9rem;
        border-bottom-width: 0;
        border-radius: 0.65rem;
        background: var(--color-secondary);
    }

    .tab-button.active {
        color: var(--color-primary-foreground);
        background: var(--color-primary);
    }

    .tab-icon {
        font-size: 1.05rem;
        width: 1.05rem;
        height: 1.05rem;
    }

    .tab-label {
        font-size: 0.82rem;
    }

    .section-title-game {
        font-size: 1.5rem;
    }

    .section-description-game {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .selected-defenders {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    .selected-slots {
        grid-template-columns: repeat(4, minmax(56px, 1fr));
    }

    .defender-card {
        padding: 1.1rem;
    }

    .defender-card:hover,
    .defender-card.selected,
    .shop-item:hover,
    .upgrade-card:hover,
    .story-chapter:not(.locked):hover,
    .tutorial-card:hover,
    .lore-chapter:hover,
    .achievement-item.unlocked:hover,
    .upgrade-item:hover,
    .start-game-button:hover {
        transform: none;
    }

    .defender-icon {
        width: 56px;
        height: 56px;
        font-size: 2rem;
    }

    .start-game-section {
        padding: 1.25rem 0;
    }

    .start-game-button {
        width: 100%;
        justify-content: center;
        padding: 1rem 1.1rem;
        font-size: 1.02rem;
    }

    .defenders-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .tutorial-steps {
        grid-template-columns: 1fr;
    }
    
    .shop-items {
        grid-template-columns: 1fr;
    }
    
    .upgrades-grid {
        grid-template-columns: 1fr;
    }
    
    .achievement-card {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .game-logo-text {
        display: none;
    }

    .game-main {
        padding: 1rem 0;
    }

    .selected-slots {
        grid-template-columns: repeat(4, minmax(52px, 1fr));
        gap: 0.55rem;
    }

    .defender-slot {
        font-size: 1.6rem;
    }

    .tab-label {
        font-size: 0.78rem;
    }
}

@media (hover: none) and (pointer: coarse) {
    .tab-button:active,
    .defender-card:active,
    .shop-item:active,
    .upgrade-card:active,
    .tutorial-card:active,
    .story-chapter:active,
    .start-game-button:active {
        transform: scale(0.98);
    }

    .defender-card:hover,
    .shop-item:hover,
    .upgrade-card:hover,
    .tutorial-card:hover,
    .story-chapter:hover,
    .lore-chapter:hover,
    .achievement-item.unlocked:hover,
    .upgrade-item:hover,
    .start-game-button:hover,
    .guest-banner-link-btn:hover,
    .level-clickable:hover,
    .shop-buy-button:hover,
    .upgrade-buy-button:hover,
    .btn-lore-play:hover {
        transform: none;
    }
}
