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

html,
body {
  min-height: 100%;
  background:
    radial-gradient(ellipse at 50% -10%, #6b3a1f 0%, transparent 42%),
    radial-gradient(ellipse at 10% 80%, #3d2463 0%, transparent 40%),
    radial-gradient(ellipse at 90% 70%, #1d3a4a 0%, transparent 38%),
    #120c14;
  color: #fff8ef;
  font-family: 'Press Start 2P', monospace;
}

body {
  padding: 24px 16px 48px;
}

.hidden {
  display: none !important;
}

.home-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 30;
  font-size: 8px;
  color: #e9c46a;
  text-decoration: none;
  padding: 8px 10px;
  border: 2px solid #e9c46a;
  background: rgba(18, 12, 20, 0.88);
}

.home-link:hover {
  color: #fff;
  background: #3d2914;
}

.screen {
  max-width: 560px;
  margin: 56px auto 0;
  text-align: center;
}

.kicker {
  font-size: 8px;
  letter-spacing: 3px;
  color: #e9c46a;
  margin-bottom: 14px;
}

h1,
h2 {
  font-size: 18px;
  line-height: 1.5;
  margin-bottom: 14px;
  text-shadow: 3px 3px 0 #000;
}

h2 {
  font-size: 13px;
}

.lead,
.hint,
.save-line,
.heard,
.tiny,
.speech,
.name-label,
.stat span {
  font-size: 8px;
  line-height: 1.8;
}

.lead {
  color: #d4b896;
  margin-bottom: 20px;
}

.save-line {
  color: #ffd166;
  margin-bottom: 16px;
}

.hint {
  color: #cbb79a;
  margin: 14px 0 10px;
}

.hint.warn {
  color: #ff8fab;
}

.tiny {
  color: #8d7a66;
  margin-top: 10px;
}

.instrument-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.chip {
  font: inherit;
  font-size: 7px;
  color: #fff8ef;
  background: #1a120c;
  border: 2px solid #e9c46a;
  padding: 8px 10px;
  cursor: pointer;
}

.chip.on,
.chip:hover {
  background: #e9c46a;
  color: #1a120c;
}

#record-btn,
#serenade-btn,
#adopt-btn,
.care-item {
  font: inherit;
  cursor: pointer;
}

#record-btn,
#serenade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 180px;
  padding: 14px 22px;
  border: 3px solid #000;
  background: #c41e3a;
  color: #fff;
  box-shadow: 4px 4px 0 #000;
}

#record-btn.listening,
#serenade-btn.listening {
  background: #7a1024;
  animation: recpulse 1s ease-in-out infinite;
}

#record-btn:hover,
#serenade-btn:hover,
#adopt-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #000;
}

.rec-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.rec-dot.small {
  width: 10px;
  height: 10px;
}

@keyframes recpulse {
  50% { box-shadow: 4px 4px 0 #000, 0 0 18px #ff4d6d; }
}

.viz-wrap {
  margin: 18px auto 16px;
  padding: 12px;
  border: 3px solid #e9c46a;
  background: rgba(0, 0, 0, 0.4);
}

#viz {
  display: block;
  width: 100%;
  height: 88px;
  background: #0c0810;
}

.meter-row,
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.meter-row span,
.stat span {
  width: 64px;
  text-align: left;
  color: #e9c46a;
}

.meter {
  flex: 1;
  height: 12px;
  border: 2px solid #e9c46a;
  background: #1a120c;
}

.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e9c46a, #f4a261);
}

.heard {
  margin-top: 10px;
  color: #ffd166;
  min-height: 16px;
}

.keys {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.key {
  width: 42px;
  height: 92px;
  border: 3px solid #000;
  background: #fff8ef;
  color: #1a120c;
  font: inherit;
  font-size: 7px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #000;
}

.key:active,
.key.down {
  background: #e9c46a;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #000;
}

.ghost,
#adopt-btn {
  font: inherit;
  font-size: 8px;
  padding: 12px 16px;
  border: 3px solid #e9c46a;
  background: transparent;
  color: #fff8ef;
  cursor: pointer;
}

#adopt-btn {
  background: #e9c46a;
  color: #1a120c;
  border-color: #000;
  box-shadow: 4px 4px 0 #000;
}

.ghost.thin {
  font-size: 7px;
  padding: 8px 10px;
  border-color: #8d7a66;
  color: #cbb79a;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.pet-hall {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pet-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 12px;
  border: 3px solid #000;
  background: linear-gradient(180deg, #4a2c17 0%, #2b1810 100%);
  color: inherit;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
}

.pet-card:hover,
.pet-card:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 #000;
}

.pet-card canvas,
.pet-card img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: contain;
  background: #1a120c;
  border: 2px solid #e9c46a;
}

.pet-card h3 {
  font-size: 8px;
  line-height: 1.5;
}

.pet-card p {
  font-size: 7px;
  line-height: 1.7;
  color: #d4b896;
}

.name-label {
  display: block;
  color: #e9c46a;
  margin: 8px 0 8px;
}

#pet-name {
  font: inherit;
  font-size: 10px;
  text-align: center;
  padding: 12px 10px;
  width: min(280px, 100%);
  border: 3px solid #e9c46a;
  background: #1a120c;
  color: #fff8ef;
}

