/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --body-font: 'Cinzel', serif;
    --title-font: 'MedievalSharp', serif;
    --ui-font: 'Segoe UI', Tahoma, Arial, sans-serif;
    --text-outline: 0 0 2px rgba(0, 0, 0, 0.95), 1px 1px 2px rgba(0, 0, 0, 0.85);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

body {
    font-family: var(--body-font);
    background: linear-gradient(135deg, #2c1810 0%, #1a0f0a 50%, #0d0805 100%);
    background-attachment: fixed;
    color: #d4af37;
    min-height: 100vh;
    /* ✅ Changed from height: 100vh */
    overflow-x: hidden;
    /* ✅ Prevent horizontal scroll */
    overflow-y: auto;
    /* ✅ Allow vertical scroll */
    position: relative;
}

.landing-page {
    background: linear-gradient(135deg, #241108 0%, #181008 48%, #0c0704 100%);
}

/* Medieval background texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 69, 19, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(160, 82, 45, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Medieval Typography */
.medieval-title {
    font-family: var(--title-font);
    font-size: 2.5em;
    color: #d4af37;
    text-shadow: var(--text-outline);
    text-align: center;
    margin-bottom: 10px;
}

.medieval-welcome {
    font-family: var(--title-font);
    font-size: 1.2em;
    /* ✅ REDUCED from 1.5em */
    color: #d4af37;
    text-shadow: var(--text-outline);
}

.subtitle {
    text-align: center;
    color: #f3e6c5;
    font-weight: 600;
    font-style: italic;
    margin-bottom: 20px;
    font-size: 0.9em;
    text-shadow: var(--text-outline);
}

.panel-title,
.section-title {
    font-family: var(--title-font);
    color: #d4af37;
    text-shadow: var(--text-outline);
    margin-bottom: 8px;
    /* ✅ REDUCED from 10px */
    text-align: center;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 4px;
    /* ✅ REDUCED from 5px */
    font-size: 0.85em;
    /* ✅ REDUCED from 1em */
}

/* Login Page Styles */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-scroll {
    max-width: 450px;
    width: 100%;
}

.medieval-frame {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.9), rgba(101, 67, 33, 0.9));
    border: 3px solid #d4af37;
    border-radius: 15px;
    box-shadow:
        0 0 30px rgba(212, 175, 55, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
}

.landing-page .medieval-frame {
    background: linear-gradient(145deg, rgba(103, 56, 20, 0.94), rgba(73, 47, 25, 0.94));
}

.medieval-frame::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, #d4af37, #b8860b, #d4af37);
    border-radius: 18px;
    z-index: -1;
}

.card {
    padding: 40px;
    text-align: center;
}

.login-form h1 {
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #d4af37;
    text-shadow: var(--text-outline);
}

.medieval-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #8b4513;
    border-radius: 8px;
    color: #d4af37;
    font-family: var(--body-font);
    font-size: 1em;
    transition: all 0.3s ease;
}

.medieval-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.medieval-input::placeholder {
    color: #b8860b;
    font-style: italic;
}

