* {
  box-sizing: border-box;
  image-rendering: pixelated;
}

html, body {
  padding: 18px;
  margin: 0;
  height: 100%;
  width: 100%;

  font-family: var(--font-ui);
  background: var(--ui-black);
  user-select: none;
}

@media (max-width: 768px) {
  html, body {
    padding: 8px;
  }

  #desktop {
    grid-template-columns: repeat(auto-fill, 60px);
    gap: 5px;
    padding: 10px;
    justify-content: center;
  }

  .icon {
    width: 60px;
  }

  /* Hide desktop-only menu items on mobile */
  .desktop-only {
    display: none !important;
  }

  /* Mobile dropdown menu */
  .mobile-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--ui-light);
    border: 2px solid var(--ui-black);
    box-shadow: 2px 2px 0 var(--ui-dark);
    min-width: 160px;
    z-index: 100;
  }

  .mobile-dropdown.show {
    display: block;
  }

  .mobile-dropdown a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ui-black);
    font-size: 13px;
    border-bottom: 1px solid var(--ui-dark);
  }

  .mobile-dropdown a:last-child {
    border-bottom: none;
  }

  .mobile-dropdown a:hover {
    background: var(--ui-black);
    color: var(--ui-light);
  }

  .apple-logo {
    cursor: pointer !important;
  }

  .menu-item {
    position: relative;
  }
}

#desktop {
  position: relative;
  border-bottom-left-radius: var(--bezel-radius);
  border-bottom-right-radius: var(--bezel-radius);
  width: 100%;
  height: 100%;
  background-image: url('../assets/backgrounds/147.png');
  background-repeat: repeat;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, 72px);
  grid-template-rows: repeat(auto-fill, 90px);
  gap: 10px;
  padding: 20px;
  align-content: start;
  justify-content: end;
}

#menu-bar {
  height: fit-content;
  background: var(--ui-light);
  border-bottom: 2px solid var(--ui-black);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: normal;
  border-top-left-radius: var(--bezel-radius);
  border-top-right-radius: var(--bezel-radius);
}

.menu-item a {
  margin-right: 16px;
  text-decoration: none;
  color: var(--ui-black);
  cursor: default;
}

.menu-right {
  margin-right: 16px;
  margin-left: 16px;
  font-size: inherit;
  font-weight: inherit;
}

.menu-item img {
  margin-left: 10px;
  margin-right: 8px;
  width: 14px;
  height: 14px;
}

.menu-dropdown {
  position: relative;
  display: inline-block;
}

.menu-trigger {
  cursor: default;
  padding-right: 6px;
}

.menu-dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 20px;
  left: 0;
  background: var(--ui-light);
  border: 2px solid var(--ui-black);
  box-shadow: 2px 2px 0 var(--ui-dark);
  min-width: 140px;
  z-index: 100;
}

.dropdown-menu a {
  display: block;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--ui-black);
  font-size: 13px;
}

.dropdown-menu a:hover {
  background: var(--ui-black);
  color: var(--ui-light);
}

/* Mobile dropdown - hidden by default on desktop */
.mobile-dropdown {
  display: none;
}

.icon {
  width: 72px;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
}

.icon img {
  width: 32px;
  height: 32px;
}

.icon div {
  font-family: var(--font-ui);
  background: var(--ui-light);
}

@keyframes flicker {
  0%   { opacity: 0.27861; }
  5%   { opacity: 0.34769; }
  10%  { opacity: 0.23604; }
  15%  { opacity: 0.90626; }
  20%  { opacity: 0.18128; }
  25%  { opacity: 0.83891; }
  30%  { opacity: 0.65583; }
  35%  { opacity: 0.67807; }
  40%  { opacity: 0.26559; }
  45%  { opacity: 0.84693; }
  50%  { opacity: 0.96019; }
  55%  { opacity: 0.08594; }
  60%  { opacity: 0.20313; }
  65%  { opacity: 0.71988; }
  70%  { opacity: 0.53455; }
  75%  { opacity: 0.37288; }
  80%  { opacity: 0.71428; }
  85%  { opacity: 0.70419; }
  90%  { opacity: 0.7003;  }
  95%  { opacity: 0.36108; }
  100% { opacity: 0.24387; }
}

.crt::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(18, 16, 16, 0.1);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  animation: flicker 0.05s infinite;
}

.crt::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  z-index: 2;
  background-size: 100% 2px, 3px 100%;
  pointer-events: none;
}
