﻿@import url("https://cdn.jsdelivr.net/gh/neodgm/neodgm-webfont@latest/neodgm/style.css");

#tamagotchi-game {
  --px-ink: #2a1a0f;
  --px-bark: #5c3a1a;
  --px-bark-2: #7a4b22;
  --px-cream: #ffe6a8;
  --px-cream-2: #fff4cf;
  --px-gold-panel: #ffe7a3;
  --px-gold-panel-2: #fff1c6;
  --px-gold-accent: #f2c14d;
  --px-gold-shadow: #8b5a16;
  --px-leaf: #6f9b45;
  --px-leaf-dark: #3f6f37;
  --px-sky: #9fd6c0;
  --px-water: #73bdd0;
  --px-orange: #d98b3a;
  --px-red: #bf5140;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 0;
  box-sizing: border-box;
  font-family: "NeoDunggeunmo", "Galmuri9", "Press Start 2P", monospace;
  color: #f5f5d3;
  -webkit-font-smoothing: none; /* 폰트 안티앨리어싱 제거로 픽셀 아트 느낌 극대화 */
  -moz-osx-font-smoothing: grayscale;
}

#tamagotchi-game * {
  box-sizing: border-box;
}

#tamagotchi-game .user-greeting {
  width: fit-content;
  margin: 0 auto 16px;
  padding: 8px 18px;
  border: 1px solid #d3d6da;
  border-radius: 0;
  background: #fafafa;
  color: #555;
  font-size: 14px;
}

.tamagotchi-main-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  width: 100%;
  align-items: center;
}

.tamagotchi-stage {
  position: relative;
  overflow: hidden;
  border: 4px solid #1d1107;
  border-radius: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(248, 251, 247, 0.2)),
    var(--tama-bg) center bottom / cover no-repeat;
  background-color: #bdebd2;
  image-rendering: pixelated;
  box-shadow: 8px 8px 0 #1d1107;
  width: 100%;
  height: 680px;
}

.tamagotchi-top-ui {
  display: grid;
}

.tamagotchi-header {
  position: absolute;
  top: 32px;
  left: 32px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-sizing: border-box;
  width: auto;
  min-width: 180px;
  padding: 16px 20px;
  background: #fff3be !important;
  backdrop-filter: blur(4px);
  height: fit-content;
  box-shadow:
    0 -6px 0 0 #fff3be,
    0 6px 0 0 #fff3be,
    -6px 0 0 0 #fff3be,
    6px 0 0 0 #fff3be,
    0 -12px 0 0 #f2c14d,
    0 12px 0 0 #8b5a16,
    -12px 0 0 0 #f2c14d,
    12px 0 0 0 #8b5a16,
    -6px -6px 0 0 #ffe08a,
    6px -6px 0 0 #b8771f,
    -6px 6px 0 0 #b8771f,
    6px 6px 0 0 #5c3a1a,
    12px 12px 0 0 rgba(29, 17, 7, 0.28) !important;
}

.tamagotchi-title-card {
  min-width: 0;
  padding: 0;
  background: transparent;
  position: relative;
  z-index: 1;
  box-shadow: none;
}

/* 픽셀 스타일 둥근 모서리 적용 */
.pixel-rounded {
  background-color: #ffecb3 !important;
  border: none !important;
  border-radius: 0 !important;
  margin: 8px !important;
  box-shadow:
    0 -4px 0 0 #ffecb3,
    0 4px 0 0 #ffecb3,
    -4px 0 0 0 #ffecb3,
    4px 0 0 0 #ffecb3,
    0 -8px 0 0 #5c3a1a,
    0 8px 0 0 #5c3a1a,
    -8px 0 0 0 #5c3a1a,
    8px 0 0 0 #5c3a1a,
    -4px -4px 0 0 #5c3a1a,
    4px -4px 0 0 #5c3a1a,
    -4px 4px 0 0 #5c3a1a,
    4px 4px 0 0 #5c3a1a !important;
  filter: drop-shadow(6px 6px 0 rgba(92, 58, 26, 0.15)) !important;
}

.tama-owner-badge {
  display: inline-block;
  color: var(--px-bark);
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 8px;
}

.tamagotchi-header h2 {
  margin: 0;
  min-height: 22px;
  color: var(--px-ink);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 2px 2px 0 #ffe08a;
}

.tamagotchi-meta {
  position: absolute;
  top: 32px;
  right: 32px;
  z-index: 10;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  margin: 0;
}

.tamagotchi-meta span {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: var(--px-ink);
  font-size: 13px;
  font-weight: 900;
  box-shadow: none;
  filter: none;
}

.tama-meta-icon {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: none;
}

.tamagotchi-room {
  --tama-bubble-lift: 0px;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 120px;
  z-index: 1;
}

