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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Courier New', monospace;
  background: #000;
  color: #fff;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#auth-bar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 100;
}

#rotate-hint {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #00ff00;
  font-family: 'Courier New', monospace;
}

.rotate-icon {
  font-size: 60px;
  margin-bottom: 20px;
  animation: rotate-anim 1.5s ease-in-out infinite;
}

@media (orientation: landscape) and (max-height: 500px) {
  #rotate-hint { display: flex !important; }
  #loading-screen, #menu-screen, #leaderboard-screen, #achievements-screen, #game-canvas { display: none !important; }
}

@keyframes rotate-anim {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}

#loading-screen, #menu-screen, #leaderboard-screen, #achievements-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 10;
}

.pixel-title {
  font-size: 32px;
  text-shadow: 4px 4px 0 #00ff00;
  margin-bottom: 40px;
  letter-spacing: 2px;
}

.pixel-button {
  background: #00ff00;
  color: #000;
  padding: 12px 40px;
  margin: 10px;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  transition: all 0.1s;
}

.pixel-button:hover {
  background: #00cc00;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #fff;
}

.pixel-button:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 #fff;
}

.daily-btn {
  background: #ff6600;
}

.daily-btn:hover {
  background: #cc5500;
}

.share-btn {
  background: #ff6600;
  margin-top: 20px;
  font-size: 14px;
  padding: 8px 24px;
}

.share-btn:hover {
  background: #cc5500;
}

.pixel-loader {
  width: 60px;
  height: 60px;
  border: 8px solid #00ff00;
  border-top: 8px solid transparent;
  border-radius: 0;
  animation: spin 1s linear infinite;
}

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

.stats-panel {
  margin-top: 30px;
  background: #111;
  border: 4px solid #00ff00;
  padding: 20px;
  min-width: 250px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;
  font-size: 16px;
}

.stat-label {
  color: #00ff00;
}

#leaderboard-list {
  width: 90%;
  max-width: 500px;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  background: #111;
  border: 4px solid #00ff00;
  padding: 10px;
  margin: 20px 0;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 10px;
  margin: 5px 0;
  background: #222;
  border: 2px solid #444;
}

.leaderboard-rank {
  font-size: 20px;
  font-weight: bold;
  color: #00ff00;
  width: 40px;
  text-align: center;
}

.leaderboard-avatar {
  width: 40px;
  height: 40px;
  border: 2px solid #00ff00;
  margin: 0 10px;
  border-radius: 50%;
  object-fit: cover;
}

.leaderboard-avatar-placeholder {
  width: 40px;
  height: 40px;
  border: 2px solid #00ff00;
  margin: 0 10px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #333;
  font-size: 16px;
  color: #00ff00;
}

.leaderboard-info {
  flex: 1;
  min-width: 0;
}

.leaderboard-name {
  font-size: 16px;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-size: 14px;
  color: #00ff00;
}

.guest-hint {
  color: #888;
  font-size: 12px;
  margin-top: 15px;
  text-align: center;
}

.settings-panel {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  justify-content: center;
}

.settings-toggle {
  background: #333;
  color: #666;
  padding: 8px 16px;
  border: 2px solid #444;
  cursor: pointer;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
}

.settings-toggle.active {
  background: #1a3a1a;
  color: #00ff00;
  border-color: #00ff00;
}

.settings-toggle:active {
  transform: scale(0.95);
}

.top-rank {
  font-size: 24px !important;
}

#game-canvas {
  width: 100%;
  height: 100%;
}

canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* Achievements */
#achievements-list {
  width: 90%;
  max-width: 500px;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  background: #111;
  border: 4px solid #00ff00;
  padding: 10px;
  margin: 20px 0;
}

.achievement-item {
  display: flex;
  align-items: center;
  padding: 10px;
  margin: 5px 0;
  background: #1a1a1a;
  border: 2px solid #333;
  opacity: 0.5;
}

.achievement-item.unlocked {
  opacity: 1;
  border-color: #ffff00;
  background: #1a1a0a;
}

.ach-icon {
  font-size: 28px;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.ach-info {
  flex: 1;
  min-width: 0;
  margin: 0 10px;
}

.ach-name {
  font-size: 14px;
  color: #fff;
  font-weight: bold;
}

.ach-desc {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.ach-check, .ach-lock {
  font-size: 20px;
  width: 30px;
  text-align: center;
  flex-shrink: 0;
}
