:root {
  --ink: #fff7dc;
  --paper: #f5dfaa;
  --gold: #f3c45f;
  --amber: #b56a24;
  --dark: #070b16;
  --line: rgba(255, 221, 143, 0.44);
  --glow: 0 0 24px rgba(98, 218, 255, 0.55), 0 0 42px rgba(243, 196, 95, 0.2);
}

* { box-sizing: border-box; }
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050711;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  cursor: url("cursor.svg") 5 4, auto;
}

button,
a {
  font: inherit;
  cursor: url("cursor.svg") 5 4, pointer;
}

.hopa-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(46, 87, 139, 0.28), transparent 52%),
    linear-gradient(180deg, #060816 0%, #02030a 100%);
}

.hopa-scene {
  position: relative;
  width: min(100vw, calc(100svh * 1.7916667));
  height: min(100svh, calc(100vw / 1.7916667));
  overflow: hidden;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.72);
  isolation: isolate;
}
.portrait-heading, .portrait-projects { display: none; }
.has-open-spot .hotspot::after { animation-play-state: paused; }

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.back-link {
  position: absolute;
  left: 1.4%;
  top: 1.7%;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255, 230, 158, 0.46);
  border-radius: 999px;
  background: rgba(6, 9, 20, 0.58);
  color: #fff7dc;
  text-decoration: none;
  font-weight: 900;
  font-size: clamp(0.72rem, 1.1vw, 0.95rem);
  backdrop-filter: blur(8px);
}

.name-plaque,
.role-plaque {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 950;
  background: transparent;
  border: 0;
  box-shadow: none;
  pointer-events: none;
}

.name-plaque {
  left: 37.24%;
  top: 3.25%;
  width: 29.2%;
  height: 3.8%;
  color: #8a3f0b;
  font-size: clamp(0.72rem, 1.35vw, 1.2rem);
  text-shadow:
    0 1px 0 rgba(255, 242, 190, 0.9),
    0 2px 8px rgba(57, 24, 0, 0.2);
}

.role-plaque {
  left: 37.39%;
  top: 87.35%;
  width: 28.4%;
  height: 3.3%;
  color: #ffeaa6;
  font-size: clamp(0.54rem, 0.93vw, 0.92rem);
  text-shadow:
    0 2px 2px rgba(0, 0, 0, 0.85),
    0 0 10px rgba(0, 0, 0, 0.8),
    0 0 16px rgba(53, 218, 255, 0.52);
}

.hotspot {
  position: absolute;
  z-index: 3;
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: transparent;
  cursor: url("cursor.svg") 5 4, pointer;
  outline: none;
}

.hotspot::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(105, 232, 255, 0);
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 50%, rgba(116, 222, 255, 0.02), rgba(116, 222, 255, 0.001) 64%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.001), rgba(255, 255, 255, 0.001));
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.hotspot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 238, 174, 0.9);
  box-shadow: 0 0 0 8px rgba(98, 218, 255, 0.13), 0 0 24px rgba(98, 218, 255, 0.75);
  transform: translate(-50%, -50%);
  opacity: 0.72;
  animation: pulse 2.2s ease-in-out infinite;
}

.hotspot span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hotspot:hover::before,
.hotspot:focus-visible::before {
  border-color: rgba(105, 232, 255, 0.82);
  background: radial-gradient(circle at 50% 50%, rgba(116, 222, 255, 0.18), rgba(116, 222, 255, 0.04) 66%);
  box-shadow: inset 0 0 28px rgba(105, 232, 255, 0.24), var(--glow);
}

.hotspot-playrix {
  left: 1.5%;
  top: 29.1%;
  width: 29.2%;
  height: 58.8%;
}

.hotspot-nexters {
  left: 31.2%;
  top: 31.8%;
  width: 35.9%;
  height: 48.7%;
}

.hotspot-redneck {
  left: 67.4%;
  top: 4.4%;
  width: 21.5%;
  height: 58.6%;
}

.hotspot-superengineer {
  left: 76.9%;
  top: 39.5%;
  width: 21.3%;
  height: 57.1%;
}

.spot-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 24px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.spot-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.spot-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(22, 39, 64, 0.55), rgba(0, 0, 0, 0.88) 70%),
    rgba(0, 0, 0, 0.68);
}

