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

body {
  background: #000;
  overflow: hidden;
  font-family: monospace;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
}

/* Landscape mobile: compact bottom panel so it doesn't cover Anton */
@media (orientation: landscape) and (max-height: 500px) {
  #coin-panel {
    bottom: 4px;
    padding: 3px 12px;
  }
  #coin-btn {
    font-size: 11px;
    padding: 4px 14px;
  }
  #coin-progress-wrap {
    height: 14px;
    margin: 2px auto 0;
  }
  #coin-progress-text { font-size: 8px; }
  #coin-stats { margin-top: 1px; font-size: 9px; gap: 10px; }
  #coin-fine-print { display: none; }
  #achievements-btn, #forks-btn {
    font-size: 9px;
    padding: 2px 8px;
    margin-top: 1px;
  }
  #hud { padding: 4px 12px; top: 4px; }
  #timer-label { font-size: 9px; }
  #timer-value { font-size: 14px; }
  #audio-btn { width: 28px; height: 28px; font-size: 14px; }
}

/* ── Splash screen ── */
#splash {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: #000;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: splashFade 0.5s ease-out;
}
#splash-inner {
  text-align: center;
  max-width: 400px;
  padding: 20px;
}
#splash-title {
  color: #ffcc00;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 16px;
}
#splash-desc {
  color: #ccc;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
}
#splash-disclaimer {
  color: #666;
  font-size: 10px;
  line-height: 1.5;
  font-style: italic;
  margin-bottom: 24px;
}
#splash-author {
  color: #555;
  font-size: 10px;
  margin-bottom: 12px;
}
#splash-author a {
  color: #4fc3f7;
  text-decoration: none;
}
#splash-skip {
  color: #555;
  font-size: 11px;
  animation: blink 1.5s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
@keyframes splashFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

#hud {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 8px 20px;
  text-align: center;
  z-index: 10;
  image-rendering: pixelated;
}

#timer-label {
  color: #ffcc00;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#timer-value {
  color: #fff;
  font-size: 24px;
  margin-top: 4px;
  letter-spacing: 1px;
}

#coin-panel {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
}

#coin-btn {
  background: #ffcc00;
  color: #000;
  border: 3px solid #b8941a;
  padding: 8px 24px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

#coin-btn:hover { background: #ffe066; }
#coin-btn:active { transform: scale(0.95); }

#coin-progress-wrap {
  position: relative;
  width: 95vw;
  max-width: 400px;
  height: 22px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  margin: 6px auto 0;
  overflow: hidden;
}

#coin-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffcc00, #ff8800);
  transition: width 0.3s;
}

#coin-progress-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-family: monospace;
  text-shadow: 0 0 3px #000;
  white-space: nowrap;
}

#coin-fine-print {
  color: rgba(255,255,255,0.35);
  font-size: 10px;
  font-family: monospace;
  margin-top: 3px;
}

#audio-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 18px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  z-index: 10;
}

#milestone-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#milestone-popup-inner {
  background: #1a1a2e;
  border: 3px solid #ffcc00;
  padding: 20px 30px;
  text-align: center;
  max-width: 320px;
  font-family: monospace;
}

#milestone-achievement {
  color: #ffcc00;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 8px;
}

#milestone-name {
  color: #fff;
  font-size: 18px;
  margin-bottom: 6px;
}

#milestone-bonus {
  color: #4fc3f7;
  font-size: 13px;
  margin-bottom: 14px;
}

#milestone-claim {
  background: #ffcc00;
  color: #000;
  border: 2px solid #b8941a;
  padding: 8px 24px;
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

#milestone-claim:hover { background: #ffe066; }

#coin-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
  color: #4fc3f7;
  font-size: 11px;
}

#achievements-btn {
  margin-top: 4px;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.5);
  font-family: monospace;
  font-size: 10px;
  padding: 3px 12px;
  cursor: pointer;
}

#achievements-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}

#achievements-inner {
  background: #1a1a2e;
  border: 2px solid #4fc3f7;
  padding: 16px;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
  font-family: monospace;
}

#achievements-inner h3 {
  color: #ffcc00;
  text-align: center;
  margin-bottom: 10px;
}

.ach-item {
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 11px;
}

.ach-item.locked { color: #555; border-color: #333; }
.ach-item.unlocked { color: #fff; border-color: #4fc3f7; background: rgba(79,195,247,0.1); }
.ach-item .ach-name { font-weight: bold; }
.ach-item .ach-text { color: #ffcc00; font-size: 10px; }

#achievements-close {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 5px 20px;
  cursor: pointer;
  font-family: monospace;
}

#online-indicator {
  position: fixed;
  top: 12px;
  left: 12px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 4px 10px;
  z-index: 10;
  font-family: monospace;
  font-size: 11px;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 6px;
}

#online-dot {
  width: 6px;
  height: 6px;
  background: #4caf50;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Forks panel ── */
#forks-btn {
  margin-top: 2px;
  background: none;
  border: 1px solid rgba(255,204,0,0.3);
  color: rgba(255,204,0,0.6);
  font-family: monospace;
  font-size: 10px;
  padding: 3px 12px;
  cursor: pointer;
}
#forks-btn:hover { color: #ffcc00; border-color: #ffcc00; }

