/* ===========================
   Tournament Streaming UI
   Modern / glass / neon / animated bg
   =========================== */

:root{
  --bg:#070A12;
  --bg2:#0b1020;
  --panel: rgba(12, 18, 34, .72);
  --panel2: rgba(10, 16, 30, .55);
  --card: rgba(10, 14, 26, .70);
  --line: rgba(96,165,250,.18);

  --txt:#e5e7eb;
  --muted:#9aa5b1;

  --accent:#60a5fa;
  --accent2:#a78bfa;
  --ok:#22c55e;
  --warn:#f59e0b;
  --err:#ef4444;

  --shadow: 0 18px 60px rgba(0,0,0,.45);
  --shadow2: 0 10px 30px rgba(0,0,0,.35);

  --radius:16px;
  --radius2: 14px;

  --stroke: rgba(148, 163, 184, .14);
  --field: rgba(2, 6, 23, .75);

  --pad:14px;
  --pad-sm:10px;
  --gap:12px;

  --glow: 0 0 0 1px rgba(96,165,250,.10), 0 0 24px rgba(96,165,250,.16);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--txt);
  background: radial-gradient(1200px 700px at 20% -10%, #0d1b3b 0%, #070b16 55%, #05070d 100%), var(--bg);
  font: 14px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow-x:hidden;
}

/* animated bg */
body::before,
body::after{
  content:"";
  position:fixed;
  inset:-20%;
  z-index:-2;
  pointer-events:none;
}
body::before{
  background:
    radial-gradient(600px 400px at 25% 25%, rgba(96,165,250,.22), transparent 60%),
    radial-gradient(700px 460px at 75% 30%, rgba(167,139,250,.18), transparent 62%),
    radial-gradient(700px 520px at 55% 85%, rgba(34,197,94,.12), transparent 60%);
  filter: blur(28px);
  animation: floatGlow 10s ease-in-out infinite alternate;
  opacity:.9;
}
body::after{
  background:
    linear-gradient(115deg, rgba(96,165,250,.10), transparent 45%),
    linear-gradient(225deg, rgba(167,139,250,.08), transparent 45%);
  mix-blend-mode: screen;
  opacity:.6;
  animation: drift 18s linear infinite;
}
@keyframes floatGlow{
  0%{ transform: translate3d(-1%, -2%, 0) scale(1.02); }
  100%{ transform: translate3d(2%, 2%, 0) scale(1.06); }
}
@keyframes drift{
  0%{ transform: translate3d(-2%, 0, 0) rotate(0deg); }
  100%{ transform: translate3d(2%, -1%, 0) rotate(10deg); }
}

/* ---------- Topbar ---------- */
.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px;
  background: rgba(6, 10, 20, .55);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--stroke);
  box-shadow: 0 10px 35px rgba(0,0,0,.25);
}
.brand{
  display:flex; align-items:center; gap:10px;
  font-weight:800;
  letter-spacing:.2px;
}
.top-actions{ display:flex; align-items:center; gap:10px; }

.badge{
  display:inline-flex; align-items:center; gap:8px;
  padding:7px 12px;
  border:1px solid var(--stroke);
  border-radius:999px;
  color: var(--muted);
  background: rgba(2, 6, 23, .55);
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset;
}

/* menu button */
.menu-btn{
  background:none;
  border:none;
  color:inherit;
  cursor:pointer;
  padding:0;
  display:flex;
  align-items:center;
  opacity:.9;
  transition: opacity .15s ease, transform .08s ease;
}
.menu-btn:hover{ opacity:1; }
.menu-btn:active{ transform: translateY(1px); }

/* ---------- Grid ---------- */
.grid{
  max-width:1400px;
  margin: 16px auto;
  padding: 0 16px;
  display:grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0,1fr));
}
@media (max-width: 1180px){
  .grid{ grid-template-columns: 1fr; }
}

