:root {
  color-scheme: light;
  --ink: #151820;
  --muted: #626a78;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(21, 24, 32, 0.12);
  --red: #f05252;
  --blue: #3578ff;
  --green: #21a67a;
  --yellow: #f3c74f;
  --violet: #7a5cff;
  --dark: #22283a;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(53, 120, 255, 0.18), transparent 34%),
    linear-gradient(225deg, rgba(240, 82, 82, 0.16), transparent 38%),
    #f4f2e9;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  grid-template-columns: minmax(320px, 620px) minmax(280px, 340px);
  gap: 16px;
  align-items: center;
  justify-content: center;
}

.game-panel,
.side {
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 5vw, 4.4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

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

nav a,
.ghost,
.mode {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--dark);
  font-weight: 850;
}

.mode.active {
  color: #fff;
  background: var(--dark);
}

.stage {
  position: relative;
  width: min(100%, 62vh);
  max-width: 620px;
  justify-self: center;
  border: 4px solid #fff;
  border-radius: 8px;
  overflow: hidden;
  background: #dce8f8;
  box-shadow: 0 22px 54px rgba(21, 24, 32, 0.2);
}

canvas {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: block;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(rgba(255, 255, 255, 0.08), rgba(21, 24, 32, 0.28));
}

.overlay.hidden {
  display: none;
}

.modal {
  width: min(370px, 96%);
  padding: 20px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 20px 44px rgba(21, 24, 32, 0.18);
}

.modal h2 {
  margin-bottom: 8px;
  font-size: 2rem;
  line-height: 1;
}

.modal p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.primary {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 10px 20px rgba(240, 82, 82, 0.24);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hud div,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(21, 24, 32, 0.08);
}

.hud div {
  min-height: 62px;
  padding: 10px;
}

.hud span,
.loadout span,
dt,
.status-card p {
  color: var(--muted);
}

.hud span,
.loadout span,
dt {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 850;
}

.hud strong {
  font-size: 1.25rem;
  font-weight: 950;
}

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

.side {
  align-content: center;
}

.card {
  padding: 14px;
}

.loadout,
dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.loadout div,
dl div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(21, 24, 32, 0.05);
}

.loadout strong,
dd {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 950;
}

.status-card p {
  min-height: 52px;
  margin-bottom: 0;
  font-weight: 800;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 16px, 560px);
    grid-template-columns: 1fr;
    align-items: start;
    padding: max(8px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  }

  .stage {
    width: min(100%, calc((100dvh - 214px) * 0.62));
    min-width: 300px;
  }

  .side {
    align-content: start;
  }
}

@media (max-width: 460px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

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

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

  .ghost,
  .mode {
    padding: 8px 6px;
    font-size: 0.86rem;
  }
}