/* Medieval Buttons */
.medieval-btn {
    background: linear-gradient(145deg, #d4af37, #b8860b);
    color: #2c1810;
    border: none;
    padding: 8px 15px;
    /* ✅ REDUCED from 15px 30px */
    border-radius: 8px;
    /* ✅ REDUCED from 10px */
    font-family: var(--body-font);
    font-weight: 600;
    font-size: 0.9em;
    /* ✅ REDUCED from 1.1em */
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    width: 100%;
}

.medieval-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
    background: linear-gradient(145deg, #f4d03f, #d4af37);
}

.medieval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.medieval-btn-small {
    background: linear-gradient(145deg, #cd853f, #a0522d);
    color: #d4af37;
    border: 1px solid #8b4513;
    padding: 5px 10px;
    /* ✅ REDUCED from 8px 16px */
    border-radius: 5px;
    /* ✅ REDUCED from 6px */
    font-family: var(--body-font);
    font-weight: 500;
    font-size: 0.75em;
    /* ✅ REDUCED from 0.9em */
    cursor: pointer;
    transition: all 0.3s ease;
}

.medieval-btn-primary {
    background: linear-gradient(145deg, #228b22, #006400);
    color: #d4af37;
    border: 2px solid #32cd32;
    padding: 8px 15px;
    /* ✅ REDUCED */
    font-size: 0.85em;
    /* ✅ REDUCED */
}

.medieval-btn-danger {
    background: linear-gradient(145deg, #dc143c, #8b0000);
    color: #ffd700;
    border: 2px solid #ff6347;
    padding: 8px 15px;
    /* ✅ REDUCED */
    font-size: 0.85em;
    /* ✅ REDUCED */
}

/* Login Page Styles */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-scroll {
    max-width: 450px;
    width: 100%;
}

.medieval-frame {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.9), rgba(101, 67, 33, 0.9));
    border: 3px solid #d4af37;
    border-radius: 15px;
    box-shadow:
        0 0 30px rgba(212, 175, 55, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
}

.medieval-frame::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, #d4af37, #b8860b, #d4af37);
    border-radius: 18px;
    z-index: -1;
}

.card {
    padding: 40px;
    text-align: center;
}

.login-form h1 {
    margin-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #d4af37;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.medieval-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #8b4513;
    border-radius: 8px;
    color: #d4af37;
    font-family: 'Cinzel', serif;
    font-size: 1em;
    transition: all 0.3s ease;
}

.medieval-input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    background: rgba(0, 0, 0, 0.6);
}

.medieval-input::placeholder {
    color: #b8860b;
    font-style: italic;
}

/* Medieval Buttons */
.medieval-btn {
    background: linear-gradient(145deg, #d4af37, #b8860b);
    color: #2c1810;
    border: none;
    padding: 8px 15px;
    /* ✅ REDUCED from 15px 30px */
    border-radius: 8px;
    /* ✅ REDUCED from 10px */
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.9em;
    /* ✅ REDUCED from 1.1em */
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    width: 100%;
}

.medieval-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
    background: linear-gradient(145deg, #f4d03f, #d4af37);
}

.medieval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.medieval-btn-small {
    background: linear-gradient(145deg, #cd853f, #a0522d);
    color: #d4af37;
    border: 1px solid #8b4513;
    padding: 5px 10px;
    /* ✅ REDUCED from 8px 16px */
    border-radius: 5px;
    /* ✅ REDUCED from 6px */
    font-family: 'Cinzel', serif;
    font-weight: 500;
    font-size: 0.75em;
    /* ✅ REDUCED from 0.9em */
    cursor: pointer;
    transition: all 0.3s ease;
}

.medieval-btn-primary {
    background: linear-gradient(145deg, #228b22, #006400);
    color: #d4af37;
    border: 2px solid #32cd32;
    padding: 8px 15px;
    /* ✅ REDUCED */
    font-size: 0.85em;
    /* ✅ REDUCED */
}

.medieval-btn-danger {
    background: linear-gradient(145deg, #dc143c, #8b0000);
    color: #ffd700;
    border: 2px solid #ff6347;
    padding: 8px 15px;
    /* ✅ REDUCED */
    font-size: 0.85em;
    /* ✅ REDUCED */
}

/* ✅ DASHBOARD - FIT EVERYTHING ON ONE SCREEN */
#dashboardPage {
    min-height: 100vh;
    /* ✅ Changed from height to min-height */
    display: flex;
    flex-direction: column;
    padding: 10px 8px 15px 8px;
    /* ✅ REDUCED from 20px 10px 40px 10px */
    overflow-y: auto;
    /* ✅ Allow vertical scrolling */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

#dashboardPage.hidden {
    display: none !important;
}

.medieval-header {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.9), rgba(101, 67, 33, 0.9));
    border: 2px solid #d4af37;
    border-radius: 12px;
    /* ✅ REDUCED from 15px */
    padding: 12px;
    /* ✅ REDUCED from 20px */
    margin-bottom: 10px;
    /* ✅ REDUCED from 20px */
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    z-index: 100;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info-header h1 {
    margin-bottom: 8px;
    /* ✅ Reduced from 10px */
}

.medieval-stats {
    display: flex;
    gap: 8px;
    /* ✅ REDUCED from 15px */
    flex-wrap: wrap;
}

.stat-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    /* ✅ REDUCED from 6px 10px */
    border-radius: 6px;
    /* ✅ REDUCED from 8px */
    border: 1px solid #8b4513;
    font-weight: 500;
    font-size: 0.75em;
    /* ✅ REDUCED from 0.9em */
    transition: all 0.3s ease;
    text-shadow: var(--text-outline);
}

/* Login-specific typography for readability */
#loginPage .login-form,
#loginPage .form-group label,
#loginPage .medieval-input,
#loginPage .medieval-btn,
#loginPage .medieval-btn-small {
    font-family: var(--ui-font);
}

.stat-item:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: #d4af37;
}