.tamagotchi-bubble {
  position: relative;
  z-index: 4;
  max-width: min(78%, 360px);
  margin-bottom: calc(20px + var(--tama-bubble-lift));
  padding: 12px 16px;
  color: #5c3a1a;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  word-break: keep-all;
}

.tamagotchi-bubble::after {
  display: none;
}

.tamagotchi-pet {
  position: relative;
  width: 180px;
  aspect-ratio: 1;
  background: transparent;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  transition: filter 0.2s ease;
  z-index: 2;
}

.tamagotchi-pet[data-stage="special"] {
  width: 240px;
}

.tamagotchi-pet.is-sick {
  filter: saturate(0.75);
  animation-duration: 3s;
}

.tamagotchi-shadow {
  display: none;
}

.tamagotchi-shadow[data-stage="egg"] {
  width: 68px;
  height: 16px;
  margin-top: -34px;
  transform: translateX(0);
}

.tamagotchi-shadow[data-stage="kitten"] {
  width: 86px;
  height: 18px;
  margin-top: -38px;
  transform: translateX(2px);
}

.tamagotchi-shadow[data-stage="special"] {
  width: 132px;
  height: 28px;
  margin-top: -48px;
  transform: translateX(4px);
}

.tamagotchi-panel {
  position: relative;
  box-sizing: border-box;
  padding: 24px 28px;
  color: #5c3a1a;
  width: min(100%, 948px);
  margin: 0 auto;
  height: fit-content;
  background: #fff3be !important;
  box-shadow:
    0 -6px 0 0 #fff3be,
    0 6px 0 0 #fff3be,
    -6px 0 0 0 #fff3be,
    6px 0 0 0 #fff3be,
    0 -12px 0 0 #f2c14d,
    0 12px 0 0 #8b5a16,
    -12px 0 0 0 #f2c14d,
    12px 0 0 0 #8b5a16,
    -6px -6px 0 0 #ffe08a,
    6px -6px 0 0 #b8771f,
    -6px 6px 0 0 #b8771f,
    6px 6px 0 0 #5c3a1a,
    12px 12px 0 0 rgba(29, 17, 7, 0.28) !important;
}

.tamagotchi-name-edit {
  position: relative;
  margin-bottom: 18px;
}

.tamagotchi-name-edit input {
  width: calc(100% - 24px);
  margin: 12px 12px 16px 12px;
  height: 46px;
  padding: 0 14px;
  border: none;
  border-radius: 0;
  background: linear-gradient(180deg, #fff0a8 0%, #ffd568 52%, #f3a93d 100%);
  color: #5c3514;
  font-size: 16px;
  font-weight: 900;
  transition: all 0.2s;
  box-shadow:
    inset 0 0 0 3px #fff6c9,
    inset 0 -4px 0 #d8872f,
    0 -4px 0 0 #fff0a8,
    0 4px 0 0 #f3a93d,
    -4px 0 0 0 #ffd568,
    4px 0 0 0 #ffd568,
    0 -8px 0 0 #7a4b16,
    0 8px 0 0 #7a4b16,
    -8px 0 0 0 #7a4b16,
    8px 0 0 0 #7a4b16,
    -4px -4px 0 0 #7a4b16,
    4px -4px 0 0 #7a4b16,
    -4px 4px 0 0 #7a4b16,
    4px 4px 0 0 #7a4b16,
    4px 12px 0 0 #5c3a1a,
    12px 4px 0 0 #5c3a1a,
    8px 8px 0 0 #5c3a1a;
  text-shadow: 1px 1px 0 #fff4b8;
}

.tamagotchi-name-edit input:focus {
  outline: none;
  box-shadow:
    inset 0 0 0 3px #fff6c9,
    inset 0 -4px 0 #d8872f,
    0 -4px 0 0 #fff0a8,
    0 4px 0 0 #f3a93d,
    -4px 0 0 0 #ffd568,
    4px 0 0 0 #ffd568,
    0 -8px 0 0 var(--px-leaf),
    0 8px 0 0 var(--px-leaf),
    -8px 0 0 0 var(--px-leaf),
    8px 0 0 0 var(--px-leaf),
    -4px -4px 0 0 var(--px-leaf),
    4px -4px 0 0 var(--px-leaf),
    -4px 4px 0 0 var(--px-leaf),
    4px 4px 0 0 var(--px-leaf),
    4px 12px 0 0 var(--px-leaf-dark),
    12px 4px 0 0 var(--px-leaf-dark),
    8px 8px 0 0 var(--px-leaf-dark);
}

.tamagotchi-name-edit::before,
.tamagotchi-name-edit::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  background: #fffdf0;
  box-shadow:
    5px 0 0 #fffdf0,
    -5px 0 0 #fffdf0,
    0 5px 0 #fffdf0,
    0 -5px 0 #fffdf0;
  image-rendering: pixelated;
  animation: tama-owner-sparkle 1.6s steps(2, end) infinite;
  z-index: 2;
  pointer-events: none;
}

