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

html,
body {
  width: 100%;
  height: 100%;
  background: #050608;
  color: #f5f5f5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #050608;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

#tutorial-ui {
  position: absolute;
  bottom: 12vh;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80vw;
  z-index: 150;
  pointer-events: none;
  display: flex;
  justify-content: center;
  text-align: center;
}

#tutorial-text {
  display: inline-block;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 4px;
  border: 1px solid rgba(0, 255, 170, 0.4);
  box-shadow: 0 0 18px rgba(0, 255, 170, 0.25);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #e8fff5;
}

#screen-fade-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 400;
  transition: opacity 2.5s ease-in-out;
}

#main-menu {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.menu-background {
  position: absolute;
  inset: 0;
  background-image: url("20260102225513_1.jpg");
  background-size: cover;
  background-position: center;
  filter: grayscale(0.85) contrast(1.5) brightness(0.25);
  animation: bg-jitters 20s steps(1) infinite, bg-drift 60s linear infinite;
}

@keyframes bg-drift {
  0% { transform: scale(1); }
  50% { transform: scale(1.1) translate(1%, 1%); }
  100% { transform: scale(1); }
}

@keyframes bg-jitters {
  0%, 100% { transform: scale(1) translate(0,0); }
  33% { transform: scale(1.02) translate(2px, -1px); filter: grayscale(0.85) brightness(0.3); }
  34.5% { transform: scale(1) translate(-4px, 2px); filter: grayscale(1) brightness(0.15) invert(0.05); }
  35% { transform: scale(1) translate(0,0); filter: grayscale(0.85) brightness(0.25); }
  66% { transform: scale(1.01) translate(-1px, 2px); }
  98% { transform: scale(1.2) translate(10px, 10px); filter: invert(0.2) brightness(0.4); }
  99% { transform: scale(1) translate(0,0); }
}

.menu-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 20%, rgba(0,0,0,0.85) 90%);
  pointer-events: none;
  z-index: 2;
}

.menu-scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  z-index: 3;
  pointer-events: none;
  animation: scanline-scroll 0.2s linear infinite;
}

@keyframes scanline-scroll {
  0% { background-position: 0 0; }
  100% { background-position: 0 4px; }
}

.menu-glitch-overlay {
  position: absolute;
  inset: 0;
  background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAGFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs697FAAAACHRSTlMA78fVz6p7X0C0BwAAADtJREFUKM9jYMAHGBPBYYIJIBXGZIIJJBVGZYIJIBXmZIIJIBUWFIAJJBWmZIIJIBXGZIIJJBVGZYIJIBUAGB8CP0O00GIAAAAASUVORK5CYII=");
  pointer-events: none;
  z-index: 4;
  opacity: 0.05;
}

.menu-monster-flicker {
  position: absolute;
  inset: 0;
  background-image: url("./STALKERSCARE (2).jpg");
  background-size: cover;
  background-position: center;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: overlay;
  animation: monster-glitch 12s linear infinite;
}

@keyframes monster-glitch {
  0%, 94.5%, 95.5%, 96.5%, 97.5%, 100% { opacity: 0; }
  95% { opacity: 0.4; transform: scale(1.1) translate(10px, -5px); }
  96% { opacity: 0.2; transform: scale(0.9) translate(-10px, 5px); filter: hue-rotate(90deg); }
  97% { opacity: 0.5; transform: scale(1.3) translate(0, 0); filter: invert(1); }
}

.menu-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  animation: menu-fade-in 0.5s ease-out;
}

@keyframes menu-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.title-container {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: -15vh; /* Shifts the entire title/beta group significantly upwards */
}

.title-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0 20px;
}

.menu-title {
  width: 90vw;
  max-width: 580px;
  filter: drop-shadow(0 0 25px rgba(255, 0, 0, 0.4)) brightness(1.1);
  position: relative;
  z-index: 2;
}

.beta-wrapper {
  position: relative;
  margin-top: 5px; /* Places the beta text clearly below the title instead of overlapping */
  width: 100%;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.menu-beta {
  width: 30vw;
  max-width: 220px;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.6));
  opacity: 0.9;
  animation: beta-pulse 4s ease-in-out infinite;
  z-index: 3;
}

@keyframes beta-pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3)); }
  50% { transform: scale(1.04); opacity: 1; filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.8)); }
}

