:root {
  color-scheme: dark;
  --background: #090c10;
  --grid-size: 48px;
  --grid-major-size: 240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--background);
}

body {
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(27, 41, 54, 0.22), transparent 48%),
    linear-gradient(145deg, #0b0f14 0%, var(--background) 48%, #080b0f 100%);
  color: #aeb8c3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ambient-grid {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  isolation: isolate;
}

.ambient-grid::before,
.ambient-grid::after {
  position: absolute;
  inset: 0;
  content: "";
}

/* Static layers: the browser can paint and cache them as part of the background. */
.ambient-grid::before {
  background-image:
    linear-gradient(rgba(116, 145, 169, 0.052) 1px, transparent 1px),
    linear-gradient(90deg, rgba(116, 145, 169, 0.052) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  -webkit-mask-image: radial-gradient(ellipse 96% 86% at 50% 48%, #000 24%, transparent 92%);
  mask-image: radial-gradient(ellipse 96% 86% at 50% 48%, #000 24%, transparent 92%);
}

.ambient-grid::after {
  background-image:
    linear-gradient(rgba(130, 159, 184, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130, 159, 184, 0.075) 1px, transparent 1px);
  background-size: var(--grid-major-size) var(--grid-major-size);
  -webkit-mask-image: radial-gradient(ellipse 82% 76% at 50% 48%, #000 12%, transparent 88%);
  mask-image: radial-gradient(ellipse 82% 76% at 50% 48%, #000 12%, transparent 88%);
}

.ambient-grid__signals {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.grid-segment {
  fill: none;
  stroke: rgba(132, 184, 214, 0.62);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  will-change: opacity;
}

.grid-point {
  fill: rgba(164, 205, 228, 0.82);
  opacity: 0;
  will-change: opacity;
}

.placeholder {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 2rem;
}

.placeholder__label {
  margin: 0;
  color: rgba(196, 207, 217, 0.58);
  font-size: clamp(0.68rem, 0.62rem + 0.18vw, 0.82rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  line-height: 1;
  text-transform: lowercase;
  text-shadow: 0 0 20px rgba(111, 166, 204, 0.1);
  user-select: none;
}

.center-card {
  min-width: min(440px, calc(100vw - 2rem));
  padding: clamp(1.8rem, 5vw, 3rem);
  border: 1px solid rgba(116, 145, 169, 0.14);
  border-radius: 18px;
  background: rgba(9, 14, 19, 0.58);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.025);
  text-align: center;
  backdrop-filter: blur(10px);
}

.center-card p {
  margin: 1rem 0 0;
  color: rgba(174, 184, 195, 0.72);
  font-size: 0.9rem;
}

.game-shell {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100vw;
  height: 100vh;
  min-height: 100svh;
  height: 100dvh;
  padding: clamp(12px, 2vw, 28px);
}

.game-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - clamp(24px, 4vw, 56px));
  min-height: calc(100svh - clamp(24px, 4vw, 56px));
  height: calc(100dvh - clamp(24px, 4vw, 56px));
  overflow: hidden;
  border: 1px solid rgba(116, 145, 169, 0.18);
  border-radius: 16px;
  background: rgba(9, 14, 19, 0.72);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.game-card__header {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(116, 145, 169, 0.14);
}

.game-card__header h1 {
  margin: 0;
  color: rgba(196, 207, 217, 0.62);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.game-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #05070a;
}

.game-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #05070a;
}

.game-expand {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  right: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.game-expand:hover,
.game-expand:focus-visible {
  outline: none;
  transform: scale(1.12);
  filter: brightness(1.3) drop-shadow(0 0 7px rgba(117, 185, 223, 0.85));
}

.game-expand img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.game-stage:fullscreen,
.game-stage:-webkit-full-screen,
.game-stage.game-stage--expanded {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border: 0;
  background: #05070a;
}

.game-stage.game-stage--expanded {
  position: fixed;
  z-index: 99999;
  inset: 0;
}

body.game-expanded {
  overflow: hidden;
}

@media (max-width: 700px) {
  :root {
    --grid-size: 36px;
    --grid-major-size: 180px;
  }

  .game-shell {
    padding: 6px;
  }

  .game-card {
    height: calc(100vh - 12px);
    min-height: calc(100svh - 12px);
    height: calc(100dvh - 12px);
    border-radius: 10px;
  }

  .game-expand {
    bottom: max(8px, env(safe-area-inset-bottom));
    right: max(8px, env(safe-area-inset-right));
  }
}
