:root {
  --jarvis-bg: #05070b;
  --jarvis-panel: rgba(9, 18, 28, .78);
  --jarvis-panel-2: rgba(7, 28, 39, .62);
  --jarvis-cyan: #d6ff4f;
  --jarvis-mint: #a8ff3e;
  --jarvis-blue: #6ee86f;
  --jarvis-amber: #ffd36b;
  --jarvis-red: #ff6f91;
  --jarvis-text: #edfaff;
  --jarvis-dim: #8da8b6;
}

html,
body {
  letter-spacing: 0;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(rgba(214, 255, 79, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 255, 62, .035) 1px, transparent 1px),
    radial-gradient(circle at 18% 12%, rgba(168, 255, 62, .18), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(110, 232, 111, .14), transparent 24%),
    radial-gradient(circle at 52% 110%, rgba(255, 211, 107, .07), transparent 30%),
    var(--jarvis-bg);
  background-size: 38px 38px, 38px 38px, auto, auto, auto, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.04), transparent 22%, rgba(168,255,62,.04)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0, rgba(255,255,255,.025) 1px, transparent 1px, transparent 5px);
  mix-blend-mode: screen;
  opacity: .34;
  z-index: -1;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background-image:
    radial-gradient(circle, rgba(237,250,255,.62) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(168,255,62,.38) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(237,250,255,.30) 0 1px, transparent 1.5px);
  background-size: 170px 170px, 230px 230px, 310px 310px;
  background-position: 20px 30px, 90px 120px, 150px 70px;
  animation: starDrift 42s linear infinite;
  opacity: .55;
}

.space-traffic {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
}

.meteor,
.asteroid {
  position: absolute;
  display: block;
  will-change: transform, opacity;
}

.meteor {
  width: 120px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(214,255,79,.15), rgba(237,250,255,.9));
  box-shadow: 0 0 14px rgba(168,255,62,.48);
  opacity: 0;
  transform: rotate(24deg);
}

.meteor::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #edfaff;
  box-shadow: 0 0 18px rgba(214,255,79,.9);
}

.meteor-1 {
  top: 14%;
  left: -18%;
  animation: meteorFlight 9s linear infinite;
}

.meteor-2 {
  top: 42%;
  left: -24%;
  width: 86px;
  animation: meteorFlight 12s linear 3s infinite;
}

.meteor-3 {
  top: 72%;
  left: -20%;
  width: 145px;
  animation: meteorFlight 15s linear 6s infinite;
}

.asteroid {
  width: 34px;
  height: 28px;
  border-radius: 45% 55% 48% 52%;
  background:
    radial-gradient(circle at 30% 30%, rgba(237,250,255,.26), transparent 18%),
    radial-gradient(circle at 65% 62%, rgba(0,0,0,.28), transparent 20%),
    linear-gradient(135deg, rgba(143, 161, 118, .95), rgba(58, 70, 55, .9));
  border: 1px solid rgba(214,255,79,.18);
  box-shadow: 0 0 16px rgba(168,255,62,.12);
  opacity: .28;
}

.asteroid-1 {
  top: 18%;
  left: 8%;
  animation: asteroidDrift 36s ease-in-out infinite;
}

.asteroid-2 {
  top: 66%;
  left: 78%;
  width: 46px;
  height: 38px;
  animation: asteroidDrift 48s ease-in-out 4s infinite reverse;
}

.asteroid-3 {
  top: 38%;
  left: 58%;
  width: 24px;
  height: 22px;
  animation: asteroidDrift 41s ease-in-out 9s infinite;
}

@keyframes starDrift {
  from { background-position: 20px 30px, 90px 120px, 150px 70px; }
  to { background-position: 190px 200px, 320px 350px, 460px 380px; }
}

@keyframes meteorFlight {
  0% { opacity: 0; transform: translate3d(-10vw, -4vh, 0) rotate(24deg); }
  8% { opacity: .85; }
  22% { opacity: .85; }
  34% { opacity: 0; transform: translate3d(128vw, 54vh, 0) rotate(24deg); }
  100% { opacity: 0; transform: translate3d(128vw, 54vh, 0) rotate(24deg); }
}

@keyframes asteroidDrift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(28px, -22px, 0) rotate(32deg); }
}