/* Recipe Dropdown Styles - FIXED Z-INDEX */
.recipe-stat {
    position: relative;
    cursor: pointer;
}

.recipe-trigger {
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}

.medieval-scroll {
    position: absolute;
    top: calc(100% + 8px);
    /* ✅ REDUCED from 10px */
    right: 0;
    width: 280px;
    /* ✅ REDUCED from 350px */
    max-height: 300px;
    /* ✅ REDUCED from 400px */
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.95), rgba(101, 67, 33, 0.95));
    border: 2px solid #d4af37;
    border-radius: 12px;
    /* ✅ REDUCED from 15px */
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.medieval-scroll.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ✅ GAME LAYOUT - ALLOW SCROLLING */
.medieval-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    /* ✅ REDUCED from 15px */
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    /* ✅ Allow grid to shrink if needed */
    padding-bottom: 10px;
    /* ✅ REDUCED from 20px */
}

/* Left Panel - Creatures (stays same width) */
.creatures-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ✅ NEW: Center Column - Stacked Sections */
.center-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* ✅ REDUCED from 15px */
    overflow-y: auto;
    padding-right: 3px;
    max-height: calc(100vh - 150px);
    /* ✅ ADJUSTED for smaller header */
}

/* Main Creature Section - Compact */
.main-creature-section {
    flex-shrink: 0;
    /* Don't shrink */
}

/* Equipment Section - Compact */
.equipped-section {
    flex-shrink: 0;
}

.equipped-section .equipped-grid {
    grid-template-columns: 1fr 1fr;
    /* Keep 2x2 grid */
}

/* Crafting Section - Takes remaining space */
.crafting-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ✅ NEW: Right Column - Resources & Artifacts Stacked */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* ✅ REDUCED from 10px */
    overflow: hidden;
}

.resources-section {
    flex: 1;
    /* Take equal space */
    min-height: 0;
    /* Allow shrinking */
}

.artifacts-section {
    flex: 1;
    /* Take equal space */
    min-height: 0;
}

/* Ensure scrollable areas work properly */
.resources-scroll,
.artifacts-scroll,
.creatures-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    /* ✅ REDUCED from 10px */
    padding-right: 8px;
}

/* Creature and Item Styles */
.draggable-item {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(39, 26, 16, 0.4));
    border: 2px solid #8b4513;
    border-radius: 8px;
    /* ✅ REDUCED from 10px */
    padding: 6px;
    /* ✅ REDUCED from 10px */
    margin-bottom: 5px;
    /* ✅ REDUCED from 8px */
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    color: #d4af37;
    touch-action: none;
    user-select: none;
    min-height: 50px;
    /* ✅ REDUCED from 80px */
    font-size: 0.8em;
    /* ✅ REDUCED */
}

.collection-item-image {
    width: 46px;
    height: 46px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 5px;
    image-rendering: pixelated;
    background: rgba(0, 0, 0, 0.18);
}

.collection-item-image.creature-image {
    width: 72px;
    height: 72px;
}

.collection-item-emoji {
    font-size: 1.2em;
    margin-bottom: 5px;
}

.collection-item-name {
    font-weight: 700;
    font-size: 0.9em;
    margin-bottom: 3px;
    line-height: 1.15;
}

.collection-item-subtext {
    font-size: 0.7em;
    opacity: 0.8;
}

.collection-item-count {
    font-size: 0.8em;
    color: #ffd700;
}

.draggable-item:hover {
    border-color: #d4af37;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.2);
}

.draggable-item:active {
    cursor: grabbing;
    transform: scale(0.95);
    transition: transform 0.1s;
}

.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* Slots and Equipment */
.medieval-slot,
.medieval-equipment-slot,
.medieval-forge-slot {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.5), rgba(39, 26, 16, 0.5));
    border: 3px dashed #8b4513;
    border-radius: 10px;
    /* ✅ REDUCED from 12px */
    padding: 8px;
    /* ✅ REDUCED from 15px */
    text-align: center;
    transition: all 0.3s ease;
    min-height: 50px;
    /* ✅ REDUCED from 90px */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8em;
    /* ✅ REDUCED */
}

