@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Uncial+Antiqua&display=swap');

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cinzel', serif;
    background: linear-gradient(135deg, #2c1810 0%, #1a0f0a 50%, #0d0705 100%);
    background-attachment: fixed;
    color: #f4e4bc;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(139, 69, 19, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(101, 67, 33, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(160, 82, 45, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* ============================================
   LAYOUT & CONTAINERS
   ============================================ */
.page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 95%;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4 {
    font-family: 'Uncial Antiqua', cursive;
    color: #d4af37;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

h1 { font-size: 2em; }
h2 { font-size: 1.5m; }
h3 { font-size: 1em; }
h4 { font-size: 0.8em; }

.subtitle {
    color: #cd853f;
    font-style: italic;
    font-size: 1.2em;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.8), rgba(101, 67, 33, 0.8));
    padding: 20px;
    border-radius: 15px;
    border: 3px solid #8b4513;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

header h1 {
    color: #d4af37;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.9);
    letter-spacing: 2px;
}

.player-info {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    gap: 20px;
    align-items: center;
    font-weight: 600;
    padding: 10px;
}

.player-info span,
.player-info a {
    background: rgba(0,0,0,0.4);
    padding: 8px 15px;
    border-radius: 20px;
    border: 2px solid #8b4513;
    color: #fff;
    text-decoration: none;
    white-space: nowrap; /* Prevent text wrapping in buttons */
}

.player-info a:hover {
    background: rgba(0,0,0,0.6);
    transition: background 0.2s ease;
}

/* Responsive behavior on smaller screens */
@media (max-width: 600px) {
    .player-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .player-info span,
    .player-info a {
        width: 100%;
        box-sizing: border-box;
        text-align: left;
    }
}


/* ============================================
   NAVIGATION & LINKS
   ============================================ */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

nav a, .logout, .back-link {
    color: #cd853f;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 15px;
    background: rgba(139, 69, 19, 0.6);
    border-radius: 20px;
    border: 2px solid #8b4513;
    transition: all 0.3s ease;
}

nav a:hover, .logout:hover, .back-link:hover {
    background: rgba(139, 69, 19, 0.9);
    color: #d4af37;
    text-decoration: none;
}

.player-link {
    color: #d4af37;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.player-link:hover {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* ============================================
   MESSAGES & ALERTS
   ============================================ */
.message {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    font-weight: bold;
    text-align: center;
    border: 2px solid;
    transition: opacity 0.3s ease;
}

.message.success {
    background: linear-gradient(135deg, rgba(34, 139, 34, 0.8), rgba(0, 100, 0, 0.8));
    color: #90EE90;
    border-color: #228B22;
}

.message.error {
    background: linear-gradient(135deg, rgba(139, 34, 34, 0.8), rgba(100, 0, 0, 0.8));
    color: #FFB6C1;
    border-color: #8B2222;
}

.message.info {
    background: rgba(70, 130, 180, 0.2);
    border: 2px solid #4682B4;
    color: #87CEEB;
}

/* ============================================
   FORMS & INPUTS
   ============================================ */
.auth-forms {
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: flex-start;
}

.form-section, .auth-container {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.6), rgba(101, 67, 33, 0.6));
    padding: 40px;
    border-radius: 20px;
    border: 3px solid #8b4513;
    backdrop-filter: blur(10px);
    min-width: 320px;
    box-shadow: 0 0 30px rgba(0,0,0,0.7);
}

.form-section h2, .auth-form h2 {
    margin-bottom: 25px;
    text-align: center;
    font-size: 1.8em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #d4af37;
    font-weight: bold;
}

input[type="text"], 
input[type="password"], 
input[type="email"], 
textarea, 
select {
    width: 250px;
    padding: 12px;
    background: rgba(244, 228, 188, 0.9);
    border: 2px solid #8b4513;
    border-radius: 10px;
    color: #2c1810;
    font-size: 16px;
    font-family: 'Cinzel', serif;
}

input:focus, 
textarea:focus, 
select:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #cd853f;
    font-size: 0.9em;
    font-style: italic;
}

/* ============================================
   BUTTONS
   ============================================ */
