:root {
    --bg: #0e0f13;
    --bg-2: #161821;
    --panel: #1c1f2b;
    --line: #2b3040;
    --text: #e6e8ef;
    --muted: #98a0b3;
    --accent: #ffcc00;
    --accent-2: #4ea1ff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, system-ui, sans-serif;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.site-header {
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, var(--bg-2), var(--bg));
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 20px;
    padding-bottom: 20px;
}

.logo {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: .5px;
    color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo .dot { color: var(--accent); }

.site-main { min-height: 60vh; }

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}
.site-footer .container { padding-top: 20px; padding-bottom: 20px; }

h1 { font-size: 28px; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }

.back { margin-left: auto; font-size: 14px; color: var(--muted); }

/* Кнопки */
.btn {
    display: inline-block;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: #3a4155; }
.btn-primary { background: var(--accent); border-color: #ffe680; color: #1a1400; font-weight: 700; }
.btn-small { padding: 5px 11px; font-size: 13px; }
.btn.disabled { background: #3a3f4d; color: #8b93a5; cursor: not-allowed; border-color: var(--line); }

/* Главная: hero + облака платформ */
.home { padding-bottom: 48px; }
.hero { text-align: center; padding-top: 46px; padding-bottom: 26px; }
.hero h1 { font-size: 40px; margin: 0 0 10px; font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px; }
.hero .lead { max-width: 640px; margin: 0 auto 16px; }
.tg-link { font-weight: 600; }

.clouds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    align-items: start;
}

.cloud {
    position: relative;
    min-height: 260px;
    padding: 22px 18px 26px;
    background: radial-gradient(120% 90% at 30% 20%, #232838 0%, #171a24 60%, #12141c 100%);
    border: 1px solid var(--line);
    border-radius: 48% 52% 46% 54% / 38% 42% 58% 62%;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, .35);
    animation: cloud-float 7s ease-in-out infinite;
}
.cloud:nth-child(2) { animation-delay: 1.2s; }
.cloud:nth-child(3) { animation-delay: 2.4s; }
.cloud-ussr { background: radial-gradient(120% 90% at 30% 20%, #2c1c1e 0%, #1d1417 60%, #150f12 100%); }

.cloud-head {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; margin-bottom: 18px; padding: 6px;
    background: none; border: 0; color: var(--text); cursor: pointer;
    font-size: 17px; font-weight: 700; font-family: inherit;
}
.cloud-head:hover { color: var(--accent); }
.cloud-count {
    font-size: 12px; font-weight: 600; color: var(--muted);
    border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px;
}

.cloud-icons { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.cloud-empty { color: var(--muted); font-size: 13px; }

.p-icon {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    width: 104px; padding: 8px 6px; background: none; border: 0;
    color: var(--text); cursor: pointer; font-family: inherit;
    animation: icon-drift 4.5s ease-in-out infinite;
}
.p-icon:nth-child(3n) { animation-delay: .8s; }
.p-icon:nth-child(3n+1) { animation-delay: 1.6s; }
.p-icon img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5)); }
.p-emoji { font-size: 44px; line-height: 64px; }
.p-icon .p-caption { font-size: 12.5px; color: var(--muted); line-height: 1.25; }
.p-icon:hover .p-caption { color: var(--text); }

@keyframes cloud-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes icon-drift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Раскрытие облака на экран */
body.overlay-open { overflow: hidden; }
.cloud-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(8, 9, 13, .94);
    overflow: auto;
    padding: 28px 20px 60px;
}
.cloud-overlay-inner { max-width: 1080px; margin: 0 auto; }
.overlay-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.overlay-head h2 { font-size: 24px; margin: 0; }
.overlay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px; }
.overlay-grid .p-icon { width: auto; animation: none; }
.overlay-grid .p-icon img { width: 96px; height: 96px; }

/* Попап со справкой */
.p-popup {
    position: fixed; z-index: 60;
    width: 280px; max-width: calc(100vw - 24px);
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; padding: 14px 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}
.pp-title { font-weight: 700; margin-bottom: 8px; }
.pp-list { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 8px; font-size: 13px; }
.pp-list dt { color: var(--muted); }
.pp-list dd { margin: 0; }
.pp-features { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 12px; }
.pp-open { display: block; text-align: center; }

@media (max-width: 820px) {
    .clouds { grid-template-columns: 1fr; }
    .cloud { min-height: 0; border-radius: 28px; }
    .hero h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
    .cloud, .p-icon { animation: none; }
}

