/*
 * Game hub: the entry screen that picks between VirusTAP and VirusMine, and
 * the full-screen layer VirusMine runs in (game-hub.js).
 *
 * Same tokens as design-system.css (charcoal-green surfaces, #d9ff57 lime,
 * Russo One / Exo 2), dressed as a quarantine zone: hazard tape, toxic haze,
 * drifting spores. Everything decorative stops under prefers-reduced-motion.
 */

.vh-hub,
.vh-mine {
  --vh-lime: #d9ff57;
  --vh-lime-rgb: 217, 255, 87;
  --vh-toxic: #57ffd0;
  --vh-blood: #ff5a4e;
  --vh-ink: #eef6da;
  --vh-muted: #93a68a;
  --vh-surface: transparent;
  --vh-line: rgba(201, 255, 122, 0.16);
  position: fixed;
  inset: 0;
  font-family: "Exo 2", system-ui, sans-serif;
  color: var(--vh-ink);
  -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------------------------ */
/* Hub                                                                        */
/* ------------------------------------------------------------------------ */

.vh-hub {
  z-index: 3000;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #040705;
  transition: opacity 0.35s ease, visibility 0.35s;
}

.vh-hub[hidden] {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Ruined city after the outbreak (scripts/render-hub-ruins.py). One static
   image on its own fixed layer: painted once, never repainted. */
.vh-scene {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 7, 5, 0.45), rgba(4, 7, 5, 0) 22%),
    url("/assets/hub-ruins-portrait.webp") center bottom / cover no-repeat,
    #040705;
  transform: translateZ(0);
}

@media (min-aspect-ratio: 1/1) {
  .vh-scene {
    background:
      linear-gradient(180deg, rgba(4, 7, 5, 0.45), rgba(4, 7, 5, 0) 22%),
      url("/assets/hub-ruins-landscape.webp") center bottom / cover no-repeat,
      #040705;
  }
}

/* scanline + vignette */
.vh-hub::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6));
}

