* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: "Outfit", "Vazirmatn", sans-serif;
}

body {
  overscroll-behavior: none;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #000;
  cursor: default;
  touch-action: none;
}

#scoreboard {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 128px;
  justify-content: center;
  padding: 6px 18px;
  direction: ltr;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 0 22px rgba(0, 166, 255, 0.22);
  transform: translateX(-50%);
}

.score {
  min-width: 34px;
  text-align: center;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.score-p1 {
  color: #ff1515;
  text-shadow: 0 0 16px rgba(255, 21, 21, 0.85);
}

.score-p2 {
  color: #16ff00;
  text-shadow: 0 0 16px rgba(22, 255, 0, 0.85);
}

.score-divider {
  color: rgba(255, 255, 255, 0.6);
  font-size: 24px;
  font-weight: 900;
}

.side-controls {
  position: fixed;
  top: 50%;
  right: max(18px, env(safe-area-inset-right));
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: translateY(-50%);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.56);
  color: #fff;
  font-family: "Outfit", sans-serif;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0 8px #00a6ff, 0 0 16px rgba(0, 166, 255, 0.95);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  direction: rtl;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.overlay-content {
  max-width: min(440px, 92vw);
  text-align: center;
}

.overlay-content h1 {
  margin-bottom: 12px;
  font-size: 36px;
  font-weight: 900;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.overlay-content p {
  margin-bottom: 18px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  font-weight: 700;
}

.controls-info {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 13px;
  line-height: 1.7;
}

#win-overlay {
  pointer-events: auto;
}

.btn-restart {
  min-width: 150px;
  padding: 13px 24px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: #ff1515;
  color: #fff;
  box-shadow: 0 0 18px rgba(255, 21, 21, 0.9);
  cursor: pointer;
  font-family: "Outfit", "Vazirmatn", sans-serif;
  font-size: 16px;
  font-weight: 900;
}

.online-panel {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  width: min(260px, calc(100vw - 32px));
  padding: 10px;
  direction: rtl;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(0, 166, 255, 0.42);
  border-radius: 8px;
  box-shadow: 0 0 18px rgba(0, 166, 255, 0.28);
}

.online-status {
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.6;
}

.online-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.online-button {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 7px;
  background: rgba(0, 166, 255, 0.18);
  color: #fff;
  cursor: pointer;
  font-family: "Outfit", "Vazirmatn", sans-serif;
  font-size: 12px;
  font-weight: 900;
}

.online-button.accept {
  background: rgba(22, 255, 0, 0.2);
  box-shadow: 0 0 12px rgba(22, 255, 0, 0.35);
}

.online-button.decline {
  background: rgba(255, 21, 21, 0.2);
  box-shadow: 0 0 12px rgba(255, 21, 21, 0.28);
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  #scoreboard {
    top: max(10px, env(safe-area-inset-top));
    gap: 12px;
    min-width: 104px;
    padding: 5px 14px;
  }

  .score {
    min-width: 28px;
    font-size: 25px;
  }

  .side-controls {
    right: max(8px, env(safe-area-inset-right));
    gap: 14px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    font-size: 19px;
  }

  .online-panel {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(230px, calc(100vw - 16px));
    padding: 8px;
  }

  .online-status,
  .online-button {
    font-size: 11px;
  }

  .overlay-content h1 {
    font-size: 30px;
  }
}
