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

html,
body {
  height: 100%;
}

body {
  font-family: "JetBrains Mono", monospace;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #f5f5f5;
  padding: clamp(1rem, 4vw, 2rem);
  padding-top: max(env(safe-area-inset-top), clamp(1rem, 4vw, 2rem));
  padding-bottom: max(env(safe-area-inset-bottom), clamp(1rem, 4vw, 2rem));
  padding-left: max(env(safe-area-inset-left), clamp(1rem, 4vw, 2rem));
  padding-right: max(env(safe-area-inset-right), clamp(1rem, 4vw, 2rem));
  position: relative;
  overflow-x: hidden;
}

/* Background layer */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--bg-image, #0a0a0a) center/cover no-repeat;
}

/* Overlay for readability */
.overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.6) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    rgba(0, 0, 0, 0.6) 100%
  );
  backdrop-filter: blur(0.5px);
}

.container {
  position: absolute;
  max-width: 420px;
  width: calc(100% - clamp(2rem, 8vw, 4rem));
  padding: clamp(1.5rem, 5vw, 2.5rem);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: clamp(12px, 3vw, 16px);
  animation: fadeIn 0.8s ease-out;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.container:active {
  cursor: grabbing;
}

.container.dragging {
  opacity: 0.9;
  transition: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.greeting {
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 400;
  color: #fff;
  margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
  word-break: break-all;
}

.greeting span {
  color: #34d399;
  text-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
}

nav {
  margin-bottom: clamp(2rem, 6vw, 3rem);
}

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.75rem, 3vw, 1.5rem);
}

nav a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  font-size: clamp(15px, 4vw, 18px);
  padding: 0.5rem 0;
  transition: all 0.15s ease;
}

nav a:hover {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.6);
}

@media (hover: none) {
  nav a:active {
    color: #fff;
    text-decoration-color: rgba(255, 255, 255, 0.6);
  }
}

footer {
  font-size: clamp(10px, 2.5vw, 12px);
  color: rgba(255, 255, 255, 0.4);
}

/* Image credit panel */
.image-credit {
  position: absolute;
  max-width: min(320px, calc(100vw - 2rem));
  padding: clamp(0.75rem, 2.5vw, 1rem) clamp(1rem, 3vw, 1.25rem);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: clamp(10px, 2.5vw, 11px);
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.5;
  animation: slideUp 1s ease-out 0.3s both;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.image-credit:active {
  cursor: grabbing;
}

.image-credit.dragging {
  opacity: 0.9;
  transition: none;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.image-credit .meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.image-credit .meta .label {
  color: rgba(255, 255, 255, 0.2);
}

.image-credit .prompt {
  color: rgba(255, 255, 255, 0.55);
}

/* Menu button */
.menu-btn {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px) + 0.75rem, 1rem);
  right: max(env(safe-area-inset-right, 0px) + 0.75rem, 1rem);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 100;
  -webkit-tap-highlight-color: transparent;
}

.menu-btn:hover {
  background: rgba(0, 0, 0, 0.55);
  border-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.menu-btn:active {
  transform: scale(0.95);
}

.menu-btn svg {
  width: 20px;
  height: 20px;
  fill: rgba(255, 255, 255, 0.7);
  transition: fill 0.2s ease;
}

.menu-btn:hover svg {
  fill: rgba(255, 255, 255, 0.9);
}

.menu-btn.open svg {
  fill: #34d399;
}

/* Dropdown menu */
.menu-dropdown {
  position: fixed;
  top: calc(max(env(safe-area-inset-top, 0px) + 0.75rem, 1rem) + 52px);
  right: max(env(safe-area-inset-right, 0px) + 0.75rem, 1rem);
  min-width: 180px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.2s ease;
  z-index: 99;
}

.menu-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.menu-dropdown button {
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.15s ease;
}

.menu-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.menu-dropdown button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  opacity: 0.6;
}

.menu-dropdown button:hover svg {
  opacity: 1;
}

/* Responsive adjustments */

/* Small phones */
@media (max-width: 380px) {
  .container {
    width: calc(100% - 1rem);
  }

  .image-credit {
    max-width: calc(100vw - 1rem);
  }

  .greeting {
    font-size: 14px;
  }

  nav a {
    font-size: 14px;
  }
}

/* Tablets and larger - allow more breathing room */
@media (min-width: 768px) {
  .container {
    max-width: 460px;
  }
}

/* Landscape phones - stack vertically to avoid overflow */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    justify-content: flex-start;
    padding-top: 1rem;
  }

  .image-credit {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    top: auto !important;
    left: auto !important;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .container,
  .image-credit {
    /* Allow touch scrolling when not dragging */
    touch-action: manipulation;
  }

  .menu-dropdown button {
    padding: 1rem;
    min-height: 48px;
  }
}