.spot-card {
  --photo-side: min(760px, 88dvh, 54vw);
  position: relative;
  z-index: 1;
  width: min(1320px, 100%);
  height: calc(var(--photo-side) + 4px);
  max-height: 100%;
  display: grid;
  grid-template-columns: var(--photo-side) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 227, 153, 0.66);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(37, 26, 26, 0.96), rgba(9, 13, 27, 0.96)),
    #111827;
  box-shadow:
    0 28px 90px rgba(0, 0, 0, 0.68),
    0 0 42px rgba(93, 220, 255, 0.22),
    inset 0 0 24px rgba(255, 217, 139, 0.14);
  transform: scale(0.97) translateY(10px);
  transition: transform 300ms ease;
}

.spot-modal.is-open .spot-card {
  transform: scale(1) translateY(0);
}

.spot-frame {
  position: relative;
  min-height: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  padding: 8px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 223, 151, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.01));
}

.spot-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 1px solid rgba(255, 227, 153, 0.46);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
}
.spot-frame.is-magnifying { cursor: none; }

.spot-coin-layer {
  position: absolute;
  inset: 8px;
  z-index: 2;
  border-radius: 16px;
  overflow: hidden;
  pointer-events: none;
  cursor: none;
}

.hidden-coin {
  --coin-size: clamp(22px, 2.2vw, 34px);
  position: absolute;
  left: var(--coin-x);
  top: var(--coin-y);
  width: var(--coin-size);
  height: var(--coin-size);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #8a4b0d;
  font-size: calc(var(--coin-size) * 0.58);
  font-weight: 950;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  cursor: none;
  transform: translate(-50%, -50%) scale(0.62) rotate(-12deg);
  transition: opacity 0.12s ease, transform 0.12s ease, filter 0.12s ease;
  background:
    radial-gradient(circle at 34% 28%, #fff4a9 0 12%, transparent 13%),
    radial-gradient(circle at 50% 50%, #ffd86c 0 48%, #f4a82b 49% 70%, #9f5a18 71% 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 177, 0.72),
    inset 0 -4px 8px rgba(136, 70, 10, 0.32),
    0 0 16px rgba(255, 205, 84, 0.42);
}

.hidden-coin::before {
  content: "";
  width: 38%;
  height: 52%;
  border: 2px solid rgba(139, 78, 12, 0.56);
  border-radius: 50%;
}

.hidden-coin.is-visible {
  opacity: 1;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1) rotate(0deg);
  filter: drop-shadow(0 0 12px rgba(255, 232, 120, 0.78));
  animation: coin-found 1.2s ease-in-out infinite;
}

.hidden-coin.is-collected {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.2);
}

.spot-magnifier {
  --lens-size: clamp(150px, 13vw, 220px);
  --lens-x: 0px;
  --lens-y: 0px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 80;
  width: var(--lens-size);
  height: var(--lens-size);
  border: 8px solid #a96b32;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(var(--lens-x), var(--lens-y), 0) translate(-50%, -50%) scale(0.92);
  transition: opacity 0.08s ease;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.1) 30%, rgba(111, 232, 255, 0.12) 62%, rgba(0, 0, 0, 0.08) 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 226, 158, 0.72),
    inset 0 0 18px rgba(0, 0, 0, 0.25),
    0 16px 38px rgba(0, 0, 0, 0.45),
    0 0 26px rgba(245, 184, 61, 0.28);
  contain: layout paint style;
  will-change: transform, opacity;
}

.spot-magnifier::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 230, 164, 0.72);
  box-shadow: inset 0 0 10px rgba(72, 36, 12, 0.65);
}

.spot-magnifier.is-magnifying {
  opacity: 1;
  transform: translate3d(var(--lens-x), var(--lens-y), 0) translate(-50%, -50%) scale(1);
}

.hopa-coin-counter {
  position: fixed;
  left: clamp(12px, 1.8vw, 22px);
  top: clamp(12px, 1.8vw, 22px);
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.42rem 0.78rem;
  border: 1px solid rgba(255, 225, 140, 0.72);
  border-radius: 999px;
  background: rgba(7, 11, 22, 0.78);
  color: #fff3b5;
  font-weight: 950;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34), 0 0 24px rgba(255, 206, 86, 0.22);
  backdrop-filter: blur(8px);
}