.tamagotchi-name-edit::before {
  top: 8px;
  left: 20px;
}

.tamagotchi-name-edit::after {
  right: 22px;
  bottom: 60px;
  animation-delay: 0.8s;
}

#tamagotchi-reset {
  width: 100%;
  min-height: 52px;
  padding: 10px 20px;
  border: 0;
  border-radius: 0;
  background: #d95763;
  color: #fff3be;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow:
    0 -5px 0 #d95763,
    0 5px 0 #a83d4b,
    -5px 0 0 #f18a79,
    5px 0 0 #8f3340,
    5px 7px 0 #1d1107;
  text-shadow: 2px 2px 0 #8f3340;
  transition: all 0.1s;
}

.tamagotchi-reset-wrap {
  width: min(100%, 948px);
  margin: 8px auto 0;
  padding: 0 12px;
}

#tamagotchi-game .tamagotchi-guide-panel {
  width: min(calc(100% - 24px), 948px);
  margin: 24px auto;
  box-sizing: border-box;
  align-self: center;
}

#tamagotchi-game .tamagotchi-guide-rule {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 4px dotted #d8872f;
  color: #5c3a1a;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.65;
}

#tamagotchi-game .tamagotchi-collection-wrap,
#tamagotchi-game #btn-show-collection {
  pointer-events: auto;
}

#tamagotchi-game .tamagotchi-collection-wrap {
  position: absolute;
  top: 90px;
  right: 16px;
  z-index: 10;
}

#tamagotchi-game .tamagotchi-collection-popup {
  position: absolute;
  inset: 0;
  z-index: 90;
  padding: 20px;
  overflow-y: auto;
  background: rgba(29, 17, 7, 0.9);
}

#tamagotchi-game .tamagotchi-collection-popup[hidden] {
  display: none;
}

#tamagotchi-game .tamagotchi-collection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 4px solid #d8872f;
}

#tamagotchi-game .tamagotchi-collection-head h3 {
  margin: 0;
  color: #fff3be;
  font-size: 20px;
  text-shadow: 2px 2px 0 #1d1107;
}

#tamagotchi-game #btn-close-collection {
  padding: 8px 14px;
  border: 3px solid #1d1107;
  border-radius: 0;
  background: #d95763;
  color: #fff;
  box-shadow: 3px 3px 0 #1d1107;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

#tamagotchi-game .tamagotchi-collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 15px;
}

#tamagotchi-game .tamagotchi-collection-card {
  position: relative;
  min-height: 94px;
  padding: 10px 8px;
  /* border: 4px solid #1d1107; */
  border-radius: 0;
  background: #ffe6a8;
  box-shadow:
    inset 0 0 0 3px #fff3be,
    4px 4px 0 #1d1107;
  text-align: center;
}

#tamagotchi-game .tamagotchi-collection-card.is-locked {
  background: #5c3a1a;
  box-shadow:
    inset 0 0 0 3px #7a5129,
    4px 4px 0 #1d1107;
}

#tamagotchi-game .tamagotchi-collection-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 9px;
  /* border: 3px solid #1d1107; */
  border-radius: 0;
  background: #fff4cf;
  box-shadow: inset 3px 3px 0 rgba(92, 58, 26, 0.18);
  image-rendering: pixelated;
  overflow: hidden;
}

#tamagotchi-game .tamagotchi-collection-card.is-locked .tamagotchi-collection-thumb {
  background: #3f2613;
  box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.25);
}

#tamagotchi-game .tamagotchi-collection-name {
  color: #1d1107;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
  word-break: keep-all;
}

#tamagotchi-game .tamagotchi-collection-card.is-locked .tamagotchi-collection-name {
  color: #c8ad80;
}

#tamagotchi-game .tamagotchi-collection-preview-img,
#tamagotchi-game .tamagotchi-collection-preview-canvas {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.tamagotchi-name-edit button:active,
#tamagotchi-reset:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 #1d1107;
}

.tamagotchi-stats {
  display: grid;
  gap: 16px;
  padding-top: 2px;
}

.tamagotchi-pet-manager {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 4px dotted #d8872f;
  color: #5c3a1a;
  font-size: 14px;
  font-weight: 900;
}

#tamagotchi-pet-selector {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 4px solid #5c3a1a;
  border-radius: 0;
  background: #fff4cf;
  color: #5c3a1a;
  font: inherit;
  font-weight: 900;
}

