@font-face {
  font-family: "HYWenHei-85W";
  src: url("/assets/fonts/HYWenHei-85W.otf") format("opentype");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sendyun Welcome Script";
  src: url("/assets/fonts/welcome/STXingkai.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #070910;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.13);
  --text: #f8fbff;
  --muted: #a9b8c7;
  --line: rgba(255, 255, 255, 0.16);
  --cyan: #68e8ff;
  --green: #7dffcb;
  --rose: #ff7aa8;
  --amber: #ffd66b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "汉仪文黑 85W", "汉仪文黑", "HYWenHei-85W", "HYWenHei", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 14% 18%, rgba(104, 232, 255, 0.18), transparent 26rem),
    radial-gradient(circle at 82% 12%, rgba(255, 122, 168, 0.14), transparent 22rem),
    radial-gradient(circle at 72% 80%, rgba(125, 255, 203, 0.12), transparent 28rem),
    linear-gradient(135deg, #070910 0%, #101523 48%, #080b12 100%);
  overflow-x: hidden;
  animation: gamePageIn 0.42s ease both;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.82), transparent 78%);
}

.lobby-page {
  background:
    radial-gradient(circle at 14% 18%, rgba(104, 232, 255, 0.2), transparent 27rem),
    radial-gradient(circle at 84% 14%, rgba(255, 122, 168, 0.15), transparent 24rem),
    radial-gradient(circle at 70% 82%, rgba(125, 255, 203, 0.13), transparent 30rem),
    linear-gradient(135deg, #070910 0%, #101523 48%, #080b12 100%);
}

#lobbyConstellation {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.lobby-cursor-glow {
  position: fixed;
  z-index: 1;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(104, 232, 255, 0.15), rgba(125, 255, 203, 0.06) 38%, transparent 70%);
  filter: blur(10px);
  opacity: 0.84;
  transform: translate(-50%, -50%);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 1180px);
  margin: 0 auto;
  padding: 18px 0 42px;
}

.lobby-page .shell {
  z-index: 2;
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 72px;
  margin-bottom: 30px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 9, 16, 0.72);
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 0 28px rgba(104, 232, 255, 0.22);
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-actions,
.language-switch,
.actions,
.stat-grid,
.game-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nav-link,
.action,
.language-switch button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #dbe7f1;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-link,
.action {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  font-weight: 800;
}

.language-switch {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.language-switch button {
  min-width: 34px;
  height: 30px;
  border: 0;
  font-size: 12px;
  font-weight: 900;
  background: transparent;
}

.nav-link:hover,
.action:hover,
.language-switch button:hover,
.language-switch button.active {
  color: #061017;
  border-color: rgba(104, 232, 255, 0.45);
  background: linear-gradient(135deg, var(--cyan), var(--green));
  transform: translateY(-1px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: clamp(24px, 5vw, 58px);
  align-items: center;
  min-height: 560px;
  padding: clamp(24px, 5vw, 60px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.045));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  animation: liftIn 0.52s ease both;
}

.lobby-page .hero {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(46px, 8vw, 96px);
  line-height: 0.96;
}

h2 {
  margin: 0 0 14px;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.12;
}

.lead {
  max-width: 680px;
  margin: 20px 0 0;
  color: #d3e1eb;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.8;
}

.lobby-welcome {
  position: relative;
  display: grid;
  min-height: 360px;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
}

.welcome-glow {
  position: absolute;
  width: min(390px, 82vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 42% 42%, rgba(125, 255, 203, 0.2), transparent 42%),
    radial-gradient(circle at 62% 58%, rgba(214, 182, 255, 0.18), transparent 58%);
  filter: blur(12px);
  animation: welcomeGlow 8s ease-in-out infinite alternate;
}

.welcome-words {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 150px;
}

.welcome-words span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(245, 251, 255, 0.96);
  font-family: "Sendyun Welcome Script", "Segoe Script", "Snell Roundhand", "STKaiti", "KaiTi", "Yu Mincho", "Nanum Pen Script", cursive;
  font-size: clamp(42px, 5.6vw, 78px);
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 0 26px rgba(104, 232, 255, 0.2);
  white-space: nowrap;
  opacity: 0;
  transform: translate3d(20px, 10px, 0) scale(0.98);
  filter: blur(8px);
  animation: welcomeWrite 18s cubic-bezier(0.4, 0, 0.2, 1) infinite both;
}