button, 
.btn, 
.submit-btn,
.action-btn,
.battle-btn,
.buy-btn,
.sell-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #8b4513, #654321);
    color: #f4e4bc;
    border: 2px solid #d4af37;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled),
.action-btn:hover:not(:disabled),
.battle-btn:hover:not(:disabled),
.buy-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #a0522d, #8b4513);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
}

button:disabled,
.btn:disabled {
    background: linear-gradient(135deg, #555, #444);
    border-color: #666;
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
    filter: grayscale(50%);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Button Variants */
.action-btn.dungeon, .battle-btn.attack {
    background: linear-gradient(135deg, #8b0000, #654321);
    border-color: #dc143c;
}

.action-btn.shop, .buy-btn, .heal-btn {
    background: linear-gradient(135deg, #228b22, #006400);
    border-color: #32cd32;
}

.heal-btn {  
    display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;  }

.action-btn.arena {
    background: linear-gradient(135deg, #8b008b, #4b0082);
    border-color: #9370db;
}

.sell-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.battle-btn.flee {
    background: linear-gradient(135deg, #8b4513, #a0522d);
    border-color: #cd853f;
}

.battle-btn.continue {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-color: #66cc00;
}

/* ============================================
   GAME LAYOUT
   ============================================ */
.game-layout {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 25px;
    margin-bottom: 30px;
}

.stats-panel, 
.main-panel, 
.inventory-panel,
.profile-card,
.equipment-section,
.inventory-section,
.battle-history-section,
.spellbook-section {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.7), rgba(101, 67, 33, 0.7));
    border-radius: 15px;
    padding: 25px;
    border: 3px solid #8b4513;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.stats-panel h2, 
.main-panel h2, 
.inventory-panel h2,
.equipment-section h2,
.inventory-section h2,
.battle-history-section h2,
.spellbook-section h2 {
    margin-bottom: 20px;
    color: #d4af37;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 10px;
}

/* ============================================
   STATS & INFO BOXES
   ============================================ */
.stat-group, 
.game-info, 
.tips,
.bonus-breakdown,
.sell-info {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 1px solid #8b4513;
}

  .bonus-source {
        margin-bottom: 5px;
        padding-left: 5px;
        color: #cd853f;
        font-size: 0.8em;
    }

.stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
    font-size: 0.8em;
}

.stat:last-child {
    border-bottom: none;
}

.stat span {
    font-weight: bold;
}

.health { color: #dc143c; }
.mana { color: #4169e1; }
.gold { color: #ffd700; }

.stat.has-bonus {
    color: #90EE90;
    font-weight: bold;
}

.bonus-indicator {
    color: #ffd700;
    font-size: 0.9em;
    margin-left: 5px;
    font-weight: bold;
}

.stat-badge {
    display: inline-block;
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #2c1810;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

/* ============================================
   HEALTH & MANA BARS
   ============================================ */
.health-bar, .mana-bar {
    background: rgba(0,0,0,0.5);
    height: 25px;
    border-radius: 12px;
    position: relative;
    margin-bottom: 12px;
    overflow: hidden;
    border: 2px solid #8b4513;
}

.health-fill {
    background: linear-gradient(90deg, #dc143c, #8b0000);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.mana-fill {
    background: linear-gradient(90deg, #4169e1, #191970);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.health-text, .mana-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    font-size: 0.9em;
}

/* ============================================
   INVENTORY & ITEMS
   ============================================ */
.inventory-grid, .items-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
}

.items-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.inventory-item, .shop-item {
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #8b4513;
    position: relative;
    transition: all 0.3s ease;
}

.inventory-item:hover, .shop-item:hover {
    background: rgba(0,0,0,0.6);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
}

/* Rarity Colors */
.common { border-left: 4px solid #8b4513; }
.uncommon { border-left: 4px solid #228b22; }
.rare { border-left: 4px solid #4169e1; }
.epic { border-left: 4px solid #8b008b; }
.legendary { border-left: 4px solid #ffd700; }

.inventory-item.equipped,
.shop-item.equipped {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
    border-color: #d4af37;
}

.inventory-item.enchanted {
    border-color: #ff69b4;
    background: rgba(255, 105, 180, 0.05);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.item-name {
    font-weight: bold;
    color: #f4e4bc;
}

.item-type {
    font-size: 0.9em;
    color: #cd853f;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.item-stats {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.item-stats span {
    display: inline-block;
    background: rgba(0,0,0,0.3);
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.9em;
    cursor: help;
    position: relative;
}

.stat-bonus {
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.85em;
    font-weight: bold;
}

.stat-bonus.positive {
    background: rgba(34, 139, 34, 0.3);
    color: #90EE90;
}

.stat-bonus.negative {
    background: rgba(139, 34, 34, 0.3);
    color: #FFB6C1;
}

.stat-bonus.restore {
    background: rgba(65, 105, 225, 0.3);
    color: #87CEEB;
}

.enchanted-stat {
    color: #ff69b4 !important;
}

.enchanted-stat small {
    color: #ffd700;
    font-size: 0.7em;
}

/* ============================================
   BADGES
   ============================================ */
.equipped-badge,
.misc-badge,
.enchanted-badge,
.you-badge {
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 8px;
    display: inline-block;
}

.equipped-badge, .you-badge {
    background: linear-gradient(135deg, #ffd700, #daa520);
    color: #2c1810;
}

.misc-badge {
    background: linear-gradient(135deg, #9370db, #8a2be2);
    color: white;
}

.enchanted-badge {
    background: linear-gradient(135deg, #ff1493, #ff69b4);
    color: white;
    animation: shimmer 2s infinite;
}

/* ============================================
   BATTLE LAYOUT
   ============================================ */
.battle-layout {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.battle-side {
    text-align: center;
}

.character-card {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.8), rgba(101, 67, 33, 0.8));
    border-radius: 15px;
    padding: 25px;
    border: 3px solid #8b4513;
    box-shadow: 0 0 25px rgba(0,0,0,0.6);
    text-align: center;
}

.character-level {
    color: #d4af37;
    font-weight: bold;
    margin-bottom: 15px;
    font-style: italic;
}

.character-stats {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
}

.stat-item {
    background: rgba(0,0,0,0.4);
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid #8b4513;
    font-weight: bold;
    color: #f4e4bc;
    cursor: help;
}

.battle-center {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.battle-form {
    display: flex;
    justify-content: center; /* centers items horizontally */
    gap: 10px;
}


.battle-log {
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #8b4513;
    flex-grow: 1;
}

.log-entries {
    text-align: left;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #8b4513;
}

.log-entry {
    padding: 8px 0;
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
    line-height: 1.4;
    color: #f4e4bc;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.initial {
    color: #d4af37;
    font-style: italic;
    text-align: center;
}

.log-entry.victory {
    background: rgba(34, 139, 34, 0.2);
    padding: 5px 10px;
    border-radius: 5px;
    border-left: 3px solid #228b22;
}

.log-entry.defeat {
    background: rgba(139, 34, 34, 0.2);
    padding: 5px 10px;
    border-radius: 5px;
    border-left: 3px solid #dc143c;
}

/* ============================================
   SHOP LAYOUT
   ============================================ */
.shop-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 25px;
}

.shop-nav {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.7), rgba(101, 67, 33, 0.7));
    border-radius: 15px;
    padding: 20px;
    border: 3px solid #8b4513;
    height: fit-content;
}

.shop-nav ul {
    list-style: none;
    margin-bottom: 25px;
}

.shop-nav li {
    margin-bottom: 8px;
}

.shop-nav a {
    color: #f4e4bc;
    text-decoration: none;
    padding: 10px 15px;
    display: block;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.shop-nav a:hover, .shop-nav a.active {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
    color: #d4af37;
}

.shop-content {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.7), rgba(101, 67, 33, 0.7));
    border-radius: 15px;
    padding: 25px;
    border: 3px solid #8b4513;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ============================================
   PROFILE LAYOUT
   ============================================ */
.profile-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
}

.profile-column, .items-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-avatar {
    font-size: 4em;
    margin-bottom: 15px;
}

.profile-name {
    font-size: 2em;
    margin-bottom: 10px;
    color: #d4af37;
    font-family: 'Uncial Antiqua', cursive;
}

.profile-title {
    color: #d4af37;
    font-weight: bold;
    margin-bottom: 20px;
    font-size: 1.1em;
}

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}

.profile-stat {
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #8b4513;
    text-align: center;
    position: relative;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(212, 175, 55, 0.5); }
    50% { box-shadow: 0 0 20px rgba(212, 175, 55, 0.8); }
    100% { box-shadow: 0 0 5px rgba(212, 175, 55, 0.5); }
}

@keyframes shimmer {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.reward-item.loot {
    animation: glow 2s infinite;
}

.enchant-glow {
    display: inline-block;
    animation: glow 2s infinite;
}

/* ============================================
   TABLES
   ============================================ */
.players-table-container {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid #8b4513;
}

.players-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Cinzel', serif;
}

.players-table th {
    background: rgba(139, 69, 19, 0.8);
    color: #d4af37;
    padding: 12px 8px;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid #8b4513;
    white-space: nowrap;
}

.players-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
    vertical-align: middle;
}

.players-table tr:hover {
    background: rgba(212, 175, 55, 0.1);
}

.current-player-row {
    background: rgba(212, 175, 55, 0.2) !important;
    border: 2px solid #d4af37;
}

/* ============================================
   SPECIAL SECTIONS
   ============================================ */
.victory-screen, .defeat-screen {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.9), rgba(101, 67, 33, 0.9));
    border-radius: 20px;
    padding: 40px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    border: 3px solid #d4af37;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
}

.defeat-screen {
    border-color: #dc143c;
    box-shadow: 0 0 30px rgba(220, 20, 60, 0.5);
}

.highscores-section, 
.players-section {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.7), rgba(101, 67, 33, 0.7));
    border-radius: 15px;
    padding: 25px;
    border: 3px solid #8b4513;
    margin-top: 20px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.highscores-header, 
.players-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.3s ease;
}

.highscores-header:hover, 
.players-header:hover {
    background: rgba(0,0,0,0.3);
}

.highscores-content, 
.players-content {
    display: none;
    animation: slideDown 0.3s ease;
}

.highscores-content.active, 
.players-content.active {
    display: block;
}

/* ============================================
   FOOTER
   ============================================ */
.game-footer {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.9), rgba(101, 67, 33, 0.9));
    border-top: 3px solid #8b4513;
    padding: 30px 20px;
    margin-top: 50px;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    margin-bottom: 15px;
}

.footer-link {
    color: #cd853f;
    text-decoration: none;
    padding: 0 10px;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: #d4af37;
}

.footer-separator {
    color: #8b4513;
    margin: 0 5px;
}

.footer-copyright {
    color: #cd853f;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.footer-made-by {
    color: #f4e4bc;
    font-size: 0.9em;
}

.yasa-link {
    color: #d4af37;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
}

.yasa-link:hover {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* ============================================
   CUSTOM SCROLLBARS
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #8b4513;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #d4af37;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }

.empty-section, .empty-inventory {
    text-align: center;
    color: #cd853f;
    font-style: italic;
    padding: 40px 20px;
}

.gold-display {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.2em;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .game-layout,
    .battle-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .shop-layout,
    .profile-layout {
        grid-template-columns: 1fr;
    }
    
    .profile-stats {
        grid-template-columns: 1fr 1fr;
    }
    
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .shop-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    /* Typography */
    h1 { font-size: 2em; }
    h2 { font-size: 1.5em; }
    h3 { font-size: 1.2em; }
    
    /* Container */
    .container {
        padding: 10px;
    }
    
    /* Header */
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    /* Forms */
    .auth-forms {
        flex-direction: column;
        align-items: center;
    }
    
    /* Game Layout */
    .action-row {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn {
        max-width: 300px;
        width: 100%;
        padding: 15px 10px;
        font-size: 0.9em;
    }
    
    /* Battle */
    .battle-form {
        flex-direction: column;
    }
    
    .battle-btn {
        padding: 12px;
        font-size: 1em;
    }
    
    /* Tables */
    .players-table {
        font-size: 0.8em;
    }
    
    .players-table th,
    .players-table td {
        padding: 5px;
    }
    
    /* Hide some columns on mobile */
    .monsters-cell,
    .gold-cell {
        display: none;
    }
    
    /* Profiles & Stats */
    .profile-stats {
        grid-template-columns: 1fr;
    }
    
    .items-grid,
    .shop-grid {
        grid-template-columns: 1fr;
    }
    
    /* Players controls */
    .players-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sort-controls, 
    .search-controls {
        justify-content: space-between;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
    }
    
    /* Filters */
    .inventory-filters {
        justify-content: center;
    }
    
    .filter-btn {
        font-size: 0.8em;
        padding: 4px 8px;

    }
    
    /* Features */
    .features {
        grid-template-columns: 1fr;
    }
    
    /* Footer */
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .footer-separator {
        display: none;
    }
    
    /* Highscores */
    .highscore-item {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .highscore-stats {
        justify-content: center;
    }
    
    /* Chronicle rewards */
    .chronicle-rewards {
        flex-direction: column;
        gap: 8px;
    }
}

/* ============================================
   ADDITIONAL COMPONENTS
   ============================================ */

.feature {
    background: rgba(139, 69, 19, 0.3);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #8b4513;
    transition: all 0.3s ease;
}

    .feature:hover {
        transform: translateY(-3px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    }

    .feature h4 {
        color: #d4af37;
        margin-bottom: 10px;
    }

    .feature-stat {
        margin-top: 12px;
        padding: 6px 12px;
        background: rgba(0,0,0,0.3);
        border-radius: 15px;
        color: #ffd700;
        font-size: 0.9em;
        font-weight: bold;
        display: inline-block;
    }

/* Action Row */
.action-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 20px;
    min-height: 100px;
    width: 200px;
    justify-content: center;
}

.action-btn small {
    font-size: 0.8em;
    opacity: 0.8;
    font-style: italic;
}

/* Buildings */
.buildings-row {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #8b4513;
}

.building-wrapper {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 200px;
}

.action-btn.gold-mine {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-color: #FFD700;
    color: #2c1810;
}

.action-btn.temple {
    background: linear-gradient(135deg, #87CEEB, #4682B4);
    border-color: #87CEEB;
}

.mage-tower-content {
        background: linear-gradient(135deg, rgba(139, 69, 19, 0.7), rgba(101, 67, 33, 0.7));
        border-radius: 15px;
        padding: 30px;
        margin-top: 20px;
        border: 3px solid #8b4513;
}

.action-btn.mage-tower {
    background: linear-gradient(135deg, #9370DB, #4B0082);
    border-color: #9370DB;
}

.action-btn.maxed {
    background: linear-gradient(135deg, #696969, #2F4F4F);
    border-color: #808080;
}

/* Warnings */
.combat-warning {
    margin: 20px 0;
}

.warning-box, .death-warning {
    background: rgba(0,0,0,0.4);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #dc143c;
}

.death-warning {
    border-color: #ffa500;
}

.toggle-btn {
    cursor: pointer;
    margin: 0;
    padding: 0;
    font-size: 1.1rem;
    color: inherit; /* Keep same color as heading */
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.toggle-btn:hover {
    text-decoration: underline;
}

.expand-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.expandable.open .expand-content {
    max-height: 1000px;
    margin-top: 10px;
}


.warning-box h4, .death-warning h4 {
    color: #dc143c;
    margin-bottom: 10px;
}

.death-warning h4 {
    color: #ffa500;
}

/* Spell Cards */
.spell-book-grid, .spell-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}



.spell-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.spell-tier {
    margin-bottom: 30px;
}

.spell-tier h3 {
    color: #d4af37;
    text-align: center;
    margin-bottom: 20px;
}

.spell-card {
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #8b4513;
    text-align: center;
    position: relative;
}

.spell-card.damage {
    border-color: #dc143c;
    background: rgba(220, 20, 60, 0.1);
}

.spell-card.healing {
    border-color: #228b22;
    background: rgba(34, 139, 34, 0.1);

}
}

.spell-card.debuff {
    border-color: #4169e1;
    background: rgba(65, 105, 225, 0.1);

}

    .spell-item.damage {
        border-color: #dc143c;
        text-align: center;
}
    

    .spell-item.healing {
        border-color: #228b22;
        text-align: center;
    }

    .spell-item.debuff {
        border-color: #4169e1;
        text-align: center;
    }

    .spell-item h4 {
        color: #d4af37;
        margin-bottom: 10px;
    }

    .spell-item p {
        color: #f4e4bc;
        margin-bottom: 15px;
        font-size: 0.9em;
    }

    .spell-price {
        color: #ffd700;
        font-weight: bold;
        margin-bottom: 10px;
    }

    .owned-count {
        color: #90EE90;
        font-weight: bold;
        margin-bottom: 10px;
    }

    .spell-item button, .equipment-card button {
        width: 100%;
        padding: 10px;
        background: linear-gradient(135deg, #8b4513, #654321);
        color: #f4e4bc;
        border: 2px solid #cd853f;
        border-radius: 5px;
        cursor: pointer;
        font-weight: bold;
        transition: all 0.3s ease;
    }

    .spell-item button:hover:not(:disabled), .equipment-card button:hover:not(:disabled) {
        background: linear-gradient(135deg, #a0522d, #8b4513);
        box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    }

    .spell-item button:disabled, .equipment-card button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .enchantment-section {
        margin-top: 40px;
    }

    .enchantment-section h2 {
        color: #ff69b4;
        text-align: center;
        margin-bottom: 10px;
    }

.spell-quantity {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(212, 175, 55, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    color: #ffd700;
}

/* Tab Navigation */
.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #8b4513;
    color: #f4e4bc;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    font-family: 'Cinzel', serif;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(139, 69, 19, 0.5);
}

.tab-btn.active {
    background: linear-gradient(135deg, #8b4513, #654321);
    border-color: #d4af37;
    color: #d4af37;
}

/* Chronicle Entry */
.chronicle-entry {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #8b4513;
    margin-bottom: 15px;
}

.chronicle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chronicle-result.victory {
    color: #90EE90;
}

.chronicle-result.defeat {
    color: #ff6b6b;
}

/* Modal */
.battle-log-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.95), rgba(101, 67, 33, 0.95));
    margin: 50px auto;
    padding: 30px;
    width: 80%;
    max-width: 800px;
    border-radius: 15px;
    border: 3px solid #8b4513;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-modal {
    background: none;
    border: none;
    color: #f4e4bc;
    font-size: 1.5em;
    cursor: pointer;
}

/* Status Effects */
.status-effects {
    margin-top: 15px;
    text-align: center;
}

.status-effect {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: bold;
}

.status-effect.frozen {
    background: rgba(65, 105, 225, 0.2);
    border: 1px solid #4169e1;
    color: #87ceeb;
    animation: pulse-frozen 2s infinite;
}

@keyframes pulse-frozen {
    0% { box-shadow: 0 0 5px rgba(65, 105, 225, 0.5); }
    50% { box-shadow: 0 0 15px rgba(65, 105, 225, 0.8); }
    100% { box-shadow: 0 0 5px rgba(65, 105, 225, 0.5); }
}

/* Equipment */
.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.equipment-card {
    background: rgba(0,0,0,0.4);
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

/* Progress Bar */
.progress-bar {
    background: rgba(0,0,0,0.5);
    height: 8px;
    border-radius: 4px;
    margin: 5px 0 15px 0;
    overflow: hidden;
    border: 1px solid #8b4513;
}

.progress-fill {
    background: linear-gradient(90deg, #d4af37, #ffd700);
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Loading State */
.battle-loading {
    text-align: center;
    padding: 40px;
    color: #d4af37;
}

.battle-loading::after {
    content: "";
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* Lists */
ul {
    list-style: none;
    padding-left: 0;
}

li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

li::before {
    content: "";
    position: absolute;
    left: 0;
    color: #d4af37;
}

/* Pagination */
.pagination-controls {
    margin-top: 20px;
    text-align: center;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.page-btn {
    background: rgba(139, 69, 19, 0.6);
    color: #f4e4bc;
    border: 1px solid #8b4513;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
}

.page-btn:hover {
    background: rgba(139, 69, 19, 0.9);
    border-color: #d4af37;
}

.page-btn.active {
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #2c1810;
    border-color: #d4af37;
    font-weight: bold;
}

/* Final Fixes */
.duel-btn {
    background: linear-gradient(135deg, #8b0000, #654321);
    border: 2px solid #dc143c;
    font-size: 0.85em;
}

.profile-btn {
    background: linear-gradient(135deg, #4b0082, #6a5acd);
    border-color: #9370db;
}

.spell-btn, .potion-btn {
    background: linear-gradient(135deg, #8b008b, #4b0082);
    color: #f4e4bc;
    border: 1px solid #9370db;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
}

.spell-btn small, .potion-btn small {
    display: block;
    font-size: 0.8em;
    opacity: 0.8;
}

.battle-header-info {
    text-align: center;
    color: #d4af37;
    font-weight: bold;
    margin-top: 10px;
}

.turn-indicator {
    text-align: center;
    font-size: 1.2em;
    color: #d4af37;
    margin-bottom: 15px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

.combat-power-display, .combat-power {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    color: #d4af37;
    text-align: center;
    font-weight: bold;
    border: 1px solid #8b4513;
}

.tower-upgrade-section {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: center;
    border: 2px solid #ffd700;
}

.reward-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
}

.reward-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 10px;
    font-size: 1.2em;
}

.reward-item.level-up {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 140, 0, 0.2));
    border: 2px solid #ffd700;
    animation: glow 2s infinite;
}

.reward-icon {
    font-size: 1.5em;
}

.dynamic-rewards-preview {
    background: rgba(212, 175, 55, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #8b4513;
}

.battle-tips {
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #8b4513;
}

.spell-section, .potion-section {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    border: 1px solid #8b4513;
}

.spell-grid, .potion-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.update-prefix-btn {
    background: linear-gradient(135deg, #d4af37, #ffd700);
    color: #2c1810;
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.update-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    transition: all 0.3s ease;
}

.duel-notice {
    color: #d4af37;
    font-weight: bold;
    font-size: 0.9em;
    margin-top: 5px;
    text-align: center;
}

.opponent-equipment {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

.equipped-item {
    font-size: 0.8em;
    margin-bottom: 3px;
    color: #cd853f;
}

.equipped-item.enchanted {
    color: #ff69b4;
}

.enchant-indicator {
    color: #ffd700;
    animation: shimmer 2s infinite;
}

.equipped-item.misc {
    color: #9370db;
    font-style: italic;
}

.building-info {
    text-align: center;
    font-size: 0.8em;
    color: #cd853f;
    font-style: italic;
}

.gold-timer {
    font-size: 0.8em;
    color: #ffd700;
    text-align: center;
    margin-top: 5px;
    background: rgba(0,0,0,0.3);
    padding: 3px 8px;
    border-radius: 5px;
}

.timer-display {
    font-weight: bold;
    color: #fff;
}

.quantity {
    text-align: center;
    color: #d4af37;
    font-weight: bold;
    margin-bottom: 10px;
    background: rgba(0,0,0,0.2);
    padding: 5px;
    border-radius: 5px;
}

.price {
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 10px;
}

.price small {
    display: block;
    color: #cd853f;
    font-size: 0.8em;
    margin-top: 2px;
}

.item-description {
    font-size: 0.9em;
    color: #cd853f;
    margin: 15px 0;
    font-style: italic;
    line-height: 1.4;
}

.spell-details {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 10px 0;
}

.spell-details span {
    background: rgba(0,0,0,0.3);
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.8em;
}

.spell-usage {
    margin-top: 10px;
    font-style: italic;
    color: #cd853f;
}

.rarity {
    font-size: 0.8em;
    padding: 4px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: bold;
    background: rgba(0,0,0,0.3);
}

.category-notice {
    background: rgba(212, 175, 55, 0.2);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #d4af37;
    text-align: center;
    border: 1px solid #d4af37;
}

.description-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.char-count {
    font-size: 0.8em;
    color: #cd853f;
}

.profile-description {
    font-style: italic;
    color: #cd853f;
    line-height: 1.4;
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #8b4513;
}

.chronicle-rewards {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chronicle-reward {
    background: rgba(212, 175, 55, 0.1);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.9em;
}

.chronicle-loot {
    color: #ffd700;
    font-style: italic;
}

#login-tab, #register-tab {
  display: flex;
  justify-content: center; /* horizontal */
  align-items: center;     /* vertical */
  flex-direction: column;  /* stack children vertically */
  text-align: center;
  height: 100%;            /* make sure parent has height */
}
