﻿.games-body {
  --arcade-bg: rgba(12, 18, 32, 0.92);
  --arcade-panel: rgba(15, 23, 39, 0.84);
  --arcade-line: rgba(120, 187, 255, 0.18);
  --arcade-cyan: #7ae0ff;
  --arcade-mint: #8cffc1;
  --arcade-amber: #ffcf6e;
  --arcade-ink: #edf7ff;
  --arcade-muted: #95aac0;
}

.games-body .site-header {
  background: rgba(10, 17, 28, 0.82);
  border-bottom-color: rgba(120, 187, 255, 0.08);
}

.games-body .site-main,
.games-body .site-footer {
  max-width: 1340px;
}

.games-body .hero-panel,
.games-body .surface-panel,
.games-body .footer-panel {
  background: linear-gradient(180deg, rgba(18, 28, 46, 0.88), rgba(8, 13, 23, 0.94));
  border-color: rgba(120, 187, 255, 0.16);
  box-shadow: 0 28px 70px rgba(4, 9, 18, 0.36);
  color: var(--arcade-ink);
}

.games-body .section-note,
.games-body .lede,
.games-body .footer-copy,
.games-body .footer-links a,
.games-body .footer-meta,
.games-body .hero-stat span {
  color: var(--arcade-muted);
}

.games-body .button-secondary {
  background: #101d30;
  border-color: rgba(122, 224, 255, 0.42);
  color: #ffffff;
}

.games-body .button-primary {
  background: linear-gradient(135deg, #35c8f4 0%, #63eba9 100%);
  color: #031019;
  box-shadow: 0 16px 30px rgba(41, 215, 168, 0.22);
}

.games-body .button-primary,
.games-body .button-secondary {
  min-height: 46px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.games-body .button-primary:hover,
.games-body .button-primary:focus-visible {
  background: linear-gradient(135deg, #62d8fa 0%, #91f4c4 100%);
  color: #020b11;
}

.games-body .button-secondary:hover,
.games-body .button-secondary:focus-visible {
  background: #19304b;
  border-color: var(--arcade-cyan);
  color: #ffffff;
}

.games-body .button-primary:focus-visible,
.games-body .button-secondary:focus-visible,
.action-chip:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.games-body .eyebrow {
  background: rgba(27, 49, 74, 0.76);
  color: var(--arcade-cyan);
}

.games-body .eyebrow::before {
  background: var(--arcade-mint);
}

.games-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 24px;
}

.games-copy,
.games-stats {
  padding: clamp(22px, 4vw, 38px);
}

.games-title {
  max-width: 10ch;
}

.games-stats {
  display: grid;
  gap: 14px;
}

.games-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.game-card {
  padding: 22px;
  border-radius: 24px;
  border: 1px solid rgba(122, 224, 255, 0.14);
  background:
    radial-gradient(circle at top right, rgba(122, 224, 255, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(13, 21, 34, 0.9), rgba(8, 13, 22, 0.98));
  box-shadow: 0 18px 42px rgba(4, 9, 18, 0.28);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  color: var(--arcade-ink);
}

.game-card:hover,
.game-card.is-active {
  transform: translateY(-3px);
  border-color: rgba(140, 255, 193, 0.38);
  box-shadow: 0 24px 48px rgba(4, 9, 18, 0.36);
}

.game-card--external {
  border-color: rgba(255, 207, 110, 0.24);
  background:
    radial-gradient(circle at top right, rgba(255, 207, 110, 0.14), transparent 38%),
    linear-gradient(180deg, rgba(20, 24, 38, 0.92), rgba(10, 12, 22, 0.98));
}

.game-card h2 {
  margin: 14px 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2rem;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

.game-card p {
  margin: 0;
  color: var(--arcade-muted);
  line-height: 1.7;
}

.game-card-meta {
  margin-bottom: 12px !important;
  font-size: 0.84rem;
  color: var(--arcade-cyan) !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.game-card-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(24, 47, 70, 0.72);
  color: var(--arcade-amber);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.game-card-actions .button-primary,
.game-card-actions .button-secondary,
.game-card-link-row a {
  flex: 1 1 138px;
  white-space: normal;
  text-align: center;
}

.game-card-link-row a {
  text-decoration: none;
}

.games-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 24px;
  padding: 22px;
}

.games-sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.games-sidebar-head,
.games-story,
.games-controls-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(122, 224, 255, 0.14);
  background: rgba(8, 14, 24, 0.74);
}

.game-panel-title {
  margin-top: 12px;
  color: #ffffff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

.games-story h3,
.games-controls-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--arcade-cyan);
}

.games-story p {
  margin: 0;
  color: var(--arcade-muted);
  line-height: 1.7;
}

.games-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.games-field span {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--arcade-muted);
}

.games-input {
  width: 100%;
  border: 1px solid rgba(122, 224, 255, 0.14);
  border-radius: 14px;
  background: rgba(9, 16, 27, 0.88);
  color: var(--arcade-ink);
  padding: 12px 14px;
}

.games-input:focus {
  outline: none;
  border-color: rgba(140, 255, 193, 0.34);
  box-shadow: 0 0 0 4px rgba(45, 225, 157, 0.1);
}

.games-input--mono,
.lobby-code {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.games-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.games-mode-row--stack {
  display: grid;
}

.online-panel[hidden],
.lobby-panel[hidden],
.canvas-overlay[hidden] {
  display: none;
}

.lobby-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(122, 224, 255, 0.14);
}

.lobby-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(20, 38, 60, 0.74);
  border: 1px solid rgba(122, 224, 255, 0.14);
  color: var(--arcade-cyan);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lobby-list,
.games-control-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.lobby-list {
  display: grid;
  gap: 10px;
}

.lobby-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12, 21, 34, 0.9);
  border: 1px solid rgba(122, 224, 255, 0.1);
}

