* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #07070f;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(74,222,128,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(34,211,238,0.10) 0%, transparent 60%);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  touch-action: manipulation;
}

/* === Shared === */
.screen {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background-color: #07070f;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(74,222,128,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(34,211,238,0.10) 0%, transparent 60%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 3vh, 24px);
  padding: 16px;
  overflow: hidden;
  position: relative;
}
.screen.active { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.screen-gear-btn {
  position: absolute;
  top: 16px;
  right: 12px;
  background: none;
  border: none;
  color: #eef2ff;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px;
  line-height: 1;
}
.screen-gear-btn:hover { opacity: 1; }

/* === Start screen === */
.start-preview {
  opacity: 0.4;
}
.start-preview canvas {
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(74,222,128,0.4), 0 0 14px rgba(74,222,128,0.25);
}
.logo {
  font-family: 'Inter', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  color: #4ade80;
  background: linear-gradient(100deg, #4ade80, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 14px rgba(74,222,128,0.45));
  letter-spacing: 2px;
}
.logo-sub {
  font-size: 1rem;
  color: rgba(238,242,255,0.6);
  margin-top: -16px;
}
.highscore-display {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  color: rgba(238,242,255,0.5);
  letter-spacing: 1px;
  min-height: 1.2em;
}
.start-play-btn {
  padding: 16px 64px;
  border: 2px solid #4ade80;
  border-radius: 40px;
  background: rgba(13,16,33,0.7);
  color: #eef2ff;
  font-family: 'Inter', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 14px rgba(74,222,128,0.3);
}
.start-play-btn:hover {
  background: rgba(74,222,128,0.15);
  box-shadow: 0 0 22px rgba(74,222,128,0.5);
  transform: translateY(-2px);
}
.start-play-btn:active { transform: translateY(0); box-shadow: 0 0 26px rgba(74,222,128,0.6); }
.back-btn {
  background: none;
  border: none;
  color: rgba(238,242,255,0.5);
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 4px;
  text-decoration: none;
  display: block;
}
.back-btn:hover { color: rgba(238,242,255,0.8); }

/* === Game screen === */
#screen-game {
  justify-content: flex-start;
  gap: 0;
  padding: 0;
  background: #07070f;
}
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid rgba(74,222,128,0.35);
  box-shadow: 0 0 18px rgba(74,222,128,0.25);
}
.hud {
  position: absolute;
  top: 12px;
  left: 16px;
  display: flex;
  gap: 20px;
  z-index: 10;
  pointer-events: none;
}
.hud-distance {
  font-family: 'Inter', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: rgba(238,242,255,0.92);
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 12px rgba(74,222,128,0.35);
}
.hud-coins {
  font-family: 'Inter', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fde047;
  letter-spacing: 1px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 12px rgba(253,224,71,0.4);
}
.hud-coins::before {
  content: '●';
  margin-right: 4px;
  font-size: 0.9rem;
}
.hud-powerup {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  background: rgba(13,16,33,0.7);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
}
.gear-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #eef2ff;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px;
  line-height: 1;
  z-index: 10;
}
.gear-btn:hover { opacity: 1; }

/* === Pause overlay === */
.pause-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2,4,12,0.7);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.pause-overlay.open { display: flex; }
.pause-menu {
  background: rgba(13,16,33,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 24px rgba(74,222,128,0.12);
}
.pause-menu-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: #eef2ff;
  text-align: center;
  margin-bottom: 8px;
}
.pause-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #eef2ff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  text-align: left;
}
.pause-item:hover { background: rgba(255,255,255,0.14); }
.pause-item .p-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.pause-item.danger { color: #fb7185; }
.pause-item.danger:hover { background: rgba(251,113,133,0.15); }
.pause-divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 4px 0;
}

