:root {
  --cream: #f7f0de;
  --ink: #081820;
  --aqua: #52d7e8;
  --deep-aqua: #087f9a;
  --gold: #c6a86a;
  --glass: rgba(5, 20, 27, 0.76);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#game,
canvas {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: none;
}

body {
  color: var(--cream);
  background: #07131a;
  font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
  user-select: none;
}

canvas {
  display: block;
}

.hidden {
  display: none !important;
}

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(360px, 620px) 1fr;
  align-items: center;
  padding: clamp(24px, 6vw, 96px);
  background: #0b1a21 url("./assets/schloss.jpg") center / cover no-repeat;
}

.start-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(4, 15, 20, 0.96) 0%, rgba(4, 15, 20, 0.82) 43%, rgba(4, 15, 20, 0.12) 76%),
    linear-gradient(0deg, rgba(3, 11, 15, 0.75), transparent 45%);
  backdrop-filter: saturate(0.78);
}

.start-card {
  position: relative;
  z-index: 2;
  max-width: 560px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--aqua);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 0.82;
  letter-spacing: -0.055em;
  text-shadow: 0 12px 42px rgba(0, 0, 0, 0.35);
}

h1 em {
  color: transparent;
  font-style: normal;
  -webkit-text-stroke: 1.5px var(--aqua);
}

.intro {
  max-width: 520px;
  margin: 32px 0;
  color: rgba(247, 240, 222, 0.76);
  font-family: Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

.start-card label {
  display: block;
  max-width: 440px;
}

.start-card label span {
  display: block;
  margin-bottom: 8px;
  color: rgba(247, 240, 222, 0.6);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

#player-name {
  width: 100%;
  border: 1px solid rgba(247, 240, 222, 0.26);
  border-radius: 3px;
  outline: none;
  padding: 15px 16px;
  color: var(--cream);
  background: rgba(2, 11, 15, 0.64);
  font: 700 18px/1 Arial, sans-serif;
}

#player-name:focus {
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(82, 215, 232, 0.12);
}

#start-button,
#restart-button {
  width: min(440px, 100%);
  margin-top: 12px;
  border: 0;
  border-radius: 3px;
  padding: 17px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--ink);
  background: var(--aqua);
  font: 900 13px/1 Arial, sans-serif;
  letter-spacing: 0.13em;
  transition: transform 140ms ease, filter 140ms ease;
}

#start-button:hover,
#restart-button:hover {
  filter: brightness(1.12);
  transform: translateY(-2px);
}

#start-button b {
  font-size: 22px;
}

.controls {
  max-width: 440px;
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  color: rgba(247, 240, 222, 0.5);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

kbd {
  min-width: 42px;
  margin-right: 7px;
  border: 1px solid rgba(247, 240, 222, 0.24);
  border-radius: 3px;
  padding: 4px 6px;
  display: inline-block;
  color: rgba(247, 240, 222, 0.8);
  text-align: center;
  font: inherit;
}

#connection-note {
  margin-top: 18px;
  color: rgba(247, 240, 222, 0.45);
  font-size: 11px;
}

.plan-peek {
  position: absolute;
  z-index: 2;
  right: 5vw;
  bottom: 5vh;
  width: min(32vw, 440px);
  padding: 8px;
  border: 1px solid rgba(247, 240, 222, 0.18);
  background: rgba(4, 15, 20, 0.7);
  transform: rotate(-2deg);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.32);
}

.plan-peek span {
  position: absolute;
  top: -25px;
  color: rgba(247, 240, 222, 0.6);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.plan-peek img {
  width: 100%;
  display: block;
  filter: saturate(0.72) sepia(0.08);
}

.hud-top {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  min-height: 74px;
  padding: 15px 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
  background: linear-gradient(rgba(2, 11, 15, 0.72), transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.brand b {
  color: var(--aqua);
}

.brand-mark {
  font-size: 23px;
  filter: drop-shadow(0 0 7px rgba(82, 215, 232, 0.7));
}

.round {
  min-width: 112px;
  text-align: center;
}

.round span,
.score-pill span {
  display: block;
  color: rgba(247, 240, 222, 0.56);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.round strong {
  font-size: 26px;
  letter-spacing: 0.07em;
}

.score-pill {
  justify-self: end;
  min-width: 72px;
  text-align: right;
}

.score-pill strong {
  color: var(--aqua);
  font-size: 27px;
}

#crosshair {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

#crosshair i {
  position: absolute;
  top: 11px;
  left: 2px;
  width: 20px;
  height: 2px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
}

#crosshair i:last-child {
  transform: rotate(90deg);
}

#hitmarker {
  position: fixed;
  z-index: 14;
  top: 50%;
  left: 50%;
  color: white;
  font: 300 42px/1 Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(45deg) scale(1.5);
  text-shadow: 0 0 12px var(--aqua);
}

#hitmarker.pop {
  animation: hit 360ms ease-out;
}

@keyframes hit {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scale(1.7); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scale(0.8); }
}

#damage-flash {
  position: fixed;
  z-index: 8;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 120px 34px rgba(62, 219, 246, 0.8);
}

#damage-flash.flash {
  animation: damage 520ms ease-out;
}

@keyframes damage {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

#scoreboard {
  position: fixed;
  z-index: 22;
  top: 90px;
  left: 50%;
  width: min(480px, calc(100vw - 32px));
  padding: 19px;
  border: 1px solid rgba(82, 215, 232, 0.26);
  border-radius: 5px;
  background: var(--glass);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
  backdrop-filter: blur(13px);
  transition: opacity 150ms, transform 150ms;
}

#scoreboard.show {
  opacity: 1;
  transform: translateX(-50%);
}

