/* ═══════════════════════════════════════════════════════════════════
   Squad Builder Optimizer — Styles
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --bg:        #0f1117;
    --surface:   #1a1d27;
    --surface2:  #242836;
    --border:    #2e3345;
    --text:      #e8eaed;
    --text-dim:  #9aa0b0;
    --accent:    #6c8aff;

    --bg-header: #0f0d0e;
    --bg-main: #121826;
    --text-primary: #ebbf65;
    --text-secondary: #eeeeee;

    --wood:      #4caf50;
    --wood-bg:   #1b3a1c;
    --water:     #42a5f5;
    --water-bg:  #162a3e;
    --metal:     #b0bec5;
    --metal-bg:  #2a2e33;
    --earth:     #d4a04a;
    --earth-bg:  #3a2e18;
    --fire:      #ef5350;
    --fire-bg:   #3e1616;
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    background-image: url("/static/images/Background3.PNG");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    padding-bottom: 4rem;
    color: var(--text-primary);
    line-height: 1.6;
}

@media (max-width: 768px) {
    body {
        background-image: url("/static/images/MobileBackground.png");
        background-attachment: scroll;
        background-repeat: repeat-y;
        background-size: auto 360px;
        background-position: top center;
    }
}

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

.description {
    max-width: 540px;
    margin: 0 auto 1rem auto;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: #ef5350;
}

/* ── Header ──────────────────────────────────────────────────────── */

header {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

/* ── Round indicator ─────────────────────────────────────────────── */

.round-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1rem 0;
}

.round-dot {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--surface2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: all 0.3s;
}

.round-dot.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 12px rgba(108, 138, 255, 0.4);
}

.round-dot.done {
    background: #2d4a2d;
    border-color: #4caf50;
    color: #4caf50;
}

.round-line {
    width: 2.5rem;
    height: 2px;
    background: var(--border);
}

/* ── Card section ────────────────────────────────────────────────── */

.card-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}

