/* =========================================
   TECH TREE MODAL
========================================= */
#tech-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
#tech-screen.hidden {
    display: none !important;
}
.tech-modal {
    background: #4a4e57;
    width: 92vw;
    max-width: 1400px;
    height: 90vh;
    border: 2px solid #5a5e66;
    border-top-color: #9ba0ab; border-left-color: #9ba0ab;
    border-bottom-color: #33363f; border-right-color: #33363f;
    border-radius: 0; /* Classic MOO2 is square */
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
    padding: 6px; /* Match sidebar padding */
}
.tech-header {
    background: #111;
    border: 2px solid #5a5e66;
    border-top-color: #33363f; border-left-color: #33363f;
    border-bottom-color: #9ba0ab; border-right-color: #9ba0ab;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.tech-header h2 {
    margin: 0; color: #aeb3bd; font-size: 16px; font-weight: bold; text-shadow: none; font-family: 'Arial', sans-serif; text-transform: uppercase;
}
#btn-close-tech {
    background: linear-gradient(to bottom, #4a4e57, #2a2c33);
    color: #ff6666; font-family: 'Arial', sans-serif; font-size: 14px; font-weight: bold;
    border: 1px solid #5a5e66; padding: 2px 10px; border-radius: 2px;
    cursor: pointer; transition: 0.2s;
    line-height: 1;
}
#btn-close-tech:hover {
    background: linear-gradient(to bottom, #802020, #501010); color: #ff9999;
}
.tech-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: min-content;
    gap: 6px;
    background: transparent;
    overflow-y: auto;
    padding-right: 5px;
}
.tech-box-moo {
    background: linear-gradient(to bottom, #2a2c33, #1a1c20); 
    border: 2px solid #5a5e66;
    border-top-color: #1a1c20; border-left-color: #1a1c20;
    border-bottom-color: #6c7078; border-right-color: #6c7078;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    min-height: 150px;
}
.tech-header-moo {
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid #1a1c20;
    padding: 4px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    color: #aeb3bd;
    text-transform: uppercase;
    font-family: 'Arial', sans-serif;
    letter-spacing: 1px;
}
.tech-body-moo {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Custom Scrollbar for tech-body */
.tech-body::-webkit-scrollbar {
    width: 10px;
}
.tech-body::-webkit-scrollbar-track {
    background: #1a1c20; 
    border-left: 1px solid #33363f;
}
.tech-body::-webkit-scrollbar-thumb {
    background: #4a4e57;
    border: 1px solid #5a5e66;
}
.tech-body::-webkit-scrollbar-thumb:hover {
    background: #5a5e66;
}
.tech-moo-empty {
    color: #666;
    font-style: italic;
    font-size: 12px;
}
.tech-item-moo {
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.1s;
    color: #00ff00;
    font-size: 16px;
    font-weight: bold;
}
.tech-moo-unlocks {
    font-size: 11px;
    color: #44aa44;
    margin-top: 1px;
    display: flex;
    align-items: center;
}
.tech-moo-arrow {
    margin-right: 4px;
    color: #55ff55;
    font-size: 14px;
    display: inline-block;
    transform: translateY(-2px);
    opacity: 0;
    transition: opacity 0.2s;
}
.tech-item-moo:hover .tech-moo-arrow {
    opacity: 1;
}
@keyframes mooBlink {
    0% { color: #55ff55; text-shadow: 0 0 5px #55ff55; }
    50% { color: #ffffff; text-shadow: 0 0 10px #ffffff; }
    100% { color: #55ff55; text-shadow: 0 0 5px #55ff55; }
}
.tech-item-moo:hover {
    background: rgba(0, 255, 0, 0.1);
}
.tech-item-moo:hover > div > span:first-child {
    animation: mooBlink 0.6s infinite;
}
.tech-item-moo.active {
    color: #aaffaa;
    text-shadow: 0 0 5px #00ff00;
    cursor: default;
    border-left: 2px solid #00ff00;
}
.tech-item-moo.active:hover {
    background: none;
    border-color: transparent;
    border-left: 2px solid #00ff00;
}
.tech-moo-progress {
    color: #00ff00;
    font-size: 12px;
}
.tech-completed {
    color: #888; font-style: italic; text-align: center; padding: 20px; background: rgba(0,0,0,0.3); border-radius: 4px;
}

.tech-hover-prefix {
    display: inline-block;
    width: 14px;
    text-align: right;
    margin-right: 4px;
    color: #55ff55;
    font-weight: normal;
}
.tech-hover-prefix::before {
    content: '\00A0'; /* Empty space by default */
}

/* If an item in the container is hovered, draw lines on all items */
.tech-body-moo:has(.tech-item-moo:hover) .tech-item-moo .tech-hover-prefix::before {
    content: '\2502'; /* Straight vertical line | */
}

/* Hovering a specific item changes its line to an arrow */
.tech-body-moo:has(.tech-item-moo:hover) .tech-item-moo:hover .tech-hover-prefix::before {
    content: '\21B3'; /* Arrow ↳ */
}

/* Items AFTER the hovered item get nothing */
.tech-body-moo:has(.tech-item-moo:hover) .tech-item-moo:hover ~ .tech-item-moo .tech-hover-prefix::before {
    content: '\00A0';
}

/* Creative mode: all items get the arrow when an item is hovered */
.tech-body-moo.is-creative:has(.tech-item-moo:hover) .tech-item-moo .tech-hover-prefix::before {
    content: '\21B3';
}
/* Research Complete Popup */
#rc-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
}
#rc-screen.hidden { display: none !important; }
.rc-modal {
    background: #4a4e57;
    width: 90vw;
    max-width: 520px;
    height: 80vh;            /* высота 80% окна */
    max-height: 80vh;
    border: 2px solid #5a5e66;
    border-top-color: #9ba0ab; border-left-color: #9ba0ab;
    border-bottom-color: #33363f; border-right-color: #33363f;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    padding: 6px;
    overflow: hidden;
}
/* Race "science" media banner at the top of the research-complete popup: race photo
   (poster) + looping muted video on top, no player chrome. Hidden if none uploaded. */
.rc-media {
    position: relative;
    width: 100%;
    flex: 1 1 auto;      /* заполняет свободную высоту → крупное, ближе к 1:1 */
    min-height: 120px;
    overflow: hidden;
    background: #10151f;
    border: inset 2px #5a5e66;
    margin-bottom: 6px;
}
.rc-media video,
.rc-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Мягкое затемнение к низу, чтобы стык с заголовком читался аккуратно. */
.rc-media::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 45%;
    background: linear-gradient(to bottom, rgba(16,21,31,0), rgba(16,21,31,0.55));
    pointer-events: none;
}
.rc-content {
    background: #2a2c33;
    padding: 14px 18px;
    text-align: center;
    border: inset 2px #5a5e66;
    color: #fff;
    font-family: 'Arial', sans-serif;
    flex: 0 0 auto;          /* компактно, натуральная высота */
    overflow-y: auto;
    max-height: 42vh;
}
.rc-title {
    color: #4da6ff;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 10px;
    text-transform: uppercase;
}
/* Название технологии — заголовок ПО ЦЕНТРУ в начале инфо-блока. */
.rc-tech-name {
    color: #66ffaa;
    font-size: 19px;
    font-weight: bold;
    text-align: center;
    margin: 0 0 12px;
}
.rc-desc {
    color: #aeb3bd;
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.4;
}
/* Кнопка ОК — по центру снизу. */
.rc-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
}
.rc-footer .rc-btn {
    margin: 0;
}

/* Custom Tech Confirm Dialog */
#tech-confirm-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
#tech-confirm-screen.hidden {
    display: none !important;
}
.tech-confirm-modal {
    width: 90vw;
    max-width: 450px;
    height: auto;
}
.tech-confirm-body {
    background: linear-gradient(to bottom, #2a2c33, #1a1c20);
    border: 2px solid #5a5e66;
    border-top-color: #1a1c20; border-left-color: #1a1c20;
    border-bottom-color: #6c7078; border-right-color: #6c7078;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
}
.tech-confirm-name {
    color: #00ff00;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    text-transform: uppercase;
    text-shadow: 0 0 5px #00ff00;
}
.tech-confirm-desc {
    color: #aeb3bd;
    font-size: 14px;
    margin-bottom: 25px;
    line-height: 1.4;
}
.tech-confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}
.rc-btn-cancel {
    background: linear-gradient(to bottom, #666, #333);
}
.rc-btn-cancel:hover {
    background: linear-gradient(to bottom, #888, #555);
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}.rc-btn {
    background: linear-gradient(to bottom, #4da6ff, #0055aa);
    color: white;
    border: 1px solid #9ba0ab;
    border-bottom-color: #111; border-right-color: #111;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.2s;
}
.rc-btn:hover { background: linear-gradient(to bottom, #66b3ff, #0066cc); box-shadow: 0 0 10px rgba(77,166,255,0.5); }

/* Tooltip Styles */
.tech-tooltip {
    position: absolute;
    background: #1a1c20;
    color: #aeb3bd;
    border: 2px solid #5a5e66;
    border-top-color: #9ba0ab; border-left-color: #9ba0ab;
    border-bottom-color: #33363f; border-right-color: #33363f;
    padding: 10px;
    border-radius: 0;
    z-index: 4000;
    pointer-events: none;
    max-width: 300px;
    font-size: 13px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.9);
    font-family: 'Arial', sans-serif;
    line-height: 1.4;
}

/* ── УЗКИЕ СМАРТФОНЫ (<500px): дерево технологий в ОДНУ колонку ────────────
   Два столбца на такой ширине плющат заголовки полей и переносят названия
   технологий по буквам — блок поля на всю ширину читается нормально. */
@media (max-width: 499px) {
    .tech-body {
        grid-template-columns: 1fr;
    }
}
