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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-family: 'Segoe UI', Arial, sans-serif;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#touch-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  touch-action: none;
}

/* ---------- Top HUD ---------- */
#hud {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  color: #ffffff;
  background: rgba(0, 0, 0, 0.55);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

#score {
  position: fixed;
  top: 20px;
  right: 70px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.55);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  z-index: 10;
  pointer-events: none;
}

#coin-counter {
  position: fixed;
  top: 20px;
  left: 16px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.55);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  z-index: 10;
  pointer-events: none;
  transform-origin: left center;
}

#coin-counter.pop {
  animation: coinPop 0.15s ease-out;
}

@keyframes coinPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

#pause-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 20px;
  border: none;
  z-index: 11;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pause-btn.hidden {
  display: none;
}

/* ---------- Power-up HUD ---------- */
#powerup-hud {
  position: fixed;
  top: 80px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.powerup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 10px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  min-width: 110px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.powerup-icon { font-size: 20px; line-height: 1; }

.powerup-bar-outer {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.powerup-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ffcb6b, #ff9d3a);
  transition: width 0.1s linear;
}

.powerup-item.shield { border: 1px solid rgba(80, 180, 255, 0.8); }
.powerup-item.magnet { border: 1px solid rgba(255, 200, 60, 0.8); }
.powerup-item.speed  { border: 1px solid rgba(255, 100, 100, 0.8); }
.powerup-item.double { border: 1px solid rgba(120, 220, 120, 0.8); }

/* ---------- Debug ---------- */
#debug {
  display: none;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
  padding: 24px;
  text-align: center;
  background: rgba(20, 12, 5, 0.85);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.overlay.hidden {
  display: none !important;
}

@keyframes overlayFadeOut {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.03); }
}

.overlay.fade-out {
  animation: overlayFadeOut 0.5s ease-out forwards;
  pointer-events: none;
}

#loading-screen {
  background: linear-gradient(160deg, #2a1408 0%, #4a1e08 35%, #7a2e0a 70%, #2a1408 100%);
  background-size: 400% 400%;
  animation: sunsetShift 12s ease-in-out infinite;
}

@keyframes sunsetShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.loading-sun {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #ffe17a, #ff9d3a 45%, #d96c14 75%, transparent 78%);
  box-shadow:
    0 0 60px rgba(255, 157, 58, 0.7),
    0 0 120px rgba(255, 100, 0, 0.4);
  margin-bottom: 12px;
  animation: sunPulse 3s ease-in-out infinite;
}

@keyframes sunPulse {
  0%   { transform: scale(1);    filter: brightness(1); }
  50%  { transform: scale(1.06); filter: brightness(1.15); }
  100% { transform: scale(1);    filter: brightness(1); }
}

.overlay h1 {
  color: #ffcb6b;
  font-size: 36px;
  letter-spacing: 3px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
  margin-bottom: 8px;
}

.title {
  color: #ffb03a !important;
  font-size: 56px !important;
  line-height: 0.95;
  letter-spacing: 4px;
  font-weight: 900;
  text-shadow:
    0 0 40px rgba(255, 140, 40, 0.55),
    0 0 80px rgba(255, 90, 0, 0.35),
    0 4px 0 #5a2a00,
    0 6px 16px rgba(0,0,0,0.6);
  margin-bottom: 12px;
  animation: titleGlow 4s ease-in-out infinite;
}

@keyframes titleGlow {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.12); }
  100% { filter: brightness(1); }
}

.title-sub {
  display: inline-block;
  font-size: 0.72em;
  letter-spacing: 8px;
  color: #ffcb6b;
}

.game-over-title {
  color: #ff3355 !important;
  text-shadow:
    0 0 40px rgba(255, 51, 85, 0.6),
    0 4px 0 #4a0000,
    0 6px 16px rgba(0,0,0,0.6);
}

.menu-best {
  color: #fff5dd;
  font-size: 18px;
  margin: 6px 0 18px;
  letter-spacing: 1px;
}

.overlay p {
  color: #ffffff;
  font-size: 20px;
  font-weight: bold;
}

.loading-tagline {
  color: #ffffff !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  letter-spacing: 1.5px;
  opacity: 1;
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(255, 180, 80, 0.7), 0 2px 6px rgba(0, 0, 0, 0.9);
}

.loading-bar-outer {
  position: relative;
  width: 280px;
  height: 22px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 12px;
  overflow: hidden;
  margin: 20px 0 8px;
  border: 2px solid rgba(255, 203, 107, 0.55);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,0.6),
    0 0 20px rgba(255, 157, 58, 0.3);
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff7a1a, #ff9d3a, #ffcb6b);
  transition: width 0.2s ease-out;
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(255, 157, 58, 0.8);
  position: relative;
  z-index: 2;
}

.loading-bar-shimmer {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.35) 50%, transparent 100%);
  animation: shimmerSlide 2.4s ease-in-out infinite;
  z-index: 3;
  pointer-events: none;
  border-radius: 10px;
}

@keyframes shimmerSlide {
  0%   { left: -100%; }
  60%  { left: 100%; }
  100% { left: 100%; }
}

.loading-text {
  color: #fff5dd;
  font-size: 15px;
  font-weight: normal;
  margin-top: 4px;
  letter-spacing: 1px;
}

.loading-credit {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 5;
}

.loading-credit-line {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 203, 107, 0.6), transparent);
}

