@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #f06, #4a00e0);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.game-container {
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.game-container::-webkit-scrollbar {
    width: 8px;
}

.game-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.game-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

h1 {
    font-size: 2.8em;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

.inventory-section, .actions-section, .results-section {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 0;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

h2 {
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 15px;
    color: #f8c291;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    justify-content: center;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.item-grid::-webkit-scrollbar {
    width: 8px;
}

.item-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.item-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.item {
    background-color: #2c3e50;
    border: 2px solid #34495e;
    border-radius: 10px;
    padding: 15px 10px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: bold;
    color: #ecf0f1;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    text-transform: capitalize;
    position: relative;
}

.item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    background-color: #34495e;
}

.item:active {
    cursor: grabbing;
}

.item.selected {
    border-color: #3498db !important;
    box-shadow: 0 0 0 3px #3498db, 0 5px 15px rgba(0, 0, 0, 0.4) !important;
    background-color: #2980b9 !important;
}

.item.completed {
    opacity: 0.6;
    filter: grayscale(85%);
    border-color: #7f8c8d !important;
    background-color: rgba(52, 73, 94, 0.45) !important;
}

.item.completed:hover {
    opacity: 0.85;
    filter: grayscale(40%);
    background-color: rgba(52, 73, 94, 0.7) !important;
}

.completed-badge {
    color: #bdc3c7 !important;
    font-size: 0.85em !important;
    margin-left: 4px;
    vertical-align: middle;
    display: inline-block;
}

.item.drag-over-target {
    border-color: #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.7);
    transform: scale(1.05);
}

.item i {
    font-size: 2em;
    margin-bottom: 8px;
    color: #f1c40f;
}

.actions-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.gemini-button {
    background: linear-gradient(45deg, #8A2BE2, #9370DB);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.gemini-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    background: linear-gradient(45deg, #9370DB, #8A2BE2);
}

.gemini-button:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.gemini-button.loading {
    cursor: not-allowed;
    opacity: 0.7;
}

.gemini-button i {
    color: #FFD700;
}

#resultMessage {
    font-size: 1.4em;
    margin-top: 20px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f1c40f;
    flex-wrap: wrap;
    text-align: center;
}

#loreDisplay {
    font-size: 1em;
    margin-top: 15px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 15px;
    text-align: left;
    max-height: 150px;
    overflow-y: auto;
    color: #e0f7fa;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.2);
    display: none;
}

#loreDisplay.show {
    display: block;
}

.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
    z-index: 1000;
}

.toast-message.show {
    opacity: 1;
    visibility: visible;
}

.start-over-button {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    margin-top: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.start-over-button:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .game-container {
        padding: 20px;
        gap: 15px;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

    .item-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 10px;
    }

    .item {
        padding: 10px 5px;
        font-size: 0.8em;
    }

    .item i {
        font-size: 1.5em;
    }

    .actions-buttons {
        flex-direction: column;
        align-items: center;
    }

    #resultMessage {
        font-size: 1.2em;
    }
}

.merge-effect {
    animation: mergeSparkle 0.7s;
    box-shadow: 0 0 20px 10px #f1c40f, 0 0 40px 20px #fff8dc;
    border-color: #f1c40f !important;
}