/* ---------- Tiles ---------- */
.tile{
  background: linear-gradient(180deg, rgba(20, 30, 56, .78), rgba(10, 14, 26, .70));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  overflow:hidden;
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  position:relative;
}
.tile::before{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius:inherit;
  pointer-events:none;
  background: radial-gradient(600px 300px at 20% 0%, rgba(96,165,250,.12), transparent 45%),
              radial-gradient(600px 300px at 80% 0%, rgba(167,139,250,.10), transparent 45%);
  opacity:.9;
}
.tile > *{ position:relative; z-index:1; }

.tile-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(2, 6, 23, .42);
  backdrop-filter: blur(6px);
}
.title{ display:flex; align-items:baseline; gap:8px; }
.title .name{
  font-weight:800;
  font-size: clamp(14px, 1.6vw, 16px);
}
.title .id{ color: var(--muted); font-size:12px; }

.ind{ display:flex; align-items:center; gap:10px; }
.dot{
  width:10px; height:10px; border-radius:999px;
  background: var(--warn);
  box-shadow: 0 0 0 2px rgba(245,158,11,.12), 0 0 14px rgba(245,158,11,.55);
}
.dot.ok{ background: var(--ok); box-shadow: 0 0 0 2px rgba(34,197,94,.12), 0 0 14px rgba(34,197,94,.55); }
.dot.err{ background: var(--err); box-shadow: 0 0 0 2px rgba(239,68,68,.12), 0 0 14px rgba(239,68,68,.55); }
.dot.idle{ background: var(--warn); }

.stat{
  color: var(--muted);
  font-size:12px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  max-width: 240px;
}

/* ---------- Video + overlay ---------- */
.media{
  position:relative;
  aspect-ratio: 16/9;
  background:#000;
}
video{
  width:100%;
  height:100%;
  display:block;
  object-fit: cover;
  transform: translateZ(0);
}

.overlay{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background: radial-gradient(700px 360px at 50% 110%, rgba(0,0,0,.62), rgba(0,0,0,.25) 55%, transparent 70%);
  color:#dbe2ea;
  transition: opacity .2s ease;
  pointer-events:none;
}
.overlay.hide{ opacity:0; }
.ovl-inner{ display:flex; flex-direction:column; align-items:center; gap:10px; }

.spinner{
  width:28px; height:28px;
  border-radius:50%;
  border:3px solid rgba(255,255,255,.14);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  filter: drop-shadow(0 0 10px rgba(96,165,250,.35));
}
@keyframes spin{ to{ transform: rotate(360deg); } }
.ovl-text{
  font-weight:800;
  text-shadow: 0 2px 16px rgba(0,0,0,.65);
}

/* ---------- Tabs ---------- */
.tile-tabs{
  display:flex;
  gap:6px;
  padding: 8px 14px;
  border-top: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
  background: rgba(2, 6, 23, .50);
  backdrop-filter: blur(6px);
}
.tile-tab{
  flex:0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(2,6,23,.35);
  color: var(--muted);
  font-size:12px;
  cursor:pointer;
  transition: transform .08s ease, background .2s ease, border-color .2s ease, color .2s ease;
}
.tile-tab:hover{
  color: var(--txt);
  border-color: rgba(96,165,250,.25);
  background: rgba(96,165,250,.10);
}
.tile-tab:active{ transform: translateY(1px); }
.tile-tab.active{
  border-color: rgba(96,165,250,.55);
  color: #eaf2ff;
  background: linear-gradient(180deg, rgba(96,165,250,.22), rgba(96,165,250,.10));
  box-shadow: 0 0 0 1px rgba(96,165,250,.10) inset, 0 10px 22px rgba(96,165,250,.10);
}

