:root {
    --bg-base: #050508;
    --bg-panel: rgba(10, 15, 25, 0.8);
    --primary: #00E5FF;
    --primary-dim: rgba(0, 229, 255, 0.2);
    --danger: #FF004D;
    --danger-dim: rgba(255, 0, 77, 0.2);
    --success: #00FF88;
    --success-dim: rgba(0, 255, 136, 0.2);
    --text-main: #E0E5EC;
    --text-muted: #6B7B8F;
    --text-dim: #8FA2B8;
    --font-ui: 'Orbitron', sans-serif;
    --font-data: 'Rajdhani', sans-serif;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-ui);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-top: 2rem;
    background-image: 
        linear-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 229, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
}

/* Scanline effect */
.scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 10vh;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0),
        rgba(255,255,255,0.05),
        rgba(0, 229, 255, 0.1),
        rgba(255,255,255,0)
    );
    opacity: 0.1;
    animation: scan 8s linear infinite;
    pointer-events: none;
    z-index: 999;
}

@keyframes scan {
    0% { top: -10vh; }
    100% { top: 110vh; }
}

.hud-container {
    width: 100%;
    max-width: 1200px;
    padding: 0 2rem 2rem;
    position: relative;
    z-index: 10;
}

/* ============================
   HEADER
   ============================ */
.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    border-bottom: 1px solid var(--primary-dim);
    padding-bottom: 1rem;
}

.hud-header h1 {
    font-family: var(--font-data);
    font-size: 2rem;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-dim);
    letter-spacing: 2px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-data);
    color: var(--primary);
    font-size: 0.9rem;
}

.pulse {
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
    animation: pulse-anim 2s infinite;
}

@keyframes pulse-anim {
    0% { opacity: 1; box-shadow: 0 0 10px var(--primary); }
    50% { opacity: 0.4; box-shadow: 0 0 2px var(--primary); }
    100% { opacity: 1; box-shadow: 0 0 10px var(--primary); }
}

/* ============================
   TABS
   ============================ */
.hud-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tab-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-data);
    font-size: 0.95rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tab-btn::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 1px;
    background: var(--primary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(0, 229, 255, 0.03);
}

.tab-btn:hover::before {
    width: 60%;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    text-shadow: 0 0 10px var(--primary-dim);
}

.tab-btn.active::before {
    width: 100%;
    box-shadow: 0 0 10px var(--primary-dim);
}

.tab-icon {
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

/* ============================
   VIEWS
   ============================ */
.hud-view {
    display: none;
}

.hud-view.active {
    display: block;
    animation: viewFadeIn 0.3s ease;
}

@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================
   GRID & PANELS
   ============================ */
.hud-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .hud-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    position: relative;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

/* Cyber corner accents */
.panel::before, .panel::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid transparent;
    pointer-events: none;
}

.panel::before {
    top: -1px;
    left: -1px;
    border-top-color: var(--primary);
    border-left-color: var(--primary);
}

.panel::after {
    bottom: -1px;
    right: -1px;
    border-bottom-color: var(--primary);
    border-right-color: var(--primary);
}

.danger-panel::before { border-color: var(--danger) transparent transparent var(--danger); }
.danger-panel::after { border-color: transparent var(--danger) var(--danger) transparent; }

.panel-title {
    font-family: var(--font-data);
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
}

.danger-panel .panel-title {
    color: var(--danger);
}

/* ============================
   INPUT STYLES
   ============================ */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label, .group-label {
    display: block;
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    font-weight: 700;
}

.label-note {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.75rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--primary-dim);
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-dim);
}

.prefix, .suffix {
    font-family: var(--font-data);
    color: var(--primary);
    padding: 0 1rem;
}

input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-data);
    font-size: 1.5rem;
    padding: 0.75rem 0;
    outline: none;
    width: 100%;
}

input::placeholder {
    color: rgba(255,255,255,0.1);
}

/* ============================
   ELO MATCH INPUTS
   ============================ */
.elo-gains-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.match-input-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.elo-gain-wrapper {
    flex: 1;
}

.elo-gain-wrapper input {
    font-size: 0.9rem;
    padding: 0.4rem 0;
}

.elo-gain-wrapper .prefix {
    padding: 0 0.5rem;
}

/* Win/Loss toggle button */
.wl-toggle {
    font-family: var(--font-data);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--primary-dim);
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
}

.wl-toggle.win {
    color: var(--success);
    border-color: var(--success);
}

.wl-toggle.win:hover {
    background: var(--success-dim);
    box-shadow: 0 0 10px var(--success-dim);
}

.wl-toggle.loss {
    color: var(--danger);
    border-color: var(--danger);
}

.wl-toggle.loss:hover {
    background: var(--danger-dim);
    box-shadow: 0 0 10px var(--danger-dim);
}

.wl-toggle:hover {
    transform: scale(1.15);
}

/* Border and focus styling using :has() */
.match-input-col:has(.wl-toggle.win) .elo-gain-wrapper {
    border-color: var(--success-dim);
}
.match-input-col:has(.wl-toggle.win):focus-within .elo-gain-wrapper {
    border-color: var(--success);
    box-shadow: 0 0 15px var(--success-dim);
}
.match-input-col:has(.wl-toggle.loss) .elo-gain-wrapper {
    border-color: var(--danger-dim);
}
.match-input-col:has(.wl-toggle.loss):focus-within .elo-gain-wrapper {
    border-color: var(--danger);
    box-shadow: 0 0 15px var(--danger-dim);
}

