* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent mobile browser behaviors */
html, body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background: #000;
  overflow: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  position: fixed;
  width: 100%;
  height: 100%;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  /* Support for notch/safe area on modern phones */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#camera {
  display: none; /* Video ẩn, chỉ dùng để capture */
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* UI Overlay */
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  z-index: 10;
  pointer-events: none;
}

#score {
  font-size: 72px;
  font-weight: bold;
  color: white;
  text-shadow:
    3px 3px 0 #000,
    -3px -3px 0 #000,
    3px -3px 0 #000,
    -3px 3px 0 #000;
  text-align: center;
}

/* IT Club Badge - góc trái trên */
#it-club-badge {
  position: absolute;
  top: 70px;
  left: 20px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 6px 15px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}

/* IT Club Logo trong UI overlay */
#it-club-logo {
  position: absolute;
  top: 10px;
  left: 20px;
  width: 50px;
  height: auto;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

/* IT Club Logo lớn trong các màn hình */
.it-club-logo-large {
  width: 100px;
  height: auto;
  margin-bottom: 15px;
  filter: drop-shadow(2px 2px 8px rgba(102, 126, 234, 0.5));
}

#speed-indicator {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  color: #00ff88;
  text-shadow:
    2px 2px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000;
}

#fps-counter {
  position: absolute;
  top: 50px;
  right: 20px;
  font-size: 16px;
  color: #ffff00;
  text-shadow: 2px 2px 0 #000;
}

#backend-info {
  position: absolute;
  top: 75px;
  right: 20px;
  font-size: 14px;
  color: #00ffff;
  text-shadow: 2px 2px 0 #000;
}

/* IT Club Header trong các màn hình */
.it-club-header {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 6px 25px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

/* Screens */
.screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  padding: 40px 60px;
  border-radius: 20px;
  text-align: center;
  color: white;
  z-index: 100;
  border: 3px solid #667eea;
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
}

.screen.hidden {
  display: none;
}

.screen h1 {
  font-size: 48px;
  margin-bottom: 20px;
  background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.screen p {
  font-size: 18px;
  margin: 10px 0;
  color: #ccc;
}

.screen ul {
  list-style: none;
  margin: 20px 0;
  text-align: left;
}

.screen ul li {
  font-size: 16px;
  margin: 10px 0;
  color: #fff;
}

.screen button {
  margin-top: 20px;
  padding: 15px 40px;
  font-size: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
  width: 100%;
}

.screen button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.6);
}

.screen button.quit-btn {
  background: linear-gradient(45deg, #ff6b6b, #ee5a5a);
  margin-top: 10px;
}

.screen button.quit-btn:hover {
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
}

.screen .note {
  font-size: 14px;
  color: #888;
  margin-top: 20px;
}

#final-score,
#high-score,
#victory-score {
  color: #feca57;
  font-weight: bold;
  font-size: 24px;
}

/* Victory screen special */
#victory-screen h1 {
  background: linear-gradient(45deg, #ffd700, #ffaa00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    text-shadow:
      0 0 10px #ffd700,
      0 0 20px #ffd700;
  }
  to {
    text-shadow:
      0 0 20px #ffd700,
      0 0 40px #ffaa00;
  }
}

/* Loading Animation */
.loader {
  width: 50px;
  height: 50px;
  border: 5px solid #333;
  border-top: 5px solid #667eea;
  border-radius: 50%;
  margin: 20px auto;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .screen {
    padding: 25px 20px;
    width: 92%;
    max-width: 400px;
  }

  .screen h1 {
    font-size: 28px;
    margin-bottom: 15px;
  }

  .screen p {
    font-size: 14px;
  }

  .screen ul li {
    font-size: 14px;
    margin: 8px 0;
  }

  .screen button {
    padding: 12px 25px;
    font-size: 18px;
  }

  #score {
    font-size: 42px;
  }

  #speed-indicator {
    font-size: 16px;
    top: 15px;
    right: 15px;
  }

  #fps-counter {
    font-size: 12px;
    top: 40px;
    right: 15px;
  }

  #backend-info {
    font-size: 11px;
    top: 58px;
    right: 15px;
  }

  #it-club-badge {
    font-size: 14px;
    padding: 5px 12px;
    top: 55px;
    left: 15px;
  }

  #it-club-logo {
    width: 40px;
    left: 15px;
    top: 8px;
  }

  .it-club-logo-large {
    width: 70px;
  }

  .it-club-header {
    font-size: 12px;
    padding: 4px 14px;
    letter-spacing: 2px;
  }

  #ui-overlay {
    padding: 10px;
  }

  #music-toggle {
    width: 44px;
    height: 44px;
    font-size: 20px;
    bottom: 15px;
    right: 15px;
  }

  .screen .note {
    font-size: 12px;
  }

  #final-score,
  #high-score,
  #victory-score {
    font-size: 20px;
  }
}