.glitch-layer, .glitch-layer-2 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.glitch-layer {
  filter: drop-shadow(2px 0 red);
  animation: glitch-anim-1 4s infinite linear alternate-reverse;
}

.glitch-layer-2 {
  filter: drop-shadow(-2px 0 blue);
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
  0%, 90% { opacity: 0; transform: translate(0); }
  91% { opacity: 0.5; transform: translate(-5px, 2px); }
  93% { opacity: 0; transform: translate(0); }
  95% { opacity: 0.8; transform: translate(5px, -2px); }
  96% { opacity: 0; }
}

@keyframes glitch-anim-2 {
  0%, 85% { opacity: 0; transform: translate(0); }
  86% { opacity: 0.6; transform: translate(3px, -1px); }
  88% { opacity: 0; transform: translate(0); }
  97% { opacity: 0.9; transform: translate(-3px, 1px); }
  99% { opacity: 0; }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
  max-width: 320px;
  margin-top: 10px;
}

.menu-description {
  position: absolute;
  max-width: 260px;
  min-height: 40px;
  padding: 8px 10px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #cccccc;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 4px;
  border: 1px solid rgba(255, 0, 0, 0.35);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.85);
  overflow: hidden;
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition:
    opacity 0.18s ease-out,
    transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 20;
}

.menu-description.visible {
  opacity: 1;
  transform: translateX(0);
}

.menu-buttons.horizontal {
  flex-direction: row;
  max-width: 500px;
  justify-content: center;
}