/* Prefix styling */
.match-input-col:has(.wl-toggle.win) .match-prefix {
    color: var(--success);
}
.match-input-col:has(.wl-toggle.loss) .match-prefix {
    color: var(--danger);
}

/* Prefix dynamic symbols */
.match-prefix::before {
    content: '+';
}
.match-input-col:has(.wl-toggle.loss) .match-prefix::before {
    content: '-';
}

/* ============================
   READOUT STYLES
   ============================ */
.stats-readout {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--primary-dim);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.stat-value {
    font-family: var(--font-data);
    color: var(--primary);
}

/* ============================
   GRID OUTPUTS (shared)
   ============================ */
.placeholder-text {
    font-family: var(--font-data);
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 0;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

.target-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s ease, transform 0.1s ease;
}

.target-item:hover {
    background: rgba(255,255,255,0.05);
    transform: translateX(4px);
}

.target-item:last-child {
    border-bottom: none;
}

.target-perc {
    font-weight: 700;
    color: var(--primary);
}

.target-val {
    font-family: var(--font-data);
    font-size: 1.2rem;
}

.target-val span {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.danger-item .target-perc {
    color: var(--danger);
}

.danger-item .target-val {
    color: var(--danger);
}

/* Error states */
.error-message {
    color: var(--danger);
    font-family: var(--font-data);
    font-size: 0.9rem;
    margin-top: 1rem;
    padding: 0.5rem;
    background: var(--danger-dim);
    border-left: 2px solid var(--danger);
}

/* ============================
   RANK DISPLAY (ELO View)
   ============================ */
.rank-panel {
    display: flex;
    flex-direction: column;
}

.rank-display-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 1rem 0;
    width: 100%;
}

.rank-icons-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

@media (max-width: 600px) {
    .rank-icons-row {
        gap: 0.5rem;
    }
    .rank-icon-img {
        width: 80px !important;
        height: 80px !important;
    }
    .rank-arrow {
        margin: 0 0.5rem !important;
        height: 80px !important;
    }
}

.rank-icon-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rank-icon-img {
    width: 110px;
    height: 110px;
    object-fit: contain;
    animation: badge-breathe 4s ease-in-out infinite;
    display: block;
}

.next-rank-icon-col .rank-icon-img {
    animation: none;
}

@keyframes badge-breathe {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.04); filter: brightness(1.15); }
}

.rank-icon-label {
    font-family: var(--font-ui);
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-top: 0.5rem;
    text-transform: uppercase;
}


.rank-arrow {
    font-size: 2rem;
    font-weight: 900;
    opacity: 0.5;
    margin: 0 1rem;
    align-self: flex-start;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 0;
}

.rank-info-below {
    margin-top: 1.5rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rank-elo-current {
    font-family: var(--font-ui);
    font-size: 2rem;
    margin-bottom: 0.8rem;
}

/* Progress bar within division */
.rank-progress-container {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.6rem;
    position: relative;
}

.rank-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.rank-progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.4));
    border-radius: 0 3px 3px 0;
}

.rank-progress-label {
    font-family: var(--font-data);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.5px;
}

/* ============================
   ELO PROGRESSION ITEMS
   ============================ */
.elo-target-item {
    gap: 0.5rem;
}

.elo-target-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.elo-target-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.elo-target-name {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.elo-target-threshold {
    font-family: var(--font-data);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

.elo-target-item .target-val {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Rank transition divider — marks crossing into a new rank tier */
.rank-transition {
    border-top: 1px dashed rgba(255,255,255,0.1);
    margin-top: 0.25rem;
    padding-top: 0.75rem;
}

/* Archnemesis callout */
.archnemesis-note {
    margin-top: 1.2rem;
    padding: 0.8rem;
    background: rgba(12, 230, 255, 0.05);
    border: 1px solid rgba(12, 230, 255, 0.15);
    border-left: 3px solid #0ce6ff;
    font-family: var(--font-data);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    line-height: 1.5;
}

/* No-avg message */
.no-avg-message {
    font-family: var(--font-data);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1rem 0;
}

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Progression list estimated games */
.est-games {
    font-family: var(--font-data);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
    margin-top: 0.2rem;
}

.target-val-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Ensure the wrapper stretches to fill the match column width */
.elo-gain-wrapper {
    width: 100%;
}

/* Custom scroll container to prevent visual layout stretch */
#elo-progression {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

#elo-progression::-webkit-scrollbar {
    width: 4px;
}

#elo-progression::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

#elo-progression::-webkit-scrollbar-thumb {
    background: var(--primary-dim);
    border-radius: 2px;
}

#elo-progression::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Keyboard accessibility focus outline */
.wl-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Hide dynamic prefix when input is empty (placeholder-shown) */
.match-input-col:has(.elo-gain-input:placeholder-shown) .match-prefix::before {
    content: '';
}

/* Custom scroll container for target grid */
#target-grid.scrollable {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding-right: 0.5rem;
}

#target-grid.scrollable::-webkit-scrollbar {
    width: 4px;
}

#target-grid.scrollable::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

#target-grid.scrollable::-webkit-scrollbar-thumb {
    background: var(--primary-dim);
    border-radius: 2px;
}

#target-grid.scrollable::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.target-item.sticky-bottom {
    position: sticky;
    bottom: -1px;
    background: #0a0f19;
    z-index: 10;
    border-top: 1px solid var(--primary-dim);
}