.page-shell {
  padding: 18px;
  gap: 14px;
}

.topbar {
  border: 1px solid rgba(168, 255, 62, .28);
  background: linear-gradient(135deg, rgba(5, 12, 19, .86), rgba(25, 42, 17, .58));
  box-shadow: 0 0 0 1px rgba(168, 255, 62, .06) inset, 0 18px 55px rgba(0, 0, 0, .34);
  padding: 14px 16px;
  position: relative;
}

.topbar::after,
.panel::after,
.battle-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .04);
}

.title-wrap {
  min-width: 260px;
}

.eyebrow,
.login-kicker {
  color: var(--jarvis-cyan);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.title-wrap h1 {
  color: var(--jarvis-text);
  font-size: clamp(1.45rem, 2.2vw, 2.18rem);
  text-shadow: 0 0 18px rgba(168, 255, 62, .36);
}

.title-wrap p,
.muted {
  color: var(--jarvis-dim);
}

.top-actions,
.battle-actions {
  align-items: center;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(168, 255, 62, .34);
  background: rgba(18, 30, 10, .68);
  color: var(--jarvis-mint);
  font-size: .85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--jarvis-mint);
  box-shadow: 0 0 16px var(--jarvis-mint);
  animation: jarvisPulse 1.35s ease-in-out infinite;
}

@keyframes jarvisPulse {
  0%, 100% { opacity: .42; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.14); }
}

.panel,
.summary-box,
.battle-card,
.mission-item,
.reward-item,
.achievement-item,
.choice-box,
.mini {
  border-radius: 8px;
  border-color: rgba(168, 255, 62, .22);
  background:
    linear-gradient(135deg, rgba(168, 255, 62, .065), transparent 32%),
    linear-gradient(180deg, var(--jarvis-panel), rgba(4, 11, 17, .66));
  box-shadow: 0 18px 52px rgba(0, 0, 0, .26), 0 0 0 1px rgba(168, 255, 62, .04) inset;
  position: relative;
}

.panel h3,
.summary-label,
.choice-title {
  color: rgba(237, 250, 255, .72);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
}

.big,
.summary-value,
.choice-value {
  color: var(--jarvis-text);
  text-shadow: 0 0 14px rgba(168, 255, 62, .25);
}

.summary-grid {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.battle-actions {
  border: 1px solid rgba(168, 255, 62, .16);
  background: rgba(3, 9, 14, .36);
  padding: 10px;
}

.btn,
.rps-button,
.logout-btn,
.login-panel button {
  min-height: 40px;
  border-radius: 6px;
  border-color: rgba(168, 255, 62, .46);
  background: linear-gradient(135deg, rgba(168, 255, 62, .16), rgba(110, 232, 111, .10));
  color: var(--jarvis-text);
  box-shadow: 0 0 18px rgba(168, 255, 62, .11);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:hover,
.rps-button:hover,
.logout-btn:hover,
.login-panel button:hover {
  transform: translateY(-1px);
  border-color: rgba(214, 255, 79, .78);
  box-shadow: 0 0 26px rgba(168, 255, 62, .20);
}

.btn.secondary {
  background: rgba(255, 255, 255, .035);
}

.logout-btn {
  position: static;
}

.menu-toggle,
.menu-close {
  cursor: pointer;
  border: 1px solid rgba(168, 255, 62, .46);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(168, 255, 62, .16), rgba(110, 232, 111, .10));
  color: var(--jarvis-text);
  box-shadow: 0 0 18px rgba(168, 255, 62, .11);
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.menu-toggle {
  width: 42px;
  min-width: 42px;
  height: 40px;
  display: inline-grid;
  place-content: center;
  gap: 4px;
  flex: 0 0 42px;
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--jarvis-mint);
  box-shadow: 0 0 10px rgba(168, 255, 62, .35);
}

.menu-close {
  width: 38px;
  height: 38px;
  font-size: 1.35rem;
  line-height: 1;
}

.menu-toggle:hover,
.menu-close:hover {
  transform: translateY(-1px);
  border-color: rgba(214, 255, 79, .78);
  box-shadow: 0 0 26px rgba(168, 255, 62, .20);
}

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

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .54);
  backdrop-filter: blur(4px);
}