.vh-spores {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.vh-spores i {
  position: absolute;
  bottom: -12px;
  width: var(--s, 4px);
  height: var(--s, 4px);
  border-radius: 50%;
  /* Glow baked into the gradient: no box-shadow repaint per frame. */
  background: radial-gradient(circle, #eaffa0 0 22%, rgba(var(--vh-lime-rgb), 0.55) 38%, transparent 70%);
  transform: scale(2.4);
  opacity: 0;
  will-change: transform, opacity;
  animation: vh-spore var(--d, 9s) linear var(--delay, 0s) infinite;
}

.vh-spores i:nth-child(3n) {
  background: radial-gradient(circle, #d6fff2 0 22%, rgba(87, 255, 208, 0.5) 38%, transparent 70%);
}

@keyframes vh-spore {
  0% { transform: translate3d(0, 0, 0) scale(2.4); opacity: 0; }
  12% { opacity: 0.85; }
  80% { opacity: 0.5; }
  100% { transform: translate3d(var(--dx, 20px), -105vh, 0) scale(2.4); opacity: 0; }
}

.vh-tape {
  position: relative;
  z-index: 1;
  flex: none;
  height: 26px;
  overflow: hidden;
  background: repeating-linear-gradient(-45deg, #d9ff57 0 14px, #0b0f08 14px 28px);
  box-shadow: 0 0 22px rgba(var(--vh-lime-rgb), 0.28);
}

.vh-tape::before {
  content: "";
  position: absolute;
  inset: 3px 0;
  background: #0b0f08;
}

/* Only the text scrolls; the black band stays put, so the stripes never
   show through. The phrase repeats, so a -50% shift loops seamlessly. */
.vh-tape span {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  display: flex;
  align-items: center;
  width: max-content;
  white-space: nowrap;
  color: var(--vh-lime);
  font: 400 11px/1 "Russo One", sans-serif;
  letter-spacing: 0.22em;
  animation: vh-tape 22s linear infinite;
  will-change: transform;
}

.vh-tape--bottom span {
  animation-direction: reverse;
}

@keyframes vh-tape {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.vh-body {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 22px 16px 26px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.vh-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.vh-hazard {
  flex: none;
  width: 54px;
  height: 54px;
  color: var(--vh-lime);
  filter: drop-shadow(0 0 12px rgba(var(--vh-lime-rgb), 0.7));
  animation: vh-spin 18s linear infinite;
  will-change: transform;
}

@keyframes vh-spin {
  to { transform: rotate(360deg); }
}

.vh-kicker {
  margin: 0 0 4px;
  color: var(--vh-toxic);
  font: 600 10.5px/1.2 "Exo 2", sans-serif;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.vh-kicker::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--vh-blood);
  box-shadow: 0 0 8px var(--vh-blood);
  vertical-align: 1px;
  animation: vh-blink 1.4s steps(2, jump-none) infinite;
}

@keyframes vh-blink {
  50% { opacity: 0.2; }
}

.vh-title {
  margin: 0;
  font: 400 30px/1 "Russo One", sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(var(--vh-lime-rgb), 0.25);
}

.vh-title span {
  color: var(--vh-lime);
}

.vh-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--vh-line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(var(--vh-lime-rgb), 0.08), rgba(14, 25, 17, 0.92));
}

.vh-balance small {
  display: block;
  color: var(--vh-muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.vh-balance strong {
  display: block;
  margin-top: 3px;
  font: 400 21px/1.1 "Russo One", sans-serif;
  color: var(--vh-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.vh-balance strong em {
  color: var(--vh-lime);
  font-style: normal;
  font-size: 14px;
  margin-left: 4px;
}

.vh-status {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 90, 78, 0.42);
  background: rgba(255, 90, 78, 0.10);
  color: #ffb3aa;
  font: 700 10px/1 "Exo 2", sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.vh-cards {
  display: grid;
  gap: 14px;
}

.vh-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  min-height: 176px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--vh-line);
  border-radius: 22px;
  background: var(--vh-surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  isolation: isolate;
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s, box-shadow 0.25s;
}

.vh-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--card-glow);
}

.vh-card:hover,
.vh-card:focus-visible {
  border-color: rgba(var(--vh-lime-rgb), 0.55);
  box-shadow: 0 0 0 1px rgba(var(--vh-lime-rgb), 0.25), 0 20px 50px -20px rgba(var(--vh-lime-rgb), 0.35);
  outline: none;
}

.vh-card:active {
  transform: scale(0.975);
}

.vh-card--tap {
  --card-glow:
    radial-gradient(70% 110% at 100% 50%, rgba(var(--vh-lime-rgb), 0.16), transparent 62%),
    linear-gradient(90deg, rgba(9, 16, 10, 0.94) 0%, rgba(9, 16, 10, 0.82) 48%, rgba(9, 16, 10, 0.38) 100%);
}

.vh-card--mine {
  --card-glow:
    radial-gradient(70% 110% at 100% 55%, rgba(255, 90, 78, 0.18), transparent 62%),
    radial-gradient(60% 60% at 80% 100%, rgba(87, 255, 208, 0.1), transparent 70%),
    linear-gradient(90deg, rgba(20, 12, 10, 0.94) 0%, rgba(20, 12, 10, 0.82) 48%, rgba(20, 12, 10, 0.38) 100%);
  border-color: rgba(255, 90, 78, 0.24);
}

.vh-card--mine:hover,
.vh-card--mine:focus-visible {
  border-color: rgba(255, 90, 78, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 90, 78, 0.25), 0 20px 50px -20px rgba(255, 90, 78, 0.4);
}

.vh-card-text {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 0 18px 18px;
  min-width: 0;
}

.vh-card-label {
  color: var(--vh-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.vh-card-name {
  font: 400 25px/1 "Russo One", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.vh-card-name span {
  color: var(--vh-lime);
}

.vh-card--mine .vh-card-name span {
  color: var(--vh-blood);
  text-shadow: 0 0 14px rgba(255, 90, 78, 0.5);
}

.vh-card-desc {
  margin: 0;
  color: #b9c7a9;
  font-size: 13px;
  line-height: 1.35;
}

.vh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vh-chips li {
  list-style: none;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--vh-line);
  background: rgba(0, 0, 0, 0.28);
  color: #dce8c6;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.vh-chips {
  margin: 0;
  padding: 0;
}

.vh-play {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 9px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #e0ff83, #c5ed61);
  color: #0c1406;
  font: 400 13px/1 "Russo One", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 6px 18px -6px rgba(var(--vh-lime-rgb), 0.7);
}

.vh-card--mine .vh-play {
  background: linear-gradient(180deg, #ff8b7c, #ff5a4e);
  color: #1a0605;
  box-shadow: 0 6px 18px -6px rgba(255, 90, 78, 0.75);
}

.vh-play svg {
  width: 14px;
  height: 14px;
}

.vh-card-art {
  position: relative;
  width: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vh-card-art img {
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.vh-card--tap .vh-card-art {
  width: 150px;
  padding-right: 10px;
  box-sizing: border-box;
}

.vh-card--tap .vh-card-art::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(50% - 5px);
  width: 128px;
  height: 128px;
  margin: -64px 0 0 -64px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(var(--vh-lime-rgb), 0.34) 0%, rgba(var(--vh-lime-rgb), 0.12) 45%, transparent 70%);
  box-shadow: inset 0 0 0 1px rgba(var(--vh-lime-rgb), 0.18);
}

.vh-card--tap .vh-card-art img {
  position: relative;
  width: 132px;
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 0 14px rgba(var(--vh-lime-rgb), 0.45)) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.8));
  animation: vh-float 4.5s ease-in-out infinite;
  will-change: transform;
}

.vh-card--mine .vh-card-art .vh-art-virus {
  width: 118px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 16px rgba(255, 90, 78, 0.45));
  animation: vh-float 3.8s ease-in-out infinite;
}

.vh-card--mine .vh-card-art .vh-art-pick {
  position: absolute;
  right: 6px;
  bottom: 14px;
  width: 58px;
  height: auto;
  image-rendering: pixelated;
  transform-origin: 20% 85%;
  filter: drop-shadow(0 0 8px rgba(87, 255, 208, 0.55));
  animation: vh-swing 2.2s ease-in-out infinite;
  will-change: transform;
}

@keyframes vh-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes vh-swing {
  0%, 100% { transform: rotate(0deg); }
  45% { transform: rotate(-24deg); }
  55% { transform: rotate(-24deg); }
}

.vh-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--vh-blood);
  color: #1a0605;
  font: 400 10px/1 "Russo One", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 0 16px rgba(255, 90, 78, 0.6);
  transform: rotate(4deg);
}

.vh-card[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.7;
}

.vh-foot {
  margin: auto 0 0;
  color: #5d6b55;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------------ */
/* Rules gate (shown once, before the hub)                                    */
/* ------------------------------------------------------------------------ */

.vh-policy {
  --vh-lime: #d9ff57;
  --vh-lime-rgb: 217, 255, 87;
  --vh-toxic: #57ffd0;
  --vh-blood: #ff5a4e;
  --vh-ink: #eef6da;
  --vh-muted: #93a68a;
  --vh-line: rgba(201, 255, 122, 0.16);
  position: fixed;
  inset: 0;
  z-index: 3050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  background: #040705;
  color: var(--vh-ink);
  font-family: "Exo 2", system-ui, sans-serif;
}

.vh-policy-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 26px 22px 22px;
  border: 1px solid rgba(var(--vh-lime-rgb), 0.22);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(10, 17, 11, 0.93), rgba(6, 10, 7, 0.96));
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 90, 78, 0.08);
  text-align: center;
}

