:root {
  color-scheme: dark;
  --bg: #08090f;
  --ink: #f5f7fb;
  --muted: #9ca9bd;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(10, 14, 24, 0.78);
  --accent: #42e8c4;
  --accent-2: #f4d35e;
  --danger: #ff5f7a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(135deg, #090a12 0%, #121722 48%, #070910 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #051412;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  padding: 0 22px;
}

.fullscreen-button {
  position: fixed;
  top: clamp(14px, 2.4vw, 24px);
  right: clamp(14px, 2.4vw, 24px);
  z-index: 5;
  width: 52px;
  height: 52px;
  min-height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(5, 8, 14, 0.68);
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
  padding: 0;
  backdrop-filter: blur(16px);
}

input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  padding: 0 12px;
}

input::placeholder {
  color: rgba(203, 213, 225, 0.58);
}

button:focus-visible {
  outline: 3px solid rgba(244, 211, 94, 0.9);
  outline-offset: 3px;
}

input:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(66, 232, 196, 0.28);
  outline-offset: 2px;
}

.game-shell {
  min-height: 100%;
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 24px);
}

.game-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  background: #070910;
}

.game-shell:fullscreen canvas {
  width: min(100vw, calc(100vh * 16 / 9));
  max-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

.game-shell:fullscreen .fullscreen-button {
  background: rgba(5, 8, 14, 0.82);
}

canvas {
  width: min(100%, calc(100vh * 16 / 9));
  max-height: calc(100vh - clamp(24px, 4vw, 48px));
  aspect-ratio: 16 / 9;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070910;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  cursor: ew-resize;
}

.hud {
  position: fixed;
  top: clamp(14px, 2.4vw, 24px);
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr)) minmax(128px, 1.4fr);
  gap: 8px;
  pointer-events: none;
}

.hud-group {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 8, 14, 0.68);
  backdrop-filter: blur(16px);
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px 12px;
}

.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sub-label {
  overflow: hidden;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud strong {
  font-size: clamp(18px, 2.8vw, 25px);
  line-height: 1;
}

.meter {
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left center;
  transform: scaleX(1);
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(3, 6, 12, 0.46);
  backdrop-filter: blur(7px);
}

.overlay.visible {
  display: grid;
}

.panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.4);
  padding: clamp(22px, 5vw, 34px);
  text-align: center;
}

.panel h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 8vw, 54px);
  line-height: 1;
}

.panel p {
  min-height: 48px;
  margin: 0 0 20px;
  color: #cbd5e1;
  line-height: 1.6;
}

.record-form {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  text-align: left;
}

.record-form[hidden] {
  display: none;
}

.record-form label {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
}

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

@media (max-width: 680px) {
  .fullscreen-button {
    width: 46px;
    height: 46px;
    min-height: 46px;
    font-size: 22px;
  }

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

  .hud-group {
    min-height: 46px;
    padding: 7px 9px;
  }

  .hud-group.ammo {
    grid-column: 1 / -1;
  }

  .record-row {
    grid-template-columns: 1fr;
  }
}

@media (hover: none) and (pointer: coarse) {
  canvas {
    cursor: default;
  }
}