.games-control-list {
  display: grid;
  gap: 8px;
}

.games-control-list li,
.log-line {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(11, 20, 33, 0.88);
  color: var(--arcade-muted);
  line-height: 1.55;
}

.games-log {
  min-height: 140px;
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.games-stage {
  display: grid;
  gap: 14px;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stage-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.game-fullscreen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(122, 224, 255, 0.32);
  border-radius: 999px;
  background: rgba(10, 25, 42, 0.94);
  color: #fff;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.game-fullscreen-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.game-fullscreen-button:hover,
.game-fullscreen-button:focus-visible {
  border-color: var(--arcade-cyan);
  background: #19304b;
}

.game-fullscreen-button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.hud-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(12, 21, 34, 0.9);
  border: 1px solid rgba(122, 224, 255, 0.1);
  color: var(--arcade-ink);
  font-size: 0.88rem;
}

.games-stage[data-game-id="racer"] {
  --race-cyan: #5ed3ff;
  --race-amber: #ffcf6e;
  border-color: rgba(94, 211, 255, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 207, 110, 0.05), transparent 38%),
    #101725;
}

.games-stage[data-game-id="racer"] .stage-header {
  border-bottom: 1px solid rgba(94, 211, 255, 0.24);
  background: linear-gradient(90deg, rgba(9, 15, 26, 0.98), rgba(29, 16, 34, 0.96));
}