.vh-policy-card .vh-hazard {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
}

.vh-policy-card .vh-title {
  margin-bottom: 14px;
}

.vh-policy-text {
  margin: 0 0 16px;
  color: #c3cfb4;
  font-size: 14px;
  line-height: 1.45;
}

.vh-policy-link {
  width: 100%;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--vh-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--vh-ink);
  font: 700 14px/1 "Exo 2", sans-serif;
  cursor: pointer;
}

.vh-policy-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(var(--vh-lime-rgb), 0.06);
  text-align: left;
  font-size: 13.5px;
  line-height: 1.35;
  cursor: pointer;
}

.vh-policy-check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: #c2f22e;
}

.vh-policy-accept {
  width: 100%;
  justify-content: center;
  padding: 14px 16px;
  border: 0;
  font-size: 15px;
  cursor: pointer;
}

.vh-policy-accept:disabled {
  filter: grayscale(0.8) brightness(0.6);
  box-shadow: none;
  cursor: not-allowed;
}

.vh-policy-error {
  min-height: 1em;
  margin: 10px 0 0;
  color: #ff9a8f;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------------ */
/* VirusMine layer                                                           */
/* ------------------------------------------------------------------------ */

.vh-mine {
  z-index: 3100;
  background: #050807;
}

.vh-mine iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #050807;
}