/* ---------- History panel ---------- */
.history-panel{
  padding: 10px 14px 12px;
  background: rgba(2, 6, 23, .65);
  border-bottom: 1px solid var(--stroke);
  min-height: 130px;
  font-size:12px;
}
.history-inner{ max-height: 220px; overflow-y:auto; }
.history-empty{ color: var(--muted); }
.history-list{ list-style:none; margin:0; padding:0; }
.history-item{
  padding: 6px 0;
  border-bottom: 1px dashed rgba(148,163,184,.18);
}
.history-item:last-child{ border-bottom:none; }
.history-meta{ font-size:11px; color: var(--muted); }

.history-status-success{ color: var(--ok); }
.history-status-failed{ color: var(--err); }
.history-status-active{ color: #38bdf8; }

/* ---------- Slot match / effects blocks ---------- */
.slot-match{
  padding: 8px 14px 6px;
  font-size:12px;
  color: var(--muted);
}
.slot-effects{
  padding: 4px 14px 10px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

/* effect strips */
.effect-strip{
  position:relative;
  width:100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(2,6,23,.8);
  overflow:hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,.03) inset;
}
.effect-strip::after{
  content:"";
  position:absolute; inset:0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  transform: translateX(-120%);
  opacity:.35;
  animation: sheen 4.5s ease-in-out infinite;
}
@keyframes sheen{
  0%,35%{ transform: translateX(-120%); }
  65%,100%{ transform: translateX(120%); }
}
.effect-strip-inner{
  height:100%;
  display:flex;
  align-items:center;
  gap:8px;
  padding: 0 8px;
  font-size:10px;
  line-height:1;
  white-space:nowrap;
}
.effect-strip-buff{ background: linear-gradient(90deg, rgba(34,197,94,.95), rgba(34,197,94,.55)); }
.effect-strip-debuff{ background: linear-gradient(90deg, rgba(239,68,68,.95), rgba(239,68,68,.55)); }
.effect-strip-task{ background: linear-gradient(90deg, rgba(96,165,250,.95), rgba(96,165,250,.55)); }

.effect-strip-label{
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:100%;
}

.effect-tag-remove{
  margin-left:auto;
  border:none;
  background:none;
  color: rgba(148,163,184,.85);
  cursor:pointer;
  padding:0;
  font-size:11px;
  line-height:1;
  transition: color .15s ease, transform .08s ease;
}
.effect-tag-remove:hover{ color: var(--err); }
.effect-tag-remove:active{ transform: translateY(1px); }

/* roulette emphasis */
.tile.roulette-active{
  box-shadow: 0 0 0 2px rgba(56,189,248,.65), 0 0 18px rgba(56,189,248,.35), var(--shadow2);
  transition: box-shadow .12s linear, transform .12s linear;
}
.tile.roulette-selected{
  box-shadow: 0 0 0 2px rgba(34,197,94,.75), 0 0 26px rgba(34,197,94,.45), var(--shadow2);
  transform: translateY(-4px) scale(1.012);
  transition: box-shadow .15s ease-out, transform .15s ease-out;
}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:0;
  border-radius: 12px;
  padding: 9px 12px;
  cursor:pointer;
  color:#fff;
  background: linear-gradient(180deg, rgba(96,165,250,1), rgba(59,130,246,.92));
  box-shadow: 0 10px 26px rgba(59,130,246,.25);
  transition: transform .08s ease, box-shadow .2s ease, filter .2s ease, opacity .2s ease;
}
.btn svg{ pointer-events:none; }
.btn:hover{ box-shadow: 0 14px 34px rgba(59,130,246,.30); filter: brightness(1.05); }
.btn:active{ transform: translateY(1px); }

.btn-small{
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(2,6,23,.60);
  border: 1px solid rgba(96,165,250,.22);
  color: #dbeafe;
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset;
}
.btn-small:hover{
  background: rgba(96,165,250,.10);
  border-color: rgba(96,165,250,.40);
}
.btn-small:active{ transform: translateY(1px); }

/* ---------- Fields (replace inline-look) ---------- */
.field,
input[type="text"],
input[type="number"],
select,
textarea{
  background: var(--field);
  color: var(--txt);
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 10px;
  padding: 7px 10px;
  outline:none;
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset;
}
select{ cursor:pointer; }
textarea{ resize: vertical; }

