:root {
  --bg-1: #070f18;
  --bg-2: #101f32;
  --surface: rgba(9, 16, 25, 0.84);
  --surface-strong: rgba(7, 12, 20, 0.94);
  --surface-soft: rgba(15, 28, 45, 0.72);
  --stroke: rgba(190, 224, 255, 0.2);
  --stroke-strong: rgba(190, 224, 255, 0.34);
  --text-main: #edf7ff;
  --text-soft: rgba(226, 242, 255, 0.74);
  --accent: #6db8ff;
  --accent-strong: #93cbff;
  --danger: #ff8f8f;
  --shadow-main: 0 18px 40px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text-main);
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 14%, rgba(73, 128, 196, 0.24), transparent 45%),
    radial-gradient(circle at 85% 7%, rgba(0, 170, 140, 0.2), transparent 46%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

#app {
  position: relative;
}

#game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game-root {
  position: absolute;
  inset: 0;
}

#top-hud-stack {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 0.75rem;
  right: 0.75rem;
  z-index: 7;
  display: grid;
  justify-items: start;
  gap: 0.48rem;
}

#top-left-hud {
  display: grid;
  gap: 0.4rem;
  width: min(380px, 100%);
  padding: 0.75rem 0.78rem;
  border-radius: 1rem;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(170deg, rgba(20, 36, 56, 0.86), rgba(7, 14, 23, 0.87)),
    radial-gradient(circle at 100% 0%, rgba(109, 184, 255, 0.18), transparent 46%);
  box-shadow: var(--shadow-main);
  backdrop-filter: blur(9px);
  transition: opacity 140ms ease, transform 140ms ease;
}

body.project-panel-open #top-left-hud {
  opacity: 0.7;
}

.report-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 700;
  color: rgba(202, 229, 255, 0.9);
}

#report-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.34;
  color: var(--text-main);
}

#hud-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#progress-text {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-soft);
}

#email-cta,
#sound-btn,
#mobile-controls button,
#dialog-close,
#project-close {
  border: 1px solid rgba(173, 220, 255, 0.42);
  border-radius: 0.7rem;
  background: linear-gradient(180deg, rgba(25, 52, 81, 0.94), rgba(10, 23, 40, 0.94));
  color: var(--text-main);
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease;
}

#email-cta,
#sound-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.44rem;
  text-decoration: none;
}

#email-cta::before,
#sound-btn::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  flex: 0 0 0.95rem;
}

#email-cta::before {
  background-image: url("./assets/ui/icon-mail.svg");
}

#sound-btn::before {
  background-image: url("./assets/ui/icon-sound-on.svg");
}

#sound-btn[data-muted="true"]::before {
  background-image: url("./assets/ui/icon-sound-off.svg");
}

#email-cta {
  padding: 0.4rem 0.68rem;
}

#sound-btn {
  padding: 0.38rem 0.64rem;
  min-width: 110px;
}

#email-cta:hover,
#sound-btn:hover,
#mobile-controls button:hover,
#dialog-close:hover,
#project-close:hover {
  filter: brightness(1.05);
  border-color: rgba(173, 220, 255, 0.7);
}

#email-cta:active,
#sound-btn:active,
#mobile-controls button:active,
#dialog-close:active,
#project-close:active {
  transform: translateY(1px);
}

#email-cta:focus-visible,
#sound-btn:focus-visible,
#mobile-controls button:focus-visible,
#dialog-close:focus-visible,
#project-close:focus-visible,
#project-links a:focus-visible {
  outline: 3px solid rgba(147, 203, 255, 0.45);
  outline-offset: 2px;
}

#controls-indicator {
  position: relative;
  justify-self: center;
  max-width: min(680px, 100%);
  margin: 0;
  padding: 0.44rem 0.68rem;
  border-radius: 999px;
  border: 1px solid rgba(183, 220, 255, 0.42);
  background: rgba(12, 24, 40, 0.82);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.33);
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(229, 244, 255, 0.95);
  text-align: center;
  line-height: 1.15;
  transition: opacity 120ms ease, transform 120ms ease;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

body.project-panel-open #controls-indicator {
  opacity: 0;
  transform: translateY(-8px);
}

#controls-indicator kbd {
  border: 1px solid rgba(195, 226, 255, 0.46);
  border-radius: 0.34rem;
  background: linear-gradient(180deg, rgba(38, 68, 103, 0.96), rgba(20, 39, 64, 0.96));
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  padding: 0.08rem 0.3rem;
  font: inherit;
  font-weight: 700;
}

#dialog-box,
#project-panel {
  position: absolute;
  border-radius: 1rem;
  border: 1px solid var(--stroke-strong);
  box-shadow: var(--shadow-main);
  background:
    linear-gradient(170deg, rgba(14, 26, 41, 0.94), rgba(6, 12, 20, 0.94)),
    radial-gradient(circle at 100% 0%, rgba(109, 184, 255, 0.16), transparent 44%);
  z-index: 6;
  color: var(--text-main);
  backdrop-filter: blur(10px);
}