.developed-credit {
  color: #ffdca8;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 180, 80, 0.5), 0 2px 6px rgba(0, 0, 0, 0.95);
  opacity: 1;
}

/* ---------- Character Selection ---------- */
.character-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 12px 0;
  max-width: 500px;
  width: 100%;
}

.character-card {
  width: 130px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  user-select: none;
}

.character-card.selected {
  background: rgba(255, 203, 107, 0.15);
  border-color: #ffcb6b;
  box-shadow: 0 0 20px rgba(255, 203, 107, 0.5);
  transform: scale(1.05);
}

.character-portrait {
  width: 80px;
  height: 80px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.character-name {
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}

.character-tagline {
  color: #ffcb6b;
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

/* ---------- Buttons ---------- */
.big-btn {
  padding: 18px 56px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #ff9d3a, #d96c14);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  box-shadow: 0 6px 0 #7a3a00, 0 10px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.big-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #7a3a00, 0 4px 12px rgba(0, 0, 0, 0.4);
}

.big-btn:disabled {
  filter: grayscale(0.5) brightness(0.6);
  cursor: not-allowed;
}

.small-btn {
  padding: 12px 32px;
  font-size: 16px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.12);
  color: #ffcb6b;
  border: 2px solid #ffcb6b;
  border-radius: 12px;
  cursor: pointer;
  margin: 4px 0;
}

.small-btn:active {
  transform: translateY(2px);
  background: rgba(255, 203, 107, 0.25);
}

/* ---------- Settings rows ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 280px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  color: #ffffff;
  font-size: 17px;
  font-weight: bold;
}

.toggle-btn {
  padding: 8px 20px;
  font-size: 15px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #2fcc5f;
  color: #ffffff;
  min-width: 70px;
}

.toggle-btn.off {
  background: #555;
  color: #bbb;
}


/* ---------- Missions Screen ---------- */
.missions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  max-width: 90vw;
  margin: 12px 0;
}

.mission-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 203, 107, 0.35);
  border-radius: 12px;
  text-align: left;
}

.mission-card.completed {
  background: rgba(46, 204, 100, 0.15);
  border-color: #2ecc71;
}

.mission-card .mission-title {
  color: #ffffff;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.mission-card .mission-desc {
  color: #ffcb6b;
  font-size: 12px;
  font-weight: normal;
  opacity: 0.9;
}

.mission-card .mission-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.mission-card .mission-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff9d3a, #ffcb6b);
  border-radius: 4px;
  transition: width 0.2s ease-out;
}

.mission-card .mission-progress-text {
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  opacity: 0.85;
  text-align: right;
}

.career-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 320px;
  max-width: 90vw;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  margin: 12px 0;
}

.career-stats .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
}

.career-stats .stat-row .stat-value {
  color: #ffcb6b;
}

/* ---------- Mission Complete Popup ---------- */
#mission-popup {
  position: fixed;
  top: 6%;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 10px 16px;
  background: linear-gradient(180deg, #ff9d3a, #d96c14);
  color: #ffffff;
  border-radius: 10px;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 16px rgba(255, 157, 58, 0.6);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  white-space: nowrap;
  max-width: 78vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

#mission-popup.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

#mission-popup .popup-small {
  display: block;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1.5px;
  margin-bottom: 2px;
  line-height: 1.1;
  opacity: 0.95;
}

#mission-popup .popup-big {
  display: block;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
}

@media (max-height: 900px) {
  #mission-popup {
    top: 5%;
    padding: 8px 14px;
    font-size: 13px;
    max-width: 72vw;
  }
  #mission-popup .popup-small {
    font-size: 9px;
  }
  #mission-popup .popup-big {
    font-size: 14px;
  }
}

/* ---------- PWA install banner ---------- */
#install-banner {
  position: fixed;
  bottom: 56px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(20, 12, 5, 0.95);
  border: 2px solid #ffcb6b;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(255, 157, 58, 0.4);
  z-index: 30;
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.35s ease-out, opacity 0.35s ease-out;
  font-family: 'Segoe UI', Arial, sans-serif;
}

#install-banner.hidden {
  transform: translateY(140%);
  opacity: 0;
  pointer-events: none;
}

#install-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 203, 107, 0.4);
}

#install-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
  color: #ffffff;
}

#install-banner-text strong {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #ffcb6b;
}

#install-banner-text span {
  font-size: 11px;
  font-weight: normal;
  color: #fff5dd;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#install-banner-yes {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #ff9d3a, #d96c14);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 0 #7a3a00;
}

#install-banner-yes:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #7a3a00;
}

#install-banner-no {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: bold;
  background: transparent;
  color: #ffcb6b;
  border: 1px solid rgba(255, 203, 107, 0.5);
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

#install-banner-no:active {
  background: rgba(255, 203, 107, 0.15);
}

/* ---------- iOS instruction popup ---------- */
#install-ios-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
  font-family: 'Segoe UI', Arial, sans-serif;
}

#install-ios-popup.hidden {
  display: none;
}

#install-ios-popup .ios-card {
  background: #1a1208;
  border: 2px solid #ffcb6b;
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 340px;
  color: #fff5dd;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

#install-ios-popup h3 {
  color: #ffcb6b;
  font-size: 18px;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

#install-ios-popup ol {
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  padding-left: 20px;
  margin-bottom: 16px;
  color: #fff5dd;
}

#install-ios-popup button {
  padding: 10px 24px;
  background: linear-gradient(180deg, #ff9d3a, #d96c14);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}
  