#tamagotchi-pause-pet,
#tamagotchi-delete-pet {
  min-height: 38px;
  padding: 0 12px;
  border: 4px solid #5c3a1a;
  border-radius: 0;
  background: #d95763;
  color: #fff7d7;
  box-shadow: 3px 3px 0 #1d1107;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

#tamagotchi-pause-pet {
  background: #7fa96b;
}

#tamagotchi-pause-pet.is-paused {
  background: #d8872f;
}

#tamagotchi-pause-pet:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#tamagotchi-delete-pet:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 #1d1107;
}

.tamagotchi-exp {
  margin-bottom: 18px;
}

.tamagotchi-exp-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: #5c3a1a;
  font-size: 13px;
  font-weight: 900;
}

.tamagotchi-exp-track {
  overflow: hidden;
  height: 18px;
  border: 4px solid #1d1107;
  background: #2a180a;
}

#tamagotchi-exp-bar {
  display: block;
  width: 0;
  height: 100%;
  background: #f2c14d;
  box-shadow: inset 0 -3px 0 #d8872f;
  transition: width 0.25s steps(6, end);
}

#tamagotchi-game .stat-row {
  display: grid;
  grid-template-columns: 64px 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 900;
  color: #5c3a1a;
}

#tamagotchi-game .stat-track {
  overflow: hidden;
  height: 16px;
  border: 4px solid #1d1107;
  border-radius: 0;
  background: #2a180a;
  box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.5);
}

#tamagotchi-game .stat-track i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: 0;
  background: #3ddb85;
  box-shadow: none;
  transition:
    width 0.2s ease,
    background 0.2s ease;
}

/* 상태 게이지 색상 동적 적용 */
#tamagotchi-game .stat-track i.low {
  background: #ff4545 !important;
}
#tamagotchi-game .stat-track i.normal {
  background: #ff8945 !important;
}
#tamagotchi-game .stat-track i.full {
  background: #3ddb85 !important;
}

#tamagotchi-game .stat-row b {
  text-align: right;
  font-size: 15px;
  color: #5c3a1a;
}

.tamagotchi-traits {
  display: none;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 24px;
  padding: 12px 16px;
  background: var(--px-cream-2);
  border: none;
  border-radius: 0;
  color: var(--px-bark);
  font-size: 14px;
  font-weight: 900;
  box-shadow:
    0 -4px 0 0 var(--px-cream-2),
    0 4px 0 0 var(--px-cream-2),
    -4px 0 0 0 var(--px-cream-2),
    4px 0 0 0 var(--px-cream-2),
    0 -8px 0 0 var(--px-bark),
    0 8px 0 0 var(--px-bark),
    -8px 0 0 0 var(--px-bark),
    8px 0 0 0 var(--px-bark),
    -4px -4px 0 0 var(--px-bark),
    4px -4px 0 0 var(--px-bark),
    -4px 4px 0 0 var(--px-bark),
    4px 4px 0 0 var(--px-bark);
  margin: 16px 8px 8px;
}

.tamagotchi-traits strong {
  color: #5c3a1a;
  font-weight: 900;
  font-size: 16px;
  text-decoration: underline;
  text-decoration-color: #ffb300;
  text-decoration-thickness: 4px;
}
.tamagotchi-actions {
  position: absolute;
  bottom: 24px;
  left: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  width: 100%;
  padding: 0 16px;
}

#tamagotchi-game .tamagotchi-actions button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 70px;
  min-height: 72px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

#tamagotchi-game .tamagotchi-actions button:hover,
#tamagotchi-game .tamagotchi-actions button:focus-visible {
  transform: translateY(-4px);
  background: transparent;
  box-shadow: none;
  outline: none;
}

#tamagotchi-game .tamagotchi-actions button:active {
  transform: translateY(0);
  box-shadow: none;
}

#tamagotchi-game .tama-sleep-countdown {
  position: absolute;
  /* top: -7px; */
  bottom: -12px;
  /* right: -4px; */
  z-index: 5;
  min-width: 42px;
  padding: 3px 5px;
  /* border: 2px solid #1d1107; */
  /* background: #fff0b8; */
  /* box-shadow: 2px 2px 0 rgba(29, 17, 7, 0.76); */
  color: #5c3a1a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

#tamagotchi-game .tama-sleep-countdown[hidden] {
  display: none;
}

#tamagotchi-game .tama-action-remaining {
  position: absolute;
  right: 7px;
  bottom: 7px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  box-sizing: border-box;
  background: rgba(43, 30, 18, 0.78);
  color: #fff4cc;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  pointer-events: none;
}

#tamagotchi-game .tama-action-remaining.is-empty {
  opacity: 0.46;
}