.welcome-words span:nth-child(1) { animation-delay: -1s; }
.welcome-words span:nth-child(2) { animation-delay: 2s; }
.welcome-words span:nth-child(3) { animation-delay: 5s; }
.welcome-words span:nth-child(4) { animation-delay: 8s; }
.welcome-words span:nth-child(5) { animation-delay: 11s; }
.welcome-words span:nth-child(6) { animation-delay: 14s; }

.welcome-caption {
  position: absolute;
  z-index: 1;
  bottom: 74px;
  color: rgba(211, 225, 235, 0.58);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 16px;
  margin-top: 18px;
}

.card,
.game-card,
.play-shell,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
}

.game-card {
  position: relative;
  min-height: 280px;
  padding: 24px;
  overflow: hidden;
  animation: liftIn 0.52s ease both;
}

.game-card:nth-child(2) {
  animation-delay: 0.08s;
}

.game-card:nth-child(3) {
  animation-delay: 0.16s;
}

.game-card::after {
  position: absolute;
  right: -80px;
  bottom: -90px;
  width: 240px;
  height: 240px;
  content: "";
  border: 1px solid rgba(104, 232, 255, 0.22);
  border-radius: 50%;
}

.game-card h2 {
  position: relative;
  z-index: 1;
}

.game-card p,
.copyright,
.hint {
  color: var(--muted);
  line-height: 1.75;
}

.copyright {
  margin-top: 14px;
  font-size: 12px;
}

.arena-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.play-shell {
  display: grid;
  gap: 12px;
  place-items: center;
  padding: 16px;
  animation: liftIn 0.52s ease both;
}

.play-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 10px;
  align-content: center;
  justify-items: center;
  gap: 10px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(104, 232, 255, 0.18), transparent 40%),
    #050a10;
}

.play-shell:fullscreen .game-canvas {
  width: min(calc(100vw - 20px), calc((100vh - 122px) * 960 / 620));
  width: min(calc(100vw - 20px), calc((100dvh - 122px) * 960 / 620));
  max-height: calc(100vh - 122px);
  max-height: calc(100dvh - 122px);
}

.play-shell:fullscreen .tank-touch-controls {
  display: flex;
  max-width: min(720px, calc(100vw - 20px));
  padding: 0 8px 6px;
}

@media (orientation: landscape) {
  .play-shell:fullscreen {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 28vw);
    grid-template-rows: 1fr;
  }

  .play-shell:fullscreen .game-canvas {
    width: min(calc(100vw - 260px), calc((100dvh - 20px) * 960 / 620));
    max-height: calc(100dvh - 20px);
  }

  .play-shell:fullscreen .tank-touch-controls {
    width: 100%;
    max-width: 320px;
    align-self: center;
    flex-direction: column;
  }
}

canvas.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #071018;
  box-shadow: inset 0 0 60px rgba(104, 232, 255, 0.08);
}

#tankCanvas {
  max-width: 960px;
  aspect-ratio: 960 / 620;
}

#tetrisCanvas {
  width: min(100%, 420px);
  max-width: 420px;
  aspect-ratio: 420 / 760;
}

.tank-touch-controls {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 560px;
  touch-action: none;
}

.tetris-touch-controls {
  display: none;
  width: 100%;
  touch-action: none;
}

.touch-stick {
  position: relative;
  width: 116px;
  aspect-ratio: 1;
  border: 1px solid rgba(104, 232, 255, 0.35);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(104, 232, 255, 0.12), transparent 58%),
    rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 28px rgba(104, 232, 255, 0.12);
}

.touch-stick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 8px 24px rgba(104, 232, 255, 0.28);
  transform: translate(-50%, -50%);
}

.touch-fire,
.touch-key {
  min-height: 54px;
  border: 1px solid rgba(104, 232, 255, 0.34);
  border-radius: 8px;
  color: #061017;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
}

.touch-fire {
  width: min(42vw, 180px);
  min-height: 74px;
  font-size: 18px;
}

.touch-primary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.touch-primary-actions .touch-fire {
  width: 100%;
}

.touch-item {
  background: linear-gradient(135deg, var(--amber), var(--rose));
}

.tank-touch-actions {
  display: grid;
  flex: 1 1 240px;
  max-width: 360px;
  gap: 8px;
}

