:root{
  --blue:#00ffff;
  --pink:#ff00ff;
  --vh:1vh;
}

*,*::before,*::after{ box-sizing:border-box; }

html,body{
  margin:0;
  padding:0;
  height:100%;
  background:#111;
  color:var(--blue);
  font-family:'Orbitron',system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
}

/* BACKGROUND TEXT */
#background-text{
  position:fixed;
  inset:0;
  display:flex;
  flex-wrap:wrap;
  pointer-events:none;
  z-index:0;
  opacity:.68;

  font-family:'Share Tech Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-weight:700;
  line-height:1.05;
  letter-spacing:.02em;
  color:var(--blue);
  text-shadow:
    0 0 1px rgba(0,0,0,.95),
    0 0 10px rgba(0,255,255,.65),
    0 0 26px rgba(0,255,255,.30);
}
#background-text span{ flex:0 0 auto; width:1ch; height:1em; opacity:0; }
@keyframes charFade{ to{ opacity:1; } }

/* BUTTON BASE */
button,
.modal-button,
#backHomeBtn{
  font-family:inherit;
  font-weight:800;
  letter-spacing:.04em;
  background:rgba(0,0,0,.15);
  color:#fff;
  border:2px solid rgba(255,255,255,.18);
  border-radius:6px;
  cursor:pointer;
  text-shadow:0 0 10px rgba(0,255,255,.25);
  -webkit-text-stroke:.35px rgba(0,0,0,.45);
  transition:background .15s ease, border-color .15s ease, transform .15s ease;
  touch-action:manipulation;
}
button:hover,
.modal-button:hover,
#backHomeBtn:hover{
  background:rgba(255,255,255,.08);
  border-color:rgba(0,255,255,.55);
}

/* TOP NAV */
#loginBtn,#registerBtn,#logoutBtn{
  position:fixed;
  top:16px;
  width:160px;
  padding:8px 0;
  font-size:18px;
  z-index:1000;
}
#loginBtn{ left:14px; }
#registerBtn{ right:14px; }
#logoutBtn{
  left:50%;
  transform:translateX(-50%);
  border-color:rgba(255,0,255,.7);
  text-shadow:0 0 10px rgba(255,0,255,.35);
}
@media (max-width:420px){
  #loginBtn,#registerBtn,#logoutBtn{
    top:10px;width:124px;padding:7px 0;font-size:15px;
  }
  #loginBtn{ left:10px; }
  #registerBtn{ right:10px; }
}
@media (max-width:340px){
  #loginBtn,#registerBtn{
    left:50%; right:auto; transform:translateX(-50%);
    width:156px;
  }
  #loginBtn{ top:8px; }
  #registerBtn{ top:54px; }
}

/* HOME */
#home{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:40px;
  z-index:100;
}
#home button{ width:200px; padding:20px 0; font-size:24px; }

/* RECORDER */
#recorder{
  position:fixed;
  inset:0;
  background:#000;
  padding:10px;
  border:2px solid var(--blue);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:1000;
  box-shadow:0 0 14px rgba(0,255,255,.25) inset;
}
#preview{ width:100%; height:100%; object-fit:cover; border-radius:4px; }
#switchBtn,#stopBtn{
  position:absolute;
  top:16px;
  padding:10px;
  background:rgba(0,0,0,.35);
  border:2px solid var(--blue);
  border-radius:4px;
  color:var(--blue);
  font-size:16px;
}
#switchBtn{ left:16px; }
#stopBtn{ right:16px; }

/* REVIEW PANEL (stable scroll) */
#reviewPanel{
  position:fixed;
  inset:0;
  height:calc(var(--vh) * 100);
  background:#111;
  z-index:1000;
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;

  padding-top: calc(20px + env(safe-area-inset-top));
  padding-left:  calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: max(140px, calc(140px + env(safe-area-inset-bottom)));
}

#backHomeBtn{
  display:block;
  margin:0 auto 16px;
  padding:10px 20px;
  font-size:16px;
  background:rgba(0,0,0,.85);
  border:2px solid var(--blue);
  color:var(--blue);
}