.field:focus,
input:focus,
select:focus,
textarea:focus{
  border-color: rgba(96,165,250,.55);
  box-shadow: 0 0 0 3px rgba(96,165,250,.12);
}
::placeholder{ color: rgba(148,163,184,.55); }

/* helper sizes (to keep your existing HTML working) */
.field.sm{ padding: 5px 8px; border-radius: 9px; font-size:13px; }
.w90{ width:90px; }
.w110{ width:110px; }
.min140{ min-width:140px; }
.min160{ min-width:160px; }
.min200{ min-width:200px; }
.flex1{ flex:1 1 160px; }

h3{
  margin:0 0 10px;
  font-size:14px;
  letter-spacing:.2px;
}
.muted{ color: var(--muted); }
.p0{ margin:0; }
.ol-clean{ margin:0; padding-left:18px; }
.hr{ border:none; border-top:1px solid rgba(148,163,184,.16); margin:10px 0; }

/* internal subpanel (host controls area) */
.subpanel{
  padding: 12px;
  border-radius: 14px;
  background: rgba(2,6,23,.55);
  border: 1px solid rgba(148,163,184,.16);
  box-shadow: 0 0 0 1px rgba(255,255,255,.02) inset;
}

/* ---------- Footer ---------- */
.foot{
  text-align:center;
  color: var(--muted);
  padding: 18px;
  border-top: 1px solid rgba(148,163,184,.14);
  margin-top: 16px;
}

/* ---------- Side menu ---------- */
.side-menu{
  position:fixed;
  top:0; left:0;
  height:100%;
  width: 280px;
  max-width: 86%;
  background: rgba(2,6,23,.82);
  border-right: 1px solid rgba(148,163,184,.14);
  box-shadow: 2px 0 30px rgba(0,0,0,.55);
  transform: translateX(-100%);
  transition: transform .22s ease-out;
  z-index:1000;
  display:flex;
  flex-direction:column;
  backdrop-filter: blur(10px);
}
.side-menu.open{ transform: translateX(0); }

.side-menu-header{
  padding: 16px 18px;
  border-bottom: 1px solid rgba(148,163,184,.14);
  font-weight:800;
  font-size:15px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.side-menu-body{
  padding: 12px 12px 16px;
  display:flex;
  flex-direction:column;
  gap:10px;
  overflow-y:auto;
}
.side-menu a{ text-decoration:none; }

.side-menu .menu-link{
  display:block;
  width:100%;
  text-align:left;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12,18,34,.55);
  border: 1px solid rgba(148,163,184,.14);
  color: var(--txt);
  font-size:14px;
  cursor:pointer;
  transition: background .2s ease, border-color .2s ease, transform .08s ease;
}
.side-menu .menu-link:hover{
  background: rgba(96,165,250,.10);
  border-color: rgba(96,165,250,.26);
}
.side-menu .menu-link:active{
  transform: translateY(1px);
}

.side-menu-overlay{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.52);
  opacity:0;
  visibility:hidden;
  transition: opacity .18s ease-out;
  z-index:999;
}
.side-menu-overlay.show{
  opacity:1;
  visibility:visible;
}

/* ---------- Cinema mode (keep your behavior, but nicer) ---------- */
body.cinema-mode{ overflow:hidden; }

body.cinema-mode .topbar,
body.cinema-mode .side-menu,
body.cinema-mode .side-menu-overlay,
body.cinema-mode footer,
body.cinema-mode main.grid:nth-of-type(2),
body.cinema-mode .tile-head,
body.cinema-mode .tile-tabs,
body.cinema-mode .tile-foot,
body.cinema-mode .slot-match,
body.cinema-mode .slot-effects,
body.cinema-mode .history-panel{
  display:none !important;
}
body.cinema-mode main.grid:nth-of-type(1){
  max-width:none;
  margin:0;
  padding:0;
  height:100vh;
  display:grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
}
body.cinema-mode main.grid:nth-of-type(1) .tile{
  border-radius:0;
  box-shadow:none;
  border:none;
  background:#000;
}
body.cinema-mode main.grid:nth-of-type(1) .media{
  aspect-ratio:auto;
  height:100%;
}
body.cinema-mode main.grid:nth-of-type(1) video{
  width:100%;
  height:100%;
  object-fit:cover;
}