/* === Confirm dialog === */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2,4,12,0.7);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: rgba(13,16,33,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px;
  width: 280px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 24px rgba(74,222,128,0.12);
}
.confirm-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: #eef2ff;
  margin-bottom: 20px;
  line-height: 1.6;
}
.confirm-actions { display: flex; gap: 12px; }
.confirm-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.confirm-yes {
  background: rgba(13,16,33,0.7);
  color: #fb7185;
  box-shadow: inset 0 0 0 2px #fb7185, 0 0 14px rgba(251,113,133,0.3);
}
.confirm-yes:hover {
  background: rgba(251,113,133,0.15);
  box-shadow: inset 0 0 0 2px #fb7185, 0 0 22px rgba(251,113,133,0.5);
}
.confirm-no { background: rgba(255,255,255,0.08); color: #eef2ff; }
.confirm-no:hover { background: rgba(255,255,255,0.14); }

/* === Result screen === */
.result-icon { font-size: clamp(2.5rem, 8vh, 4rem); }
.result-text {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  color: #eef2ff;
  text-align: center;
  text-shadow: 0 0 14px rgba(74,222,128,0.35);
}
.result-stats {
  display: flex;
  gap: 24px;
}
.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.result-stat-label {
  font-size: 0.75rem;
  color: rgba(238,242,255,0.5);
  font-weight: 600;
}
.result-stat-value {
  font-family: 'Inter', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: #eef2ff;
}
.result-coin-value { color: #fde047; text-shadow: 0 0 12px rgba(253,224,71,0.4); }
.result-record {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251,191,36,0.45);
  min-height: 1.2em;
  animation: recordPulse 1s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.level-section {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 280px;
}
.level-section.visible { display: flex; }
.result-xp {
  font-family: 'Inter', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: #4ade80;
  text-shadow: 0 0 12px rgba(74,222,128,0.45);
  letter-spacing: 1px;
}
.result-xp.penalty { color: #fb7185; text-shadow: 0 0 12px rgba(251,113,133,0.45); }
.result-bonus {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fbbf24;
}
.level-display {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.level-label {
  font-size: 0.85rem;
  color: rgba(238,242,255,0.6);
  font-weight: 600;
  letter-spacing: 2px;
}
.level-num {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 800;
  color: #eef2ff;
}
.level-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}
.level-bar {
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #4ade80);
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(74,222,128,0.5);
  transition: width 0.5s ease;
}
.level-info {
  font-size: 0.8rem;
  color: rgba(238,242,255,0.5);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
}
.result-btn {
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.result-btn:hover { transform: translateY(-2px); }
.result-btn:active { transform: translateY(0); }
.result-btn-continue {
  background: rgba(13,16,33,0.7);
  color: #eef2ff;
  border: none;
  box-shadow: inset 0 0 0 2px #4ade80, 0 0 14px rgba(74,222,128,0.3);
}
.result-btn-continue:hover {
  background: rgba(74,222,128,0.15);
  box-shadow: inset 0 0 0 2px #4ade80, 0 0 22px rgba(74,222,128,0.5);
}
.result-btn-quit {
  background: transparent;
  color: rgba(238,242,255,0.7);
  border: 2px solid rgba(255,255,255,0.3);
  text-decoration: none;
}
.result-btn-quit:hover {
  border-color: rgba(34,211,238,0.6);
  color: #eef2ff;
  box-shadow: 0 0 14px rgba(34,211,238,0.3);
}

/* === Info overlays (Rules / About) === */
.info-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2,4,12,0.7);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.info-overlay.open { display: flex; }
.info-box {
  background: rgba(13,16,33,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px;
  width: 300px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 24px rgba(74,222,128,0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.info-title {
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: #eef2ff;
  text-align: center;
}
.info-body {
  font-size: 0.88rem;
  color: rgba(238,242,255,0.8);
  line-height: 1.7;
}
.info-body p { margin-bottom: 12px; }
.info-section-title {
  font-weight: 700;
  color: #eef2ff;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.info-card-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
}
.info-card-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.info-card-row strong { color: #eef2ff; }
.info-note {
  font-size: 0.8rem;
  color: rgba(238,242,255,0.5);
  margin-top: 4px;
  margin-bottom: 0;
}
.info-close-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #eef2ff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.info-close-btn:hover { background: rgba(255,255,255,0.14); }

.info-about {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.about-name {
  font-family: 'Inter', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: #4ade80;
  background: linear-gradient(100deg, #4ade80, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 14px rgba(74,222,128,0.45));
}
.about-version { font-size: 0.85rem; color: rgba(238,242,255,0.5); }
.about-creator { font-size: 0.9rem; color: rgba(238,242,255,0.7); margin-top: 8px; }
.about-copy { font-size: 0.75rem; color: rgba(238,242,255,0.4); margin-top: 4px; }

/* === Equipment HUD (in-game) === */
.hud-equipment {
  font-size: 0.75rem;
  color: rgba(238,242,255,0.55);
  font-weight: 600;
  display: flex;
  gap: 10px;
}
.hud-equipment:empty { display: none; }
.hud-equip-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.hud-equip-item .equip-bonus {
  color: #fde047;
  font-size: 0.68rem;
}

/* === Equipment HUD (start screen) === */
.equipment-hud {
  display: flex;
  gap: 12px;
  justify-content: center;
  min-height: 1.2em;
  font-size: 0.78rem;
  color: rgba(238,242,255,0.55);
  font-weight: 600;
}
.equipment-hud:empty { display: none; }
.equip-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
}
.equip-item .equip-bonus {
  color: #fde047;
  font-size: 0.72rem;
}

/* === Economy detail on result screen === */
.economy-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 1em;
}
.economy-detail .eco-line {
  display: flex;
  align-items: center;
  gap: 4px;
}
.economy-detail .eco-coins {
  color: #fde047;
}
.economy-detail .eco-bonus {
  color: #4ade80;
  font-size: 0.78rem;
}
.economy-detail .eco-penalty {
  color: #fb7185;
}
.economy-detail .eco-armor {
  color: rgba(238,242,255,0.5);
  font-size: 0.75rem;
}
.economy-detail .eco-durability {
  color: rgba(238,242,255,0.45);
  font-size: 0.75rem;
}
