/* CRT shell ported from src/shell.css for the DevilutionX page. */

:root {
  --crt-plastic: #c9bba0;
  --crt-plastic-hi: #ddd0b6;
  --crt-plastic-lo: #a89878;
  --ui-font: "Exo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-ink: #f2e6c8;
  --ui-ink-dim: #b8a888;
  --ui-accent: #e8c98a;
  --ui-accent-hi: #f5e6c0;
  --ui-good: #8dff9a;
  --ui-danger: #ff8a7a;
  --ui-glass: rgba(14, 12, 10, 0.88);
  --ui-glass-border: rgba(232, 201, 138, 0.28);
}

.svg-sprite-hidden {
  position: absolute;
  width: 0;
  height: 0;
}

#stage {
  background: #000;
  font-family: var(--ui-font);
}

.crt-chassis {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: transparent;
}

#stage.crt-mode .crt-chassis {
  overflow: visible;
  background-color: var(--crt-plastic);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, rgba(255, 250, 235, 0.45), transparent 55%),
    radial-gradient(ellipse 90% 70% at 50% 110%, rgba(90, 75, 55, 0.28), transparent 50%),
    linear-gradient(165deg, var(--crt-plastic-hi) 0%, var(--crt-plastic) 42%, var(--crt-plastic-lo) 100%);
  box-shadow:
    0 0 0 1px rgba(30, 24, 16, 0.65),
    0 1px 0 rgba(255, 245, 220, 0.28),
    0 16px 40px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 245, 220, 0.12),
    inset 18px 0 28px rgba(0, 0, 0, 0.14),
    inset -18px 0 28px rgba(0, 0, 0, 0.14),
    inset 0 14px 22px rgba(255, 245, 220, 0.08),
    inset 0 -18px 26px rgba(40, 30, 20, 0.18);
}

#stage.crt-mode .crt-chassis::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.4;
  background-image:
    repeating-linear-gradient(0deg, transparent 0, transparent 1px, rgba(60, 45, 30, 0.035) 1px, rgba(60, 45, 30, 0.035) 2px),
    repeating-linear-gradient(90deg, transparent 0, transparent 1px, rgba(60, 45, 30, 0.028) 1px, rgba(60, 45, 30, 0.028) 2px);
  mix-blend-mode: multiply;
}

.crt-badge-samsung,
.crt-badge-model,
.crt-well,
.crt-scanlines,
.crt-glass,
.crt-phosphor {
  display: none;
  pointer-events: none;
}

#stage.crt-mode .crt-well {
  display: block;
  position: absolute;
  z-index: 1;
  border-radius: 3.8% / 4.8%;
  background: radial-gradient(ellipse 94% 92% at 50% 48%, #3a342c 0%, var(--crt-plastic-lo) 55%, var(--crt-plastic) 100%);
  box-shadow:
    inset 0 4px 7px rgba(0, 0, 0, 0.28),
    inset 0 -2px 4px rgba(255, 240, 210, 0.08),
    inset 5px 0 8px rgba(0, 0, 0, 0.18),
    inset -5px 0 8px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

#stage.crt-mode .crt-badge-samsung {
  display: block;
  position: absolute;
  z-index: 2;
  width: auto;
  filter: drop-shadow(0 1px 0 rgba(255, 245, 220, 0.15));
}

#stage.crt-mode .crt-badge-model {
  display: flex;
  position: absolute;
  z-index: 2;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
  color: #2a2e32;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.2);
  font-family: Helvetica, Arial, "Liberation Sans", sans-serif;
  white-space: nowrap;
}

#stage.crt-mode .crt-badge-model-name {
  font-weight: 700;
}

#stage.crt-mode .crt-badge-model-sub {
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-top: 0.22em;
  opacity: 0.85;
}

.crt-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

#stage.crt-mode .crt-screen {
  z-index: 2;
  overflow: hidden;
  isolation: isolate;
  border-radius: 3.2% / 4.2%;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 0 28px rgba(0, 0, 0, 0.35),
    0 0 0 2px #0c0a08,
    0 0 0 3px rgba(255, 245, 220, 0.08);
}

#stage.crt-mode .crt-screen canvas,
#stage.crt-mode .crt-scanlines,
#stage.crt-mode .crt-glass,
#stage.crt-mode .crt-phosphor {
  border-radius: inherit;
}

#stage.scan-mode .crt-scanlines,
#stage.crt-mode .crt-scanlines {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  mix-blend-mode: multiply;
  opacity: 0.9;
}

#stage.crt-mode .crt-phosphor {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse 90% 88% at 50% 50%, rgba(255, 220, 160, 0.035) 0%, transparent 62%),
    linear-gradient(180deg, rgba(36, 72, 48, 0.045) 0%, rgba(20, 28, 24, 0.025) 40%, rgba(48, 32, 20, 0.035) 100%);
  mix-blend-mode: soft-light;
}

#stage.crt-mode .crt-glass {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 4;
  background:
    linear-gradient(165deg, rgba(255, 240, 220, 0.22) 0%, rgba(255, 230, 200, 0.06) 7%, transparent 34%),
    radial-gradient(ellipse 96% 94% at 50% 50%, transparent 48%, rgba(4, 10, 8, 0.38) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 220, 0.3),
    inset 0 0 56px rgba(12, 24, 20, 0.12);
}

#tyr-controls {
  display: flex;
  flex-direction: column;
  position: absolute;
  z-index: 20;
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  font-family: var(--ui-font);
}

#tyr-controls .crt-hotkey {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  #tyr-controls .crt-hotkey {
    display: flex;
    position: absolute;
    right: -4px;
    bottom: -4px;
    box-sizing: border-box;
    width: 1.7em;
    height: 1.7em;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 1px solid rgba(232, 201, 138, 0.4);
    background: rgba(18, 16, 14, 0.92);
    color: var(--ui-ink);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}

#tyr-controls .crt-ctrl-btn {
  appearance: none;
  border: 1px solid rgba(232, 201, 138, 0.28);
  cursor: pointer;
  position: relative;
  width: clamp(36px, 4vw, 44px);
  height: clamp(36px, 4vw, 44px);
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-ink);
  background: rgba(18, 16, 14, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
}

#tyr-controls .crt-ctrl-btn::before {
  content: "";
  position: absolute;
  inset: -8px;
}

#tyr-controls .crt-ctrl-btn:hover {
  background: rgba(40, 34, 28, 0.88);
  border-color: rgba(232, 201, 138, 0.45);
}

#tyr-controls .crt-ctrl-btn:active {
  transform: scale(0.96);
}

#tyr-controls .crt-ctrl-btn.active {
  color: var(--ui-good);
  border-color: rgba(125, 255, 154, 0.45);
  background: rgba(28, 48, 32, 0.75);
}

#tyr-controls .crt-ctrl-btn svg {
  width: 54%;
  height: 54%;
  display: block;
  pointer-events: none;
}

#tyr-controls .crt-ctrl-btn [hidden] {
  display: none !important;
}

#tyr-controls #btn-mute.is-muted {
  color: var(--ui-danger);
  border-color: rgba(255, 138, 122, 0.4);
}

#tyr-controls #btn-mute .mute-slash {
  display: none;
  position: absolute;
  inset: 18%;
  pointer-events: none;
}

#tyr-controls #btn-mute .mute-slash::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2.5px;
  margin-top: -1px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-42deg);
}

#tyr-controls #btn-mute.is-muted .mute-slash {
  display: block;
}