.hopa-coin-counter.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.hopa-coin-counter.is-bump {
  animation: counter-bump 0.62s ease;
}

.counter-coin,
.flying-coin {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  background:
    radial-gradient(circle at 34% 28%, #fff6b6 0 13%, transparent 14%),
    radial-gradient(circle at 50% 50%, #ffd86c 0 48%, #f4a82b 49% 70%, #9f5a18 71% 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 245, 177, 0.74), 0 0 14px rgba(255, 210, 80, 0.42);
}

.flying-coin {
  position: fixed;
  z-index: 60;
  left: 0;
  top: 0;
  pointer-events: none;
  transform: translate3d(var(--from-x), var(--from-y), 0) scale(1);
  animation: fly-to-counter 0.72s cubic-bezier(0.18, 0.88, 0.28, 1) forwards;
}

.coin-spark {
  position: fixed;
  z-index: 61;
  left: 0;
  top: 0;
  width: var(--spark-size, 7px);
  height: var(--spark-size, 7px);
  border-radius: 50%;
  pointer-events: none;
  background: #ffe781;
  box-shadow: 0 0 12px rgba(255, 229, 126, 0.86);
  transform: translate3d(var(--spark-x), var(--spark-y), 0);
  animation: coin-spark 0.72s ease-out forwards;
}

.coin-burst {
  position: fixed;
  z-index: 60;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 231, 129, 0.88);
  border-radius: 50%;
  pointer-events: none;
  transform: translate3d(calc(var(--burst-x) - 10px), calc(var(--burst-y) - 10px), 0) scale(0.3);
  box-shadow: 0 0 24px rgba(255, 217, 88, 0.8), inset 0 0 18px rgba(255, 244, 170, 0.42);
  animation: coin-burst 0.72s ease-out forwards;
}

.spot-info {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 2.4rem clamp(1rem, 2.4vw, 1.65rem) 1rem;
}

.spot-kicker {
  margin: 0 0 0.55rem;
  color: rgba(255, 247, 220, 0.58);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.spot-info h1 {
  margin: 0 0 0.8rem;
  color: #fff7dc;
  font-size: clamp(1.6rem, 3vw, 2.45rem);
  line-height: 1.04;
}

.spot-text p {
  margin: 0 0 1rem;
  color: rgba(255, 247, 220, 0.78);
  line-height: 1.48;
}

.spot-text strong {
  color: #ffe58d;
  font-weight: 950;
  text-shadow:
    0 0 12px rgba(245, 184, 61, 0.42),
    0 0 22px rgba(111, 232, 255, 0.22);
}

.spot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.spot-tags span {
  padding: 0.38rem 0.55rem;
  border: 1px solid rgba(255, 227, 153, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffe6a4;
  font-weight: 800;
  font-size: 0.82rem;
}
.spot-modal.is-open .spot-tags span {
  animation: tag-magic-glow 3s ease-in-out 2;
  animation-delay: calc(var(--tag-index, 0) * 0.28s);
}

.spot-tags span:nth-child(1) { --tag-index: 0; }
.spot-tags span:nth-child(2) { --tag-index: 1; }
.spot-tags span:nth-child(3) { --tag-index: 2; }
.spot-tags span:nth-child(4) { --tag-index: 3; }
.spot-tags span:nth-child(5) { --tag-index: 4; }
.spot-tags span:nth-child(6) { --tag-index: 5; }
.spot-tags span:nth-child(7) { --tag-index: 6; }
.spot-tags span:nth-child(8) { --tag-index: 7; }

.spot-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 230, 158, 0.54);
  border-radius: 50%;
  background: rgba(8, 12, 25, 0.9);
  color: #fff7dc;
  cursor: url("cursor.svg") 5 4, pointer;
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
}

.spot-close:hover,
.spot-close:focus-visible {
  background: #f3c45f;
  color: #211203;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.86); opacity: 0.58; }
  50% { transform: translate(-50%, -50%) scale(1.12); opacity: 0.98; }
}

@keyframes tag-magic-glow {
  0%, 100% {
    color: #ffe6a4;
    border-color: rgba(255, 227, 153, 0.32);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
    text-shadow: none;
  }
  18%, 34% {
    color: #fff8cf;
    border-color: rgba(111, 232, 255, 0.72);
    background: rgba(111, 232, 255, 0.12);
    box-shadow:
      0 0 18px rgba(111, 232, 255, 0.42),
      0 0 28px rgba(245, 184, 61, 0.22);
    text-shadow:
      0 0 10px rgba(255, 245, 199, 0.82),
      0 0 18px rgba(111, 232, 255, 0.48);
  }
}

@keyframes coin-found {
  0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); }
  50% { transform: translate(-50%, -50%) scale(1.12) rotate(5deg); }
}