.cockpit-menu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  width: min(460px, calc(100vw - 22px));
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-left: 1px solid rgba(168, 255, 62, .34);
  background:
    linear-gradient(135deg, rgba(168, 255, 62, .06), transparent 30%),
    linear-gradient(180deg, rgba(5, 12, 19, .96), rgba(4, 9, 14, .94));
  box-shadow: -22px 0 65px rgba(0, 0, 0, .46), 0 0 42px rgba(168, 255, 62, .12);
  transform: translateX(104%);
  transition: transform .22s ease;
}

.cockpit-menu.open {
  transform: translateX(0);
}

body.menu-open {
  overflow: hidden;
}

.menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.menu-head h2 {
  margin: 0;
  color: var(--jarvis-text);
  font-size: 1.35rem;
  text-shadow: 0 0 18px rgba(168, 255, 62, .28);
}

.menu-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex-shrink: 0;
}

.menu-tab {
  cursor: pointer;
  min-height: 38px;
  border: 1px solid rgba(168, 255, 62, .24);
  border-radius: 6px;
  background: rgba(255, 255, 255, .035);
  color: var(--jarvis-dim);
  font-weight: 800;
  font-size: .8rem;
}

.menu-tab.active {
  color: var(--jarvis-text);
  border-color: rgba(214, 255, 79, .65);
  background: rgba(168, 255, 62, .13);
  box-shadow: 0 0 22px rgba(168, 255, 62, .12);
}

.menu-panels {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
}

.menu-panel {
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.menu-panel[hidden] {
  display: none;
}

#globalMessage {
  min-height: 34px;
  padding: 6px 2px 8px;
}

.battle-card.active {
  border-color: rgba(168, 255, 62, .62);
  box-shadow: 0 0 0 1px rgba(168, 255, 62, .24), 0 0 32px rgba(168, 255, 62, .14);
}

.badge,
.tag {
  border-radius: 6px;
  border-color: rgba(168, 255, 62, .26);
  background: rgba(168, 255, 62, .09);
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(150px, 1fr));
}

.battle-buttons .rps-button {
  flex: 1 1 130px;
  justify-content: center;
}

#battleList,
.scroll-panel {
  scrollbar-color: rgba(168, 255, 62, .52) rgba(255, 255, 255, .04);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: auto;
  color: var(--jarvis-text);
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
}

.login-panel {
  border: 1px solid rgba(168, 255, 62, .32);
  border-radius: 8px;
  padding: 28px;
  background: linear-gradient(135deg, rgba(7, 22, 31, .9), rgba(4, 10, 17, .86));
  box-shadow: 0 22px 70px rgba(0, 0, 0, .42), 0 0 44px rgba(168, 255, 62, .10);
}

.login-panel h2 {
  margin: 0 0 20px;
  color: var(--jarvis-text);
  text-align: left;
}

.login-panel form {
  display: grid;
  gap: 12px;
}

.login-panel input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(168, 255, 62, .34);
  border-radius: 6px;
  padding: 0 12px;
  background: rgba(1, 8, 12, .72);
  color: var(--jarvis-text);
  font: inherit;
}

.login-error {
  color: var(--jarvis-red);
  text-align: left;
  margin: 0 0 14px;
}