.vh-mine-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(70% 50% at 50% 60%, rgba(255, 90, 78, 0.16), transparent 70%),
    #050807;
  transition: opacity 0.4s ease;
}

.vh-mine-state[hidden] {
  display: flex;
  opacity: 0;
  pointer-events: none;
}

.vh-mine-state img {
  width: 96px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 16px rgba(255, 90, 78, 0.5));
  animation: vh-float 1.6s ease-in-out infinite;
}

.vh-mine-state p {
  margin: 0;
  font: 400 14px/1.3 "Russo One", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.vh-mine-state .vh-mine-bar {
  width: min(220px, 70vw);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.vh-mine-state .vh-mine-bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: repeating-linear-gradient(-45deg, #d9ff57 0 8px, #9bd516 8px 16px);
  animation: vh-bar 1.1s ease-in-out infinite;
}

@keyframes vh-bar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.vh-mine-state button {
  padding: 11px 18px;
  border: 1px solid var(--vh-line);
  border-radius: 12px;
  background: rgba(14, 25, 17, 0.9);
  color: var(--vh-ink);
  font: 400 13px/1 "Russo One", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.vh-mine-state button.is-primary {
  border-color: transparent;
  background: linear-gradient(180deg, #e0ff83, #c5ed61);
  color: #0c1406;
}

.vh-mine-actions {
  display: flex;
  gap: 10px;
}

.vh-toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 3200;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border: 1px solid rgba(var(--vh-lime-rgb, 217, 255, 87), 0.35);
  border-radius: 14px;
  background: rgba(10, 18, 11, 0.94);
  color: #eef6da;
  font: 600 13px/1.3 "Exo 2", sans-serif;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.8);
  transform: translateX(-50%);
  animation: vh-toast 3.2s ease forwards;
}

@keyframes vh-toast {
  0% { opacity: 0; transform: translate(-50%, 12px); }
  10%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 6px); }
}

html.vh-locked,
html.vh-locked body {
  overflow: hidden !important;
}

/* Whatever is covered stops painting: the tap game under the hub, and both
   the hub and the tap game under VirusMine. */
html.vh-hub-open #root,
html.vh-mine-open #root {
  visibility: hidden;
}

html.vh-mine-open .vh-hub {
  display: none;
}

/* Phones: fewer moving parts (spore count is also lower, see game-hub.js). */
@media (pointer: coarse) {
  .vh-hub::after {
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.6));
  }
  .vh-card--tap .vh-card-art img,
  .vh-card--mine .vh-card-art .vh-art-virus {
    animation: none;
  }
}

@media (max-width: 360px) {
  .vh-status { display: none; }
  .vh-kicker { letter-spacing: 0.14em; }
  .vh-hazard { width: 46px; height: 46px; }
  .vh-title { font-size: 25px; }
  .vh-card-name { font-size: 21px; }
  .vh-card-art { width: 104px; }
  .vh-card--tap .vh-card-art { width: 118px; padding-right: 8px; }
  .vh-card--tap .vh-card-art img { width: 106px; }
  .vh-card--tap .vh-card-art::before { width: 104px; height: 104px; margin: -52px 0 0 -52px; left: calc(50% - 4px); }
  .vh-card--mine .vh-card-art .vh-art-virus { width: 94px; }
  .vh-card--mine .vh-card-art .vh-art-pick { width: 46px; }
}

@media (min-height: 760px) {
  .vh-body { padding-top: 30px; gap: 22px; }
  .vh-card { min-height: 196px; }
}

@media (prefers-reduced-motion: reduce) {
  .vh-hub *,
  .vh-mine * {
    animation: none !important;
  }
  .vh-spores { display: none; }
}
