:root {
  color-scheme: dark;
  --halloween-bg: #11130f;
  --halloween-panel: #20231e;
  --halloween-panel-raised: #29271f;
  --halloween-line: #49443a;
  --halloween-text: #ece9df;
  --halloween-muted: #c5c2b8;
  --halloween-orange: #f2a45f;
  --halloween-orange-dark: #d85b20;
  --halloween-green: #b5d47d;
}

body {
  color: var(--halloween-text) !important;
  background-color: var(--halloween-bg) !important;
  background-image:
    radial-gradient(ellipse at 12% 8%, rgba(157, 57, 20, .2), transparent 34%),
    radial-gradient(ellipse at 90% 80%, rgba(101, 39, 18, .16), transparent 38%),
    linear-gradient(145deg, #10120f, #1b1d18 55%, #111310) !important;
}

.navbar,
.nav-links,
.dropdown-content {
  background-color: #171a16 !important;
}

.navbar {
  border-bottom: 1px solid rgba(237, 105, 39, .45) !important;
  box-shadow: 0 5px 22px rgba(0, 0, 0, .38) !important;
}

.navbar a,
.dropbtn,
.menu-toggle {
  color: #f2eee5 !important;
}

.navbar a:hover,
.navbar a.active-link,
.dropbtn:hover,
.dropbtn.active-link,
.menu-toggle:hover,
.dropdown-content a:hover {
  color: #ffbd78 !important;
  background-color: #39251b !important;
}

.nav-links > a,
.nav-links > .dropdown > .dropbtn {
  border-color: rgba(237, 105, 39, .24) !important;
}

.container,
.login-container,
.table-container,
.panel,
.card,
.modal-box,
.chart-modal-dialog,
.chart-stage,
.chart-stat,
.encoder-chart-card {
  color: var(--halloween-text) !important;
  background: linear-gradient(145deg, #252822, #1b1e19) !important;
  border-color: var(--halloween-line) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .32) !important;
}

.dashboard-container::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: -50px;
  right: -55px;
  width: 220px;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: .14;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 14deg, #d4c5aa 14.5deg 15deg),
    repeating-radial-gradient(circle at center, transparent 0 19px, #d4c5aa 20px 21px, transparent 22px 39px);
  mask-image: radial-gradient(circle, #000 0 68%, transparent 70%);
}

.season-tag {
  display: inline-block;
  margin: 0 auto 10px;
  padding: 7px 12px;
  border: 1px solid rgba(242, 137, 65, .55);
  border-radius: 4px;
  background: rgba(102, 43, 20, .28);
  color: #ffc07d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}

.theme-picker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin: -24px 0 18px;
}

.theme-picker-label {
  color: #d4d0c4 !important;
  font-size: 12px;
  font-weight: 700;
}

.theme-picker-options {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid #62594b;
  border-radius: 7px;
  background: #171a16;
}

.theme-picker-options button {
  min-height: 32px;
  padding: 6px 11px;
  border: 0 !important;
  border-radius: 4px;
  color: #d4d0c4 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.theme-picker-options button[aria-pressed="true"] {
  color: #fff8ee !important;
  background: #d85b20 !important;
}

.theme-picker-options button:hover {
  background: #39251b !important;
}

.theme-picker-options button[aria-pressed="true"]:hover {
  background: #f07832 !important;
}

body > header {
  background: linear-gradient(110deg, #39271d, #20231e) !important;
  border-bottom: 1px solid var(--halloween-line) !important;
}

.btn-home {
  color: #fff8ee !important;
  background-color: var(--halloween-orange-dark) !important;
  border-color: var(--halloween-orange-dark) !important;
}

.halloween-signin-message {
  display: none;
  width: 100%;
  height: 58px;
  margin: -5px 0 16px;
  overflow: hidden;
  border-top: 1px solid rgba(242, 164, 95, .38);
  border-bottom: 1px solid rgba(242, 164, 95, .38);
  background: rgba(75, 36, 20, .35);
}

html[data-app-theme="halloween"] .halloween-signin-message {
  display: flex;
  align-items: center;
}

.halloween-signin-track {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  width: max-content;
  animation: halloween-signin-slide 7s linear infinite;
}

.halloween-signin-text {
  flex: 0 0 auto;
  color: #ffbd78;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 10px rgba(255, 112, 37, .65), 0 0 24px rgba(255, 112, 37, .32);
  white-space: nowrap;
}

.pacman-chase {
  position: relative;
  display: inline-block;
  flex: 0 0 210px;
  width: 210px;
  height: 46px;
}

.pacman-ghost {
  position: absolute;
  top: 4px;
  left: 104px;
  width: 34px;
  height: 38px;
  border-radius: 50% 50% 3px 3px;
  background: #f4eee4;
  clip-path: polygon(0 100%, 0 42%, 5% 24%, 18% 9%, 37% 1%, 50% 0, 64% 2%, 82% 10%, 95% 26%, 100% 43%, 100% 100%, 84% 87%, 68% 100%, 51% 87%, 34% 100%, 17% 87%);
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, .35));
}

.pacman-ghost-pink { left: 88px; background: #ff70b5; animation: pacman-catch-pink 2s linear infinite; }
.pacman-ghost-red { left: 124px; background: #ef4d54; animation: pacman-catch-red 2s linear infinite; }
.pacman-ghost-blue { left: 160px; background: #50bce8; animation: pacman-catch-blue 2s linear infinite; }

.pacman-ghost::before {
  content: "";
  position: absolute;
  top: 13px;
  left: 9px;
  width: 5px;
  height: 8px;
  border-radius: 50%;
  background: #28231d;
  box-shadow: 11px 0 #28231d;
}

.pacman-dots {
  position: absolute;
  top: 20px;
  left: 48px;
  display: flex;
  width: 40px;
  align-items: center;
  justify-content: space-between;
}

.pacman-pellet {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #ffe4a1;
  box-shadow: 0 0 6px rgba(255, 219, 130, .75);
  animation: pacman-pellet-eat 2s steps(1, end) infinite;
}

.pacman-pellet:nth-child(1) { animation-name: pacman-pellet-one; }
.pacman-pellet:nth-child(2) { animation-name: pacman-pellet-two; }
.pacman-pellet:nth-child(3) { animation-name: pacman-pellet-three; }
.pacman-pellet:nth-child(4) { animation-name: pacman-pellet-four; }

@keyframes pacman-pellet-one {
  0%, 10% { opacity: 1; transform: scale(1); }
  12%, 100% { opacity: .12; transform: scale(.4); }
}

@keyframes pacman-pellet-two {
  0%, 18% { opacity: 1; transform: scale(1); }
  20%, 100% { opacity: .12; transform: scale(.4); }
}

@keyframes pacman-pellet-three {
  0%, 25% { opacity: 1; transform: scale(1); }
  27%, 100% { opacity: .12; transform: scale(.4); }
}

@keyframes pacman-pellet-four {
  0%, 31% { opacity: 1; transform: scale(1); }
  33%, 100% { opacity: .12; transform: scale(.4); }
}

.pacman-chomper {
  position: absolute;
  top: 3px;
  left: 2px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffd447;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  animation: pacman-chomp .18s steps(1, end) infinite alternate,
    pacman-chase-step 2s ease-in-out infinite;
}

@keyframes pacman-catch-pink {
  0%, 5% { transform: translate(0, 2px) scale(.2); opacity: 0; }
  9% { transform: translate(0, 0) scale(1); opacity: 1; }
  22% { transform: translate(8px, -2px) rotate(5deg); opacity: 1; }
  36% { transform: translate(14px, 1px) rotate(-5deg); opacity: 1; }
  40% { transform: translate(14px, 0) scale(1); opacity: 1; }
  42% { transform: translate(8px, 0) scale(.35); opacity: .25; }
  44%, 100% { transform: translate(0, 0) scale(.1); opacity: 0; }
}

@keyframes pacman-catch-red {
  0%, 21% { transform: translate(0, 2px) scale(.2); opacity: 0; }
  25% { transform: translate(0, 0) scale(1); opacity: 1; }
  42% { transform: translate(8px, -2px) rotate(5deg); opacity: 1; }
  55% { transform: translate(14px, 1px) rotate(-5deg); opacity: 1; }
  58% { transform: translate(14px, 0) scale(1); opacity: 1; }
  60% { transform: translate(8px, 0) scale(.35); opacity: .25; }
  62%, 100% { transform: translate(0, 0) scale(.1); opacity: 0; }
}

@keyframes pacman-catch-blue {
  0%, 45% { transform: translate(0, 2px) scale(.2); opacity: 0; }
  49% { transform: translate(0, 0) scale(1); opacity: 1; }
  62% { transform: translate(8px, -2px) rotate(5deg); opacity: 1; }
  68% { transform: translate(14px, 1px) rotate(-5deg); opacity: 1; }
  70% { transform: translate(14px, 0) scale(1); opacity: 1; }
  72% { transform: translate(8px, 0) scale(.35); opacity: .25; }
  74%, 100% { transform: translate(0, 0) scale(.1); opacity: 0; }
}

@keyframes pacman-chase-step {
  0%, 8% { transform: translateX(0); }
  20% { transform: translateX(22px); }
  34% { transform: translateX(50px); }
  48% { transform: translateX(78px); }
  62% { transform: translateX(108px); }
  70%, 90% { transform: translateX(140px); }
  99% { transform: translateX(140px); }
  100% { transform: translateX(0); }
}

@keyframes pacman-chomp {
  from { clip-path: polygon(0 0, 100% 0, 100% 25%, 48% 50%, 100% 75%, 100% 100%, 0 100%); }
  to { clip-path: polygon(0 0, 100% 0, 100% 47%, 48% 50%, 100% 53%, 100% 100%, 0 100%); }
}

@keyframes halloween-signin-slide {
  from { transform: translateX(100%); }
  to { transform: translateX(-100%); }
}

h1,
h2,
h3,
h4,
.chart-modal-title h3,
.encoder-chart-header h4 {
  color: var(--halloween-orange) !important;
}

p,
label,
.small-muted,
.chart-modal-title p,
.chart-status,
.chart-legend,
.chart-empty,
.encoder-chart-meta,
.encoder-chart-header span,
.encoder-chart-count span {
  color: var(--halloween-muted) !important;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  color: var(--halloween-text) !important;
  background-color: #171a16 !important;
  border-color: #62594b !important;
}

input::placeholder,
textarea::placeholder {
  color: #a19c90 !important;
}

table,
tbody,
td {
  color: var(--halloween-text) !important;
  background-color: #1c1f1a !important;
  border-color: #393b33 !important;
}

th {
  color: #ffc07d !important;
  background-color: #39271d !important;
  border-color: #514033 !important;
}

tr:hover,
.encoder-chart-card:hover,
.encoder-chart-card.active {
  background-color: #30291f !important;
}

button,
.btn,
.view-btn,
.chart-btn,
.encoder-all-btn {
  color: #fff8ee !important;
  background-color: var(--halloween-orange-dark) !important;
  border-color: #bd4d1e !important;
}

button:hover,
.btn:hover,
.view-btn:hover,
.chart-btn:hover,
.encoder-all-btn:hover,
.encoder-all-btn.active {
  background-color: #f07832 !important;
}

.logout-link,
.logout-link:hover {
  color: #fff !important;
  background-color: #a9362d !important;
}

.status-unauthenticated {
  color: #ffd28c !important;
  background-color: #49341d !important;
}

.status-authenticated,
.auth-count-box {
  color: #c8df9a !important;
  background-color: #27301f !important;
  border-color: #56633d !important;
}

.coc-link,
.chart-stat strong,
.encoder-chart-meta strong,
.encoder-chart-count {
  color: #f2a45f !important;
}

.chart-modal {
  background: rgba(4, 5, 4, .82) !important;
}

.chart-modal-header {
  border-color: var(--halloween-line) !important;
}

.chart-close {
  color: var(--halloween-text) !important;
  background: #39352d !important;
}

.chart-progress,
.encoder-progress {
  background: #3a3930 !important;
}

.encoder-progress span {
  background: linear-gradient(90deg, #b64d22, #e89a4e) !important;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 5;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

body::before {
  top: 34vh;
  left: 0;
  width: clamp(150px, 20vw, 270px);
  height: clamp(150px, 20vw, 270px);
  opacity: .3;
  background-image: url("theme/scary1.png");
  filter: drop-shadow(0 0 18px rgba(255, 255, 255, .4));
  animation: halloween-ghost-flight 12s linear -4.8s infinite;
}

body::after {
  top: 8vh;
  right: 0;
  width: clamp(170px, 23vw, 300px);
  height: clamp(170px, 23vw, 300px);
  opacity: .38;
  background-image: url("theme/scary2.png");
  filter: drop-shadow(0 0 20px rgba(230, 111, 52, .55));
  animation: halloween-ghoul-flight 16s linear -12s infinite;
}

@keyframes halloween-ghost-flight {
  0% { transform: translate(-30vw, 18vh) rotate(-12deg) scale(.78); }
  25% { transform: translate(20vw, -8vh) rotate(7deg) scale(.95); }
  55% { transform: translate(66vw, 18vh) rotate(-8deg) scale(1.08); }
  100% { transform: translate(125vw, -16vh) rotate(12deg) scale(.9); }
}

@keyframes halloween-ghoul-flight {
  0% { transform: translate(120vw, -15vh) rotate(10deg) scale(.82); }
  30% { transform: translate(62vw, 16vh) rotate(-8deg) scale(1); }
  65% { transform: translate(15vw, -6vh) rotate(6deg) scale(1.12); }
  100% { transform: translate(-120vw, 18vh) rotate(-12deg) scale(.88); }
}

@media (max-width: 768px) {
  .nav-links {
    background-color: #171a16 !important;
  }

  .theme-picker {
    margin: -7px 0 16px;
  }

  body::before {
    top: 38vh;
    width: clamp(120px, 34vw, 170px);
    height: clamp(120px, 34vw, 170px);
    opacity: .2;
  }

  body::after {
    top: 12vh;
    width: clamp(130px, 38vw, 190px);
    height: clamp(130px, 38vw, 190px);
    opacity: .25;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after { animation: none; }

  .halloween-signin-track {
    width: max-content;
    animation: none;
  }

  .pacman-ghost,
  .pacman-chomper,
  .pacman-pellet { animation: none; }
}