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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #000;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#ui-layer > * { pointer-events: auto; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.overlay.centered { align-items: center; }

.popup {
  background: #ffffff;
  color: #111;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  max-width: 560px;
  width: 100%;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 22px;
  position: relative;
  animation: slideUp 220ms ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.popup h2 {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.4;
  color: #c01810;
  margin-bottom: 2px;
}
.popup .years {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: #555;
  margin-bottom: 12px;
}
.popup h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}
.popup ul { padding-left: 18px; }
.popup ul li { margin: 6px 0; line-height: 1.4; }
.popup .close {
  position: sticky;
  top: 0;
  float: right;
  margin: -8px -12px 0 0;
  background: #000;
  color: #fff;
  border: none;
  width: 28px; height: 28px;
  cursor: pointer;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  z-index: 2;
}

#timeline {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 44px;
  display: flex;
  background: #000;
  border-bottom: 2px solid #fff;
  z-index: 20;
}
.tl-seg {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border-right: 1px solid rgba(255,255,255,0.3);
  padding: 0 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter 120ms;
}
.tl-seg:last-child { border-right: none; }
.tl-seg:hover { filter: brightness(1.3); }
.tl-arrow {
  position: absolute;
  top: 44px;
  width: 14px;
  height: 10px;
  background: #ffd966;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  transition: left 80ms linear;
  pointer-events: none;
  z-index: 21;
}

.corner-btn {
  position: absolute;
  top: 60px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #000;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 2px 2px 0 #000;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
}
.corner-btn:hover { transform: scale(1.05); }
.corner-btn.skills { right: 16px; }
.corner-btn.contact { left: 16px; }

.skills-panel {
  background: #fff;
  color: #111;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  width: 100%;
  max-width: 420px;
  padding: 20px;
  align-self: flex-start;
  margin-top: 80px;
  margin-right: 16px;
  animation: slideLeft 220ms ease-out;
}
.overlay.right-align { align-items: flex-start; justify-content: flex-end; }
@keyframes slideLeft {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.skills-panel h2 {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 14px;
  margin-bottom: 14px;
}
.skill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 2px solid #ccc;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 120ms;
}
.skill-row.checked { border-color: #000; background: #fffbe0; }
.skill-row.disabled { opacity: 0.5; cursor: default; }
.skill-row .icon { font-size: 22px; width: 30px; text-align: center; }
.skill-row .label { flex: 1; }
.skill-row .label .name { font-weight: 700; }
.skill-row .label .desc { font-size: 12px; color: #555; }
.skill-row .chk {
  width: 20px; height: 20px;
  border: 2px solid #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.banner {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 22px;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 14px;
  border: 2px solid #fff;
  z-index: 15;
  opacity: 0;
  transition: opacity 320ms;
  pointer-events: none;
}
.banner.show { opacity: 1; }

.end-card {
  background: #000;
  color: #fff;
  border: 4px solid #fff;
  padding: 32px;
  max-width: 520px;
  text-align: center;
}
.end-card h1 {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 22px;
  margin-bottom: 18px;
}
.end-card p { margin-bottom: 22px; line-height: 1.5; }
.end-card .contact-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.end-card .contact-links a {
  background: #fff;
  color: #000;
  padding: 12px;
  text-decoration: none;
  font-weight: 700;
  border: 2px solid #fff;
}
.end-card .contact-links a:hover { background: #ffd966; }
.end-card .play-again {
  background: transparent;
  border: 2px solid #fff;
  color: #fff;
  padding: 10px 20px;
  cursor: pointer;
  font-family: inherit;
}

#mobile-controls {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
  left: 16px;
  right: 16px;
  display: none;
  justify-content: space-between;
  pointer-events: none;
  z-index: 30;
}
@media (pointer: coarse), (max-width: 768px) {
  #mobile-controls { display: flex; }
}
.mc-group { display: flex; gap: 12px; pointer-events: auto; }
.mc-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: 3px solid #fff;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  touch-action: none;
  user-select: none;
}
.mc-btn:active { background: rgba(255, 217, 102, 0.6); }