#meet-art,
#yard {
  display: block;
  margin: 0 auto 12px;
  background: #0c0810;
  border: 3px solid #e9c46a;
}

.world-screen {
  max-width: 420px;
}

.device {
  position: relative;
  margin: 0 auto 16px;
  padding: 18px 14px 14px;
  background: linear-gradient(180deg, #d9c4a0 0%, #b08968 100%);
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
}

.device-ear {
  position: absolute;
  top: 36px;
  width: 18px;
  height: 46px;
  background: #c9ae86;
  border: 3px solid #000;
}

.device-ear.left { left: -16px; }
.device-ear.right { right: -16px; }

.lcd {
  background: #8fbc5a;
  border: 4px solid #2b1810;
  padding: 8px;
}

.lcd-top {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: #1a120c;
  margin-bottom: 6px;
}

#yard {
  width: 100%;
  height: auto;
  border-color: #3d5a1f;
  background: #7aa644;
}

.speech {
  min-height: 28px;
  margin: 8px 0 4px;
  color: #1a120c;
}

.lcd .meter {
  border-color: #2b1810;
  background: #3d5a1f;
}

.lcd .meter i {
  background: #1a120c;
}

.lcd .stat span {
  color: #1a120c;
  width: 58px;
}

.care-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.care-hint {
  margin: 10px 0 0;
  color: #4a2c17;
}

.care-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px 8px;
  border: 3px solid #000;
  background: #fff8ef;
  color: #1a120c;
  box-shadow: 2px 2px 0 #000;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.care-item span {
  font-size: 7px;
  line-height: 1.3;
}

.care-item canvas {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  background: transparent;
  border: none;
}

.care-item:hover,
.care-item.dragging {
  background: #e9c46a;
}

.care-item.dragging {
  cursor: grabbing;
  opacity: 0.45;
}

.care-ghost {
  position: fixed;
  z-index: 60;
  width: 88px;
  pointer-events: none;
  transform: translate(-50%, -60%);
  filter: drop-shadow(3px 4px 0 rgba(0, 0, 0, 0.45));
}

.care-ghost canvas {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
  border: none;
}

#yard.drop-ready {
  outline: 3px solid #e9c46a;
  outline-offset: -3px;
}

#serenade-btn {
  margin-bottom: 8px;
}

.world-screen.waiting .care-item,
.world-screen.waiting #serenade-btn,
.world-screen.home .care-item,
.world-screen.home #serenade-btn {
  opacity: 0.45;
  pointer-events: none;
}

.home-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 8, 16, 0.55);
}

.home-card {
  width: min(420px, 100%);
  padding: 28px 22px;
  border: 4px solid #000;
  background: linear-gradient(180deg, #fff3d6, #e9c46a);
  box-shadow: 8px 8px 0 #000;
  text-align: center;
  animation: popup-pop 0.4s ease-out;
}

.home-title {
  font-size: 12px;
  line-height: 1.7;
  color: #1a120c;
  margin-bottom: 14px;
}

.home-sub {
  font-size: 9px;
  line-height: 1.8;
  color: #6b3a1f;
}

.day-popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  background: rgba(12, 8, 16, 0.62);
}

.day-popup-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px 16px 20px;
  border: 4px solid #000;
  background:
    linear-gradient(180deg, #fff3d6 0%, #f4d6a0 40%, #e7c07a 100%);
  color: #1a120c;
  box-shadow: 8px 8px 0 #000;
  animation: popup-pop 0.42s ease-out;
}

.day-badge {
  display: inline-block;
  font-size: 8px;
  letter-spacing: 2px;
  padding: 6px 10px;
  margin-bottom: 10px;
  border: 3px solid #000;
  background: #c41e3a;
  color: #fff8ef;
}

.day-popup-card h2 {
  font-size: 13px;
  color: #1a120c;
  text-shadow: none;
}

.day-popup-card .lead,
.day-popup-card .kicker,
.day-popup-card .name-label {
  color: #5c3a28;
}

.day-popup-card .kicker {
  margin-top: 4px;
}

.day-popup-card .pet-card {
  background: linear-gradient(180deg, #fff8ef 0%, #ead7b2 100%);
  color: #1a120c;
}

.day-popup-card .pet-card p {
  color: #5c3a28;
}

.day-popup-card .pet-card canvas,
.day-popup-card .pet-card img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: contain;
  background: #1a120c;
  border: 2px solid #2b1810;
}

.day-popup-card #pet-name {
  background: #fff8ef;
  color: #1a120c;
  border-color: #000;
}

.day-popup-card #meet-art {
  background: #7aa644;
  border-color: #2b1810;
}

@keyframes popup-pop {
  0% { transform: scale(0.72) translateY(18px); opacity: 0; }
  72% { transform: scale(1.05) translateY(-3px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

@media (max-width: 560px) {
  h1 { font-size: 14px; }
  .key { width: 32px; height: 74px; }
  .pet-hall { grid-template-columns: 1fr; }
  .care-row { grid-template-columns: repeat(2, 1fr); }
}