.hint {
    color: var(--text-dim);
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

/* ── Class buttons ───────────────────────────────────────────────── */

.class-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.class-btn {
    padding: 0.7rem 0.2rem;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    line-height: 1.3;
    color: #fff;
}

.class-btn:active {
    transform: scale(0.95);
}

.class-btn.wood  { background: var(--wood-bg);  border-color: var(--wood);  color: var(--wood); }
.class-btn.water { background: var(--water-bg); border-color: var(--water); color: var(--water); }
.class-btn.metal { background: var(--metal-bg); border-color: var(--metal); color: var(--metal); }
.class-btn.earth { background: var(--earth-bg); border-color: var(--earth); color: var(--earth); }
.class-btn.fire  { background: var(--fire-bg);  border-color: var(--fire);  color: var(--fire); }

.class-btn:hover {
    filter: brightness(1.3);
}

.btn-count {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* ── Hand display (chips) ────────────────────────────────────────── */

.hand-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 2.4rem;
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.card-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.card-chip:not(.kept):hover {
    filter: brightness(0.7);
    text-decoration: line-through;
}

.card-chip.kept {
    cursor: default;
    opacity: 0.6;
}

.card-chip.small {
    padding: 0.2rem 0.5rem;
    font-size: 0.72rem;
    cursor: default;
}

.card-chip.small:hover {
    filter: none;
    text-decoration: none;
}

.card-chip.wood  { background: var(--wood-bg);  color: var(--wood);  border: 1px solid var(--wood); }
.card-chip.water { background: var(--water-bg); color: var(--water); border: 1px solid var(--water); }
.card-chip.metal { background: var(--metal-bg); color: var(--metal); border: 1px solid var(--metal); }
.card-chip.earth { background: var(--earth-bg); color: var(--earth); border: 1px solid var(--earth); }
.card-chip.fire  { background: var(--fire-bg);  color: var(--fire);  border: 1px solid var(--fire); }

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn-primary {
    width: 100%;
    padding: 0.8rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.15);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.6rem 1rem;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary:hover {
    background: var(--border);
}

.action-buttons {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.2rem;
}

.action-buttons .btn-primary {
    flex: 1;
}

.action-buttons .btn-secondary {
    flex: 1;
    padding: 0.8rem;
    text-align: center;
}

/* ── Loading ─────────────────────────────────────────────────────── */

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 1rem auto;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingSection {
    text-align: center;
    padding: 2rem 1.5rem;
}

/* ── Results ─────────────────────────────────────────────────────── */

.current-hand-info {
    text-align: center;
    margin-bottom: 1rem;
}

.hand-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    justify-content: center;
    margin-bottom: 0.6rem;
}

.hand-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.score-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.score-label {
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* ── Recommendation box ──────────────────────────────────────────── */

.rec-box {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.rec-box.swap {
    background: rgba(108, 138, 255, 0.1);
    border: 1px solid rgba(108, 138, 255, 0.3);
}

.rec-box.keep {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.rec-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.rec-detail {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.rec-ev {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
}

/* ── Strategy list ───────────────────────────────────────────────── */

.strategies-list h3 {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.strategy-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.strategy-item:not(.top) {
    cursor: pointer;
}

.strategy-item:not(.top):hover {
    background: var(--surface2);
}

.strategy-item.top {
    background: var(--surface2);
    border: 1px solid var(--border);
    font-weight: 600;
}

.strat-rank {
    color: var(--text-dim);
    font-size: 0.78rem;
    min-width: 1.5rem;
}

.strat-label {
    flex: 1;
}

.strat-ev {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
}

.strategy-item.top .strat-ev {
    color: var(--accent);
}

/* ── Final section ───────────────────────────────────────────────── */

#finalSection {
    text-align: center;
    padding: 2rem 1.5rem;
}

.final-celebration {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--earth);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.04); }
}

.final-type {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}

.final-score {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-note {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* ── Error message ───────────────────────────────────────────────── */

.error-msg {
    background: var(--fire-bg);
    border: 1px solid var(--fire);
    color: var(--fire);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    transition: opacity 0.3s;
}

/* ── Scoring reference ───────────────────────────────────────────── */

.scoring-ref {
    margin-top: 1rem;
    padding: 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8rem;
}

.scoring-ref summary {
    cursor: pointer;
    color: var(--text-dim);
    font-weight: 500;
    padding: 0.2rem 0;
}

.scoring-ref table {
    width: 100%;
    margin-top: 0.6rem;
    border-collapse: collapse;
}

.scoring-ref th,
.scoring-ref td {
    text-align: left;
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.scoring-ref th {
    color: var(--text-dim);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.scoring-ref td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ── Utility ─────────────────────────────────────────────────────── */

.hidden {
    display: none !important;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 400px) {
    .class-btn {
        font-size: 0.7rem;
        padding: 0.6rem 0.1rem;
    }

    .card-chip {
        font-size: 0.72rem;
        padding: 0.25rem 0.5rem;
    }

    .final-score {
        font-size: 2rem;
    }
}

.site-header {
    background: transparent;
    padding: 0 2rem 0 0;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0; 
    z-index: 100;
}

@media (max-width: 768px) {
    .site-header {
        background: transparent;
        padding: 0 2rem 0 0;
        height: 80px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        top: 0; 
        z-index: 100;
    }
}

.logo-container {
    height: 80px; 
    width: 320px; /* Exactly 4x the height based on your image's 4:1 ratio */
    /* Prevents the navigation menu from squishing the logo */
    flex-shrink: 0; 
    display: flex;
}

.logo-container a {
    display: flex;
    text-decoration: none;
}

.site-logo {
    height: 80px; 
    width: 320px; 
    object-fit: contain; 
    display: block; 
}

.nav-placeholder {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1000;
}

/* Hamburger Menu Button */
.hamburger-menu {
    display: flex;
    color: var(--text-primary);
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-menu span {
    width: 100%;
    height: 3px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-menu:hover span {
    background-color: var(--text-primary);
}

/* Hamburger Menu Active State */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: 0;
    padding: 0;
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    flex-direction: column;
    background: transparent;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 1rem;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    gap: 0.5rem;
    z-index: 1001;
}

.nav-links.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-links li {
    width: 100%;
}

.nav-button {
    width: 100%;
    text-align: left;
}

.nav-links li {
    display: flex;
}

.nav-button {
    padding: 0.75rem 1rem;
    background-color: #1a2235;
    color: var(--text-primary);
    border: 1px solid #2d3748;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    white-space: nowrap;
    font-family: inherit;
}

.nav-button:hover {
    background-color: #1e2a3f;
    border-color: #4a5568;
    color: var(--text-primary);
}

.nav-button:focus {
    outline: none;
    border-color: #4a5568;
    box-shadow: 0 0 0 2px rgba(74, 85, 104, 0.3);
}

@media (max-width: 768px) {

    .site-header {
        background: transparent;
        padding: 0;
        height: auto;
        min-height: 80px;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
        position: relative;
        top: 0;
        z-index: 100;
    }

    .logo-container {
        height: 80px;
        flex-shrink: 0;
    }

    .nav-placeholder {
        flex: 1;
        position: static;
        display: block;
        z-index: 1001;
    }

    .hamburger-menu {
        position: absolute;
        top: 25px;
        right: 1.5rem;
        z-index: 1002;
    }

    .nav-links {
        position: static;
        clear: both;
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
        min-width: unset;
        border-radius: 0;
        background: transparent;
        visibility: visible;
        transform: none;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        padding: 0;
        transition:
            max-height 0.35s ease,
            opacity 0.35s ease,
            padding 0.35s ease;
    }

    .nav-links.active {
        max-height: 600px;
        opacity: 1;
        padding: 0.75rem 1rem 1rem;
        transform: none;
        visibility: visible;
    }

    .nav-button {
        width: 100%;
        white-space: normal;
        text-align: left;
    }
}