* { box-sizing: border-box; }

:root {
  --pink: #ffb6c1;
  --yellow: #ffcb66;
  --cream: #fff7e6;
  --brown: #8a5a3b;
  --green: #7fc97f;
  --red: #ff8080;
  --card-bg: #ffffff;
}

body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: linear-gradient(180deg, var(--cream), #ffe9c7);
  color: var(--brown);
  min-height: 100vh;
  padding-bottom: 40px;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

h1 {
  text-align: center;
  font-size: 28px;
  margin: 12px 0 0;
}

.lead {
  text-align: center;
  color: #b98a5e;
  margin: 4px 0 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(138, 90, 59, 0.12);
}

.field-label {
  display: block;
  font-size: 13px;
  color: #b98a5e;
  margin-bottom: 8px;
  font-weight: 600;
}

.role-select {
  display: flex;
  gap: 10px;
}

.role-btn {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  border: 2px solid #ffe0a3;
  background: #fffaf0;
  font-size: 16px;
  font-weight: 600;
  color: var(--brown);
}

.role-btn.selected {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #fff;
}

.primary-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--yellow);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.4;
}

.secondary-btn {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--yellow);
  background: #fff;
  color: var(--yellow);
  font-size: 15px;
  font-weight: 700;
  margin-top: 8px;
}

.text-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #b98a5e;
  font-size: 13px;
  margin-top: 14px;
  text-decoration: underline;
}

input#join-code {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #ffe0a3;
  font-size: 18px;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.error-text {
  color: var(--red);
  text-align: center;
  font-weight: 600;
}

.hidden { display: none !important; }

.text-input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #ffe0a3;
  font-size: 15px;
  margin-bottom: 14px;
}

.pet-name {
  font-size: 15px;
  font-weight: 700;
  color: #b98a5e;
  margin-bottom: 4px;
}

.card.anniversary {
  text-align: center;
  font-weight: 700;
  color: var(--brown);
  background: #fff0d0;
}

.topbar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--yellow);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.badge.muted {
  background: #fff0d0;
  color: #b98a5e;
}

.chick-card {
  background: var(--card-bg);
  border-radius: 22px;
  padding: 24px 16px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(138, 90, 59, 0.12);
  margin-bottom: 14px;
  overflow: hidden;
}

#chick-scene {
  position: relative;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chick-emoji {
  font-size: 90px;
  animation: bounce 2.4s ease-in-out infinite;
  transition: filter 0.4s;
}

#chick-emoji.has-image {
  animation: none;
}

#chick-emoji.sad {
  animation: shake 0.6s ease-in-out;
  filter: grayscale(0.5) brightness(0.9);
}

#chick-emoji.happy {
  animation: happy-pulse 0.6s ease-in-out 3;
}

@keyframes happy-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.3) rotate(-8deg); }
}

#chick-accessory {
  position: absolute;
  top: -6px;
  font-size: 36px;
}

.chick-image {
  width: 110px;
  height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 10px 8px rgba(138, 90, 59, 0.4));
  animation: chick-play 8s ease-in-out infinite;
  transform-origin: 50% 85%;
}

@keyframes chick-play {
  0%   { transform: translate(-70px, 0) scaleX(1) rotate(0deg); }
  6%   { transform: translate(-60px, -18px) scaleX(1) rotate(-6deg); }
  12%  { transform: translate(-40px, 0) scaleX(1) rotate(3deg); }
  18%  { transform: translate(-20px, -18px) scaleX(1) rotate(-6deg); }
  24%  { transform: translate(0, 0) scaleX(1) rotate(3deg); }
  30%  { transform: translate(20px, -18px) scaleX(1) rotate(-6deg); }
  36%  { transform: translate(40px, 0) scaleX(1) rotate(3deg); }
  42%  { transform: translate(60px, -18px) scaleX(1) rotate(-6deg); }
  47%  { transform: translate(70px, 0) scaleX(1) rotate(0deg); }
  50%  { transform: translate(70px, 0) scaleX(-1) rotate(0deg); }
  56%  { transform: translate(50px, -18px) scaleX(-1) rotate(6deg); }
  62%  { transform: translate(30px, 0) scaleX(-1) rotate(-3deg); }
  68%  { transform: translate(10px, -18px) scaleX(-1) rotate(6deg); }
  74%  { transform: translate(-10px, 0) scaleX(-1) rotate(-3deg); }
  80%  { transform: translate(-30px, -18px) scaleX(-1) rotate(6deg); }
  86%  { transform: translate(-50px, 0) scaleX(-1) rotate(-3deg); }
  92%  { transform: translate(-70px, -10px) scaleX(-1) rotate(3deg); }
  97%  { transform: translate(-70px, 0) scaleX(-1) rotate(0deg); }
  100% { transform: translate(-70px, 0) scaleX(1) rotate(0deg); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

#stage-name {
  font-size: 18px;
  font-weight: 700;
  margin: 10px 0 16px;
}

.gauge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.gauge-label {
  width: 64px;
  font-size: 12px;
  color: #b98a5e;
  text-align: left;
  font-weight: 600;
}

.bar {
  flex: 1;
  height: 12px;
  background: #ffe9c7;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.bar-fill.growth { background: var(--green); }
.bar-fill.vitality { background: var(--pink); }

#today-panel h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

#today-panel p {
  font-size: 13px;
  color: #b98a5e;
  margin: 0 0 12px;
}

.judge-row {
  display: flex;
  gap: 10px;
}

.judge-btn {
  flex: 1;
  padding: 14px 8px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.judge-btn.good { background: var(--green); }
.judge-btn.bad { background: var(--red); }

.surprise-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink), var(--yellow));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  margin-top: 10px;
}