.touch-mini-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.touch-mini {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #dbe7f1;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}

.touch-mini.warn {
  color: #061017;
  background: linear-gradient(135deg, var(--amber), var(--rose));
}

.tetris-touch-controls {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.touch-key.wide {
  grid-column: span 4;
  background: linear-gradient(135deg, var(--amber), var(--rose));
}

.side-panel {
  padding: 18px;
  animation: liftIn 0.52s ease both;
  animation-delay: 0.08s;
}

.stat-grid {
  align-items: stretch;
  margin: 12px 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.mode-switch button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #dbe7f1;
  font-weight: 900;
  background: transparent;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, transform 0.22s ease;
}

.mode-switch button:hover,
.mode-switch button.active {
  color: #061017;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  transform: translateY(-1px);
}

.mode-switch button:disabled {
  color: rgba(219, 231, 241, 0.42);
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.04);
  transform: none;
}

.duo-layout-switch {
  margin-top: -4px;
  border-color: rgba(214, 182, 255, 0.32);
}

.duo-layout-switch.is-disabled {
  opacity: 0.55;
}

.boss-option-switch {
  border-color: rgba(155, 92, 255, 0.42);
}

.boss-option-switch button.active {
  background: linear-gradient(135deg, #d6b6ff, #9b5cff);
  color: #130823;
}

.stat {
  flex: 1 1 90px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
}

.action.primary {
  color: #061017;
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.action.warn {
  color: #061017;
  background: linear-gradient(135deg, var(--amber), var(--rose));
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes welcomeWrite {
  0% {
    opacity: 0;
    transform: translate3d(20px, 10px, 0) scale(0.98);
    filter: blur(8px);
  }
  3%, 11% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(0);
  }
  16%, 100% {
    opacity: 0;
    transform: translate3d(-18px, -7px, 0) scale(1.015);
    filter: blur(7px);
  }
}

@keyframes welcomeGlow {
  from { opacity: 0.58; transform: scale(0.92) rotate(-4deg); }
  to { opacity: 1; transform: scale(1.08) rotate(4deg); }
}

@keyframes gamePageIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .topbar,
  .nav-actions {
    height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .nav-actions,
  .language-switch {
    width: 100%;
  }

  .nav-link,
  .language-switch button {
    flex: 1;
    justify-content: center;
  }

  .hero,
  .arena-layout,
  .grid {
    grid-template-columns: 1fr;
  }

  .play-shell {
    padding: 10px;
  }

  canvas.game-canvas,
  #tetrisCanvas {
    width: 100%;
    max-width: 100%;
  }

  #tankCanvas {
    max-height: 58vh;
  }

  #tetrisCanvas {
    width: min(100%, 360px);
    max-width: 360px;
  }

  .tank-touch-controls {
    display: flex;
  }

  .tetris-touch-controls {
    display: grid;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    top: 8px;
    margin-bottom: 12px;
    padding: 12px;
  }

  .brand small {
    display: none;
  }

  .side-panel {
    padding: 14px;
  }

  .lobby-welcome {
    min-height: 240px;
  }

  .welcome-words {
    min-height: 112px;
  }

  .welcome-words span {
    padding: 0 8px;
    font-size: clamp(30px, 10.5vw, 46px);
    white-space: normal;
  }

  .welcome-caption {
    bottom: 38px;
    font-size: 9px;
    letter-spacing: 0.2em;
  }

  .stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat {
    min-width: 0;
    padding: 10px;
  }

  .stat strong {
    font-size: 20px;
  }

  .touch-stick {
    width: 104px;
  }

  .touch-fire {
    width: 100%;
    min-height: 66px;
  }

  .tank-touch-controls {
    gap: 10px;
  }

  .tank-touch-actions {
    min-width: 0;
  }

  .touch-mini {
    min-height: 38px;
    font-size: 12px;
  }

  #tetrisCanvas {
    width: min(100%, 260px);
    max-width: 260px;
  }

  .tetris-touch-controls {
    position: sticky;
    bottom: 8px;
    z-index: 8;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: rgba(7, 9, 16, 0.76);
    backdrop-filter: blur(14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-glow,
  .welcome-words span {
    animation: none;
  }

  .welcome-words span {
    display: none;
  }

  .welcome-words span:first-child {
    display: grid;
    opacity: 1;
    transform: none;
    filter: none;
  }

  .lobby-cursor-glow,
  #lobbyConstellation {
    display: none;
  }
}