.almanac-container {
  width: 90%;
  max-width: 720px;
  max-height: 55vh;
  padding: 18px;
  background: rgba(0, 0, 0, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.9);
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.achievements-container {
  width: 90%;
  max-width: 720px;
  max-height: 55vh;
  padding: 18px;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.9);
  overflow-y: auto;
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.achievement-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 4px;
  background: linear-gradient(to right, rgba(15, 15, 15, 0.9), rgba(10, 10, 10, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.achievement-row.locked {
  opacity: 0.35;
  filter: grayscale(1);
}

.achievement-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: radial-gradient(circle at 30% 20%, #00ffaa, #004422);
  flex-shrink: 0;
  position: relative;
}

.achievement-row-icon::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.6);
}

.achievement-row-body {
  display: flex;
  flex-direction: column;
}

.achievement-row-title {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: #ffffff;
  text-transform: uppercase;
}

.achievement-row-desc {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: #bbbbbb;
  margin-top: 2px;
}

.achievement-row-status {
  margin-left: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #00ffaa;
}

.almanac-section {
  padding: 10px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.almanac-section:last-child {
  border-bottom: none;
}

.almanac-section-title {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: #ff3333;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.almanac-section-body {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #ddd;
}

.almanac-section-body p {
  margin-bottom: 6px;
}

.almanac-section-body p:last-child {
  margin-bottom: 0;
}

.almanac-subtitle {
  margin-top: 8px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #00ffaa;
  text-transform: uppercase;
}

.almanac-tag {
  color: #ffcc00;
}

.almanac-red {
  color: #ff5555;
}

.almanac-footer {
  margin-top: 12px;
}

.menu-btn.small {
  padding: 10px 15px;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.menu-btn {
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #888;
  padding: 14px 20px;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 500;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-text {
  position: relative;
  z-index: 2;
}

.menu-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: #ff0000;
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.menu-btn:hover {
  background: rgba(255, 0, 0, 0.05);
  border-color: rgba(255, 0, 0, 0.3);
  color: #fff;
  text-shadow: 0 0 8px rgba(255, 0, 0, 0.6);
  padding-left: 30px;
}

.menu-btn:hover::before {
  transform: scaleY(1);
}

.btn-glitch {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
}

.menu-btn:hover .btn-glitch {
  animation: btn-glitch-anim 0.4s steps(2) infinite;
}

/* Click feedback */
.menu-btn.clicked {
  animation: menu-btn-click 0.14s ease-out;
}

@keyframes menu-btn-click {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}

@keyframes btn-glitch-anim {
  0%, 100% { opacity: 0; transform: translate(0); }
  25% { opacity: 0.15; transform: translate(-4px, 2px); background: rgba(255, 0, 0, 0.2); }
  50% { opacity: 0.1; transform: translate(4px, -2px); background: rgba(0, 0, 255, 0.2); }
  75% { opacity: 0.2; transform: translate(-2px, -1px); }
}

.ticker-container {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: rgba(10, 0, 0, 0.8);
  border-top: 1px solid rgba(255, 0, 0, 0.2);
  padding: 10px 0;
  white-space: nowrap;
  overflow: hidden;
  z-index: 100;
  box-shadow: 0 -10px 20px rgba(0,0,0,0.5);
}

.ticker-text {
  display: inline-block;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: rgba(255, 50, 50, 0.8);
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: ticker 40s linear infinite;
  text-shadow: 0 0 5px rgba(255, 0, 0, 0.3);
}

@keyframes ticker {
  from { transform: translateX(100%); }
  to { transform: translateX(-100%); }
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 10%, rgba(40,0,0,0.5), rgba(0,0,0,0.96));
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: linear-gradient(145deg, #080808, #151515);
  border: 1px solid rgba(255, 0, 0, 0.3);
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
  padding: 26px 22px;
  width: 90%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  0% { opacity: 0; transform: scale(0.9) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(0, 255, 136, 0.1);
  border-top-color: #00ff88;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-family: 'Courier New', Courier, monospace;
  color: #00ff88;
  letter-spacing: 4px;
  font-weight: bold;
}

.loading-subtext {
  font-family: 'Courier New', Courier, monospace;
  color: #666;
  font-size: 0.8rem;
  letter-spacing: 2px;
}

.modal-content h2 {
  font-family: 'Courier New', Courier, monospace;
  color: #ff3333;
  margin-bottom: 6px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.death-title {
  color: #ff0000 !important;
  font-size: 2.5rem;
  text-shadow: 0 0 15px rgba(255, 0, 0, 0.7);
  animation: death-flicker 0.2s infinite;
}

@keyframes death-flicker {
  0% { opacity: 1; }
  50% { opacity: 0.8; }
  100% { opacity: 1; }
}

.death-screen-layout {
  background: #000 !important;
  flex-direction: column;
  justify-content: space-between;
  padding: 5vh 0;
}

#death-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
}

.death-screen-layout[style*="display: flex"] #death-flash {
  animation: impact-frames 0.4s ease-out forwards;
  animation-delay: 0.75s; /* Sync with skull slam peak */
}

@keyframes impact-frames {
  0% { opacity: 0; }
  10% { opacity: 1; }
  20% { opacity: 0; }
  30% { opacity: 0.8; }
  100% { opacity: 0; }
}

.death-skull-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
}

.death-skull-img {
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
  opacity: 0;
  animation: skull-slam 1.4s cubic-bezier(0.15, 0.85, 0.35, 1.2) forwards;
  animation-delay: 0.2s;
}

@keyframes skull-slam {
  0% {
    transform: scale(0.1) translateZ(-500px);
    opacity: 0;
  }
  40% {
    transform: scale(8) translateZ(200px);
    opacity: 1;
    filter: brightness(2) contrast(2);
  }
  60% {
    transform: scale(1) translateZ(0);
    opacity: 1;
    filter: brightness(1) contrast(1);
  }
  100% {
    transform: scale(1) translateZ(0);
    opacity: 1;
  }
}

.death-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  opacity: 0;
  animation: fade-in 1s ease-out forwards;
  animation-delay: 1.2s;
}

#death-cause {
  font-family: 'Courier New', Courier, monospace;
  color: #ff3333;
  font-weight: bold;
  letter-spacing: 4px;
  font-size: 1.1rem;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.4);
}

#death-hint {
  font-family: 'Courier New', Courier, monospace;
  color: #888;
  font-style: italic;
  font-size: 0.9rem;
  max-width: 80%;
  text-align: center;
}

.death-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-bottom: 40px;
  opacity: 0;
  animation: fade-in 1s ease-out forwards;
  animation-delay: 1.8s;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.death-buttons-horizontal {
  flex-direction: row !important;
  gap: 30px !important;
}

.death-btn-text {
  background: transparent !important;
  border: none !important;
  font-size: 1.2rem !important;
  color: #555 !important;
  transition: color 0.3s ease !important;
}

.death-btn-text:hover {
  color: #fff !important;
  padding-left: 40px !important; /* Keep movement effect */
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5) !important;
}

