:root {
  --bg-a: #ffefd2;
  --bg-b: #dff2ff;
  --bg-c: #ffe7f3;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(120, 146, 184, 0.25);
  --text: #1f2532;
  --subtext: #596273;
  --accent: #ff8e5d;
  --accent-soft: #ffc17b;
  --sky: #5a8bd8;
  --mint: #45c193;
  --shadow: 0 18px 50px rgba(47, 62, 88, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Hannotate SC", "Marker Felt", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg-a) 0%, var(--bg-b) 55%, var(--bg-c) 100%);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.sky-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 9% 14%, rgba(255, 196, 146, 0.58), rgba(255, 196, 146, 0) 34%),
    radial-gradient(circle at 82% 16%, rgba(173, 212, 255, 0.52), rgba(173, 212, 255, 0) 38%),
    radial-gradient(circle at 50% 90%, rgba(255, 198, 228, 0.45), rgba(255, 198, 228, 0) 40%);
}

.sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sparkles span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.95);
  animation: twinkle 4.6s linear infinite;
}

.sparkles span:nth-child(1) {
  top: 14%;
  left: 7%;
}

.sparkles span:nth-child(2) {
  top: 29%;
  left: 21%;
  animation-delay: 0.7s;
}

.sparkles span:nth-child(3) {
  top: 9%;
  left: 42%;
  animation-delay: 1.4s;
}

.sparkles span:nth-child(4) {
  top: 33%;
  left: 68%;
  animation-delay: 2.1s;
}

.sparkles span:nth-child(5) {
  top: 18%;
  left: 87%;
  animation-delay: 2.8s;
}

.sparkles span:nth-child(6) {
  top: 56%;
  left: 14%;
  animation-delay: 1.1s;
}

.sparkles span:nth-child(7) {
  top: 72%;
  left: 58%;
  animation-delay: 3.1s;
}

.sparkles span:nth-child(8) {
  top: 80%;
  left: 85%;
  animation-delay: 3.7s;
}

.app-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
    calc(42px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
  overflow: hidden;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  padding: 24px;
  margin-bottom: 16px;
}

.kicker {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #3f6bb0;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5vw, 47px);
  line-height: 1.1;
}

h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

h3 {
  margin: 10px 0 8px;
}

p {
  margin: 0 0 12px;
  color: var(--subtext);
  line-height: 1.55;
}

.exclusive-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #ffd09d;
  background: linear-gradient(120deg, #fff3df, #f0f8ff);
  color: #704216;
  font-size: 14px;
  font-weight: 700;
}

.exclusive-tag::before {
  content: "⭐";
  font-size: 13px;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #616b79;
}

input,
textarea,
select,
button,
audio {
  font: inherit;
  font-size: 16px;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #d7deea;
  background: #fff;
  padding: 10px 12px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #81b0f5;
  box-shadow: 0 0 0 3px rgba(129, 176, 245, 0.24);
}

button {
  border: none;
  border-radius: 14px;
  padding: 10px 16px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(120deg, var(--accent), var(--accent-soft));
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.status-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 15px;
}

.status-row span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(163, 181, 213, 0.33);
}

.status-row strong {
  color: #2552ce;
}

.hero-characters {
  border-radius: 22px;
  border: 1px dashed rgba(104, 139, 205, 0.42);
  padding: 14px;
  background:
    radial-gradient(circle at 10% 8%, rgba(255, 222, 181, 0.55), rgba(255, 222, 181, 0) 38%),
    linear-gradient(180deg, #f4fbff 0%, #eef5ff 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  justify-items: center;
}

.avatar-card {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 1 / 0.84;
  border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  border: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow:
    inset 0 14px 30px rgba(255, 255, 255, 0.36),
    inset 0 -18px 30px rgba(51, 79, 129, 0.22),
    0 14px 26px rgba(58, 76, 113, 0.18);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0 8px 12px;
  isolation: isolate;
  overflow: hidden;
  animation: bob 4s ease-in-out infinite;
  margin: 0 auto;
}

.avatar-card span {
  position: relative;
  z-index: 3;
  font-size: 14px;
  font-weight: 700;
  color: #2b3342;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 4px 10px;
}

.avatar-card::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1f2a45;
  top: 38%;
  left: calc(50% - 44px);
  box-shadow: 58px 0 0 #1f2a45;
  animation: blink 5.5s ease-in-out infinite;
}

.avatar-card::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 16px;
  border-bottom: 4px solid #26324f;
  border-radius: 0 0 22px 22px;
  top: 58%;
  left: calc(50% - 23px);
}

.avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  z-index: 1;
}

.avatar-card.has-photo::before,
.avatar-card.has-photo::after {
  display: none;
}