.login-links {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(168, 255, 62, .18);
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.login-links a {
  color: var(--jarvis-mint);
  font-weight: 800;
  text-decoration: none;
}

.login-links a:hover {
  color: var(--jarvis-cyan);
  text-decoration: underline;
}

.legal-footer {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 20;
  display: flex;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(168, 255, 62, .22);
  border-radius: 6px;
  background: rgba(3, 9, 14, .72);
  backdrop-filter: blur(8px);
}

.legal-footer a,
.legal-content a,
.legal-nav a {
  color: var(--jarvis-mint);
  font-weight: 800;
  text-decoration: none;
}

.legal-footer a:hover,
.legal-content a:hover,
.legal-nav a:hover {
  color: var(--jarvis-cyan);
  text-decoration: underline;
}

.legal-page {
  min-height: 100vh;
  overflow: auto;
  color: var(--jarvis-text);
}

.legal-shell {
  width: min(980px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
  display: grid;
  gap: 14px;
}

.legal-header {
  min-height: auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.legal-header h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  text-shadow: 0 0 18px rgba(168, 255, 62, .34);
}

.legal-header p {
  margin: 8px 0 0;
  color: var(--jarvis-dim);
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.legal-nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(168, 255, 62, .24);
  border-radius: 6px;
  background: rgba(255, 255, 255, .035);
}

.legal-nav a.active {
  color: var(--jarvis-text);
  border-color: rgba(214, 255, 79, .65);
  background: rgba(168, 255, 62, .13);
}

.legal-content {
  min-height: auto;
  line-height: 1.65;
}

.legal-content h2 {
  margin: 24px 0 8px;
  color: var(--jarvis-text);
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.legal-content h2:first-child {
  margin-top: 0;
}

.legal-content p {
  color: var(--jarvis-dim);
}

.legal-updated {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid rgba(168, 255, 62, .18);
  font-size: .9rem;
}

@media (max-width: 760px) {
  .page-shell {
    padding: 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: stretch;
  }

  .top-actions,
  .battle-actions {
    width: 100%;
  }

  .top-actions > *,
  .battle-actions > * {
    flex: 1 1 auto;
  }

  .top-actions .menu-toggle {
    flex: 0 0 42px;
  }

  .cockpit-menu {
    width: min(380px, calc(100vw - 18px));
    padding: 12px;
  }

  .menu-tabs {
    grid-template-columns: 1fr;
  }

  .menu-tab {
    text-align: left;
    padding: 0 12px;
  }

  .legal-footer {
    position: static;
    margin: 0 12px 12px;
    justify-content: center;
  }

  .legal-header {
    display: grid;
  }

  .legal-nav {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after,
  .meteor,
  .asteroid,
  .pulse-dot {
    animation: none;
  }
}

/* Overview tuning: keep the command area compact so battles stay visible. */
@media (min-width: 1101px) {
  body {
    overflow: hidden;
  }

  .page-shell {
    height: 100dvh;
    min-height: 100dvh;
    padding: 10px 14px;
    gap: 9px;
  }

  .topbar {
    min-height: 92px;
    padding: 10px 14px;
  }

  .eyebrow {
    margin-bottom: 4px;
  }

  .title-wrap h1 {
    font-size: clamp(1.55rem, 1.8vw, 2rem);
    line-height: 1.05;
  }

  .title-wrap p {
    margin-top: 6px;
    font-size: .92rem;
  }

  .live-status,
  .btn,
  .rps-button,
  .logout-btn {
    min-height: 36px;
    padding: 8px 12px;
  }

  .hero-grid {
    gap: 9px;
  }

  .panel {
    min-height: 96px;
    padding: 10px 12px;
  }

  .panel h3 {
    margin-bottom: 8px;
  }

  .big {
    margin-bottom: 5px;
    font-size: 1.05rem;
  }

  .muted {
    font-size: .92rem;
    line-height: 1.38;
  }

  .summary-grid {
    gap: 9px;
  }

  .summary-box {
    min-height: 58px;
    padding: 8px 10px;
  }

  .summary-label {
    margin-bottom: 5px;
    font-size: .7rem;
  }

  .summary-value {
    font-size: 1.05rem;
  }

  .battle-actions {
    min-height: 48px;
    padding: 7px 10px;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: 0;
  }

  .scroll-panel {
    min-height: 0;
    padding: 10px;
  }

  .mission-list,
  .reward-list,
  .achievement-list {
    gap: 8px;
  }

  .mission-item,
  .reward-item,
  .achievement-item {
    padding: 9px 10px;
  }

  #globalMessage {
    min-height: 26px;
    padding: 2px 2px 6px;
    font-size: .9rem;
  }

  #battleList {
    gap: 10px;
  }

  .battle-card {
    padding: 12px;
  }

  .battle-top {
    margin-bottom: 8px;
  }

  .battle-top h3 {
    margin-bottom: 4px;
  }

  .choice-grid {
    gap: 8px;
    margin-top: 10px;
  }

  .choice-box {
    padding: 8px 10px;
  }

  .battle-buttons {
    gap: 8px;
    margin-top: 10px;
  }
}