#tamagotchi-game .tamagotchi-actions button.is-sleeping .tama-action-remaining {
  display: none;
}

#tamagotchi-game .tama-action-icon {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(3px 0 0 rgba(29, 17, 7, 0.86))
    drop-shadow(-3px 0 0 rgba(29, 17, 7, 0.86))
    drop-shadow(0 3px 0 rgba(29, 17, 7, 0.86))
    drop-shadow(0 -3px 0 rgba(29, 17, 7, 0.72))
    drop-shadow(5px 6px 0 rgba(29, 17, 7, 0.46));
  transition: transform 0.14s ease;
}

#tamagotchi-game .tamagotchi-actions button:hover .tama-action-icon,
#tamagotchi-game .tamagotchi-actions button:focus-visible .tama-action-icon {
  transform: scale(1.08);
  filter: drop-shadow(3px 0 0 rgba(29, 17, 7, 0.98))
    drop-shadow(-3px 0 0 rgba(29, 17, 7, 0.98))
    drop-shadow(0 3px 0 rgba(29, 17, 7, 0.98))
    drop-shadow(0 -3px 0 rgba(29, 17, 7, 0.82))
    drop-shadow(6px 7px 0 rgba(29, 17, 7, 0.54));
}

#tamagotchi-game .tama-action-text {
  position: absolute;
  bottom: 100%;
  left: 50%;
  display: block;
  margin: 0 0 14px;
  padding: 8px 11px;
  transform: translate(-50%, 10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: nowrap;
  background: var(--px-cream, #ffe6a8);
  color: var(--px-bark, #5c3a1a);
  border: 0;
  border-radius: 0;
  font-size: 12px;
  line-height: 1.15;
  font-weight: 900;
  text-align: center;
  box-shadow:
    0 -4px 0 0 var(--px-cream, #ffe6a8),
    0 4px 0 0 var(--px-cream, #ffe6a8),
    -4px 0 0 0 var(--px-cream, #ffe6a8),
    4px 0 0 0 var(--px-cream, #ffe6a8),
    0 -9px 0 0 var(--px-bark, #5c3a1a),
    0 9px 0 0 var(--px-bark, #5c3a1a),
    -9px 0 0 0 var(--px-bark, #5c3a1a),
    9px 0 0 0 var(--px-bark, #5c3a1a),
    -5px -5px 0 0 var(--px-bark, #5c3a1a),
    5px -5px 0 0 var(--px-bark, #5c3a1a),
    -5px 5px 0 0 var(--px-bark, #5c3a1a),
    5px 5px 0 0 var(--px-bark, #5c3a1a);
  transition:
    opacity 0.12s ease,
    visibility 0.12s ease,
    transform 0.12s ease;
}

#tamagotchi-game .tama-action-text::after {
  display: none;
  content: none;
}

#tamagotchi-game .tamagotchi-actions button:hover .tama-action-text,
#tamagotchi-game .tamagotchi-actions button:focus-visible .tama-action-text,
#tamagotchi-game .tamagotchi-actions button:active .tama-action-text {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* 이름 정하기 오버레이 모달 */
#tama-name-modal {
  position: absolute;
  inset: 0;
  background: rgba(29, 17, 7, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#tamagotchi-game .icon-feed {
  background-image: url("../assets/tamagotchi/icon-fruit.png");
}

#tamagotchi-game .icon-pet {
  background-image: url("../assets/tamagotchi/icon-heart.png");
}

#tamagotchi-game .icon-wash {
  background-image: url("../assets/tamagotchi/icon-soap.png");
}

#tamagotchi-game .icon-sleep {
  background-image: url("../assets/tamagotchi/icon-moon.png");
}

#tamagotchi-game .icon-heal {
  background-image: url("../assets/tamagotchi/icon-heal.png");
}

#tamagotchi-game .icon-collection {
  width: 48px;
  height: 48px;
  background-image: url("../assets/tamagotchi/icon-book02.png");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

#tamagotchi-game .icon-collection::before {
  content: none;
}

#tamagotchi-game .icon-collection::after {
  content: none;
}

#tamagotchi-game .tamagotchi-actions button.is-unavailable {
  cursor: not-allowed;
}

#tamagotchi-game .tamagotchi-actions button.is-unavailable .tama-action-icon {
  opacity: 0.52;
  filter: grayscale(0.35) drop-shadow(2px 3px 0 rgba(29, 17, 7, 0.42));
  transform: none;
}

#tamagotchi-game .tamagotchi-actions button.is-unavailable:hover,
#tamagotchi-game .tamagotchi-actions button.is-unavailable:focus-visible {
  transform: none;
}

#tamagotchi-game
  .tamagotchi-actions
  button.is-unavailable:hover
  .tama-action-icon,
#tamagotchi-game
  .tamagotchi-actions
  button.is-unavailable:focus-visible
  .tama-action-icon {
  opacity: 0.52;
  filter: grayscale(0.35) drop-shadow(2px 3px 0 rgba(29, 17, 7, 0.42));
  transform: none;
}

@media (max-width: 420px) {
  #tamagotchi-game .tamagotchi-actions {
    gap: 10px;
  }
}

/* 도감 버튼 Hover 효과 및 좌측 툴팁 렌더링 */
#tamagotchi-game .tamagotchi-collection-wrap button:hover .tama-action-icon,
#tamagotchi-game
  .tamagotchi-collection-wrap
  button:focus-visible
  .tama-action-icon {
  transform: scale(1.08);
  filter: drop-shadow(3px 0 0 rgba(29, 17, 7, 0.98))
    drop-shadow(-3px 0 0 rgba(29, 17, 7, 0.98))
    drop-shadow(0 3px 0 rgba(29, 17, 7, 0.98))
    drop-shadow(0 -3px 0 rgba(29, 17, 7, 0.82))
    drop-shadow(6px 7px 0 rgba(29, 17, 7, 0.54));
}

#tamagotchi-game .tama-action-text.left-tooltip {
  bottom: auto;
  top: 50%;
  left: auto;
  right: 100%;
  transform: translate(10px, -50%);
  margin: 0 14px 0 0;
}

#tamagotchi-game
  .tamagotchi-collection-wrap
  button:hover
  .tama-action-text.left-tooltip,
#tamagotchi-game
  .tamagotchi-collection-wrap
  button:focus-visible
  .tama-action-text.left-tooltip,
#tamagotchi-game
  .tamagotchi-collection-wrap
  button:active
  .tama-action-text.left-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
}

@media (max-width: 760px) {
  #tamagotchi-game {
    padding: 12px 14px 24px;
  }

  .tamagotchi-stage {
    height: auto;
    min-height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 0;
  }

  .tamagotchi-top-ui {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
    order: 1;
    width: calc(100% - 32px);
    margin: 0 auto;
    z-index: 10;
  }

  .tamagotchi-header {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
    margin: 0;
    padding: 16px 16px 6px;
  }

  .tamagotchi-meta {
    position: relative;
    top: auto;
    right: auto;
    padding: 6px 16px 16px;
    justify-content: center;
    flex-wrap: wrap;
  }

  #tamagotchi-game .tamagotchi-collection-wrap {
    position: relative;
    order: 1;
    top: auto;
    right: auto;
    display: flex;
    justify-content: flex-end;
    width: calc(100% - 32px);
    margin: 12px auto 10px;
    padding-right: 6px;
    box-sizing: border-box;
  }

  .tamagotchi-room {
    position: relative;
    order: 2;
    flex: 1;
    padding-bottom: 20px;
    min-height: 250px;
  }

  #tamagotchi-game .tamagotchi-actions {
    position: relative;
    bottom: auto;
    order: 3;
    padding: 0 16px;
    margin-bottom: 16px;
  }

  .tamagotchi-pet-manager {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .tamagotchi-pet-manager label,
  #tamagotchi-pet-selector {
    grid-column: 1 / -1;
  }

  #tamagotchi-pause-pet,
  #tamagotchi-delete-pet {
    width: 100%;
    min-height: 42px;
  }
}