/* Equipment and Crafting grids - Compact */
.equipped-grid,
.forge-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    /* ✅ REDUCED from 10px */
    margin-bottom: 8px;
    /* ✅ REDUCED from 10px */
}

/* Crafting buttons - Compact */
.forge-buttons {
    display: flex;
    gap: 5px;
    /* ✅ REDUCED from 8px */
}

/* Make Food button - Compact */
.make-food-btn {
    background: linear-gradient(145deg, #ff6347, #dc143c);
    border: 3px dashed #8b4513;
    border-radius: 10px;
    /* ✅ REDUCED from 12px */
    padding: 10px;
    /* ✅ REDUCED from 20px */
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 6px;
    /* ✅ REDUCED from 10px */
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.85em;
    /* ✅ REDUCED from 1.1em */
}

/* Creature stats - Compact */
.medieval-stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    /* ✅ REDUCED from 4px 8px */
    border-radius: 5px;
    /* ✅ REDUCED from 6px */
    margin: 3px;
    /* ✅ REDUCED from 4px */
    border: 1px solid #8b4513;
    font-size: 0.75em;
    /* ✅ REDUCED from 0.9em */
}

.creature-stats {
    display: flex;
    justify-content: center;
    gap: 5px;
    /* ✅ REDUCED from 8px */
    margin-top: 5px;
    /* ✅ REDUCED from 8px */
}

.assigned-creature-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.assigned-creature-image {
    width: 132px;
    height: 132px;
    object-fit: contain;
    image-rendering: pixelated;
}

.assigned-creature-name {
    font-weight: 700;
    font-size: 0.9em;
    line-height: 1.1;
    text-align: center;
}

/* Recipe dropdown - Compact */
.medieval-scroll {
    position: absolute;
    top: calc(100% + 8px);
    /* ✅ REDUCED from 10px */
    right: 0;
    width: 280px;
    /* ✅ REDUCED from 350px */
    max-height: 300px;
    /* ✅ REDUCED from 400px */
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.95), rgba(101, 67, 33, 0.95));
    border: 2px solid #d4af37;
    border-radius: 12px;
    /* ✅ REDUCED from 15px */
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    font-size: 0.85em;
    /* ✅ REDUCED */
}

/* Recipe items - Compact */
.recipe-item {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid #d4af37;
    border-radius: 6px;
    /* ✅ REDUCED from 8px */
    padding: 8px;
    /* ✅ REDUCED from 12px */
    margin-bottom: 6px;
    /* ✅ REDUCED from 8px */
    transition: all 0.3s ease;
}

.recipe-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    /* ✅ REDUCED from 8px */
    color: #d4af37;
    font-weight: 600;
    font-size: 0.85em;
    /* ✅ REDUCED from 0.95em */
}

.recipe-ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    /* ✅ REDUCED from 6px */
}

.ingredient {
    background: rgba(139, 69, 19, 0.6);
    padding: 3px 6px;
    /* ✅ REDUCED from 4px 8px */
    border-radius: 4px;
    /* ✅ REDUCED from 5px */
    font-size: 0.75em;
    /* ✅ REDUCED from 0.8em */
    color: #b8860b;
}

/* Ensure panels fit on screen */
.creatures-panel,
.resources-section,
.artifacts-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 150px);
    /* ✅ ADJUSTED for compact header */
}

/* Scrollable areas - Compact padding */
.resources-scroll,
.artifacts-scroll,
.creatures-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    /* ✅ REDUCED from 10px */
    padding-right: 8px;
}

/* Empty messages - Compact */
.empty-message {
    text-align: center;
    color: #b8860b;
    font-style: italic;
    padding: 10px;
    /* ✅ REDUCED from 15px */
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px dashed #8b4513;
    font-size: 0.8em;
    /* ✅ REDUCED from 0.9em */
}

/* Scrollbars */
.medieval-scroll-area::-webkit-scrollbar,
.recipe-list::-webkit-scrollbar,
.center-panel::-webkit-scrollbar,
.resources-scroll::-webkit-scrollbar,
.artifacts-scroll::-webkit-scrollbar,
.creatures-scroll::-webkit-scrollbar {
    width: 10px;
    /* ✅ Increased from 8px */
}