/* Small phones (< 480px) */
@media (max-width: 480px) {
  .screen {
    padding: 20px 15px;
    width: 95%;
    border-radius: 15px;
    border-width: 2px;
  }

  .screen h1 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  .screen p {
    font-size: 13px;
    margin: 8px 0;
  }

  .screen ul {
    margin: 15px 0;
  }

  .screen ul li {
    font-size: 13px;
    margin: 6px 0;
  }

  .screen button {
    padding: 10px 20px;
    font-size: 16px;
    margin-top: 15px;
    border-radius: 8px;
  }

  #score {
    font-size: 36px;
  }

  #it-club-badge {
    font-size: 12px;
    padding: 4px 10px;
    top: 48px;
    left: 10px;
    border-radius: 15px;
  }

  #it-club-logo {
    width: 35px;
    left: 10px;
    top: 6px;
  }

  .it-club-logo-large {
    width: 60px;
    margin-bottom: 10px;
  }

  .it-club-header {
    font-size: 11px;
    padding: 4px 12px;
    margin-bottom: 10px;
  }

  #speed-indicator {
    font-size: 14px;
    top: 10px;
    right: 10px;
  }

  #fps-counter {
    font-size: 11px;
    top: 32px;
    right: 10px;
  }

  #backend-info {
    font-size: 10px;
    top: 48px;
    right: 10px;
  }

  #ui-overlay {
    padding: 8px;
  }

  #music-toggle {
    width: 40px;
    height: 40px;
    font-size: 18px;
    bottom: 10px;
    right: 10px;
  }

  .screen .note {
    font-size: 11px;
    margin-top: 15px;
  }

  #final-score,
  #high-score,
  #victory-score {
    font-size: 18px;
  }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
  .screen {
    padding: 35px 45px;
    max-width: 500px;
  }

  .screen h1 {
    font-size: 40px;
  }

  #score {
    font-size: 60px;
  }

  #it-club-badge {
    font-size: 16px;
  }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .screen {
    padding: 15px 25px;
    max-height: 90vh;
    overflow-y: auto;
  }

  .screen h1 {
    font-size: 22px;
    margin-bottom: 8px;
  }

  .screen p {
    font-size: 12px;
    margin: 5px 0;
  }

  .screen ul {
    margin: 8px 0;
  }

  .screen ul li {
    font-size: 12px;
    margin: 4px 0;
  }

  .screen button {
    padding: 8px 20px;
    font-size: 14px;
    margin-top: 10px;
  }

  .it-club-logo-large {
    width: 50px;
    margin-bottom: 8px;
  }

  .it-club-header {
    font-size: 10px;
    padding: 3px 10px;
    margin-bottom: 8px;
  }

  #score {
    font-size: 32px;
  }

  #it-club-badge {
    font-size: 11px;
    top: 40px;
    padding: 3px 8px;
  }

  #it-club-logo {
    width: 30px;
  }

  .screen .note {
    font-size: 10px;
    margin-top: 8px;
  }

  #final-score,
  #high-score,
  #victory-score {
    font-size: 16px;
  }
}

/* Touch-friendly: larger tap targets */
@media (hover: none) and (pointer: coarse) {
  .screen button {
    min-height: 48px;
    min-width: 120px;
  }

  #music-toggle {
    min-width: 48px;
    min-height: 48px;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #score {
    text-shadow:
      2px 2px 0 #000,
      -2px -2px 0 #000,
      2px -2px 0 #000,
      -2px 2px 0 #000;
  }
}

/* Music Toggle Button */
#music-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  z-index: 100;
}

#music-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#music-toggle.muted {
  background: linear-gradient(135deg, #666 0%, #444 100%);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
