:root {
  --bg-1: #04151f;
  --bg-2: #082638;
  --bg-3: #104f67;
  --panel: #071f2bd6;
  --panel-edge: #56d4ee;
  --text-main: #ebfdff;
  --text-dim: #9ccfdb;
  --accent: #f5c874;
  --accent-2: #e28d4b;
  --danger: #ff6464;
  --ok: #58e0a1;
  --focus: #ffffff;
  --shadow: 0 14px 38px #020f1673;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Optima", "Trebuchet MS", sans-serif;
  color: var(--text-main);
  background:
    linear-gradient(180deg, #031019, #051b2a 42%, #04111b 100%),
    radial-gradient(circle at 18% 12%, #16708c 0%, #083d54 45%, #041922 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 15, 22, 0.34), rgba(2, 10, 16, 0.84)),
    url("assets/generated/bg-underwater-arena.png") center / cover no-repeat;
  filter: saturate(0.9) brightness(0.58);
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: -4%;
  background: url("assets/generated/texture-caustics-overlay.png") center / cover no-repeat;
  opacity: 0.14;
  mix-blend-mode: screen;
  animation: caustic-drift 28s linear infinite;
  z-index: -1;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 1rem 1rem 1.2rem;
}

.app-shell {
  width: min(1200px, 100%);
  display: grid;
  gap: 0.85rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.8rem 1rem;
  background:
    linear-gradient(120deg, rgba(10, 45, 60, 0.86), rgba(6, 30, 44, 0.9)),
    url("assets/generated/texture-caustics-overlay.png") center / cover no-repeat;
  border: 1px solid #67d5ea9e;
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(3px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.9vw, 2.3rem);
  letter-spacing: 0.03em;
  line-height: 1.05;
  color: #f1fdff;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 2px 10px rgba(1, 11, 17, 0.4);
}

.brand-emblem {
  display: block;
  width: clamp(56px, 8vw, 86px);
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 14px rgba(1, 12, 18, 0.62));
}

.subtitle {
  margin: 0.22rem 0 0;
  color: var(--text-dim);
  font-size: clamp(0.74rem, 1.5vw, 0.98rem);
  line-height: 1.2;
}

.hud-readout {
  font-size: clamp(0.85rem, 1.6vw, 1.12rem);
  color: #fff8de;
  text-align: right;
  padding: 0.46rem 0.78rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #0f455dbf, #0b3042bf);
  border: 1px solid #6fe0f38b;
  max-width: 50%;
  font-weight: 600;
}

.canvas-wrap {
  position: relative;
  border-radius: 18px;
  border: 1px solid #72dff2a8;
  background: linear-gradient(145deg, #041722, #092a37);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(176, 236, 255, 0.14), rgba(176, 236, 255, 0));
}

#game-canvas {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  outline: none;
  touch-action: none;
}

.control-dock {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
  padding: 0.6rem;
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(7, 30, 42, 0.9), rgba(6, 21, 30, 0.92)),
    url("assets/generated/texture-caustics-overlay.png") center / cover no-repeat;
  border: 1px solid #4ecde48c;
  box-shadow: inset 0 1px 0 rgba(176, 236, 255, 0.12);
}

.control {
  border: 1px solid #6fd3e6d6;
  border-radius: 11px;
  background: linear-gradient(180deg, #1a6784, #0d3b4d);
  color: var(--text-main);
  font-weight: 600;
  letter-spacing: 0.02em;
  min-height: 2.55rem;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
  transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  box-shadow: inset 0 1px 0 rgba(179, 236, 255, 0.22);
}

.control:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: inset 0 1px 0 rgba(212, 247, 255, 0.36), 0 5px 10px rgba(2, 10, 18, 0.3);
}

.control:active {
  transform: translateY(0);
}

.control.primary {
  background: linear-gradient(180deg, #efc372, #bf7536);
  border-color: #ffe2a8;
  color: #1f1002;
  box-shadow: inset 0 1px 0 rgba(255, 242, 211, 0.6);
}

.control[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.assist-panel {
  display: grid;
  gap: 0.2rem;
  padding: 0.66rem 0.88rem;
  border-radius: 12px;
  border: 1px solid #5ad2e68a;
  background: linear-gradient(180deg, rgba(8, 36, 48, 0.84), rgba(6, 26, 35, 0.9));
  color: #d0f5ff;
  font-size: 0.86rem;
}

.assist-panel p {
  margin: 0;
}

.status-line {
  min-height: 1.2em;
  color: #fff3bf;
  font-weight: 600;
}

button:focus-visible,
#game-canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  body {
    padding: 0.55rem;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand-block {
    width: 100%;
  }

  .hud-readout {
    max-width: 100%;
    text-align: left;
    width: 100%;
  }

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

@media (max-width: 640px) {
  .control-dock {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control {
    min-height: 2.9rem;
    font-size: 0.92rem;
  }

  .assist-panel {
    font-size: 0.8rem;
  }

  .brand-copy h1 {
    font-size: clamp(1.2rem, 6.9vw, 1.78rem);
  }

  .brand-emblem {
    width: clamp(52px, 18vw, 82px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes caustic-drift {
  0% {
    transform: translate3d(-1.5%, -1%, 0) scale(1.05);
  }
  50% {
    transform: translate3d(1.2%, 0.6%, 0) scale(1.07);
  }
  100% {
    transform: translate3d(-1.5%, -1%, 0) scale(1.05);
  }
}
