:root {
  --ink: #111315;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(20, 22, 24, 0.16);
  --hot: #ff3f39;
  --cool: #1f9dff;
  --gold: #ffc72c;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #202629;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

#game-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#home-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(16, 28, 30, 0.58), rgba(16, 28, 30, 0.42)),
    radial-gradient(circle at 50% 36%, rgba(255, 199, 44, 0.34), transparent 32%),
    rgba(17, 24, 25, 0.62);
  color: #ffffff;
  pointer-events: auto;
  z-index: 40;
  transition: opacity 180ms ease, transform 180ms ease;
}

body.game-started #home-screen {
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

#home-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  width: min(430px, calc(100vw - 48px));
  padding: 28px 24px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(18, 28, 31, 0.78);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
  text-align: center;
}

#home-kicker,
#home-rules {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

#home-kicker {
  font-size: 0.76rem;
  text-transform: uppercase;
}

#home-screen h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(3rem, 11vw, 5.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

#home-rules {
  max-width: 320px;
  font-size: 0.94rem;
  line-height: 1.35;
}

#start-button {
  width: min(240px, 100%);
  height: 58px;
  border: 0;
  border-radius: 8px;
  background: #ff3f39;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 950;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.25), inset 0 -5px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

#start-button:active {
  transform: translateY(3px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22), inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

body.looking #game-canvas {
  cursor: grabbing;
}

#hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, max-content));
  gap: 8px;
  pointer-events: none;
}

#hud > div {
  display: grid;
  gap: 2px;
  min-width: 74px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
}

.label {
  color: rgba(17, 19, 21, 0.62);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

#hud strong {
  font-size: 1rem;
  line-height: 1.12;
}

#toast {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  max-width: min(300px, calc(100vw - 28px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
  color: rgba(17, 19, 21, 0.78);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.22;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

#toast.quiet {
  opacity: 0;
  transform: translateY(-8px);
}

#mobile-controls {
  position: absolute;
  inset: auto max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 12;
}

#joystick {
  position: relative;
  width: 122px;
  height: 122px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(17, 19, 21, 0.36);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 16px 28px rgba(0, 0, 0, 0.22);
  pointer-events: auto;
  touch-action: none;
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #ffffff;
  border: 3px solid var(--cool);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  transform: translate(-50%, -50%);
}

#action-buttons {
  display: grid;
  gap: 12px;
  pointer-events: auto;
}

#jump-button,
#camera-button {
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 900;
  line-height: 1;
  pointer-events: auto;
  touch-action: none;
}

#jump-button {
  width: 92px;
  height: 92px;
  background: var(--cool);
  font-size: 1rem;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22), inset 0 -7px 0 rgba(0, 0, 0, 0.16);
}

#camera-button {
  justify-self: end;
  width: 70px;
  height: 70px;
  background: #273236;
  border: 2px solid rgba(255, 255, 255, 0.56);
  font-size: 0.86rem;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22), inset 0 -7px 0 rgba(0, 0, 0, 0.16);
}

#jump-button:active,
#jump-button.pressed,
#camera-button:active,
#camera-button.pressed {
  transform: translateY(4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

body.player-it #role-readout {
  color: var(--hot);
}

body.player-runner #role-readout {
  color: #12774d;
}

body.player-hunter #role-readout {
  color: var(--hot);
}

@media (hover: none), (pointer: coarse), (max-width: 760px) {
  #hud {
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #hud > div {
    min-width: 0;
    padding: 8px 9px;
  }

  #hud strong {
    font-size: 0.92rem;
  }

  #toast {
    top: auto;
    right: 50%;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 136px);
    transform: translateX(50%);
    text-align: center;
  }

  #toast.quiet {
    transform: translate(50%, 8px);
  }
}

@media (max-width: 430px) {
  #joystick {
    width: 104px;
    height: 104px;
  }

  #joystick-knob {
    width: 46px;
    height: 46px;
  }

  #jump-button {
    width: 78px;
    height: 78px;
  }

  #action-buttons {
    gap: 10px;
  }
}