@keyframes mergeSparkle {
    0% { box-shadow: 0 0 0 0 #f1c40f; border-color: #fff; }
    40% { box-shadow: 0 0 20px 10px #f1c40f, 0 0 40px 20px #fff8dc; border-color: #f1c40f; }
    100% { box-shadow: 0 0 0 0 #f1c40f; border-color: #fff; }
}

.new-item-effect {
    animation: popAndGlow 0.7s;
    box-shadow: 0 0 20px 8px #00e6e6;
    border: 3px solid #00e6e6 !important;
    z-index: 2;
}

@keyframes popAndGlow {
    0% { transform: scale(1); box-shadow: 0 0 0 0 #00e6e6; }
    40% { transform: scale(1.2); box-shadow: 0 0 20px 8px #00e6e6; }
    100% { transform: scale(1); box-shadow: 0 0 0 0 #00e6e6; }
}

.first-time-frame {
    border: 3px solid gold !important;
    box-shadow: 0 0 20px 8px gold;
    animation: firstTimePulse 10s linear forwards;
}

@keyframes firstTimePulse {
    0% { border-color: gold; box-shadow: 0 0 20px 8px gold; }
    50% { border-color: gold; box-shadow: 0 0 10px 4px gold; }
    100% { border-color: gold; box-shadow: 0 0 10px 4px gold; }
}

/* Progress Section CSS */
.progress-section {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.2);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: #e0f7fa;
}

.progress-bar {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    background: linear-gradient(90deg, #9b59b6, #f1c40f);
    height: 100%;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
}

/* Overlays CSS */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 5, 20, 0.9);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeInOverlay 0.4s ease-out forwards;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px 30px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    animation: scaleUpCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleUpCard {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.victory-card {
    border-color: #f1c40f;
    box-shadow: 0 0 35px rgba(241, 196, 15, 0.25), 0 20px 50px rgba(0, 0, 0, 0.6);
}

.dead-end-card {
    border-color: #e74c3c;
    box-shadow: 0 0 35px rgba(231, 76, 60, 0.25), 0 20px 50px rgba(0, 0, 0, 0.6);
}

.trophy-icon {
    font-size: 4.5rem;
    color: #f1c40f;
    text-shadow: 0 0 20px rgba(241, 196, 15, 0.6);
    animation: trophyGlow 2s infinite alternate;
}

@keyframes trophyGlow {
    from { transform: scale(1); filter: drop-shadow(0 0 5px rgba(241, 196, 15, 0.4)); }
    to { transform: scale(1.08); filter: drop-shadow(0 0 20px rgba(241, 196, 15, 0.8)); }
}

.dead-end-icon {
    font-size: 4.5rem;
    color: #e74c3c;
    text-shadow: 0 0 20px rgba(231, 76, 60, 0.6);
    animation: pulseRed 1.5s infinite alternate;
}

@keyframes pulseRed {
    from { transform: scale(1); filter: drop-shadow(0 0 5px rgba(231, 76, 60, 0.4)); }
    to { transform: scale(1.05); filter: drop-shadow(0 0 15px rgba(231, 76, 60, 0.8)); }
}

.overlay-card h2 {
    font-size: 2.2rem;
    margin: 10px 0 5px;
    color: #fff;
}

.victory-card h2 {
    color: #f1c40f;
}

.dead-end-card h2 {
    color: #e74c3c;
}

.overlay-card p {
    font-size: 1.1rem;
    color: #d1d8e0;
    line-height: 1.6;
}

.stats-summary {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 25px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 1.15rem;
    margin: 10px 0;
}

.overlay-button {
    background: linear-gradient(45deg, #8a2be2, #f1c40f);
    border: none;
    color: #fff;
    font-size: 1.15rem;
    font-weight: bold;
    padding: 12px 35px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(138, 43, 226, 0.4);
    transition: all 0.2s ease;
}

.overlay-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(241, 196, 15, 0.5);
    background: linear-gradient(45deg, #f1c40f, #8a2be2);
}

.overlay-button.secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    box-shadow: none;
}

.overlay-button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: none;
}

/* Ad Banner Styles */
.ad-banner-container {
    margin-top: 25px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 90px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    width: 100%;
}

.ad-banner-container ins.adsbygoogle {
    width: 100%;
}

.ad-placeholder {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 5px;
    font-family: 'Inter', sans-serif;
}

/* Hide placeholder and borders when the ad is successfully filled */
.ad-banner-container:has(ins.adsbygoogle[data-ad-status="filled"]) {
    background: transparent;
    border-color: transparent;
    padding: 0;
}
.ad-banner-container:has(ins.adsbygoogle[data-ad-status="filled"]) .ad-placeholder {
    display: none;
}

/* Guide Collapsible Section */
.guide-details {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    text-align: right;
    direction: rtl;
}

.guide-summary {
    padding: 15px 20px;
    font-weight: bold;
    font-size: 1.05rem;
    color: #a0d9e2;
    cursor: pointer;
    list-style: none; /* Hide default HTML bullet */
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s ease;
}

.guide-summary::-webkit-details-marker {
    display: none; /* Hide Safari default bullet */
}

.guide-summary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.summary-arrow {
    font-size: 0.85rem;
    transition: transform 0.3s ease;
    color: rgba(255, 255, 255, 0.5);
}

.guide-details[open] .summary-arrow {
    transform: rotate(180deg);
    color: #a0d9e2;
}

.guide-content {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e0f2f1;
    max-height: 400px;
    overflow-y: auto;
}

.guide-content h3 {
    color: #f1c40f;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.guide-content h3:not(:first-of-type) {
    margin-top: 20px;
}

.guide-content p {
    margin-top: 0;
    margin-bottom: 12px;
}

.guide-content ul {
    margin: 0;
    padding-right: 20px;
    padding-left: 0;
}

.guide-content li {
    margin-bottom: 8px;
}

/* Layout Wrapper for Desktop Sidebar Ads */
.game-layout-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    width: 100%;
    max-width: 1350px;
    margin: 0 auto;
    box-sizing: border-box;
}

.layout-sidebar-column {
    width: 160px;
    min-width: 160px;
    height: 600px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: sticky;
    top: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

.sidebar-placeholder-text {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 5px;
    font-family: 'Inter', sans-serif;
}

/* Hide bottom ad on desktop when sidebar ads are visible */
@media (min-width: 1281px) {
    .game-container .ad-banner-container {
        display: none;
    }
}

/* Hide sidebars on smaller desktop & tablets/mobile */
@media (max-width: 1280px) {
    .layout-sidebar-column {
        display: none;
    }
}

/* Desktop Collection Modal Styles */
.collection-modal-card {
    max-width: 680px;
    width: 90%;
    max-height: 85vh;
    padding: 24px;
    background: #18232c;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    text-align: right;
    direction: rtl;
    overflow: hidden;
    position: relative;
}

.collection-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 14px;
    margin-bottom: 16px;
    width: 100%;
}

.collection-modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
    color: #f1c40f;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-modal-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: rgba(231, 76, 60, 0.8);
    transform: scale(1.05);
}

.collection-filter-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    width: 100%;
}

.pill-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.pill-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.pill-btn.active {
    background: #f1c40f;
    color: #12181b;
    border-color: #f1c40f;
    font-weight: 600;
}

.collection-list-container {
    overflow-y: auto;
    max-height: 52vh;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 6px;
    width: 100%;
    box-sizing: border-box;
}

.collection-list-container::-webkit-scrollbar {
    width: 6px;
}
.collection-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.collection-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    transition: all 0.2s;
}

.collection-item-row:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.collection-item-row.completed-item {
    border-right: 4px solid #2ecc71;
}

.collection-item-row.active-item {
    border-right: 4px solid #f1c40f;
}

.collection-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
}

.collection-item-thumb {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.collection-item-thumb img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.collection-item-thumb i {
    font-size: 1.5rem;
    color: #f1c40f;
}

.collection-item-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: right;
}

.collection-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #fff;
}

.collection-item-status {
    font-size: 0.78rem;
    color: #94a3b8;
}

.collection-item-status.status-gold {
    color: #f1c40f;
}

.collection-item-status.status-green {
    color: #2ecc71;
}

.collection-on-board-tag {
    font-size: 0.78rem;
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.15);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.collection-restore-btn {
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid #3498db;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
}

.collection-restore-btn:hover {
    background: #2980b9;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
    transform: translateY(-1px);
}
 