:root {
  --bg: #07080a;
  --ink: #f4f7f2;
  --muted: #9aa394;
  --panel: rgba(16, 20, 18, 0.82);
  --line: rgba(255, 255, 255, 0.08);
  --accent: #7cff6b;
  --accent-2: #b8ff6a;
  font-family: "Segoe UI", "Avenir Next", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

.auth-bar {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 8, 10, 0.82);
  backdrop-filter: blur(16px);
}

.auth-brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.auth-trigger,
.auth-dialog button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--accent);
  color: #10210d;
  font-weight: 700;
  cursor: pointer;
}

.auth-user {
  position: relative;
  min-width: 0;
}

.auth-user-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  cursor: pointer;
}

.auth-user-summary::-webkit-details-marker {
  display: none;
}

.auth-user-summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
}

.auth-user[open] .auth-user-summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.auth-user img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.auth-user span {
  max-width: min(36vw, 280px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #101412;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.auth-menu button {
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.auth-menu button:hover,
.auth-menu button:focus-visible {
  background: rgba(255, 255, 255, 0.06);
}

.auth-menu button.danger,
.auth-dialog button.danger {
  color: #fff;
  background: #b4232f;
}

.auth-menu button.danger {
  color: #ff8e98;
  background: transparent;
}

.auth-dialog button.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.auth-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #101412;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.auth-dialog h2 {
  margin: 0 44px 8px 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.auth-dialog .auth-close {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.auth-dialog .google-button {
  width: 100%;
  margin-top: 18px;
  background: #fff;
  color: #202124;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form > div {
  display: grid;
  gap: 10px;
}

.auth-form label {
  color: var(--muted);
  font-size: 14px;
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 255, 107, 0.12);
}

.auth-form button:first-of-type {
  margin-top: 8px;
}

.auth-error {
  margin: 16px 0 0;
}

.auth-bar [hidden],
.auth-dialog [hidden] {
  display: none !important;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(124, 255, 107, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 110%, rgba(92, 225, 255, 0.1), transparent 50%),
    #07080a;
}

.grid {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at center, #000 40%, transparent 85%);
}

.topbar,
.qr-card,
.status-pill {
  position: relative;
  z-index: 2;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 28px 32px 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand strong {
  font-size: 28px;
  letter-spacing: -0.04em;
}

.brand span,
.hint,
.meta {
  color: var(--muted);
}

.players {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 48vw;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.qr-card {
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: min(320px, calc(100vw - 40px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.qr-card img {
  display: block;
  width: 100%;
  border-radius: 16px;
  background: #f4ffe8;
}

.qr-card h2 {
  margin: 14px 0 6px;
  font-size: 18px;
}

.qr-card p,
.phone p {
  margin: 0;
  line-height: 1.45;
}

.qr-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.qr-actions button,
.phone button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--accent);
  color: #10210d;
  font-weight: 700;
  cursor: pointer;
}

.qr-actions button.ghost,
.phone button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.cursor {
  position: absolute;
  width: 72px;
  aspect-ratio: 144 / 165;
  /* aim point = visual center */
  margin: -41px 0 0 -36px;
  pointer-events: none;
  z-index: 10;
  will-change: left, top;
  filter:
    drop-shadow(0 8px 10px rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 12px color-mix(in srgb, currentColor 70%, transparent));
}

.cursor.is-finger-gun {
  width: 78px;
  aspect-ratio: 1;
  margin: -39px 0 0 -39px;
}

.cursor-hand {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.cursor-fill {
  display: block;
  width: 100%;
  height: 100%;
}

.cursor-outline {
  position: absolute;
  inset: 0;
  background: currentColor;
  -webkit-mask: url("/cursor-outline.png") center / 100% 100% no-repeat;
  mask: url("/cursor-outline.png") center / 100% 100% no-repeat;
}

.cursor.is-finger-gun .cursor-outline {
  -webkit-mask-image: url("/cursors/finger_gun/cursor-outline.png");
  mask-image: url("/cursors/finger_gun/cursor-outline.png");
}

.cursor-name {
  position: absolute;
  top: 18px;
  left: calc(100% - 4px);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(7, 8, 10, 0.78);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.cursor-ammo {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.cursor-ammo[hidden] {
  display: none;
}

.cursor-ammo i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 25%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 55%, transparent);
}

.cursor-ammo i.is-on {
  background: currentColor;
  box-shadow: 0 0 8px color-mix(in srgb, currentColor 70%, transparent);
}

.cursor.is-empty .cursor-ammo i {
  background: color-mix(in srgb, #ff5a5a 35%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #ff5a5a 70%, transparent);
}

.cursor.clicking {
  animation: poke 180ms ease-out;
}

.pairing {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(124, 255, 107, 0.12), transparent 55%),
    radial-gradient(900px 500px at 90% 110%, rgba(92, 225, 255, 0.1), transparent 50%),
    #07080a;
}

.pairing-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  text-align: center;
}

.pairing-card h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -0.04em;
}

.pairing-card img {
  display: block;
  width: min(320px, 100%);
  margin: 22px auto 0;
  border-radius: 20px;
  background: #f4ffe8;
}

.pairing-card .qr-actions {
  justify-content: center;
}

@keyframes poke {
  50% { transform: scale(1.35); }
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: none;
}

.empty strong {
  display: block;
  font-size: clamp(32px, 6vw, 72px);
  letter-spacing: -0.05em;
}

html:has(.phone-page) {
  height: 100%;
}

.phone-page {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.phone-page input {
  -webkit-user-select: text;
  user-select: text;
}

.phone {
  min-height: 100dvh;
  height: 100dvh;
  padding: 28px 22px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(124, 255, 107, 0.16), transparent 36%),
    #07080a;
}

.phone header strong {
  display: block;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.status {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.pad {
  flex: 1;
  min-height: 280px;
  border-radius: 28px;
  border: 1px dashed rgba(124, 255, 107, 0.35);
  background: rgba(124, 255, 107, 0.04);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

.phone .row {
  display: flex;
  gap: 10px;
}

.phone .row button {
  flex: 1;
}

.error {
  color: #ffb4c0;
}

.gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 88px 24px 24px;
  background:
    radial-gradient(900px 500px at 90% 110%, rgba(92, 225, 255, 0.08), transparent 50%),
    #07080a;
}

.gate-logo {
  display: block;
  width: 480px;
  max-width: 88vw;
  height: auto;
}

.gate-card {
  width: min(560px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}

.gate-card h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: -0.04em;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.gate-card button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--accent);
  color: #10210d;
  font-weight: 700;
  cursor: pointer;
}

.gate-card button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.gate-card button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.gate-card .join-form {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.join-form label {
  color: var(--muted);
  font-size: 14px;
}

.join-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.join-form input:focus {
  outline: 2px solid rgba(124, 255, 107, 0.35);
}

.gate-card button.ghost span {
  color: var(--muted);
}

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.mode-card {
  text-align: left;
  border-radius: 20px !important;
  padding: 16px 18px !important;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}

.mode-card:hover,
.mode-card:focus-visible {
  border-color: rgba(124, 255, 107, 0.55) !important;
  background: rgba(124, 255, 107, 0.1) !important;
}

.mode-card em {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.mode-card strong {
  font-size: 18px;
  letter-spacing: -0.03em;
}

.mode-card span {
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  opacity: 1;
}

.mode-card.ghost span {
  color: var(--muted);
  opacity: 1;
}

.hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 120px;
}

.hud span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hud strong {
  font-size: 36px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.field {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.tgt {
  position: absolute;
  width: calc(var(--r) * 200%);
  aspect-ratio: 1;
  margin: calc(var(--r) * -100%);
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  background: var(--accent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 70%, transparent);
}

.tgt.orb {
  border-radius: 50%;
}

.tgt.diamond {
  border-radius: 8px;
  rotate: 45deg;
  background: #5ce1ff;
  box-shadow: 0 0 22px rgba(92, 225, 255, 0.7);
}

.tgt.plus {
  border-radius: 4px;
  background: #ffb347;
  box-shadow: 0 0 22px rgba(255, 179, 71, 0.7);
}

.tgt.ship {
  background-color: transparent;
  box-shadow: none;
  background-image: url("/games/space-shooter/ships.png");
  background-repeat: no-repeat;
  background-size: 500% 300%;
  background-position: calc(var(--col, 0) * 25%) calc(var(--row, 0) * 50%);
  image-rendering: pixelated;
  rotate: var(--rot, 0deg);
}

.tgt.ship.is-exploding {
  background-image: url("/games/space-shooter/explosion.png");
  background-size: 800% 100%;
  background-position: calc(var(--frame, 0) * 100% / 7) 0;
  rotate: 0deg;
}

.stage.is-ships .field {
  background-color: #000;
  background-image: url("/games/space-shooter/stars.png");
  background-repeat: repeat;
  background-size: 256px 224px;
  image-rendering: pixelated;
  animation: stars-drift 90s linear infinite;
}

@keyframes stars-drift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 256px 224px;
  }
}

.start-game {
  appearance: none;
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  z-index: 4;
  border: 0;
  border-radius: 999px;
  padding: 20px 42px;
  background: var(--accent);
  color: #10210d;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  pointer-events: none;
}

.start-wait {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  z-index: 4;
  margin: 0;
  color: var(--muted);
  font-size: 20px;
}

.banner {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 4;
  padding: 16px 28px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 28px;
  font-weight: 800;
}

.results {
  position: absolute;
  inset: 18% 16% auto;
  z-index: 5;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.results h2 {
  margin: 0 0 16px;
  font-size: 36px;
  letter-spacing: -0.04em;
}

.results h3 {
  margin: 20px 0 8px;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.results ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.results li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.results .start-game {
  position: static;
  transform: none;
  display: block;
  width: 100%;
  margin-top: 18px;
  font-size: 20px;
}

.catalog {
  position: absolute;
  inset: 108px 28px 28px;
  z-index: 2;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  grid-template-rows: 1fr auto;
  align-items: center;
  column-gap: 16px;
  pointer-events: none;
}

.catalog-grid {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 14px;
  height: min(70vh, 620px);
  overflow: visible;
}

.game-tile {
  appearance: none;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #101214;
  transform: scale(1);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.game-tile.is-hot {
  z-index: 2;
  transform: scale(1.035);
  box-shadow:
    0 0 0 3px #fff,
    0 8px 18px rgba(0, 0, 0, 0.4);
}

.game-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.game-tile.is-empty {
  visibility: hidden;
}

.catalog-nav {
  appearance: none;
  grid-row: 1;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #10210d;
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
}

.catalog-nav[data-dir="-1"] {
  grid-column: 1;
}

.catalog-nav[data-dir="1"] {
  grid-column: 3;
}

.catalog-dots {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 10px 0 0;
  text-align: center;
  letter-spacing: 0.35em;
  color: var(--muted);
  font-size: 18px;
}

.stage.is-playing .empty,
.stage.is-playing .qr-card,
.stage.is-playing .catalog,
.stage.is-playing .start-game,
.stage.is-playing .start-wait,
.stage.is-finished .empty,
.stage.is-finished .qr-card,
.stage.is-finished .catalog,
.stage.is-finished .start-wait {
  display: none !important;
}

.qr-actions[hidden],
.qr-card[hidden],
.pairing[hidden],
.stage[hidden],
.empty[hidden],
.pad[hidden],
.row[hidden],
.join-form[hidden],
.field[hidden],
.hud[hidden],
.start-game[hidden],
.start-wait[hidden],
.catalog[hidden],
.catalog-nav[hidden],
.banner[hidden],
.results[hidden] {
  display: none !important;
}

.phone .join-form {
  margin-top: 0;
}

@media (max-width: 720px) {
  .auth-bar {
    padding-inline: 16px;
  }

  .auth-user span {
    max-width: 34vw;
  }

  .topbar {
    flex-direction: column;
  }

  .players {
    max-width: none;
    justify-content: flex-start;
  }

  .qr-card {
    position: static;
    margin: 24px 16px 20px;
  }
}