/* GRID */
#sessionList{
  list-style:none;
  margin:0;
  padding:0;

  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap:24px;

  justify-content:center;
  align-content:start;
  align-items:start;
}
@media (max-width:360px){
  #sessionList{
    grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
    gap:18px;
  }
}

/* TILE (no infinite animations / no 3D tearing) */
.tile{
  display:flex;
  flex-direction:column;
  gap:12px;

  background:rgba(10,10,10,.86);
  border:2px solid rgba(0,255,255,.90);
  border-radius:10px;
  padding:20px;
  min-height:280px;
  text-align:center;

  overflow:hidden;              /* prevents any internal bleed */
  isolation:isolate;
  contain:layout paint;          /* keeps layout stable */
  transform:translateZ(0);       /* stable compositing, no 3D */
  box-shadow:
    0 0 20px rgba(0,255,255,.45),
    inset 0 0 16px rgba(0,255,255,.16);
}

/* Hover effect only on desktop (safe) */
@media (hover:hover) and (pointer:fine){
  .tile:hover{
    transform:translateZ(0) translateY(-2px);
    box-shadow:
      0 0 26px rgba(0,255,255,.60),
      inset 0 0 18px rgba(0,255,255,.18);
  }
}

.timestamp{
  margin:0;
  font-size:.85em;
  color:var(--blue);
  background:rgba(0,0,0,.55);
  padding:6px 10px;
  border-radius:6px;
  text-shadow:0 0 8px rgba(0,255,255,.55);
  border:1px solid rgba(0,255,255,.20);
}

.tile button{ width:100%; }

/* ACTION buttons */
.download-button{
  padding:10px 18px;
  background:linear-gradient(120deg,var(--blue),var(--pink),var(--blue));
  background-size:200% 200%;
  color:#111;
  font-weight:900;
  border:none;
  border-radius:6px;
}
.trailer-button{
  padding:8px 14px;
  background:rgba(0,0,0,.72);
  border:2px solid rgba(0,255,255,.85);
  border-radius:6px;
  color:var(--blue);
  font-size:.9em;
  text-shadow:0 0 8px rgba(0,255,255,.55);
}

/* Bottom action row (delete never disappears) */
.tile-actions{
  margin-top:auto;
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  justify-content:center;
}
.tile-actions .delete-button{
  flex:1 1 160px;
  min-width:160px;
  padding:10px 14px;
  background:rgba(0,0,0,.80);
  border:2px solid rgba(255,0,255,.85);
  color:var(--pink);
  text-shadow:0 0 10px rgba(255,0,255,.35);
}

/* MODALS (fast show) */
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.86);
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:opacity .12s ease;
  z-index:99999;
}
.modal.show{
  opacity:1;
  visibility:visible;
  pointer-events:auto;
}
.modal-content{
  position:relative;
  background:#111;
  padding:20px;
  border-radius:10px;
  border:2px solid rgba(0,255,255,.85);
  box-shadow:0 0 22px rgba(0,255,255,.55);
  text-align:center;
  width:min(92vw, 360px);
}
.modal-close{
  position:absolute;
  top:8px;
  right:10px;
  background:none;
  border:none;
  color:var(--pink);
  font-size:1.8em;
  cursor:pointer;
  line-height:1;
  text-shadow:0 0 12px rgba(255,0,255,.70);
}
.modal-content h2{
  color:#fff;
  font-size:1.15em;
  margin:0 0 16px;
  font-weight:900;
  text-shadow:
    0 0 10px rgba(255,0,255,.35),
    0 0 14px rgba(0,255,255,.18);
}
.modal-buttons{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  justify-content:center;
}
.modal-button{ min-width:128px; padding:10px 14px; font-size:16px; }
.modal-button.blue{ border-color:rgba(0,255,255,.85); color:var(--blue); }
.modal-button.pink{ border-color:rgba(255,0,255,.85); color:var(--pink); }