/* PC 화면에서 상태 게이지를 가로로 나란히 배치 */
@media (min-width: 761px) {
  .tamagotchi-stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (max-width: 420px) {
  .tamagotchi-pet-manager {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  #tamagotchi-pause-pet,
  #tamagotchi-delete-pet {
    width: 100%;
  }

  #tamagotchi-game .stat-row {
    grid-template-columns: 52px 1fr 30px;
  }

  #tamagotchi-game .tamagotchi-actions {
    gap: 10px;
    padding: 0 5px;
  }

  #tamagotchi-game .tamagotchi-actions button {
    width: 56px;
    min-height: 60px;
  }

  #tamagotchi-game .tama-action-icon {
    width: 48px;
    height: 48px;
  }

  #tamagotchi-game .tama-action-text {
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* Pixel forest theme refinement */
#tamagotchi-game .pixel-rounded {
  background-color: var(--px-cream) !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow:
    0 -4px 0 0 var(--px-cream),
    0 4px 0 0 var(--px-cream),
    -4px 0 0 0 var(--px-cream),
    4px 0 0 0 var(--px-cream),
    0 -8px 0 0 var(--px-bark),
    0 8px 0 0 var(--px-bark),
    -8px 0 0 0 var(--px-bark),
    8px 0 0 0 var(--px-bark),
    -4px -4px 0 0 var(--px-bark),
    4px -4px 0 0 var(--px-bark),
    -4px 4px 0 0 var(--px-bark),
    4px 4px 0 0 var(--px-bark) !important;
}