.death-btn-text::after {
  display: none !important;
}

.death-btn-text:hover::after {
  animation: none !important;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
}

.setting-row input {
  accent-color: #a00;
}

/* Pause overlay */
#pause-overlay .pause-content {
  background: linear-gradient(145deg, #050505, #151010);
  border: 1px solid rgba(255, 0, 0, 0.35);
  padding: 24px 20px;
  max-width: 320px;
  text-align: center;
}

#pause-overlay .pause-content h2 {
  font-family: 'Courier New', Courier, monospace;
  color: #ff4444;
  letter-spacing: 4px;
  margin-bottom: 18px;
}

.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Start confirmation overlay */
#start-confirm-overlay .start-confirm-content {
  max-width: 360px;
  text-align: center;
}

#start-confirm-overlay p {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  color: #ccc;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Ensure confirm buttons sit side-by-side cleanly on mobile */
#start-confirm-overlay .menu-buttons.horizontal {
  margin-top: 10px;
}

/* Existing HUD */
#hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 12px;
  color: #e6e6e6;
  text-shadow: 0 0 4px #000;
}

#hud span {
  margin-right: 8px;
}

#win-screen {
  position: absolute;
  inset: 0;
  z-index: 500;
  background: #000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.win-background {
  position: absolute;
  inset: 0;
  background-image: url("escape.jpg");
  background-size: cover;
  background-position: center;
  filter: brightness(0.7) contrast(1.1);
  animation: win-bg-pulse 20s ease-in-out infinite;
}

@keyframes win-bg-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.win-content {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 60%);
}

.win-text-container {
  width: 80%;
  max-width: 600px;
  height: 40vh;
  margin-bottom: 5vh;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
}

.win-text-scroll {
  position: absolute;
  width: 100%;
  top: 100%;
  animation: win-scroll 18s linear forwards;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
}

.win-text-scroll p {
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  font-size: 1.2rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

@keyframes win-scroll {
  0% { top: 100%; }
  100% { top: -140%; }
}

.fade-out-overlay {
  animation: fade-out-final 2s forwards;
}

@keyframes fade-out-final {
  from { opacity: 0; }
  to { opacity: 1; }
}

#joystick-container {
  position: absolute;
  left: 6vw;
  bottom: 8vh;
  width: 140px;
  height: 140px;
  max-width: 35vw;
  max-height: 35vw;
  z-index: 10;
}

#inventory {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(5, 6, 8, 0.7);
  border-radius: 6px;
  border: 1px solid rgba(220, 220, 220, 0.12);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.inventory-slot {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 1px solid rgba(220, 220, 220, 0.25);
  background: rgba(10, 12, 16, 0.9);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.8);
  position: relative;
}

.inventory-slot.has-gas {
  border-color: rgba(160, 220, 160, 0.9);
  box-shadow:
    inset 0 0 0 1px rgba(20, 255, 120, 0.25),
    0 0 6px rgba(20, 255, 120, 0.3);
}

.inventory-slot.has-gas::before {
  content: "";
  position: absolute;
  inset: 4px;
  background-image: url("gas.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
}

/* Multi-player & Lobby Styles */

.terminal-header {
  font-family: 'Courier New', Courier, monospace;
  color: #ff3333;
  letter-spacing: 5px;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
  margin-bottom: 20px;
}

.browser-container {
  width: 90%;
  max-width: 600px;
  height: 40vh;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 0, 0, 0.2);
  overflow-y: auto;
  padding: 10px;
  box-shadow: inset 0 0 20px rgba(255, 0, 0, 0.1);
}

.lobby-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-item {
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid #333;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.lobby-item:hover {
  border-color: #ff0000;
  background: rgba(40, 10, 10, 0.9);
}

.lobby-item.searching {
  justify-content: center;
  color: #666;
  font-style: italic;
  pointer-events: none;
}

.lobby-header {
  text-align: center;
  margin-bottom: 20px;
}

#lobby-id-display {
  font-family: 'Courier New', Courier, monospace;
  color: #00ffaa;
  font-size: 1.4rem;
}

.player-count {
  font-size: 0.9rem;
  color: #888;
  margin-top: 5px;
}

.mingebag-slots {
  display: flex;
  gap: 20px;
  justify-content: center;
  width: 100%;
  padding: 0 20px;
  margin-bottom: 30px;
}

