:root {
    --bg-dark: #07050d;
    --bg-gradient: linear-gradient(135deg, #151025, #080612);
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.5);
    --purple: #8b3dff;
    --purple-glow: rgba(139, 61, 255, 0.4);
    --text-main: #e0e0e0;
    --text-muted: #999;
    --border-glass: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(20, 15, 30, 0.6);
    --red-alert: #ff4757;

    --c-inf: #e74c3c;
    --c-cav: #3498db;
    --c-art: #2ecc71;
    --c-siege: #9b59b6;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-gradient);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    background-attachment: fixed;
}

h1,
h2,
h3,
.tab-btn,
.epic-btn,
.troop-icon {
    font-family: 'Cinzel', serif;
}

h1 {
    font-size: 2.2rem;
    color: var(--gold);
    text-align: center;
    text-shadow: 0 0 10px var(--gold-glow);
    margin-bottom: 5px;
}

h2 {
    color: var(--gold);
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 10px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.nav-bar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.back-link {
    color: var(--gold);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
    background: rgba(255, 215, 0, 0.1);
    padding: 8px 15px;
    border-radius: 50px;
    border: 1px solid transparent;
}

.back-link:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

header p {
    color: var(--purple);
    font-style: italic;
}

@media (max-width: 600px) {
    .nav-bar {
        justify-content: center;
    }
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
}

/* Glassmorphism Cards */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* Form Inputs */
.input-group-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: bold;
}

input[type="number"],
select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

input[type="number"]:focus,
select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

.input-group small {
    font-size: 0.8rem;
    color: var(--purple);
    margin-top: 5px;
}

/* Troops Input */
.troops-container {
    display: flex;
    gap: 15px;
}

.troop-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-glass);
}

.troop-infantry {
    border-top: 3px solid var(--c-inf);
}

.troop-cavalry {
    border-top: 3px solid var(--c-cav);
}

.troop-artillery {
    border-top: 3px solid var(--c-art);
}

.troop-siege {
    border-top: 3px solid var(--c-siege);
}

.troop-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.troop-input label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.troop-input input {
    width: 100%;
    text-align: center;
}

.troop-qty-input {
    width: 100%;
    max-width: 80px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-glass);
    color: #fff;
    border-radius: 5px;
    font-size: 1rem;
    text-align: center;
    margin: 0 auto;
    display: block;
}

.troop-qty-input:focus {
    outline: none;
    border-color: var(--gold);
}

@media (max-width: 600px) {

    .troops-table th,
    .troops-table td {
        padding: 4px;
        font-size: 0.85rem;
    }

    .troops-table img {
        width: 20px !important;
        margin-right: 4px !important;
    }

    .troop-qty-input {
        max-width: 55px;
        font-size: 0.85rem;
        padding: 5px;
    }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-glass);
    color: #aaa;
    padding: 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s;
}

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

.tab-btn.active {
    background: var(--purple);
    color: white;
    border-color: var(--purple);
    box-shadow: 0 0 15px var(--purple-glow);
}

.tab-content {
    display: none;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 8px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Heroes Grid */
.heroes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    justify-items: center;
}

.hero-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
    width: 80px;
}

.hero-item:hover {
    transform: scale(1.05);
}

.hero-img-box {
    width: 60px;
    height: 60px;
    border-radius: 5px;
    border: 2px solid #555;
    overflow: hidden;
    margin-bottom: 5px;
    position: relative;
    background-color: #222;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-img-box.p2p::after {
    content: "P2P";
    position: absolute;
    top: 0;
    right: 0;
    background: var(--gold);
    color: black;
    font-size: 0.6rem;
    padding: 1px 3px;
    font-weight: bold;
    border-bottom-left-radius: 4px;
}

.hero-item.selected .hero-img-box {
    border-color: var(--gold);
    box-shadow: 0 0 10px var(--gold);
}

.hero-item.selected .hero-img-box::before {
    content: "✓";
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: var(--gold);
    color: black;
    width: 16px;
    height: 16px;
    font-size: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 2;
}

.hero-img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
}

.hero-item.selected img {
    opacity: 1;
}

.hero-name {
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
    color: #ccc;
}

.hero-item.selected .hero-name {
    color: var(--gold);
    font-weight: bold;
}

.selected-heroes-bar {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--gold);
}

/* Action Button */
.action-section {
    text-align: center;
    margin: 30px 0;
}

.epic-btn {
    background: linear-gradient(to right, #d4af37, #f1c40f);
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.epic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.6);
}

.reset-btn, .tips-btn {
    font-size: 1rem;
    padding: 12px 20px;
}

/* Result Area */
.result-container {
    background: linear-gradient(to bottom, rgba(20, 15, 30, 0.9), rgba(10, 8, 15, 0.9));
    border: 2px solid var(--purple);
    box-shadow: 0 0 30px var(--purple-glow);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 40px;
}

.result-container h2 {
    border-bottom: none;
    font-size: 2rem;
}

.result-content {
    font-size: 1.2rem;
    margin: 20px 0;
}

.strategy-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
}

.stat-val {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--gold);
    display: block;
}

.stat-pct {
    font-size: 1.2rem;
    color: var(--purple);
}

.suggested-heroes {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .action-section {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .epic-btn {
        margin-left: 0 !important;
        width: 100%;
    }

    .troops-container,
    .input-group-row {
        flex-direction: column;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        min-width: 45%;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-dark);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--gold);
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 0 30px var(--gold-glow);
    animation: modalFade 0.3s;
    position: relative;
}

@keyframes modalFade {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--gold);
    border-bottom: none;
    padding-bottom: 0;
}

.close-btn {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.3s;
}

.close-btn:hover {
    color: var(--gold);
}

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

.tip-section {
    margin-bottom: 25px;
}

.tip-section h4 {
    color: var(--gold);
    margin-bottom: 10px;
    border-left: 3px solid var(--gold);
    padding-left: 10px;
    font-family: 'Cinzel', serif;
}

.tip-section ul {
    list-style: none;
    padding-left: 5px;
}

.tip-section li {
    margin-bottom: 10px;
    position: relative;
    padding-left: 20px;
    font-size: 0.95rem;
    color: #ccc;
}

.tip-section li::before {
    content: '◈';
    position: absolute;
    left: 0;
    color: var(--gold);
}

.tip-section p {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: #bbb;
}