@keyframes counter-bump {
  0%, 100% { transform: scale(1); }
  28% { transform: scale(1.22); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34), 0 0 46px rgba(255, 227, 126, 0.86), 0 0 70px rgba(105, 232, 255, 0.32); }
  58% { transform: scale(1.06); }
}

@keyframes fly-to-counter {
  0% {
    opacity: 1;
    transform: translate3d(var(--from-x), var(--from-y), 0) scale(1) rotate(0deg);
    filter: drop-shadow(0 0 12px rgba(255, 218, 92, 0.8));
  }
  100% {
    opacity: 0.15;
    transform: translate3d(var(--to-x), var(--to-y), 0) scale(0.45) rotate(520deg);
    filter: drop-shadow(0 0 4px rgba(255, 218, 92, 0.2));
  }
}

@keyframes coin-spark {
  0% {
    opacity: 1;
    transform: translate3d(var(--spark-x), var(--spark-y), 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--spark-x) + var(--spark-dx)), calc(var(--spark-y) + var(--spark-dy)), 0) scale(0.15);
  }
}

@keyframes coin-burst {
  0% {
    opacity: 0.95;
    transform: translate3d(calc(var(--burst-x) - 10px), calc(var(--burst-y) - 10px), 0) scale(0.3);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--burst-x) - 10px), calc(var(--burst-y) - 10px), 0) scale(4.8);
  }
}

@media (max-width: 860px) and (orientation: portrait) {
  .hopa-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: max(8px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    overflow: auto;
    background: #101421;
  }
  .portrait-heading, .portrait-projects, .hopa-scene {
    width: min(100%, 540px);
    flex: none;
  }
  .portrait-heading { display: block; }
  .portrait-heading a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--paper);
    text-decoration: none;
    font-size: 0.875rem;
  }
  .portrait-heading h1 { margin: 0; font-size: 1.65rem; }
  .portrait-heading p { margin: 5px 0 0; color: #d6cad0; font-size: 0.85rem; }
  .hopa-scene {
    height: auto;
    aspect-ratio: 2752 / 1536;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: none;
  }
  .back-link, .name-plaque, .role-plaque { display: none; }
  .hotspot::after { animation: none; }
  .portrait-projects {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .portrait-projects button {
    display: grid;
    align-content: center;
    gap: 4px;
    min-height: 58px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #232735;
    color: var(--ink);
    text-align: start;
    font-size: 0.875rem;
    overflow-wrap: anywhere;
  }
  .portrait-projects span { color: var(--paper); font-size: 0.78rem; }
  .spot-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    width: min(100%, 540px);
    height: calc(100dvh - 32px);
    border-radius: 12px;
  }
  .spot-frame {
    width: min(100%, 50dvh);
    height: auto;
    justify-self: center;
    padding: 6px;
  }
  .spot-frame img { border-radius: 8px; box-shadow: none; }
  .spot-info {
    padding: 0.7rem 0.9rem 0.9rem;
    font-size: 0.92rem;
  }
  .spot-info h1 { font-size: 1.35rem; }
  .spot-close { right: 6px; top: 6px; }
}

@media (hover: none), (pointer: coarse) {
  .hotspot::before, .spot-magnifier, .spot-coin-layer, .hopa-coin-counter { display: none; }
  .spot-magnifier { will-change: auto; }
  .spot-modal.is-open .spot-tags span { animation: none; }
}

@media (max-width: 640px) {
  .hotspot::after {
    width: 20px;
    height: 20px;
  }
  .back-link {
    min-height: 32px;
    padding: 0.28rem 0.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