#forks-panel {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
}
#forks-inner {
  background: #1a1a2e;
  border: 2px solid #ffcc00;
  padding: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  font-family: monospace;
}
#forks-inner h3 {
  color: #ffcc00;
  text-align: center;
  margin-bottom: 12px;
}
.fork-row {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid #333;
  border-radius: 6px;
}
.fork-row.locked {
  opacity: 0.4;
  border-color: #222;
}
.fork-row.available {
  border-color: #ffcc00;
  cursor: pointer;
}
.fork-row.available:hover {
  background: rgba(255,204,0,0.08);
}
.fork-row.chosen {
  border-color: #4fc3f7;
  background: rgba(79,195,247,0.08);
}
.fork-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.fork-row-name {
  color: #ffcc00;
  font-weight: bold;
  font-size: 13px;
}
.fork-row-threshold {
  color: #888;
  font-size: 11px;
}
.fork-row-status {
  font-size: 11px;
  color: #aaa;
}
.fork-row-chosen-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: #4fc3f7;
}
.fork-reset-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #c44;
  color: #c44;
  font-family: monospace;
  font-size: 10px;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 3px;
}
.fork-reset-btn:hover { background: rgba(204,68,68,0.15); }

#forks-close {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 5px 20px;
  cursor: pointer;
  font-family: monospace;
}

/* ── Upgrade popup ── */
#upgrade-popup {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); display: flex; align-items: center;
  justify-content: center; z-index: 200;
}
#upgrade-popup-inner {
  background: #1a1a2e; border: 3px solid #ffcc00; border-radius: 12px;
  padding: 24px; max-width: 700px; width: 90%; font-family: monospace;
}
#upgrade-title {
  text-align: center; color: #ffcc00; font-size: 18px; font-weight: bold;
  margin-bottom: 4px;
}
#upgrade-subtitle {
  text-align: center; color: #aaa; font-size: 13px; margin-bottom: 16px;
}
#upgrade-options {
  display: flex; gap: 12px;
}
.upgrade-card {
  flex: 1; background: #0d0d1a; border: 2px solid #555; border-radius: 8px;
  padding: 14px; cursor: pointer; transition: border-color 0.2s;
}
.upgrade-card:hover { border-color: #ffcc00; }
.upgrade-card-emoji { text-align: center; font-size: 24px; margin-bottom: 8px; }
.upgrade-card-name { color: #ffcc00; font-weight: bold; text-align: center; font-size: 13px; }
.upgrade-card-desc { color: #ccc; font-size: 11px; margin-top: 8px; line-height: 1.4; }
.upgrade-card-stats { margin-top: 10px; padding-top: 8px; border-top: 1px solid #333; }
.upgrade-card-stats div { font-size: 11px; }
.upgrade-stat-bonus { color: #4fc3f7; }
.upgrade-stat-costume { color: #a78bfa; }
.upgrade-stat-world { color: #4ade80; }
#upgrade-footer {
  text-align: center; margin-top: 16px; color: #666; font-size: 11px;
}

/* ── Event banner ── */
#event-banner {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  background: rgba(20, 10, 0, 0.9); border: 2px solid #ffcc00;
  border-top: none; border-radius: 0 0 12px 12px;
  padding: 8px 20px; z-index: 150; text-align: center;
  animation: slideDown 0.3s ease-out;
  max-width: 90%;
}
@keyframes slideDown { from { transform: translateX(-50%) translateY(-100%); } to { transform: translateX(-50%) translateY(0); } }
@keyframes slideUp { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-100%); } }
#event-text { color: #ffcc00; font-size: 13px; font-family: monospace; font-weight: bold; }
#event-progress-bar { height: 3px; background: #333; margin-top: 6px; border-radius: 2px; }
#event-progress-fill { height: 100%; background: #ffcc00; border-radius: 2px; transition: width 0.1s linear; }

@media (max-width: 600px) {
  #timer-value { font-size: 16px; }
  #timer-label { font-size: 10px; }
  #coin-btn { font-size: 12px; padding: 6px 16px; }
  #upgrade-options { flex-direction: column; }
}

/* ── Portrait: zoomed canvas on top, UI panel at bottom ── */
@media (max-aspect-ratio: 4/3) {
  body { overflow: hidden; }

  /* Canvas fills space above panel, maintaining 16:9 ratio.
     Width overflows viewport — sides are clipped naturally.
     Camera follows Anton so important stuff is always centered. */
  #game {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: calc(100vh - 140px);
    width: calc((100vh - 140px) * 1.778);
    min-width: 100vw;
  }

  #hud {
    top: 4px;
    padding: 4px 10px;
  }
  #timer-label { font-size: 9px; letter-spacing: 1px; }
  #timer-value { font-size: 13px; margin-top: 1px; }

  #online-indicator {
    top: 4px;
    left: 4px;
    padding: 2px 6px;
    font-size: 9px;
  }

  #audio-btn {
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  #coin-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    background: rgba(0, 0, 0, 0.95);
    padding: 6px 16px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-top: 2px solid rgba(255,204,0,0.3);
  }

  #coin-btn {
    font-size: 13px;
    padding: 8px 16px;
    width: 100%;
  }

  #coin-progress-wrap {
    max-width: 100%;
    width: 100%;
    margin: 4px 0 0;
    height: 18px;
  }

  #coin-stats { margin-top: 3px; font-size: 10px; }
  #coin-fine-print { margin-top: 1px; font-size: 9px; }

  #achievements-btn, #forks-btn {
    display: inline-block;
    margin-top: 3px;
    font-size: 10px;
    padding: 3px 12px;
  }

  /* Event banner */
  #event-banner {
    top: 0;
    transform: translateX(-50%);
  }

  /* Upgrade popup: scroll-friendly */
  #upgrade-options { flex-direction: column; }
  #upgrade-popup-inner { max-height: 80vh; overflow-y: auto; }
}