#scoreboard h2 {
  margin: 0 0 12px;
  color: var(--aqua);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.player-row {
  padding: 8px 4px;
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  gap: 10px;
  border-top: 1px solid rgba(247, 240, 222, 0.1);
  align-items: center;
  font-size: 12px;
}

.player-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.player-row small {
  color: rgba(247, 240, 222, 0.48);
}

.player-row b {
  color: var(--aqua);
  font-size: 15px;
}

.status-bar {
  position: fixed;
  z-index: 10;
  bottom: 21px;
  left: 22px;
  display: flex;
  gap: 34px;
  align-items: end;
  pointer-events: none;
}

.water-meter {
  width: 210px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
}

.water-meter span,
.throw-state small {
  color: rgba(247, 240, 222, 0.55);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.water-meter > div {
  grid-column: 1 / -1;
  width: 100%;
  height: 7px;
  border: 1px solid rgba(247, 240, 222, 0.28);
  background: rgba(2, 11, 15, 0.55);
}

.water-meter i {
  width: 0;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, #3baac2, #7eeaff);
  box-shadow: 0 0 10px rgba(82, 215, 232, 0.45);
  transition: width 240ms ease;
}

.water-meter b {
  color: var(--aqua);
  font-size: 12px;
}

.throw-state {
  display: grid;
  grid-template-columns: 34px auto;
  align-items: center;
  gap: 0 8px;
}

#ammo-orb {
  grid-row: 1 / 3;
  width: 31px;
  height: 31px;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 58% 53% 62% 48%;
  display: block;
  background: radial-gradient(circle at 35% 28%, white 0 6%, #65e7f7 11%, #1297b3 72%);
  box-shadow: 0 0 13px rgba(82, 215, 232, 0.62);
  transition: opacity 160ms, transform 160ms;
}

.cooldown #ammo-orb {
  opacity: .25;
  transform: scale(.75);
}

.throw-state b {
  color: var(--cream);
  font-size: 11px;
  letter-spacing: .08em;
}

.minimap {
  position: fixed;
  z-index: 11;
  right: 19px;
  bottom: 18px;
  width: 190px;
  height: 122px;
  overflow: hidden;
  border: 1px solid rgba(247, 240, 222, 0.26);
  background: rgba(3, 14, 18, 0.75);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.24);
  transition: width 180ms, height 180ms;
}

.minimap.open {
  width: min(600px, calc(100vw - 38px));
  height: min(400px, calc(100vh - 120px));
}

.minimap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.68;
  filter: saturate(.6) contrast(1.08);
}

#map-player {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  margin: -4px;
  border: 2px solid white;
  border-radius: 50% 50% 50% 0;
  background: var(--aqua);
  box-shadow: 0 0 7px #032c38;
  transform: rotate(-45deg);
}

#map-toggle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  border: 0;
  padding: 5px 7px;
  cursor: pointer;
  color: var(--cream);
  background: rgba(2, 11, 15, .72);
  font: 800 8px/1 Arial, sans-serif;
  letter-spacing: .1em;
}

#room-name {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: 24px;
  color: rgba(247, 240, 222, .72);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .2em;
  pointer-events: none;
  transform: translateX(-50%);
  text-shadow: 0 2px 5px #000;
}

#toast {
  position: fixed;
  z-index: 15;
  top: 88px;
  left: 50%;
  padding: 8px 13px;
  border-radius: 2px;
  color: var(--ink);
  background: var(--aqua);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
}

#toast.show {
  animation: toast 2s ease;
}

@keyframes toast {
  0%, 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  12%, 82% { opacity: 1; transform: translateX(-50%); }
}

#touch-ui {
  display: none;
}

#round-end {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: rgba(2, 12, 16, .84);
  backdrop-filter: blur(12px);
}

#round-end p {
  color: var(--aqua);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .24em;
}

#round-end h2 {
  max-width: 600px;
  margin: 10px 20px 20px;
  font-size: clamp(28px, 5vw, 56px);
  letter-spacing: -.04em;
}

#restart-button {
  margin-inline: auto;
  justify-content: center;
}

@media (pointer: coarse), (max-width: 720px) {
  #start-screen {
    grid-template-columns: 1fr;
    padding: 25px;
  }

  .start-card {
    align-self: center;
  }

  .plan-peek {
    display: none;
  }

  h1 {
    font-size: clamp(46px, 15vw, 72px);
  }

  .intro {
    margin: 22px 0;
    font-size: 13px;
  }

  .controls {
    display: none;
  }

  .hud-top {
    padding: 12px;
  }

  .brand {
    font-size: 7px;
  }

  .brand-mark {
    display: none;
  }

  .round strong {
    font-size: 20px;
  }

  .score-pill strong {
    font-size: 22px;
  }

  .status-bar {
    left: 14px;
    bottom: 14px;
  }

  .water-meter {
    width: 145px;
  }

  .throw-state,
  .minimap,
  #room-name {
    display: none;
  }

  #touch-ui {
    position: fixed;
    z-index: 18;
    inset: 0;
    display: block;
    pointer-events: none;
  }

  #joystick {
    position: absolute;
    left: 27px;
    bottom: 76px;
    width: 104px;
    height: 104px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 50%;
    pointer-events: auto;
    background: rgba(4, 18, 24, .24);
  }

  #joystick span {
    position: absolute;
    top: 32px;
    left: 32px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(126, 234, 255, .55);
    box-shadow: 0 0 14px rgba(82, 215, 232, .5);
  }

  #touch-throw {
    position: absolute;
    right: 28px;
    bottom: 75px;
    width: 78px;
    height: 78px;
    border: 2px solid rgba(255,255,255,.5);
    border-radius: 50%;
    color: white;
    background: rgba(10, 128, 154, .62);
    font-size: 34px;
    pointer-events: auto;
  }
}
