@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --ink: #f7f7f5;
  --muted: #8c8c86;
  --cyan: #64f4ff;
  --pink: #ff5baf;
  --black: #0a0a0a;
  --panel-black: #101010;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--black);
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: "Press Start 2P", "Courier New", monospace;
  color: var(--ink);
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  cursor: none;
}

#hud {
  position: fixed;
  inset: 0 0 auto;
  z-index: 4;
  height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: start;
  gap: 6px;
  padding: 14px 12px;
  pointer-events: none;
}

.brand {
  text-align: left;
}
.brand .title {
  font-size: clamp(10px, 1.35vw, 18px);
  letter-spacing: 1px;
}
.brand .sub {
  margin-top: 9px;
  font-size: 8px;
  color: var(--muted);
}

.score-wrap {
  text-align: center;
}
.score-label {
  color: var(--muted);
  font-size: 8px;
  margin-bottom: 8px;
}
#score {
  font-size: clamp(22px, 4vw, 48px);
  line-height: 1;
  text-shadow: 0 0 16px rgba(100, 244, 255, 0.22);
}

.stats {
  text-align: right;
  font-size: 8px;
  line-height: 2.1;
  color: var(--muted);
}
.stats b {
  color: var(--ink);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.76);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
}

.panel {
  width: min(560px, calc(100vw - 36px));
  border: 3px solid var(--ink);
  background: var(--panel-black);
  box-shadow: 10px 10px 0 rgba(100, 244, 255, 0.16);
  padding: 34px 28px 28px;
  text-align: center;
}
.panel h1 {
  margin: 0 0 18px;
  font-size: clamp(24px, 6vw, 52px);
  color: var(--cyan);
  text-shadow: 4px 4px 0 #17384a;
}
.panel h1.loss {
  color: var(--pink);
  text-shadow: 4px 4px 0 #5d183f;
}
.panel p {
  margin: 10px 0 24px;
  color: #b7b7af;
  font-size: 10px;
  line-height: 1.9;
}

.retro-button {
  border: 3px solid var(--ink);
  background: var(--ink);
  color: var(--black);
  font:
    10px "Press Start 2P",
    "Courier New",
    monospace;
  padding: 16px 18px;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--cyan);
}
.retro-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--cyan);
}
.retro-button.secondary {
  margin-left: 12px;
  background: transparent;
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--pink);
}

.pause-button {
  pointer-events: auto;
  border: 2px solid var(--ink);
  background: rgba(10, 10, 10, 0.82);
  color: var(--ink);
  font:
    8px "Press Start 2P",
    "Courier New",
    monospace;
  min-height: 36px;
  padding: 8px 10px;
  cursor: pointer;
  max-width: 72px;
  font-size: 6px;
}
.pause-button:focus-visible,
.retro-button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.checkpoint-toast {
  position: fixed;
  z-index: 8;
  top: 112px;
  left: 50%;
  transform: translate(-50%, -10px);
  max-width: calc(100vw - 24px);
  border: 2px solid var(--cyan);
  background: rgba(10, 10, 10, 0.92);
  padding: 12px 14px;
  color: var(--cyan);
  font-size: 9px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: 180ms ease;
  pointer-events: none;
}
.checkpoint-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.resume-button {
  display: none;
}
.resume-button.show {
  display: inline-block;
}

.start-hint {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  color: #a7a7a1;
  font-size: 8px;
  white-space: nowrap;
  pointer-events: none;
}

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.92);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease;
}
.onboarding.show {
  opacity: 1;
  visibility: visible;
}
.onboarding-panel {
  width: min(560px, calc(100vw - 28px));
  border: 3px solid var(--ink);
  background: var(--panel-black);
  box-shadow: 10px 10px 0 rgba(100, 244, 255, 0.16);
  padding: 30px 24px 24px;
  text-align: center;
}
.onboarding-kicker {
  color: var(--cyan);
  font-size: 8px;
  margin-bottom: 16px;
}
.onboarding-panel h1 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: clamp(18px, 5vw, 34px);
  line-height: 1.35;
}
.onboarding-panel p {
  margin: 0 auto 18px;
  max-width: 470px;
  color: #b7b7af;
  font-size: 9px;
  line-height: 1.9;
}
.onboarding-button {
  min-width: 210px;
}
.arrow-demo {
  display: none;
  position: relative;
  height: 150px;
  width: min(410px, 100%);
  margin: 4px auto 16px;
  border: 2px solid rgba(247, 247, 245, 0.18);
  overflow: hidden;
}
.arrow-demo.show {
  display: block;
}
.demo-paddle {
  position: absolute;
  right: 18px;
  top: 55px;
  width: 12px;
  height: 70px;
  background: var(--pink);
  animation: paddle-demo 2.2s ease-in-out infinite;
}
.demo-ball {
  position: absolute;
  left: 26px;
  top: 68px;
  width: 8px;
  height: 8px;
  background: var(--ink);
  animation: ball-demo 2.2s ease-in-out infinite;
}
.demo-arrows {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  gap: 20px;
  transform: translate(-50%, -50%);
  color: var(--cyan);
  font-size: 28px;
}
.demo-arrows span {
  text-shadow: 0 0 12px rgba(100, 244, 255, 0.7);
  animation: arrow-pulse 1.1s ease-in-out infinite alternate;
}
.demo-arrows span:last-child {
  animation-delay: 1.1s;
}
@keyframes paddle-demo {
  0%,
  100% {
    transform: translateY(24px);
  }
  50% {
    transform: translateY(-24px);
  }
}
@keyframes ball-demo {
  0%,
  100% {
    transform: translate(0, 28px);
  }
  50% {
    transform: translate(300px, -28px);
  }
}
@keyframes arrow-pulse {
  from {
    opacity: 0.35;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1.12);
  }
}

