/* The screen and the glass over it: scanlines, flicker, glow, power-on,
   interference and the CRT extras. Motion plays only under
   html[data-motion="full"], set by S.syncContext. */
.screen {
  position: relative;
  height: 100%;
  border-radius: 18px / 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: radial-gradient(ellipse at 50% 45%, #242B2E 0%, var(--hall) 58%, #171C1E 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.55);
  font-size: clamp(13px, 1.5vw, 15.5px);
  line-height: 1.5;
  text-shadow: var(--glow);
  /* A long press opens the game's context menu, so the iOS callout stays away */
  -webkit-touch-callout: none;
}
.screen.size-s {
  font-size: clamp(11.5px, 1.2vw, 13px);
}
.screen.size-l {
  font-size: clamp(14.5px, 1.75vw, 18px);
}
body.frameless .screen {
  border-radius: 0;
}
body.no-glow .screen {
  text-shadow: none;
}
@media (max-width: 640px) {
  .screen {
    border-radius: 10px;
    font-size: 13px;
  }
}
/* The glass covers every interface layer (--z-effects) */
.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.45) 100%), linear-gradient(160deg, rgba(255, 255, 255, 0.035) 0%, transparent 35%);
  z-index: var(--z-effects);
}
/* Scanlines */
.glass::before {
  content: "";
  position: absolute;
  inset: -2px 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 0, rgba(0, 0, 0, 0.2) 1px, transparent 1px, transparent 3px);
}
body.no-scan .glass {
  background: radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.35) 100%);
}
body.no-scan .glass::before {
  display: none;
}
body.sr-mode .glass {
  display: none;
}
/* Rolling scanline: fainter lines with a slow bright band, drifting down.
   context.js sets body.scan-roll only while motion is full. */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(to bottom, transparent 0%, rgba(214, 195, 150, 0.07) 50%, transparent 100%) 0 -40% / 100% 30% no-repeat,
    repeating-linear-gradient(to bottom, rgba(214, 195, 150, 0.045) 0, rgba(214, 195, 150, 0.045) 1px, transparent 1px, transparent 4px);
}
body.scan-roll .glass::after {
  opacity: 1;
  animation: scan-roll 18s linear infinite;
}
@keyframes scan-roll {
  from { background-position: 0 -40%, 0 0; }
  to { background-position: 0 140%, 0 48px; }
}
/* Glare and curvature: dim edges and a faint curved glare. The curved
   outline is a clip path from js/ui/crtmask.js. */
body.crt-curve .glass {
  background:
    radial-gradient(ellipse 58% 34% at 26% 10%, rgba(255, 244, 220, 0.075), transparent 70%),
    radial-gradient(ellipse 46% 18% at 72% 97%, rgba(255, 244, 220, 0.035), transparent 70%),
    radial-gradient(ellipse 82% 80% at 50% 50%, transparent 66%, rgba(0, 0, 0, 0.24) 100%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.035) 0%, transparent 35%);
}
/* Content and overlays move inside the curved corners */
body.crt-curve .screen {
  padding: var(--crt-pad, 0px);
}
body.crt-curve .notification-stack {
  right: calc(0.8em + var(--crt-pad, 0px));
  top: calc(2.2em + var(--crt-pad, 0px));
}
body.crt-curve .screen.desktop .notification-stack {
  top: auto;
  right: auto;
  bottom: calc(1em + var(--crt-pad, 0px));
  left: calc(1em + var(--crt-pad, 0px));
}
body.crt-curve .cine {
  padding: calc(1.5em + var(--crt-pad, 0px));
}
body.crt-curve .dlg-ov {
  padding: calc(1em + var(--crt-pad, 0px));
}
/* Flicker, power-on and the interference shake */
html[data-motion="full"] body:not(.no-flicker) .glass {
  animation: flicker 3.8s infinite steps(1);
}
html[data-motion="full"] body.powered:not(.no-poweron) .screen {
  animation: poweron 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
html[data-motion="full"] .screen.interfere .panes {
  animation: jitter 0.48s steps(6) 1;
}
.screen.interfere .glass {
  box-shadow: inset 0 0 0 9999px rgba(214, 195, 150, 0.12);
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  24% { opacity: 0.84; }
  25% { opacity: 1; }
  68% { opacity: 0.9; }
  69% { opacity: 1; }
}
@keyframes poweron {
  0% { transform: scale(1, 0.004); filter: brightness(3); }
  45% { transform: scale(1, 0.004); filter: brightness(3); }
  70% { transform: scale(1, 1.02); filter: brightness(1.4); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}
@keyframes jitter {
  0% { transform: translate(0, 0); filter: none; }
  20% { transform: translate(-2.5px, 1px); filter: brightness(1.12) blur(0.4px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1.5px, 0.5px); filter: brightness(0.85); }
  80% { transform: translate(1px, 0.5px); }
  100% { transform: translate(0, 0); filter: none; }
}
/* The ending plays as film: body.cinema, set while its stage covers the
   screen, removes every CRT effect */
body.cinema .screen {
  clip-path: none !important;
  padding: 0 !important;
  animation: none !important;
  transform: none !important;
  text-shadow: none;
}
body.cinema .glass {
  display: none;
}
body.cinema .cine {
  padding: 1.5em;
  text-shadow: none;
}