#tamagotchi-game .tamagotchi-kicker,
#tamagotchi-game .tamagotchi-bubble,
#tamagotchi-game .tamagotchi-log-head h3 {
  color: var(--px-ink);
}

#tamagotchi-game .tamagotchi-header h2 {
  text-shadow: 2px 2px 0 var(--px-cream-2);
  color: var(--px-ink);
}

#tamagotchi-game .tamagotchi-meta span {
  border-radius: 0;
  box-shadow: none;
}

#tamagotchi-game .tamagotchi-traits,
#tamagotchi-game .tamagotchi-log li {
  background: var(--px-cream-2);
  color: var(--px-bark);
}

#tamagotchi-game .tamagotchi-traits {
  display: none;
}

#tamagotchi-game .tamagotchi-top-ui,
#tamagotchi-game .tamagotchi-header,
#tamagotchi-game .tamagotchi-panel,
#tamagotchi-game .tamagotchi-meta {
  background-color: #fff3be !important;
  box-shadow:
    0 -6px 0 0 #fff3be,
    0 6px 0 0 #fff3be,
    -6px 0 0 0 #fff3be,
    6px 0 0 0 #fff3be,
    0 -12px 0 0 #f2c14d,
    0 12px 0 0 #8b5a16,
    -12px 0 0 0 #f2c14d,
    12px 0 0 0 #8b5a16,
    -6px -6px 0 0 #ffe08a,
    6px -6px 0 0 #b8771f,
    -6px 6px 0 0 #b8771f,
    6px 6px 0 0 #5c3a1a,
    12px 12px 0 0 rgba(29, 17, 7, 0.28) !important;
}

@media (max-width: 760px) {
  #tamagotchi-game .tamagotchi-header,
  #tamagotchi-game .tamagotchi-meta {
    background-color: transparent !important;
    box-shadow: none !important;
  }
}

/* Stable Tamagotchi HUD pass */
#tamagotchi-game .tamagotchi-header,
#tamagotchi-game .tamagotchi-meta {
  background-color: var(--px-gold-panel) !important;
  color: var(--px-bark);
  box-shadow:
    0 -6px 0 0 var(--px-gold-panel),
    0 6px 0 0 var(--px-gold-panel),
    -6px 0 0 0 var(--px-gold-panel),
    6px 0 0 0 var(--px-gold-panel),
    0 -12px 0 0 var(--px-gold-accent),
    0 12px 0 0 var(--px-gold-shadow),
    -12px 0 0 0 var(--px-gold-accent),
    12px 0 0 0 var(--px-gold-shadow),
    -6px -6px 0 0 #ffe08a,
    6px -6px 0 0 #b8771f,
    -6px 6px 0 0 #b8771f,
    6px 6px 0 0 #5c3a1a,
    12px 12px 0 0 rgba(29, 17, 7, 0.28) !important;
}

#tamagotchi-game .tamagotchi-top-ui {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 10;
  width: auto;
  padding: 0;
  background: transparent !important;
  box-shadow: none !important;
  font-family: "NeoDunggeunmo", "Galmuri9", "Press Start 2P", monospace;
  pointer-events: none;
}

#tamagotchi-game .tamagotchi-header {
  position: absolute;
  top: 32px;
  left: 32px;
  width: auto;
  min-width: 180px;
  padding: 16px 20px;
  margin: 0;
  align-items: center;
  pointer-events: auto;
}

#tamagotchi-game .tamagotchi-meta {
  position: absolute;
  top: 32px;
  right: 32px;
  width: auto;
  min-width: 0;
  padding: 12px 16px;
  margin: 0;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  pointer-events: auto;
}

@keyframes tama-owner-sparkle {
  0%,
  45% {
    opacity: 0;
    transform: scale(0.75);
  }
  50%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

#tamagotchi-game .tamagotchi-panel {
  width: min(calc(100% - 24px), 948px);
  margin: 16px auto !important;
  background-color: var(--px-gold-panel) !important;
}