#dialog-box {
  left: clamp(0.6rem, 2vw, 1rem);
  right: clamp(0.6rem, 2vw, 1rem);
  bottom: clamp(0.6rem, 2vw, 1rem);
  max-width: 900px;
  margin: 0 auto;
  padding: 0.78rem 0.82rem;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.58rem;
}

#dialog-text {
  line-height: 1.35;
  font-size: 0.92rem;
}

#dialog-text p {
  margin: 0 0 0.35rem 0;
}

#dialog-text p:last-child {
  margin-bottom: 0;
}

#project-panel {
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  width: min(560px, calc(100% - 1.5rem));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.95rem 0.9rem;
}

#project-panel .eyebrow {
  margin: 0;
  width: fit-content;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(173, 220, 255, 0.32);
  background: rgba(21, 43, 66, 0.72);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: rgba(214, 238, 255, 0.92);
}

#project-close {
  position: absolute;
  right: 0.62rem;
  top: 0.62rem;
  width: 1.95rem;
  height: 1.95rem;
  font-size: 0;
  background-image: url("./assets/ui/icon-close.svg"), linear-gradient(180deg, rgba(29, 57, 86, 0.97), rgba(14, 30, 51, 0.98));
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: 1rem 1rem, auto;
}

#project-panel h2 {
  margin: 0.38rem 0 0.36rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.24;
  letter-spacing: 0.01em;
  padding-right: 2.1rem;
}

#project-panel h3 {
  margin: 0.95rem 0 0.44rem;
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: rgba(208, 236, 255, 0.82);
}

#project-meta {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-soft);
}

#project-story {
  margin: 0;
  line-height: 1.45;
  font-size: 0.92rem;
  color: rgba(230, 244, 255, 0.92);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.55rem;
}

.gallery-card {
  border: 1px solid rgba(173, 220, 255, 0.26);
  border-radius: 0.78rem;
  padding: 0.52rem;
  background:
    linear-gradient(170deg, rgba(20, 40, 61, 0.72), rgba(12, 24, 38, 0.72)),
    radial-gradient(circle at 100% 0%, rgba(109, 184, 255, 0.12), transparent 52%);
}

.gallery-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.58rem;
  border: 1px solid rgba(173, 220, 255, 0.22);
  background: linear-gradient(135deg, rgba(40, 68, 97, 0.6), rgba(18, 35, 55, 0.8));
  margin-bottom: 0.46rem;
}

.gallery-media img,
.gallery-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-media-missing::after {
  content: "Missing media";
  position: absolute;
  left: 0.55rem;
  bottom: 0.42rem;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 211, 211, 0.92);
}

.gallery-card h4 {
  margin: 0 0 0.16rem;
  font-size: 0.85rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.gallery-card p {
  margin: 0;
  line-height: 1.34;
  font-size: 0.78rem;
  color: var(--text-soft);
}

#project-links {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  list-style: none;
}

#project-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.44rem;
  width: fit-content;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

#project-links a:hover {
  color: #c6e6ff;
}

.link-icon {
  width: 1.02rem;
  height: 1.02rem;
  flex: 0 0 1.02rem;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}

.link-icon-mail {
  background-image: url("./assets/ui/icon-mail.svg");
}

.link-icon-external {
  background-image: url("./assets/ui/icon-external.svg");
}

#mobile-controls {
  position: absolute;
  inset: auto 0 0 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.72rem;
  padding: 0 0.75rem max(0.75rem, env(safe-area-inset-bottom));
  z-index: 8;
  pointer-events: none;
  transition: opacity 120ms ease;
}

#joystick-zone {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, rgba(144, 201, 255, 0.58), rgba(10, 26, 43, 0.7));
  border: 1px solid rgba(173, 220, 255, 0.5);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
}

#mobile-controls button {
  pointer-events: auto;
  min-width: 104px;
  padding: 0.72rem 0.88rem;
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

@media (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }

  #controls-indicator {
    display: none;
  }
}

@media (max-width: 900px) {
  #top-hud-stack {
    top: max(0.5rem, env(safe-area-inset-top));
    left: 0.5rem;
    right: 0.5rem;
  }

  #top-left-hud {
    width: 100%;
    padding: 0.64rem 0.7rem;
  }

  #report-text {
    font-size: 0.82rem;
  }

  #progress-text {
    font-size: 0.7rem;
  }

  #controls-indicator {
    max-width: 100%;
    font-size: 0.73rem;
    padding: 0.33rem 0.52rem;
  }

  #project-panel {
    left: 0.45rem;
    right: 0.45rem;
    bottom: max(0.45rem, env(safe-area-inset-bottom));
    top: auto;
    width: auto;
    max-height: min(71vh, 560px);
    padding: 0.88rem 0.8rem 0.76rem;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  body.project-panel-open #top-hud-stack,
  body.project-panel-open #mobile-controls {
    display: none;
  }

  #dialog-box {
    bottom: calc(max(0.45rem, env(safe-area-inset-bottom)) + 112px);
    left: 0.45rem;
    right: 0.45rem;
    grid-template-columns: 1fr;
  }
}