.dad-avatar {
  background:
    radial-gradient(circle at 34% 22%, rgba(233, 246, 255, 0.95) 0 24%, rgba(233, 246, 255, 0) 42%),
    linear-gradient(180deg, #9ed0ff 0%, #74a8f3 100%);
}

.dad-avatar::marker {
  content: "";
}

.dad-avatar::selection {
  background: transparent;
}

.dad-avatar::before {
  animation-delay: 0.4s;
}

.dad-avatar > span::before {
  content: "🧢";
  margin-right: 4px;
}

.dad-avatar::after {
  border-bottom-color: #1f3765;
}

.daughter-avatar {
  background:
    radial-gradient(circle at 34% 22%, rgba(255, 246, 252, 0.95) 0 24%, rgba(255, 246, 252, 0) 42%),
    linear-gradient(180deg, #ffd7ec 0%, #ffb0d3 100%);
  animation-delay: 0.9s;
}

.daughter-avatar > span::before {
  content: "🎀";
  margin-right: 4px;
}

.daughter-avatar::after {
  border-bottom-color: #6b2d58;
}

.avatar-card.pop {
  animation: pop-scale 0.4s ease;
}

.dialogue-chip {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: #f7fbff;
  border: 1px dashed #bfd2ef;
  color: #2d3850;
  font-size: 15px;
}

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

.content-grid .panel {
  padding: 20px;
}

.result-box {
  margin: 10px 0 0;
  min-height: 52px;
  border-radius: 14px;
  border: 1px dashed #c9d7ec;
  background: #f8fbff;
  color: #2b3650;
  padding: 12px;
}

.badge-list {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.badge-item {
  border: 1px solid #d8e1f0;
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
  color: #617089;
}

.badge-item.unlocked {
  background: linear-gradient(180deg, #fff7e8, #fffef9);
  border-color: #ffc98b;
  color: #553a16;
}

.badge-item strong {
  display: block;
  margin-bottom: 6px;
}

.mood-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.mood-buttons button {
  border-radius: 999px;
  border: 1px solid #d7dce8;
  background: #fff;
  color: #36415a;
  padding: 7px 12px;
}

.mood-buttons button.active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(120deg, #4d91e5, #79b9fd);
}

.game-header {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.game-board {
  margin-top: 10px;
  height: 230px;
  border-radius: 16px;
  border: 1px solid #d4ddf0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(232, 244, 255, 0.95)),
    repeating-linear-gradient(45deg, rgba(110, 174, 244, 0.1), rgba(110, 174, 244, 0.1) 12px, transparent 12px, transparent 24px);
  position: relative;
  overflow: hidden;
}

.star-btn {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #ffd078;
  background: #fff7dd;
  color: #7a5200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 6px 15px rgba(121, 91, 0, 0.22);
  user-select: none;
}

.btn-secondary {
  background: linear-gradient(120deg, #5998e0, #79b7f8);
}

.dad-title {
  color: #293347;
  margin-top: 14px;
}

.dad-signature {
  margin: 10px 0;
  text-align: right;
  font-weight: 700;
  color: #516281;
}

.message-panel {
  margin-top: 16px;
  padding: 20px;
}

.message-header {
  margin-bottom: 8px;
}

.message-tools {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
}

.text-message-form,
.record-box {
  border-radius: 16px;
  border: 1px solid #d5e0f0;
  background: linear-gradient(180deg, #fafdff, #f2f8ff);
  padding: 12px;
}

.text-message-form {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 10px;
  align-items: end;
}

.text-message-form .grow {
  grid-column: 2;
}

.text-message-form textarea {
  min-height: 74px;
  resize: vertical;
}

.record-actions {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.record-actions button {
  min-height: 44px;
}

#recordPreview {
  width: 100%;
  margin-top: 6px;
}

.hint-text {
  margin-top: 8px;
  font-size: 13px;
  color: #5d708f;
}

.message-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.message-item {
  border-radius: 14px;
  border: 1px solid #d7dfef;
  background: #ffffff;
  padding: 10px;
}

.message-item.dad {
  border-color: #f0c089;
  background: linear-gradient(180deg, #fff8ec, #fffcf5);
}

.message-item.daughter {
  border-color: #d6c9ff;
  background: linear-gradient(180deg, #f9f5ff, #fcfaff);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: #60708b;
  flex-wrap: wrap;
}

.message-meta span {
  overflow-wrap: anywhere;
}

.message-body {
  color: #283346;
  white-space: pre-wrap;
  line-height: 1.5;
}

.message-item audio {
  width: 100%;
  margin-top: 6px;
}

.empty-state {
  border: 1px dashed #c8d6eb;
  border-radius: 12px;
  background: #f8fbff;
  color: #50648a;
  padding: 14px;
}

.footer {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
}

@keyframes twinkle {
  0%,
  100% {
    transform: scale(0.72);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes blink {
  0%,
  45%,
  100% {
    transform: scaleY(1);
  }
  48%,
  52% {
    transform: scaleY(0.1);
  }
}

@keyframes pop-scale {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 980px) {
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .profile-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .message-tools {
    grid-template-columns: 1fr;
  }

  .text-message-form {
    grid-template-columns: 1fr;
  }

  .text-message-form .grow {
    grid-column: auto;
  }

  .badge-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px 10px 40px;
  }

  .panel {
    border-radius: 22px;
  }

  .hero-panel,
  .content-grid .panel,
  .message-panel {
    padding: 14px;
  }

  .hero-characters {
    grid-template-columns: 1fr;
  }

  .avatar-card {
    width: min(100%, 290px);
    aspect-ratio: 1 / 0.86;
  }

  .profile-form {
    grid-template-columns: 1fr;
  }

  .status-row {
    gap: 8px;
  }

  .status-row span {
    width: 100%;
  }

  .record-actions {
    flex-direction: column;
  }

  .record-actions button {
    width: 100%;
  }

  .game-header button {
    width: 100%;
  }

  .text-message-form button {
    width: 100%;
  }

  .message-item {
    padding: 9px;
  }

  h2 {
    font-size: 22px;
  }
}