.games-stage[data-game-id="racer"] .hud-item {
  border-radius: 5px;
  border-color: rgba(94, 211, 255, 0.26);
  box-shadow: inset 3px 0 0 var(--race-cyan);
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.games-stage[data-game-id="racer"] .hud-item:nth-child(3),
.games-stage[data-game-id="racer"] .hud-item:nth-child(5) {
  box-shadow: inset 3px 0 0 var(--race-amber);
}

.games-stage[data-game-id="racer"] .canvas-shell {
  border-radius: 8px;
  border-color: rgba(94, 211, 255, 0.32);
  box-shadow: 0 18px 50px rgba(2, 5, 12, 0.48);
}

.canvas-shell {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(122, 224, 255, 0.16);
  background: linear-gradient(180deg, rgba(4, 10, 18, 0.94), rgba(8, 12, 20, 0.98));
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(circle at center, rgba(21, 59, 78, 0.2), rgba(3, 7, 12, 0.84)),
    linear-gradient(180deg, rgba(8, 15, 24, 0.32), rgba(8, 12, 20, 0.86));
  text-align: center;
}

.canvas-overlay h3 {
  margin: 14px 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.canvas-overlay p,
.games-caption {
  margin: 0;
  color: var(--arcade-muted);
  line-height: 1.7;
}

.mobile-game-controls {
  display: none;
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 5;
}

.mobile-control-rail {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.mobile-control-rail--left {
  left: max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 5px;
}

.mobile-control-rail--right {
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-control-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 16px;
  background: rgba(8, 18, 31, 0.74);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
  font: inherit;
  font-weight: 900;
  touch-action: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mobile-control-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-control-button--up {
  grid-column: 2;
  grid-row: 1;
}

.mobile-control-button--left {
  grid-column: 1;
  grid-row: 2;
}

.mobile-control-button--right {
  grid-column: 3;
  grid-row: 2;
}

.mobile-control-button--down {
  grid-column: 2;
  grid-row: 3;
}

.mobile-control-button--action {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border-color: rgba(140, 255, 193, 0.58);
  background: rgba(20, 105, 85, 0.78);
  color: #fff;
  font-size: 1.05rem;
}

.mobile-control-button--secondary {
  transform: translateY(22px);
  border-color: rgba(122, 224, 255, 0.58);
  background: rgba(24, 76, 115, 0.8);
}

.mobile-control-button.is-pressed {
  transform: scale(0.92);
  background: rgba(57, 213, 166, 0.92);
  border-color: #fff;
}

.mobile-control-button--secondary.is-pressed {
  transform: translateY(22px) scale(0.92);
}

.games-stage:fullscreen,
.games-stage.is-mobile-expanded {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: #030912;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.games-stage.is-mobile-expanded {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.games-stage:fullscreen .canvas-shell,
.games-stage.is-mobile-expanded .canvas-shell {
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
}

.games-stage:fullscreen #game-canvas,
.games-stage.is-mobile-expanded #game-canvas {
  width: auto;
  max-width: calc(100vw - 200px);
  height: 100%;
  max-height: calc(100dvh - 132px);
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

.games-stage:fullscreen .mobile-game-controls,
.games-stage.is-mobile-expanded .mobile-game-controls {
  display: block;
}

.games-stage:fullscreen .games-caption,
.games-stage.is-mobile-expanded .games-caption {
  display: none;
}

body.has-mobile-game-expanded {
  overflow: hidden;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(122, 224, 255, 0.18);
  background: #101d30;
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  transition: transform 180ms ease, border-color 180ms ease;
}

.action-chip:hover,
.action-chip.is-active {
  transform: translateY(-1px);
  border-color: rgba(140, 255, 193, 0.36);
  background: #19304b;
  color: #ffffff;
}

@media (max-width: 1320px) {
  .games-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .games-hero-grid,
  .games-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .games-card-grid {
    grid-template-columns: 1fr;
  }

  .games-shell {
    padding: 16px;
  }

  .game-card,
  .games-sidebar-head,
  .games-story,
  .games-controls-card {
    padding: 16px;
  }

  .stage-header,
  .game-card-actions,
  .games-mode-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .game-card-actions .button-primary,
  .game-card-actions .button-secondary,
  .game-card-link-row a,
  .games-mode-row .button-primary,
  .games-mode-row .button-secondary {
    width: 100%;
    flex: 0 0 auto;
  }

  .canvas-overlay {
    padding: 18px;
  }

  .stage-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .game-fullscreen-button {
    min-height: 46px;
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .games-stage:fullscreen #game-canvas,
  .games-stage.is-mobile-expanded #game-canvas {
    max-width: calc(100vw - 136px);
    max-height: calc(100dvh - 150px);
  }

  .mobile-control-rail--left {
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(3, 42px);
  }

  .mobile-control-button {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .mobile-control-button--action {
    width: 50px;
    height: 50px;
  }
}