.minge-slot {
  width: 180px;
  height: 260px;
  background: #000;
  border: 2px solid rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  clip-path: polygon(15% 0, 100% 0, 100% 85%, 85% 100%, 0 100%, 0 15%);
}

.minge-slot::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 4px, 100% 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0.4;
}

.minge-slot.active {
  border-color: #00ffaa;
  box-shadow: 0 0 35px rgba(0, 255, 170, 0.2);
  transform: translateY(-8px);
}

.minge-slot.ready {
  border-color: #ffcc00;
  box-shadow: 0 0 30px rgba(255, 204, 0, 0.4);
}

.minge-portrait-bg {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: url("360_F_319202173_lChFjDK92X4FwE7pbzfjFueIRrRjkJiL.jpg");
  background-size: cover;
  background-position: center;
  opacity: 0.15;
  filter: grayscale(1) brightness(0.2);
  transition: opacity 0.5s, filter 0.5s;
}

.minge-slot.active .minge-portrait-bg {
  opacity: 1;
  filter: grayscale(0.2) contrast(1.4) brightness(0.8) hue-rotate(45deg);
  animation: swirl-bg 15s linear infinite;
}

@keyframes swirl-bg {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.minge-img {
  width: 130%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  filter: grayscale(1) contrast(1.5) brightness(0.1);
  opacity: 0.4;
  transition: all 0.5s ease;
}

.minge-slot.active .minge-img {
  opacity: 1;
  filter: grayscale(0) contrast(1.1) brightness(1.1) drop-shadow(0 0 10px rgba(0, 255, 170, 0.3));
  transform: translateX(-50%) scale(1.05);
}

.minge-slot.ready .minge-img {
  filter: contrast(1.2) brightness(1.2) drop-shadow(0 0 20px rgba(255, 204, 0, 0.5));
}

.minge-info {
  margin-top: auto;
  width: 100%;
  background: rgba(0, 0, 0, 0.9);
  padding: 12px 5px;
  text-align: center;
  border-top: 1px solid rgba(0, 255, 170, 0.2);
  z-index: 3;
  backdrop-filter: blur(5px);
}

.terminal-decorator {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  color: #00ffaa;
  opacity: 0.6;
  margin-bottom: 5px;
  letter-spacing: 1px;
}

.minge-name {
  display: block;
  font-weight: bold;
  font-size: 0.9rem;
  color: #fff;
  text-transform: uppercase;
}

.minge-status {
  font-size: 0.7rem;
  color: #555;
  margin-top: 4px;
}

.minge-slot.ready .minge-status {
  color: #00ff88;
  text-shadow: 0 0 5px #00ff88;
}

.lobby-controls {
  display: flex;
  gap: 15px;
}

.lobby-scroller {
  position: absolute;
  bottom: 80px;
  width: 100%;
  height: 30px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.scroller-inner {
  white-space: nowrap;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: rgba(0, 255, 170, 0.4);
  line-height: 30px;
  animation: lobby-scroll 20s linear infinite;
}

@keyframes lobby-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Lobby side lore strips */
.lobby-lore-strip {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 110px; /* Narrower so it hugs the edge and doesn't intrude into main lobby content */
  pointer-events: none;
  z-index: 1; /* Sit visually behind the main lobby UI */
  display: flex;
  align-items: flex-end;
  padding-bottom: 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent 65%);
}

.lobby-lore-left {
  left: 0;
  padding-left: 10px;
}

.lobby-lore-right {
  right: 0;
  padding-right: 10px;
}

.lobby-lore-strip .lore-inner {
  display: flex;
  flex-direction: column;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: rgba(255, 40, 40, 0.9);
  text-transform: uppercase;
  animation: lobby-lore-scroll 6s linear infinite; /* Much faster continuous scroll */
  opacity: 0.85;
}

.lobby-lore-strip .lore-inner span {
  /* Each span holds the same binary so scrolling -50% loops seamlessly */
  padding-bottom: 8px;
}

@keyframes lobby-lore-scroll {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-100%); } /* Scroll an entire content height so the duplicated spans loop seamlessly */
}

#joystick-container {
  z-index: 10;
}