.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid #ffe0a3;
  background: #fffaf0;
  color: var(--brown);
  font-size: 13px;
  font-weight: 700;
}

.mode-btn.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #fff;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.time-row .text-input {
  flex: 1;
  margin-bottom: 0;
}

.time-row span {
  font-size: 14px;
  font-weight: 700;
  color: #b98a5e;
}

.hours-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.hours-row .text-input {
  flex: 1;
  margin-bottom: 0;
}

.hours-unit {
  font-size: 14px;
  font-weight: 700;
  color: #b98a5e;
}

.status-line {
  text-align: center;
  font-weight: 700;
  padding: 10px;
  border-radius: 12px;
  background: #fff0d0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid #fff0d0;
  font-size: 14px;
}

.history-list .result-icon { font-size: 16px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-content {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

.closet-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.closet-item {
  border: 2px solid #ffe0a3;
  border-radius: 14px;
  padding: 12px 4px;
  text-align: center;
  font-size: 30px;
  background: #fffaf0;
  position: relative;
}

.closet-item.locked {
  opacity: 0.35;
  filter: grayscale(1);
}

.closet-item.equipped {
  border-color: var(--green);
  background: #eefbee;
}

.closet-item .closet-name {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  color: var(--brown);
}

.skin-thumb {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin: 0 auto;
}

.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(74, 46, 20, 0.6), rgba(74, 46, 20, 0.8));
  text-align: center;
}

.celebration-message {
  position: absolute;
  top: 6vh;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  z-index: 2;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.celebration-message h3 {
  margin: 0 0 6px;
  font-size: 7vw;
  line-height: 1.2;
}

.celebration-sub {
  margin: 0;
  font-size: 4.5vw;
  opacity: 0.9;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 16px;
  border-radius: 2px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(560deg); opacity: 0; }
}

.celebration-grid {
  position: absolute;
  inset: 0;
}

.celebration-char {
  position: absolute;
  width: 34vw;
  max-width: 165px;
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.22, 1.3, 0.36, 1);
  animation-fill-mode: both;
}

.celebration-char:nth-child(1) { top: 24%; left: 3%; animation-name: enter-from-left; animation-delay: 0s; }
.celebration-char:nth-child(2) { top: 18%; left: 60%; animation-name: enter-from-top; animation-delay: 0.08s; }
.celebration-char:nth-child(3) { top: 46%; left: 30%; animation-name: enter-from-right; animation-delay: 0.16s; }
.celebration-char:nth-child(4) { top: 60%; left: 4%; animation-name: enter-from-bottom; animation-delay: 0.24s; }
.celebration-char:nth-child(5) { top: 64%; left: 58%; animation-name: enter-from-topleft; animation-delay: 0.32s; }
.celebration-char:nth-child(6) { top: 38%; left: 68%; animation-name: enter-from-bottomright; animation-delay: 0.4s; }

.celebration-wobble {
  animation: celebration-tremble 0.35s ease-in-out infinite;
  animation-delay: 0.5s;
}

.celebration-img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: none;
  background: none;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35));
}

@keyframes enter-from-left {
  0% { transform: translate(-120vw, 0) scale(0.5) rotate(-20deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) scale(1) rotate(-7deg); opacity: 1; }
}

@keyframes enter-from-right {
  0% { transform: translate(120vw, 0) scale(0.5) rotate(20deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) scale(1) rotate(5deg); opacity: 1; }
}

@keyframes enter-from-top {
  0% { transform: translate(0, -120vh) scale(0.5) rotate(-15deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) scale(1) rotate(4deg); opacity: 1; }
}

@keyframes enter-from-bottom {
  0% { transform: translate(0, 120vh) scale(0.5) rotate(15deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) scale(1) rotate(-5deg); opacity: 1; }
}

@keyframes enter-from-topleft {
  0% { transform: translate(-100vw, -100vh) scale(0.5) rotate(-25deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) scale(1) rotate(-9deg); opacity: 1; }
}

@keyframes enter-from-bottomright {
  0% { transform: translate(100vw, 100vh) scale(0.5) rotate(25deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translate(0, 0) scale(1) rotate(8deg); opacity: 1; }
}

@keyframes celebration-tremble {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-3px, 1px) rotate(-4deg); }
  30% { transform: translate(3px, -1px) rotate(4deg); }
  45% { transform: translate(-2px, 2px) rotate(-3deg); }
  60% { transform: translate(2px, -2px) rotate(3deg); }
  75% { transform: translate(-2px, 1px) rotate(-2deg); }
  90% { transform: translate(2px, -1px) rotate(2deg); }
}

@keyframes celebration-cheer {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(-10px) rotate(-8deg); }
  40% { transform: translateY(0) rotate(6deg); }
  60% { transform: translateY(-10px) rotate(-6deg); }
  80% { transform: translateY(0) rotate(8deg); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--brown);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
}
