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

:root {
  --page-bg: radial-gradient(ellipse at 50% 10%, #dceefb 0%, #c4e4f8 55%, #a8d4f0 100%);
}

body {
  background: var(--page-bg);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  font-family: "Press Start 2P", monospace;
  color: #a5d6a7;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0 24px;
}

.navbar {
  display: flex;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 12px 16px;
  background: rgba(210, 235, 250, 0.85);
  border-bottom: 2px solid rgba(140, 190, 230, 0.45);
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-link {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.8;
  padding: 12px 16px;
  cursor: pointer;
  color: #e8f6ff;
  background: #7ab4dc;
  border: 3px solid #5a90b8;
  border-radius: 0;
  box-shadow: 3px 3px 0 rgba(90, 140, 180, 0.25);
}

.nav-link:first-child {
  border-radius: 6px 0 0 6px;
}

.nav-link + .nav-link {
  margin-left: -3px;
}

.nav-link:last-child {
  border-radius: 0 6px 6px 0;
}

.nav-link:hover {
  background: #94c8ec;
  color: #ffffff;
}

.nav-link.active {
  background: #68a8d4;
  color: #ffffff;
  box-shadow:
    0 0 0 2px #d0ecff inset,
    3px 3px 0 rgba(90, 140, 180, 0.25);
}

.nav-link.locked {
  background: #5a88a8;
  color: #b8d4e8;
  cursor: not-allowed;
  opacity: 0.72;
  box-shadow: none;
}

.nav-link.locked:hover {
  background: #5a88a8;
  color: #b8d4e8;
}

.nav-link.locked::after {
  content: " · LOCKED";
  font-size: 6px;
  letter-spacing: 0.04em;
}

.app {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 0;
}

.tab-panel[hidden] {
  display: none !important;
}

.tab-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#game-root {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#ui {
  text-align: center;
  padding: 14px 16px 10px;
  z-index: 1;
  width: 100%;
  max-width: 360px;
}

#ui h1 {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #1a4060;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.35);
}

.controls {
  font-size: 0.45rem;
  line-height: 1.8;
  opacity: 1;
  margin-top: 8px;
  color: #285878;
}

#status {
  font-size: 0.5rem;
  line-height: 1.8;
  margin-top: 10px;
  min-height: 1.6em;
  color: #5a3818;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid #1a3050;
  border-radius: 2px;
  box-shadow:
    0 0 0 2px #0f2038,
    0 12px 40px rgba(15, 32, 56, 0.45);
  background: #1e3a58;
  margin-top: 8px;
}

body.section-money {
  padding-bottom: 0;
  min-height: auto;
}

body.section-money .tab-panel {
  padding-bottom: 0;
}

body.section-money #ui {
  padding-bottom: 6px;
}

body.section-money #game {
  margin-bottom: 0;
  box-shadow:
    0 0 0 2px #0f2038,
    0 0 24px rgba(0, 0, 0, 0.3);
}

body.game-paused::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 6, 0.55);
  z-index: 15;
  pointer-events: none;
}

#coin-balloon {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(92vw, 440px);
  animation: balloon-pop 0.28s ease-out;
}

#coin-balloon[hidden] {
  display: none !important;
}

.coin-balloon-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #eef8ff;
  color: #102840;
  border: 3px solid #285880;
  border-radius: 10px;
  padding: 20px 18px 12px;
  box-shadow:
    0 0 0 2px #ffffff inset,
    4px 4px 0 rgba(16, 40, 64, 0.28);
}

.coin-balloon-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.8em;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(42, 36, 24, 0.15);
}

.coin-balloon-header[hidden] {
  display: none !important;
}

.coin-balloon-title {
  margin: 0;
  width: 100%;
  font-size: 0.68rem;
  line-height: 1.7;
  text-align: center;
  color: #1a2818;
}

#coin-balloon-text {
  width: 100%;
  font-size: 0.58rem;
  line-height: 1.85;
  text-align: center;
  margin: 0;
  padding-top: 4px;
}

.coin-balloon-hint {
  font-size: 0.45rem;
  line-height: 1.7;
  text-align: center;
  margin-top: 12px;
  color: #6a5a40;
  opacity: 0.85;
}

@keyframes balloon-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

#victory-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 24, 48, 0.82);
  overflow-y: auto;
}

#victory-screen[hidden] {
  display: none !important;
}