.spectate-banner {
  background: rgba(10, 0, 0, 0.8);
  display: inline-block;
  padding: 15px 30px;
  border: 1px solid #ff0000;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
  color: #ff0000;
  font-family: 'Courier New', Courier, monospace;
  text-transform: uppercase;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.spectate-label {
  font-size: 0.7rem;
  letter-spacing: 3px;
  opacity: 0.7;
}

.spectate-name {
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: 5px;
  margin: 5px 0;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.6);
}

.spectate-hint {
  font-size: 0.6rem;
  letter-spacing: 1px;
  color: #888;
}

/* Chat UI */
#arcade-hud {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 100;
  pointer-events: none;
  font-family: 'Courier New', Courier, monospace;
}

.hud-item {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(0, 255, 170, 0.3);
  padding: 8px 15px;
  box-shadow: 0 0 15px rgba(0, 255, 170, 0.1);
  backdrop-filter: blur(4px);
}

.hud-label {
  font-size: 0.6rem;
  color: #00ffaa;
  opacity: 0.8;
  letter-spacing: 2px;
  margin-bottom: 2px;
}

#hud-score {
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.gens-container {
  width: 200px;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#hud-gens-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  margin: 5px 0;
  border-radius: 3px;
  overflow: hidden;
}

#hud-gens-fill {
  height: 100%;
  width: 0%;
  background: #00ffaa;
  box-shadow: 0 0 10px #00ffaa;
  transition: width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#hud-gens-text {
  font-size: 0.8rem;
  color: #fff;
}

#chat-container {
  position: absolute;
  left: 20px;
  bottom: 110px;
  width: 320px;
  height: 220px;
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}

#chat-log {
  flex: 1;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: #00ffaa;
  text-shadow: 0 0 5px rgba(0, 255, 170, 0.5);
  mask-image: linear-gradient(to top, black 80%, transparent);
}

.chat-msg {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 4px;
  margin-bottom: 2px;
  animation: msg-fade 5s forwards;
}

@keyframes msg-fade {
  0% { opacity: 1; transform: translateX(-5px); }
  5% { transform: translateX(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.chat-input-wrapper {
  pointer-events: all;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 255, 170, 0.2);
}

#chat-input {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  padding: 8px;
  font-family: 'Courier New', Courier, monospace;
  outline: none;
}

#chat-input::placeholder {
  color: rgba(0, 255, 170, 0.3);
}

/* Notifications */
#notification-area {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  z-index: 1000;
}

.achievement-toast {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 260px;
  background: rgba(10, 10, 10, 0.96);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 10px 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  font-family: 'Courier New', Courier, monospace;
  z-index: 1200;
  pointer-events: none;
  transform: translateX(120%);
  opacity: 0;
}

.achievement-toast.show {
  animation: achievement-slide-in 0.4s cubic-bezier(0.22, 0.61, 0.36, 1) forwards,
             achievement-slide-out 0.4s ease-in forwards 4.4s;
}

.achievement-icon {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  background: radial-gradient(circle at 30% 20%, #00ffaa, #004422);
  margin-right: 10px;
  position: relative;
}

.achievement-icon::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.7);
}

.achievement-text {
  display: flex;
  flex-direction: column;
}

.achievement-title {
  font-size: 0.8rem;
  font-weight: bold;
  color: #ffffff;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.achievement-desc {
  font-size: 0.7rem;
  color: #bbbbbb;
  margin-top: 2px;
}

@keyframes achievement-slide-in {
  0% {
    transform: translateX(120%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes achievement-slide-out {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(120%);
    opacity: 0;
  }
}

.notification {
  background: rgba(0, 0, 0, 0.85);
  border-left: 3px solid #ff0000;
  color: #fff;
  padding: 12px 20px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  letter-spacing: 1px;
  animation: notification-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
             notification-out 0.4s ease-in forwards 4.6s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

@keyframes notification-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes notification-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

#countdown-display {
  transition: all 0.3s ease;
}

.countdown-pulse {
  animation: countdown-impact 0.5s ease-out;
}

@keyframes countdown-impact {
  0% { transform: scale(1.5); opacity: 0.5; filter: blur(5px); }
  100% { transform: scale(1); opacity: 1; filter: blur(0); }
}

/* Joystick only visible on touch */
@media (hover: hover) and (pointer: fine) {
  #joystick-container {
    display: none;
  }
}