/* Section layout */
.game-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-section.hidden {
  display: none !important;
}

.section-tag {
  margin: 0 0 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  color: #333;
  text-align: center;
}

body.pixel-mode .section-tag {
  color: #1a1a1a;
}

.section-power.is-swooshing-out,
.section-power.is-swooshing-out .power-pipe,
.section-power.is-swooshing-out .flow-node,
.system-power-panel.is-swooshing-out {
  animation: swoosh-away 0.75s cubic-bezier(0.4, 0, 0.85, 0.2) forwards;
  pointer-events: none;
}

.section-power.is-swooshing-out .levels-stack > * {
  animation: swoosh-away 0.7s cubic-bezier(0.4, 0, 0.85, 0.2) forwards;
}

.section-power.is-swooshing-out .levels-stack > *:nth-child(2) {
  animation-delay: 0.05s;
}
.section-power.is-swooshing-out .levels-stack > *:nth-child(4) {
  animation-delay: 0.1s;
}
.section-power.is-swooshing-out .levels-stack > *:nth-child(6) {
  animation-delay: 0.15s;
}
.section-power.is-swooshing-out .levels-stack > *:nth-child(8) {
  animation-delay: 0.2s;
}

@keyframes swoosh-away {
  0% {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateX(110vw) rotate(18deg);
  }
}

.section-shapes .pixel-game,
.section-click .pixel-game {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.section-shapes.hidden,
.section-click.hidden,
.section-chat.hidden {
  display: none !important;
}

.section-shapes:not(.hidden) {
  display: flex;
}

.section-click:not(.hidden),
.section-chat:not(.hidden) {
  display: flex;
}

/* Section 2 — Mom chat (always visible when section is shown) */
.section-chat .pixel-game,
.section-chat .section-chat-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.section-chat-panel {
  width: 320px;
  max-width: calc(100vw - 32px);
}

.chat-body {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  max-height: min(420px, 70vh);
  padding: 12px 10px 14px;
  background: #ece5dd;
  border-bottom: 2px solid #1a1a1a;
}

.chat-thread {
  flex: 1;
  min-height: 180px;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 10px;
  scroll-behavior: smooth;
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-row--mom {
  align-self: flex-start;
}

.chat-row--mom .chat-sender {
  color: #007aff;
}

.chat-row--you {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-row.is-popping {
  opacity: 0;
  transform: scale(0.7) translateY(18px);
  animation: chat-pop 0.45s cubic-bezier(0.2, 0.95, 0.35, 1.1) forwards;
}

@keyframes chat-pop {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(18px);
  }
  60% {
    opacity: 1;
    transform: scale(1.03) translateY(-3px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.chat-sender {
  margin: 0 6px 4px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  color: #5c4a3a;
}

.chat-row--you .chat-sender {
  color: #4a4a4a;
}

.chat-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.82rem;
  line-height: 1.35;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

.chat-bubble--mom {
  background: #007aff;
  color: #fff;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.35);
}

.chat-bubble--you {
  background: #e5e5ea;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}

.chat-prompt {
  margin: 8px 0 0;
  padding: 10px 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #d93025;
  text-align: center;
  background: #fff5f5;
  border-radius: 8px;
  border: 2px solid #d93025;
}

.gate-sub--error {
  color: #d93025 !important;
  font-weight: 700 !important;
}

.chat-prompt.hidden {
  display: none !important;
}

.chat-replies {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-replies.hidden {
  display: none !important;
}

.chat-reply-btn {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.78rem;
  color: #1a1a1a;
  background: #e5e5ea;
  border: 2px solid #1a1a1a;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 2px 2px 0 #1a1a1a;
  transition: transform 0.08s ease, background 0.12s ease;
}

.chat-reply-btn:hover:not(:disabled) {
  background: #d8d8de;
}

.chat-reply-btn:active:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1a1a;
}

.chat-reply-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.section-chat-panel.is-slide-exit {
  animation: slide-out-right 0.45s cubic-bezier(0.45, 0, 0.75, 0.2) forwards;
  pointer-events: none;
}

.section-chat-panel.is-slide-enter {
  animation: slide-in-left 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

/* Section 3 — click challenge */
.section-click-panel {
  width: 320px;
}

.click-challenge-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 24px;
  background: #c8c8c8;
  border-bottom: 2px solid #1a1a1a;
}

.shape-carousel-viewport,
.click-carousel-viewport {
  position: relative;
  width: 100%;
  min-height: 140px;
  overflow: hidden;
}

.shape-slide-inner,
.click-round-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.shape-slide-inner.is-slide-exit,
.click-round-panel.is-slide-exit,
.level-sun.is-slide-exit,
.section-click-panel.is-slide-exit {
  animation: slide-out-right 0.45s cubic-bezier(0.45, 0, 0.75, 0.2) forwards;
  pointer-events: none;
}

.shape-slide-inner.is-slide-enter,
.click-round-panel.is-slide-enter,
.level-sun.is-slide-enter,
.section-click-panel.is-slide-enter {
  animation: slide-in-left 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

@keyframes slide-out-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(115%);
  }
}

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-115%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.click-object-mount {
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  line-height: 0;
}

.click-object-mount svg {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.3));
}

.click-next-btn {
  margin-top: 14px;
  width: 100%;
  max-width: 200px;
}

.pixel-btn-next {
  flex: 1;
  max-width: 160px;
  margin-left: auto;
  padding: 10px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  color: #fff;
  background: #4285f4;
  box-shadow: 2px 2px 0 #1a1a1a;
  border: 2px solid #1a1a1a;
  cursor: pointer;
}

.pixel-btn-next:hover {
  background: #5a95f5;
}

.pixel-btn-next:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1a1a;
}

.pixel-btn-next.hidden {
  display: none !important;
}

.pixel-click-btn {
  position: relative;
  width: 80px;
  height: 80px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.pixel-click-btn .click-sprite-wrap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  pointer-events: none;
  line-height: 0;
}

.pixel-click-btn .click-sprite-wrap svg {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, 0.35));
}