.mode-gate,
.lobby {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.94);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease;
}
.mode-gate.show,
.lobby.show {
  opacity: 1;
  visibility: visible;
}
.mode-panel,
.lobby-panel {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  border: 3px solid var(--ink);
  background: var(--panel-black);
  box-shadow: 10px 10px 0 rgba(100, 244, 255, 0.16);
  padding: 30px 24px 24px;
  text-align: center;
}
.mode-panel h1,
.lobby-panel h1 {
  margin: 10px 0 16px;
  color: var(--cyan);
  font-size: clamp(22px, 5vw, 38px);
}
.mode-panel p {
  color: #b7b7af;
  font-size: 9px;
  line-height: 1.9;
}
.mode-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}
.mode-actions .retro-button.secondary {
  margin: 0;
}
.lobby-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  text-align: left;
}
.field-label,
.room-list-header {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 8px;
  text-align: left;
}
.lobby-input {
  width: 100%;
  border: 2px solid var(--ink);
  background: #080808;
  color: var(--ink);
  font:
    10px "Press Start 2P",
    "Courier New",
    monospace;
  padding: 14px;
  outline: none;
}
.lobby-input:focus {
  border-color: var(--cyan);
}
.room-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: 12px;
}
.room-controls .retro-button.secondary {
  margin: 0;
}
.side-picker {
  display: none;
}
.side-button,
.small-button {
  border: 2px solid var(--ink);
  background: #080808;
  color: var(--ink);
  font:
    9px "Press Start 2P",
    "Courier New",
    monospace;
  min-height: 42px;
  cursor: pointer;
}
.side-button.selected {
  border-color: var(--cyan);
  background: var(--cyan);
  color: var(--black);
  box-shadow: 4px 4px 0 #17384a;
}
.small-button {
  min-height: 36px;
  padding: 8px 10px;
}
.lobby-status {
  min-height: 34px;
  margin-top: 14px;
  color: var(--cyan);
  font-size: 8px;
  line-height: 1.8;
  text-align: left;
}
.start-match-button {
  width: 100%;
  margin: 10px 0 0;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.invite-button {
  width: 100%;
  margin: 8px 0 0;
  display: none;
}
.invite-button.show {
  display: block;
}
.room-list {
  display: grid;
  gap: 8px;
}
.room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 2px solid #3a3a36;
  padding: 8px;
  font-size: 8px;
}
.room-row button {
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--black);
  font:
    7px "Press Start 2P",
    "Courier New",
    monospace;
  padding: 8px;
  cursor: pointer;
}
.leave-button {
  display: none;
  width: 100%;
  margin-top: 12px;
}
.leave-button.show {
  display: block;
}

@media (max-width: 600px) {
  #hud {
    height: 72px;
    padding: 14px 12px;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 6px;
  }
  .brand .sub,
  .stats {
    font-size: 6px;
  }
  .score-label {
    font-size: 6px;
  }
  .start-hint {
    bottom: 14px;
    font-size: 6px;
  }
  .panel {
    padding: 26px 16px 22px;
  }
  .retro-button {
    width: 100%;
    margin: 8px 0 !important;
  }
  .onboarding-panel {
    padding: 24px 14px 18px;
  }
  .onboarding-panel p {
    font-size: 8px;
  }
  .onboarding-button {
    width: 100%;
  }
}
