* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background-color: #b0e0ff;
  transition: background-color 3s ease;
  font-family: 'Courier New', monospace;
}

.page-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 32px 20px;
  width: 100%;
  max-width: 980px;
}

.shell {
  width: 440px;
  max-width: 100%;
  background: #ff3fa4;
  border: 6px solid #1a1a1a;
  border-radius: 28px;
  padding: 18px 20px 26px;
  box-shadow:
    0 0 0 5px #ffb3dd inset,
    8px 8px 0 #1a1a1a;
  position: relative;
}

.title {
  text-align: center;
  color: #1a1a1a;
  font-weight: bold;
  letter-spacing: 3px;
  font-size: 20px;
  text-shadow: 2px 2px 0 #fff59a;
  margin-bottom: 12px;
}

.screen {
  background: #9bbc0f;
  border: 5px solid #1a1a1a;
  border-radius: 10px;
  box-shadow: inset 0 0 0 4px #4d6a06, inset 0 0 22px rgba(0,0,0,0.35);
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.top-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: #1a1a1a;
  font-weight: bold;
  margin-bottom: 8px;
}

.pet-stage {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pet-canvas {
  width: 148px;
  height: 148px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(3px 3px 0 rgba(0,0,0,0.2));
}

.pet-canvas.is-dead {
  filter: drop-shadow(3px 3px 0 rgba(0,0,0,0.2)) grayscale(1);
}

.bonus-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 11px;
  font-weight: bold;
  background: rgba(255,255,255,0.9);
  color: #1a1a1a;
  padding: 3px 8px;
  border-radius: 10px;
  border: 2px solid #1a1a1a;
  animation: pulse 1.2s ease-in-out infinite;
}

.anim-idle { animation: pulse 2.4s ease-in-out infinite; }
.anim-happy { animation: bounce 0.6s ease-in-out infinite; }
.anim-sad { animation: shake 1.6s ease-in-out infinite; }
.anim-sick { animation: flicker 1s steps(2) infinite; }
.anim-sleep { animation: dim 3s ease-in-out infinite; }
.anim-egg { animation: wobble 1.8s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.05); }
}
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes dim {
  0%, 100% { opacity: 0.85; transform: translateY(0); }
  50% { opacity: 0.55; transform: translateY(4px); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.event-banner {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translate(-50%, -6px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: bold;
  max-width: 92%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 6;
}
.event-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bars {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #1a1a1a;
  font-weight: bold;
}

.bar-label { width: 70px; flex-shrink: 0; }

.bar-track {
  flex: 1;
  height: 12px;
  background: #4d6a06;
  border: 2px solid #1a1a1a;
  position: relative;
}

.bar-fill {
  height: 100%;
  transition: width 0.4s ease;
}

.buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.btn {
  background: #ffe45c;
  border: 3px solid #1a1a1a;
  border-radius: 10px;
  box-shadow: 3px 3px 0 #1a1a1a;
  padding: 14px 5px;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  color: #1a1a1a;
  cursor: pointer;
  user-select: none;
  transition: transform 0.05s;
}
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 #1a1a1a;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-feed { background: #ffb347; }
.btn-pet { background: #ff9ec4; }
.btn-play { background: #7dd3fc; }
.btn-sleep { background: #a78bfa; }
.btn-heal { background: #86efac; }
.btn-speed { background: #fbbf24; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #fff;
  text-align: center;
  padding: 16px;
  z-index: 5;
}
.overlay.show { display: flex; }

.overlay h2 {
  font-size: 26px;
  margin: 0 0 10px;
  color: #ff5c5c;
  text-shadow: 2px 2px 0 #000;
}

.overlay p { font-size: 13px; margin: 6px 0; }

.overlay button {
  margin-top: 14px;
  background: #9bbc0f;
  border: 3px solid #fff;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
}

.mini-game-title { font-size: 16px; }

.mini-game-result { min-height: 20px; font-size: 14px; }

.cancel-btn {
  background: #555 !important;
  color: #fff;
}

.game-numbers {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.game-numbers button {
  min-width: 84px;
  height: 44px;
  font-size: 14px;
  margin-top: 0;
}

.side-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-panel {
  width: 235px;
  max-width: 100%;
  background: #fff8e6;
  border: 4px solid #1a1a1a;
  border-radius: 14px;
  padding: 14px 16px;
  position: relative;
  box-shadow: 5px 5px 0 rgba(0,0,0,0.25);
  color: #1a1a1a;
}

.side-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.panel-handle.draggable-handle {
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.panel-handle.draggable-handle.dragging {
  cursor: grabbing;
}

.side-panel ul {
  margin: 0;
  padding-left: 16px;
  font-size: 11.5px;
  line-height: 1.55;
  list-style: none;
}

.side-panel li { margin-bottom: 7px; }

#rulesPanel ul { list-style: disc; padding-left: 18px; }

.gallery-hint {
  font-size: 11px;
  margin: 0 0 8px;
  color: #555;
}

.gallery-canvas {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 5px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#speciesList li {
  display: flex;
  align-items: center;
  padding: 3px 6px;
  border-radius: 6px;
}

#speciesList li.unknown {
  color: #999;
  letter-spacing: 2px;
}

#speciesList li.current-species {
  background: #ffe45c;
  font-weight: bold;
  border: 2px solid #1a1a1a;
}

#galleryPanel.all-discovered {
  background: linear-gradient(160deg, #fff6d0, #ffd76a);
  border-color: #a8760a;
  box-shadow: 5px 5px 0 rgba(168,118,10,0.35), 0 0 18px rgba(255,215,0,0.6);
}

#galleryPanel.all-discovered h2 {
  color: #8a5c00;
}

.side-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #1a1a1a;
}
.side-close:hover { color: #e53935; }

.reopen-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reopen-btn {
  background: #ffe45c;
  border: 3px solid #1a1a1a;
  border-radius: 10px;
  box-shadow: 3px 3px 0 #1a1a1a;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
}

.hidden { display: none !important; }

@media (max-width: 860px) {
  .page-wrap { flex-direction: column; align-items: center; }
  .side-panels { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .side-panel { width: 440px; }
  .reopen-row { flex-direction: row; }
}