.victory-panel {
  width: min(96vw, 520px);
  max-height: min(92vh, 720px);
  overflow-y: auto;
  background: linear-gradient(180deg, #eef8ff 0%, #d8ecfa 100%);
  color: #102840;
  border: 3px solid #285880;
  border-radius: 12px;
  padding: 20px 18px 16px;
  box-shadow:
    0 0 0 2px #b8dcf8 inset,
    6px 6px 0 rgba(16, 40, 64, 0.28);
  animation: balloon-pop 0.35s ease-out;
}

.achievement-badge {
  margin: 0 auto 16px;
  padding: 14px 12px;
  text-align: center;
  background: linear-gradient(180deg, #e8f6ff 0%, #c8e4f8 100%);
  border: 3px solid #285880;
  border-radius: 10px;
  box-shadow: 0 0 0 2px #ffffff inset;
}

.achievement-badge.perfect {
  background: linear-gradient(180deg, #dff0ff 0%, #9ec8ec 55%, #68a8d4 100%);
  animation: achievement-glow 1.6s ease-in-out infinite alternate;
}

.achievement-label {
  font-size: 0.38rem;
  line-height: 1.7;
  color: #4878a0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.achievement-name {
  font-size: 0.58rem;
  line-height: 1.8;
  margin-top: 6px;
  color: #102840;
}

.achievement-detail {
  font-size: 0.4rem;
  line-height: 1.7;
  margin-top: 8px;
  color: #385878;
}

.victory-next {
  margin-bottom: 14px;
}

.victory-next-label {
  font-size: 0.42rem;
  line-height: 1.8;
  text-align: center;
  color: #285880;
  margin-bottom: 8px;
}

.victory-next-card {
  padding: 12px 12px 10px;
  border-radius: 8px;
  border: 2px solid #4888b0;
  background: #f4faff;
}

.victory-next-card.unlocked {
  background: linear-gradient(180deg, #f8fcff 0%, #d0e8f8 100%);
  border-color: #3880b0;
  box-shadow: 0 0 0 2px #ffffff inset;
}

.victory-next-card.locked {
  background: #dce8f2;
  border-color: #6888a0;
  border-style: dashed;
  opacity: 0.88;
}

.victory-next-title {
  font-size: 0.52rem;
  line-height: 1.8;
  color: #102840;
  text-align: center;
}

.victory-next-desc {
  font-size: 0.4rem;
  line-height: 1.75;
  color: #385878;
  margin-top: 8px;
  text-align: center;
}

.victory-next-status {
  font-size: 0.38rem;
  line-height: 1.7;
  margin-top: 8px;
  text-align: center;
  color: #4878a0;
}

.victory-next-card.locked .victory-next-status {
  color: #6888a0;
}

.victory-intro {
  font-size: 0.42rem;
  line-height: 1.85;
  text-align: center;
  color: #385878;
  margin: 0 0 12px;
  padding: 0 4px;
}

.victory-timeline {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.victory-timeline li {
  padding: 10px 10px 9px;
  margin-bottom: 6px;
  border: 2px solid #4888b0;
  border-radius: 6px;
  background: #f0f8ff;
}

.victory-timeline li.collected {
  background: linear-gradient(180deg, #f8fcff 0%, #e0f0fc 100%);
  border-color: #3880b0;
}

.victory-timeline li.missed {
  opacity: 0.82;
}

.victory-timeline li.locked {
  background: #d8e4f0;
  border-color: #6888a0;
  border-style: dashed;
}

.timeline-headline {
  font-size: 0.44rem;
  line-height: 1.75;
  color: #102840;
  margin: 0;
}

.timeline-body {
  font-size: 0.38rem;
  line-height: 1.75;
  color: #385878;
  margin: 6px 0 0;
}

.victory-timeline li.locked .timeline-headline {
  color: #6888a0;
  text-align: center;
  letter-spacing: 0.08em;
}

.victory-timeline li.locked .timeline-body {
  text-align: center;
  color: #6888a0;
}

.victory-replay {
  display: block;
  width: 100%;
  font-family: "Press Start 2P", monospace;
  font-size: 0.42rem;
  line-height: 1.8;
  padding: 12px 10px;
  cursor: pointer;
  color: #f0f8ff;
  background: #3880b0;
  border: 3px solid #285880;
  border-radius: 8px;
  box-shadow: 3px 3px 0 rgba(16, 40, 64, 0.28);
  margin-bottom: 8px;
}

.victory-replay-secondary {
  background: #6898b8;
  margin-bottom: 0;
}

.victory-replay:hover {
  background: #4898c8;
}

.victory-replay-secondary:hover {
  background: #78a8c8;
}

.victory-replay:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(16, 40, 64, 0.28);
}

@keyframes achievement-glow {
  from {
    box-shadow: 0 0 0 2px #ffffff inset, 0 0 8px rgba(104, 168, 212, 0.35);
  }
  to {
    box-shadow: 0 0 0 2px #e8f6ff inset, 0 0 16px rgba(104, 168, 212, 0.65);
  }
}