/* Страница платформы */
.platform-head { margin-bottom: 20px; }

.help {
    position: relative;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 18px 20px 54px;
    margin-bottom: 24px;
    line-height: 1.55;
}
.help h3 { margin: 0 0 8px; }
.help ul { margin: 8px 0; padding-left: 20px; }
.help .help-ok { position: absolute; right: 16px; bottom: 14px; }
.help-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 10;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent); color: #1a1400; font-size: 22px; font-weight: 700;
    border: 2px solid #ffe680; cursor: pointer;
}

.program-list h2 { font-size: 20px; margin: 0 0 14px; }
.program-row {
    display: flex; align-items: center; gap: 16px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: 14px 16px; margin-bottom: 10px;
}
.program-row.unavailable { opacity: .62; }
.program-info { flex: 1; min-width: 0; }
.program-title { font-size: 16px; font-weight: 600; }
.program-meta { font-size: 13px; margin-top: 2px; }
.program-action { flex: 0 0 auto; }

/* Поиск на странице платформы */
.search-block { margin-bottom: 24px; }
.search-block h2 { font-size: 20px; margin: 0 0 12px; }
.search-form {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 1.2fr auto;
    gap: 12px;
    align-items: end;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
}
.search-form .field { display: flex; flex-direction: column; gap: 4px; }
.search-form label { font-size: 12px; color: var(--muted); }
.search-form input,
.search-form select {
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
}
.load-more { margin-top: 12px; text-align: center; }
@media (max-width: 760px) {
    .search-form { grid-template-columns: 1fr; }
}

/* Плеер */
.player-page .site-main { min-height: 0; }
.player-page .site-footer { display: none; }
.player-wrap { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px 32px; max-width: 1180px; margin: 0 auto; }
.player-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: var(--bg-2);
    border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
    position: sticky; top: 10px; z-index: 20;
}
.player-bar .name { font-weight: 600; }
.player-bar .meta { color: var(--muted); }
.player-bar .btn-small { margin-left: auto; }

.player-stage { display: flex; justify-content: center; }
.tv-frame {
    position: relative;
    background: linear-gradient(180deg, #2a2d38, #14161d);
    border: 1px solid #3a3f4d;
    border-radius: 22px;
    padding: 22px 22px 46px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 0 0 2px rgba(255, 255, 255, .03);
    width: 100%;
    max-width: 900px;
}
.tv-screen {
    position: relative;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: inset 0 0 0 3px #0a0b0f, inset 0 0 60px rgba(0, 0, 0, .8);
    aspect-ratio: 4 / 3;
}
.tv-screen::after {
    content: "";
    position: absolute; inset: 0; pointer-events: none; z-index: 4;
    background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .03) 0 1px, transparent 1px 3px);
    mix-blend-mode: overlay;
}
.tv-brand {
    position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
    color: var(--muted); font-size: 12px; letter-spacing: .18em;
    font-family: ui-monospace, Consolas, monospace; text-transform: uppercase;
}
.tv-brand span { color: var(--accent); }

.player-frame { position: absolute; inset: 0; min-height: 0; overflow: hidden; }
.player-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
#game { position: absolute; inset: 0; }

.player-help {
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: 10px; padding: 16px 20px; line-height: 1.55;
}
.player-help h3 { margin: 0 0 8px; }
.player-help ul { margin: 8px 0; padding-left: 20px; }
.player-help a { color: var(--accent-2); }

/* Стартовый экран EmulatorJS (фон + кнопка «Играть») */
.ejs_game_background:not(.ejs_canvas_parent) {
    background-image: var(--ejs-background-image) !important;
    background-size: cover !important;
    background-position: center !important;
    background-color: var(--ejs-background-color, #0e0f13) !important;
    background-repeat: no-repeat !important;
    image-rendering: pixelated;
    filter: brightness(.45) blur(3px);
}
.ejs_start_button {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
    z-index: 5 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 220px;
    padding: 16px 32px !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #1a1400 !important;
    background: var(--accent) !important;
    border: 2px solid #ffe680 !important;
    border-radius: 999px !important;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45) !important;
    text-shadow: none !important;
}
.ejs_start_button:hover { filter: brightness(1.06); }
.ejs_loading_text { color: #e6e8ef !important; font-family: inherit !important; }

@media (max-width: 640px) {
    .tv-frame { padding: 12px 12px 36px; border-radius: 16px; }
    .player-bar .meta { display: none; }
}