.medieval-scroll-area::-webkit-scrollbar-track,
.recipe-list::-webkit-scrollbar-track,
.center-panel::-webkit-scrollbar-track,
.resources-scroll::-webkit-scrollbar-track,
.artifacts-scroll::-webkit-scrollbar-track,
.creatures-scroll::-webkit-scrollbar-track {
    background: rgba(139, 69, 19, 0.3);
    border-radius: 10px;
}

.medieval-scroll-area::-webkit-scrollbar-thumb,
.recipe-list::-webkit-scrollbar-thumb,
.center-panel::-webkit-scrollbar-thumb,
.resources-scroll::-webkit-scrollbar-thumb,
.artifacts-scroll::-webkit-scrollbar-thumb,
.creatures-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(145deg, #d4af37, #b8860b);
    border-radius: 10px;
    border: 2px solid rgba(139, 69, 19, 0.5);
    /* ✅ Add border for better grip */
}

.medieval-scroll-area::-webkit-scrollbar-thumb:hover,
.recipe-list::-webkit-scrollbar-thumb:hover,
.center-panel::-webkit-scrollbar-thumb:hover,
.resources-scroll::-webkit-scrollbar-thumb:hover,
.artifacts-scroll::-webkit-scrollbar-thumb:hover,
.creatures-scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(145deg, #ffd700, #d4af37);
    /* ✅ Brighter on hover */
}

/* Teacher Login Tab Styles */
.login-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #8b4513;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-bottom: 3px solid transparent;
    color: #f3e6c5;
    font-family: var(--ui-font);
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: var(--text-outline);
}

.tab-link {
    text-decoration: none;
}

.tab-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    color: #d4af37;
}

.tab-btn.active {
    background: rgba(212, 175, 55, 0.2);
    border-bottom-color: #d4af37;
    color: #d4af37;
    font-weight: 600;
    text-shadow: var(--text-outline);
}

.teacher-link {
    color: #d4af37;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.teacher-link:hover {
    color: #ffd700;
    text-decoration: underline;
}

/* Shake animation for invalid drops */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* Progress Modal Styles - UPDATED */
.progress-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10003;
    padding: 20px;
}

.progress-modal.active {
    display: flex;
}

.progress-container {
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.95), rgba(101, 67, 33, 0.95));
    border: 3px solid #d4af37;
    border-radius: 15px;
    padding: 20px;
    max-width: 700px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.progress-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #8b4513;
}

