:root {
  --bg-deep: #071824;
  --bg-mid: #123a52;
  --panel: rgba(4, 17, 30, 0.8);
  --line: rgba(181, 219, 255, 0.28);
  --text: #f1f8ff;
  --text-muted: #b7d6ea;
  --accent: #ffc857;
  --accent-2: #43d4aa;
  --danger: #ff6f6f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(74, 160, 214, 0.2), transparent 38%),
    radial-gradient(circle at 75% 15%, rgba(67, 212, 170, 0.18), transparent 30%),
    linear-gradient(160deg, var(--bg-deep) 5%, #0c2a3d 45%, var(--bg-mid) 100%);
  overflow-x: hidden;
}

.background-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(50px);
  z-index: 0;
  pointer-events: none;
}

.glow-a {
  width: 360px;
  height: 360px;
  top: -120px;
  left: -80px;
  background: rgba(255, 200, 87, 0.2);
}

.glow-b {
  width: 300px;
  height: 300px;
  right: -100px;
  bottom: -120px;
  background: rgba(67, 212, 170, 0.22);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.top-bar {
  padding: 0.9rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

h1,
h2 {
  margin: 0;
  font-family: "Syne", sans-serif;
  letter-spacing: 0.4px;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.35rem);
}

.subtitle {
  margin: 0.1rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.build-meta {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: #d6ecfb;
  opacity: 0.85;
  letter-spacing: 0.04em;
}

.status-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  min-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pill span {
  font-size: 0.66rem;
  opacity: 0.82;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pill strong {
  font-size: 1rem;
}

.game-layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 1rem;
}

.lake-panel {
  position: relative;
  padding: 0.8rem;
}

#gameCanvas {
  width: 100%;
  height: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: block;
  background: linear-gradient(180deg, #5bc0eb 0%, #2e7bb0 40%, #205f8f 100%);
}

.controls-overlay {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.control-item {
  font-size: 0.82rem;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 999px;
  padding: 0.26rem 0.55rem;
}

kbd {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.74rem;
  color: #061927;
  background: #ecf8ff;
  border-radius: 6px;
  padding: 0.11rem 0.35rem;
}

.event-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(6, 18, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.event-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.side-panel {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.stats-card,
.inventory-card,
.shop-card,
.net-card,
.chat-card,
.cosmetic-card,
.emote-card {
  padding: 0.95rem;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  border-radius: 9px;
  padding: 0.48rem 0.6rem;
  font: inherit;
}

input:focus {
  outline: 2px solid rgba(255, 200, 87, 0.45);
}

.stats-grid {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.stats-grid div {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stats-grid span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.button {
  appearance: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  background: linear-gradient(125deg, var(--accent), #ff9f43);
  color: #1b1202;
}

.button:hover {
  filter: brightness(1.06);
}

.button.secondary {
  background: linear-gradient(125deg, #6ef6ca, #4cc9f0);
  color: #052432;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.26);
}

.inventory-list {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 0.45rem;
}

.inventory-list li {
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 0.44rem 0.54rem;
  display: flex;
  justify-content: space-between;
}

.shop-copy {
  color: var(--text-muted);
  margin: 0.55rem 0 0.8rem;
  font-size: 0.9rem;
}

.shop-items {
  display: grid;
  gap: 0.52rem;
}

.cosmetic-title-row {
  margin-bottom: 0.7rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.emote-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.net-grid {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.net-grid label {
  display: grid;
  gap: 0.3rem;
}

.net-grid span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.net-actions {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

#connectionStateLabel {
  font-size: 0.88rem;
}

.players-list {
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
  max-height: 120px;
  overflow: auto;
}

.players-list li {
  padding: 0.3rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  font-size: 0.84rem;
}

.chat-log {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  max-height: 150px;
  overflow: auto;
}

.chat-log li {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 0.32rem 0.5rem;
  font-size: 0.84rem;
}

.chat-log strong {
  color: var(--accent);
}

.chat-form {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem;
}

.mobile-controls {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  align-items: end;
  touch-action: none;
  user-select: none;
}

.touch-left p {
  margin: 0 0 0.3rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.touch-pad {
  position: relative;
  width: 136px;
  height: 136px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.03) 70%),
    rgba(4, 18, 30, 0.62);
  overflow: hidden;
}

.touch-nub {
  position: absolute;
  width: 52px;
  height: 52px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: linear-gradient(125deg, #c6f0ff, #7bd4f6);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.touch-right {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.touch-btn {
  min-width: 82px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: rgba(6, 21, 35, 0.82);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 0.56rem 0.8rem;
}

.touch-btn.cast {
  background: linear-gradient(125deg, var(--accent), #ff9f43);
  color: #1b1202;
  border-color: transparent;
}

.touch-btn:active {
  transform: scale(0.97);
}

.hidden {
  display: none;
}

@media (max-width: 1020px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 0.7rem;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-row {
    width: 100%;
    justify-content: flex-start;
  }

  .controls-overlay {
    display: none;
  }

  .mobile-controls {
    display: block;
    position: absolute;
    inset: 0;
    margin-top: 0;
    padding: 0;
    pointer-events: none;
    z-index: 4;
  }

  .touch-left,
  .touch-right {
    position: absolute;
    bottom: 12px;
    pointer-events: auto;
  }

  .touch-left {
    left: 10px;
  }

  .touch-right {
    right: 10px;
    grid-template-columns: 1fr 1fr;
    gap: 0.42rem;
  }

  .touch-left p {
    display: none;
  }

  #gameCanvas {
    max-height: calc(100vh - 210px);
    touch-action: none;
  }

  .touch-pad {
    width: 112px;
    height: 112px;
  }
}

@media (max-width: 1020px) and (orientation: landscape) {
  #gameCanvas {
    max-height: calc(100vh - 170px);
  }

  .touch-pad {
    width: 94px;
    height: 94px;
  }

  .touch-btn {
    min-width: 64px;
    padding: 0.38rem 0.48rem;
    font-size: 0.82rem;
  }
}