.cinema-nick{
  position:absolute;
  left:50%;
  bottom:10px;
  transform:translateX(-50%);
  padding: 7px 12px;
  border-radius:999px;
  background: rgba(2,6,23,.55);
  border:1px solid rgba(255,255,255,.14);
  color:#fff;
  font-size:13px;
  font-weight:800;
  opacity:0;
  pointer-events:none;
  transition: opacity .15s ease;
  white-space:nowrap;
  max-width:90%;
  overflow:hidden;
  text-overflow:ellipsis;
  backdrop-filter: blur(6px);
}
body.cinema-mode main.grid:nth-of-type(1) .media:hover .cinema-nick{ opacity:1; }

body.cinema-mode .tile.cinema-full{
  position:fixed;
  inset:0;
  z-index:2000;
}
body.cinema-mode .tile.cinema-full .media{ height:100vh; }

/* exit btn */
.cinema-exit{
  position:fixed;
  right:12px;
  top:12px;
  z-index:2500;
  display:none;
  padding: 10px 12px;
  border-radius: 12px;
  border:1px solid rgba(148,163,184,.18);
  background: rgba(2,6,23,.65);
  color: var(--txt);
  cursor:pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 34px rgba(0,0,0,.35);
}
body.cinema-mode .cinema-exit{ display:inline-flex; }

/* ---------- tiny niceties ---------- */
::-webkit-scrollbar{ width: 10px; }
::-webkit-scrollbar-track{ background: rgba(2,6,23,.35); }
::-webkit-scrollbar-thumb{ background: rgba(148,163,184,.22); border-radius: 999px; border:2px solid rgba(2,6,23,.35); }
::-webkit-scrollbar-thumb:hover{ background: rgba(148,163,184,.32); }

/* FIX: чтобы фон был цельным при скролле (без плиток/прямоугольников) */
html{
  background: radial-gradient(1200px 700px at 20% -10%, #0d1b3b 0%, #070b16 55%, #05070d 100%), #070A12;
  background-attachment: fixed;
}

/* FIX: убираем "крутящийся прямоугольник" и черные края */
body::after{
  content:"";
  position: fixed;          /* обратно fixed — стабильнее в Chromium */
  left: 50%;
  top: 50%;
  width: 180vw;             /* огромный запас */
  height: 180vh;
  transform: translate(-50%, -50%);
  z-index:-2;
  pointer-events:none;

  background:
    radial-gradient(60% 50% at 20% 30%, rgba(96,165,250,.12), transparent 60%),
    radial-gradient(55% 45% at 80% 35%, rgba(167,139,250,.10), transparent 62%),
    radial-gradient(60% 55% at 55% 80%, rgba(34,197,94,.07), transparent 65%);
  filter: blur(18px);
  opacity:.65;
  mix-blend-mode: screen;

  /* мягкое затухание к краям — чтобы вообще не было "границ" */
  -webkit-mask-image: radial-gradient(circle at center, #000 55%, transparent 78%);
  mask-image: radial-gradient(circle at center, #000 55%, transparent 78%);

  animation: drift2 22s linear infinite;
}

@keyframes drift2{
  0%   { transform: translate(-50%,-50%) rotate(0deg)   translate3d(-1%,0,0); }
  100% { transform: translate(-50%,-50%) rotate(14deg)  translate3d( 1%,-1%,0); }
}


/* на всякий случай: стабилизируем рендер и убираем “швы” */
body{
  background: transparent;    /* фон теперь на html */
  overflow-x:hidden;
}