@media (max-width: 760px) {
  #tamagotchi-game {
    min-height: 0;
    padding: 8px 10px 20px;
  }

  #tamagotchi-game .tamagotchi-stage {
    height: clamp(590px, calc(100svh - 16px), 700px);
    min-height: 590px;
    gap: 8px;
    padding: 12px 0 8px;
  }

  #tamagotchi-game .tamagotchi-panel,
  #tamagotchi-game .tamagotchi-guide-panel,
  #tamagotchi-game .tamagotchi-reset-wrap {
    width: calc(100% - 24px);
    margin-left: auto !important;
    margin-right: auto !important;
  }

  #tamagotchi-game .tamagotchi-top-ui {
    display: grid;
    gap: 6px;
    position: relative;
    top: auto;
    left: auto;
    order: 1;
    width: min(340px, calc(100% - 40px));
    padding: 10px 14px;
    margin: 12px auto 0;
    background-color: var(--px-gold-panel) !important;
    box-shadow:
      0 -6px 0 0 var(--px-gold-panel),
      0 6px 0 0 var(--px-gold-panel),
      -6px 0 0 0 var(--px-gold-panel),
      6px 0 0 0 var(--px-gold-panel),
      0 -12px 0 0 var(--px-gold-accent),
      0 12px 0 0 var(--px-gold-shadow),
      -12px 0 0 0 var(--px-gold-accent),
      12px 0 0 0 var(--px-gold-shadow),
      -6px -6px 0 0 #ffe08a,
      6px -6px 0 0 #b8771f,
      -6px 6px 0 0 #b8771f,
      6px 6px 0 0 #5c3a1a,
      12px 12px 0 0 rgba(29, 17, 7, 0.28) !important;
    pointer-events: auto;
  }

  #tamagotchi-game .tamagotchi-header,
  #tamagotchi-game .tamagotchi-meta {
    position: static;
    width: 100%;
    padding: 0;
    background: transparent !important;
    box-shadow: none !important;
  }

  #tamagotchi-game .tamagotchi-room {
    justify-content: flex-end;
    min-height: clamp(220px, 38svh, 290px);
    padding-bottom: 8px;
  }

  #tamagotchi-game .tamagotchi-bubble {
    margin-bottom: calc(8px + var(--tama-bubble-lift));
    padding: 9px 12px;
    font-size: 13px;
    background: var(--px-cream-2) !important;
    box-shadow:
      0 -3px 0 var(--px-bark),
      0 3px 0 var(--px-bark),
      -3px 0 0 var(--px-bark),
      3px 0 0 var(--px-bark) !important;
    filter: none !important;
  }

  #tamagotchi-game .tamagotchi-pet {
    width: clamp(142px, 42vw, 174px);
  }

  #tamagotchi-game .tamagotchi-pet[data-stage="special"] {
    width: clamp(180px, 54vw, 220px);
  }

  #tamagotchi-game .tamagotchi-actions {
    flex-wrap: nowrap;
    gap: clamp(4px, 2vw, 10px);
    padding: 7px 12px 12px;
    margin: 0;
    overflow: visible;
  }

  #tamagotchi-game .tamagotchi-actions button {
    flex: 0 1 62px;
    width: 62px;
    min-width: 0;
    min-height: 66px;
    padding: 5px;
    overflow: visible;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #tamagotchi-game .tama-action-icon {
    width: 48px;
    height: 48px;
  }
}

@media (hover: none) and (pointer: coarse) {
  #tamagotchi-game .tamagotchi-actions button,
  #tamagotchi-game .tamagotchi-actions button:hover,
  #tamagotchi-game .tamagotchi-actions button:focus,
  #tamagotchi-game .tamagotchi-actions button:focus-visible {
    transform: none;
    outline: none;
    background: transparent;
    box-shadow: none;
  }

  #tamagotchi-game .tamagotchi-actions button .tama-action-icon,
  #tamagotchi-game .tamagotchi-actions button:hover .tama-action-icon,
  #tamagotchi-game .tamagotchi-actions button:focus .tama-action-icon,
  #tamagotchi-game .tamagotchi-actions button:focus-visible .tama-action-icon {
    transform: none;
    filter: drop-shadow(2px 0 0 rgba(29, 17, 7, 0.76))
      drop-shadow(-2px 0 0 rgba(29, 17, 7, 0.76))
      drop-shadow(0 2px 0 rgba(29, 17, 7, 0.76))
      drop-shadow(0 -2px 0 rgba(29, 17, 7, 0.68))
      drop-shadow(3px 4px 0 rgba(29, 17, 7, 0.36));
  }

  #tamagotchi-game .tamagotchi-actions button:active {
    transform: translateY(2px);
  }

  #tamagotchi-game .tamagotchi-actions button:active .tama-action-icon {
    transform: none;
  }

  #tamagotchi-game .tamagotchi-actions button:not(:active) .tama-action-text {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 10px);
  }
}

@media (max-width: 420px) {
  #tamagotchi-game .tamagotchi-actions {
    gap: 2px;
    padding-right: 8px;
    padding-left: 8px;
  }

  #tamagotchi-game .tamagotchi-actions button {
    width: 54px;
    min-height: 62px;
    padding: 4px;
  }

  #tamagotchi-game .tama-action-icon {
    width: 44px;
    height: 44px;
  }
}