.pixel-click-btn .click-sprite-down.hidden,
.pixel-click-btn .click-sprite-up.hidden {
  display: none;
}

/* Pixel-art mode (active after Section 1) */

body.pixel-mode {
  color: #1a1a1a;
}

body.pixel-mode .gate-title,
body.pixel-mode .gate-sub {
  display: none;
}

body.pixel-mode .gate {
  max-width: 360px;
}

body.pixel-mode .system-power-panel {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  border-radius: 0;
  box-shadow: 2px 2px 0 #404040;
  font-family: "Press Start 2P", monospace;
}

body.pixel-mode .system-power-panel .progress-label,
body.pixel-mode .system-power-rate {
  font-size: 0.5rem;
  line-height: 1.5;
}

body.pixel-mode .system-power-panel .progress-percent {
  font-size: 0.55rem;
}

body.pixel-mode .pixel-stage-panel {
  border: 2px solid #1a1a1a;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
}

body.pixel-mode .pixel-badge {
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  color: #1a1a1a !important;
  text-shadow: none;
  letter-spacing: 0;
}

body.pixel-mode .pixel-hint {
  font-family: "Press Start 2P", monospace;
  font-size: 0.45rem;
  line-height: 1.6;
  color: #333;
}

/* Level 2 — sun rotation puzzle */
.pixel-game {
  width: 320px;
  padding: 0;
  background: #c8c8c8;
  border: 2px solid #1a1a1a;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-120%);
  transition:
    opacity 0.45s ease,
    transform 0.55s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.pixel-game.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.pixel-level-header {
  margin: 0;
  padding: 14px 12px;
  background: #4285f4;
  border-bottom: 2px solid #1a1a1a;
  text-align: center;
}

.pixel-header-line {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  line-height: 1.7;
  color: #fff;
  text-shadow: 1px 1px 0 #1a1a1a;
}

.pixel-header-line--bold {
  font-size: 0.58rem;
}

.pixel-playfield {
  position: relative;
  min-height: 220px;
  padding: 12px 10px 16px;
  background: #c8c8c8;
  border-bottom: 2px solid #1a1a1a;
}

.pixel-sun-sprite,
.pixel-art-mount {
  display: block;
  margin: 0 auto 10px;
  width: 64px;
  height: 64px;
  line-height: 0;
  pointer-events: none;
}

.pixel-art-mount svg,
.pixel-art-canvas svg {
  display: block;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.28));
}

.pixel-shapes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 14px 18px;
  min-height: 140px;
  padding: 8px 4px;
}

.pixel-shape-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.pixel-shape-btn:hover {
  filter: brightness(1.06);
}

.pixel-shape-btn:active {
  transform: scale(0.94) !important;
}

.pixel-shape-btn .pixel-sprite,
.pixel-shape-btn .pixel-art-mount {
  width: 64px;
  height: 64px;
  pointer-events: none;
}

.pixel-shape-btn .pixel-art-mount svg {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.35));
}

.pixel-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 12px;
  background: #c8c8c8;
  gap: 8px;
}

.pixel-btn {
  font-family: "Press Start 2P", monospace;
  cursor: pointer;
  border: 2px solid #1a1a1a;
}

.pixel-btn-reset {
  width: 40px;
  height: 40px;
  padding: 0;
  background: #fff;
  box-shadow: 2px 2px 0 #1a1a1a;
}

.pixel-reset-icon {
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto;
  border: 3px solid #555;
  border-top-color: transparent;
  border-radius: 50%;
}

.pixel-btn-verify {
  flex: 1;
  max-width: 140px;
  margin-left: auto;
  padding: 10px 12px;
  font-size: 0.55rem;
  color: #fff;
  background: #4285f4;
  box-shadow: 2px 2px 0 #1a1a1a;
}

.pixel-btn-verify:hover {
  background: #5a95f5;
}

.pixel-btn-verify:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1a1a;
}

.pixel-feedback {
  margin: 0;
  padding: 8px 12px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.45rem;
  line-height: 1.6;
  text-align: center;
  color: #c43030;
}

.pixel-game.is-shake {
  animation: pixel-shake 0.4s ease;
}

@keyframes pixel-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.pixel-game.is-shake.is-visible {
  animation: pixel-shake-visible 0.4s ease;
}

@keyframes pixel-shake-visible {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.level-sun.is-done .pixel-playfield {
  opacity: 0.65;
}

/* Later levels slide in (pixel mode) */
body.pixel-mode .pixel-stage-panel {
  transform: translateX(120%);
}

body.pixel-mode .pixel-stage-panel.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

body.pixel-mode .level-wheel.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
