:root {
  --bg0: #05070f;
  --neon: #5ce1ff;
  --text: #e8f0ff;
  --muted: #8a97b0;
  --panel: rgba(8, 12, 24, 0.55);
  --line: rgba(92, 225, 255, 0.2);
  --danger: #ff5c7a;
  --font: 'Saira', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  font-weight: 100;
  background: #03050a;
}

body {
  overflow-x: hidden;
}

#bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(135deg, #081018, #0a1220 45%, #060a14);
  animation: bgDrift 28s ease-in-out infinite alternate;
  filter: saturate(0.85);
}

@keyframes bgDrift {
  0% {
    background: linear-gradient(125deg, #060a12 0%, #0c1524 48%, #050810 100%);
  }
  33% {
    background: linear-gradient(160deg, #0a1018 0%, #071422 50%, #0d0a14 100%);
  }
  66% {
    background: linear-gradient(200deg, #080c16 0%, #101018 45%, #061018 100%);
  }
  100% {
    background: linear-gradient(110deg, #0b0e18 0%, #091820 55%, #0a0a12 100%);
  }
}

#app {
  position: relative;
  z-index: 1;
}

a {
  color: var(--neon);
}

.hidden {
  display: none !important;
}

.view {
  min-height: 100dvh;
  padding: 1.5rem;
}

.brand {
  font-family: var(--font);
  font-weight: 100;
  letter-spacing: 0.14em;
  font-size: clamp(2.4rem, 6vw, 4rem);
  margin: 0;
  animation: brandIn 0.8s ease-out;
}

.brand.small {
  font-size: 1.6rem;
}

.brand.tiny {
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  opacity: 0.7;
}

.tagline {
  color: var(--muted);
  max-width: 36rem;
  font-weight: 100;
  animation: fadeUp 0.9s ease-out 0.1s both;
}

.hero-brand {
  margin-bottom: 1.5rem;
}

.name-banner {
  max-width: 960px;
  margin-bottom: 1.25rem;
}

.name-banner .tip {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.home-layout {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  max-width: 960px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1.25rem 1.4rem;
  backdrop-filter: blur(10px);
  animation: fadeUp 0.7s ease-out;
}

.panel h2 {
  font-family: var(--font);
  font-weight: 100;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  margin: 0 0 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
  font-weight: 100;
}

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.name-edit {
  margin-bottom: 0.85rem;
}

input[type='text'],
input[type='number'] {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  padding: 0.45rem 0;
  font: inherit;
  font-weight: 100;
}

input[type='text']:focus,
input[type='number']:focus {
  outline: none;
  border-bottom-color: var(--neon);
}

.btn {
  font-family: var(--font);
  font-weight: 100;
  letter-spacing: 0.08em;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.45rem 0.2rem;
  cursor: pointer;
  border-radius: 0;
  box-shadow: none;
}

.btn:hover {
  color: var(--neon);
}

.btn.primary {
  color: var(--neon);
  width: 100%;
  text-align: left;
}

.btn.ghost {
  font-size: 0.85rem;
}

.btn.fire {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0;
  color: var(--danger);
  text-align: right;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
}

.btn.touch {
  min-width: 2.2rem;
  min-height: 2.2rem;
  font-size: 1.1rem;
  opacity: 0.75;
}

.btn.touch:hover {
  opacity: 1;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--font);
  font-weight: 100;
  letter-spacing: 0.06em;
}

.lobby-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lobby-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.waiting-panel {
  max-width: 32rem;
  margin: 2rem auto;
}

.wait-players {
  list-style: none;
  padding: 0;
}

.wait-players li {
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.legal {
  margin-top: 2.5rem;
  font-size: 0.85rem;
}

/* —— In-game HUD: seamless, no boxes, right-aligned —— */
.game-view {
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  grid-template-rows: 1fr;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 1.1rem 1.1rem;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow-y: auto;
  z-index: 2;
  text-align: right;
  align-items: stretch;
}

.hud-top {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-end;
}

.timer {
  font-family: var(--font);
  font-weight: 100;
  font-size: 1.35rem;
  letter-spacing: 0.12em;
}

.scoreboard {
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
}

.score-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  width: 100%;
}

.controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-end;
}

.control-block {
  border: none;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.angle-display {
  font-family: var(--font);
  font-weight: 100;
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  letter-spacing: 0.06em;
  padding: 0;
  background: transparent;
  border: none;
  text-align: right;
  user-select: none;
  line-height: 1.1;
  width: 100%;
}

.angle-display .digit {
  display: inline-block;
  min-width: 0.65ch;
  padding: 0 1px;
}

.angle-display .digit.selected {
  background: rgba(92, 225, 255, 0.2);
  border-radius: 0;
}

.angle-display .sep {
  opacity: 0.5;
}

.touch-row {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  width: 100%;
}

.value-row {
  width: 100%;
  text-align: right;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
}

input[type='range'] {
  width: 100%;
  accent-color: var(--neon);
  background: transparent;
}

.energy-block {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  width: 100%;
}

.energy-bar {
  height: 0.35rem;
  flex: 1;
  max-width: 9rem;
  background: rgba(255, 255, 255, 0.08);
  border: none;
}

#energy-fill {
  height: 100%;
  width: 10%;
  background: var(--neon);
  transition: width 0.1s linear;
}

#energy-text {
  min-width: 2ch;
  text-align: right;
}

.kill-feed {
  min-height: 1.2em;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
  width: 100%;
}

.board-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 14, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
  animation: fadeUp 0.35s ease-out;
  text-align: center;
}

.board-overlay ol {
  font-family: var(--font);
  font-weight: 100;
  font-size: 1.15rem;
  line-height: 1.8;
  text-align: right;
}

@media (max-width: 820px) {
  .game-view {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(45dvh, 1fr) auto;
  }

  .hud {
    border: none;
    max-height: 48dvh;
    background: rgba(3, 5, 10, 0.35);
  }

  .angle-display {
    font-size: 2.2rem;
  }
}

@keyframes brandIn {
  from {
    opacity: 0;
    filter: blur(6px);
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