.progress-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.summary-stat {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.summary-icon {
    font-size: 2.5em;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #d4af37;
    margin: 5px 0;
}

.summary-label {
    font-size: 0.85em;
    color: #b8860b;
}

.progress-category {
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid #8b4513;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.category-header {
    font-size: 1.3em;
    font-weight: bold;
    color: #d4af37;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(212, 175, 55, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-count {
    font-size: 0.7em;
    opacity: 0.8;
    font-weight: normal;
}

.challenge-item {
    background: rgba(0, 0, 0, 0.3);
    border-left: 4px solid #d4af37;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.challenge-item:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translateX(5px);
}

.challenge-item.perfect {
    border-left-color: #32cd32;
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.challenge-name {
    font-size: 1.05em;
    font-weight: 600;
    color: #d4af37;
}

.challenge-date {
    font-size: 0.8em;
    color: #b8860b;
    font-style: italic;
}

.lives-bar-container {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    height: 30px;
    overflow: hidden;
    position: relative;
    border: 2px solid rgba(139, 69, 19, 0.5);
}

.lives-bar {
    height: 100%;
    display: flex;
    transition: all 0.5s ease;
}

.lives-segment {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    font-weight: bold;
    transition: all 0.3s ease;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
}

.lives-segment:last-child {
    border-right: none;
}

.lives-segment.survived {
    background: linear-gradient(135deg, #32cd32 0%, #228b22 100%);
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.lives-segment.lost {
    background: linear-gradient(135deg, #dc143c 0%, #8b0000 100%);
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.lives-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9em;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 1;
}

.empty-progress {
    text-align: center;
    padding: 40px 20px;
    color: #b8860b;
}

.empty-progress-icon {
    font-size: 4em;
    margin-bottom: 15px;
    opacity: 0.6;
}

.empty-progress p {
    font-size: 1.1em;
    margin: 10px 0;
}

/* Scrollbar for progress content */
.progress-container::-webkit-scrollbar {
    width: 10px;
}

.progress-container::-webkit-scrollbar-track {
    background: rgba(139, 69, 19, 0.3);
    border-radius: 10px;
}

.progress-container::-webkit-scrollbar-thumb {
    background: linear-gradient(145deg, #d4af37, #b8860b);
    border-radius: 10px;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .medieval-layout {
        grid-template-columns: 1fr;
        gap: 15px;
        /* ✅ Increased spacing */
    }

    .center-column,
    .right-column {
        max-height: none;
        /* ✅ Remove height restrictions on mobile */
        overflow-y: visible;
    }

    .creatures-panel,
    .resources-section,
    .artifacts-section {
        max-height: none;
        /* ✅ Allow natural height on mobile */
    }

    #dashboardPage {
        padding: 15px 10px 30px 10px;
        /* ✅ Adjust padding for mobile */
    }

    .medieval-scroll {
        width: 300px;
        right: -50px;
    }
}

@media (max-width: 768px) {
    #dashboardPage {
        padding: 10px 5px 25px 5px;
        /* ✅ Even more compact on small screens */
    }

    .medieval-layout {
        gap: 12px;
    }

    .medieval-header {
        padding: 15px;
        margin-bottom: 15px;
    }

    .medieval-stats {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 10px;
    }

    .medieval-scroll {
        width: 280px;
        right: -100px;
    }

    .equipped-grid,
    .forge-grid {
        grid-template-columns: 1fr;
    }

    .forge-buttons {
        flex-direction: column;
        gap: 6px;
    }

    .draggable-item {
        padding: 12px;
        margin-bottom: 10px;
        min-height: 70px;
    }

    .medieval-slot,
    .medieval-equipment-slot,
    .medieval-forge-slot {
        min-height: 80px;
        padding: 12px;
    }

    .medieval-btn {
        padding: 15px 25px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    #dashboardPage {
        padding: 10px 5px 20px 5px;
    }

    .medieval-scroll {
        width: 250px;
        right: -80px;
    }

    .medieval-title {
        font-size: 1.8em;
    }

    .card {
        padding: 25px 15px;
    }
}

/* ✅ Better touch handling for tablets */
.student-card {
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: rgba(212, 175, 55, 0.3);
    /* Show tap feedback */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    /* Prevent long-press menu */
}

.student-card:active {
    transform: scale(0.98);
    background: rgba(212, 175, 55, 0.2);
}

/* Make sure popup is above everything */
.student-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.student-popup-overlay.active {
    display: flex !important;
    /* Force display */
}

/* ===== TAP-TO-SELECT SYSTEM ===== */

/* Selected item glow */
.draggable-item.selected {
    border-color: #32cd32;
    background: rgba(50, 205, 50, 0.2);
    box-shadow: 0 0 20px rgba(50, 205, 50, 0.5);
    transform: scale(1.05);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(50, 205, 50, 0.5);
    }

    50% {
        box-shadow: 0 0 30px rgba(50, 205, 50, 0.8);
    }
}

/* Valid drop zone highlighting */
.drop-zone.valid-target {
    border-color: #32cd32 !important;
    background: rgba(50, 205, 50, 0.2) !important;
    box-shadow: 0 0 20px rgba(50, 205, 50, 0.4) !important;
    animation: glow 1s infinite;
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(50, 205, 50, 0.4);
    }

    50% {
        box-shadow: 0 0 30px rgba(50, 205, 50, 0.6);
    }
}

/* Make Food Button */
.make-food-btn {
    background: linear-gradient(145deg, #ff6347, #dc143c);
    border: 3px dashed #8b4513;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 1.1em;
}

.make-food-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 20, 60, 0.4);
}

.make-food-btn.valid-target {
    border-color: #32cd32 !important;
    border-style: solid !important;
    background: linear-gradient(145deg, rgba(50, 205, 50, 0.3), rgba(34, 139, 34, 0.3)) !important;
    box-shadow: 0 0 25px rgba(50, 205, 50, 0.6) !important;
    animation: glow 1s infinite;
}

/* Larger tap targets for mobile */
.draggable-item {
    min-height: 80px;
    padding: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(50, 205, 50, 0.3);
}

/* Invalid target feedback */
.drop-zone.invalid-shake {
    animation: shake 0.5s;
}