:root {
  color-scheme: light;
  --bg-a: #1d274f;
  --bg-b: #815aaf;
  --bg-c: #f2a7b7;
  --ink: #321c2a;
  --muted: rgba(50, 28, 42, 0.66);
  --panel: rgba(255, 255, 255, 0.42);
  --panel-strong: rgba(255, 255, 255, 0.72);
  --line: rgba(255, 255, 255, 0.52);
  --heart: #f05283;
  --accent: #ff7f9c;
  --gold: #ffe0a6;
  --shadow: rgba(73, 30, 64, 0.22);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-a);
  color: var(--ink);
}

body {
  height: 100vh;
  height: 100dvh;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  background:
    url("images/romance-bg-v03.svg?v=20260519-004") center / cover no-repeat,
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.54), transparent 21%),
    radial-gradient(circle at 78% 20%, rgba(255, 218, 169, 0.38), transparent 22%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b) 48%, var(--bg-c));
  transition: background 600ms ease;
}

body::after {
  opacity: 0.6;
  background-image:
    url("images/love-sparkles-v03.svg?v=20260519-004"),
    radial-gradient(circle, rgba(255, 255, 255, 0.82) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 234, 194, 0.8) 0 1px, transparent 1.5px);
  background-position: center, 18px 30px, 86px 92px;
  background-size: cover, 116px 116px, 144px 144px;
  animation: drift 20s linear infinite;
}

body[data-phase="morning"] {
  --bg-a: #cde7f3;
  --bg-b: #ffe3a5;
  --bg-c: #ffd0c8;
  --panel: rgba(255, 255, 255, 0.46);
  --accent: #ff8e70;
}

body[data-phase="day"] {
  --bg-a: #a7d7f7;
  --bg-b: #b8eadb;
  --bg-c: #fff3b8;
  --panel: rgba(255, 255, 255, 0.5);
  --accent: #36a9a1;
}

body[data-phase="evening"] {
  --bg-a: #f8a08f;
  --bg-b: #f6c16b;
  --bg-c: #d083b0;
  --panel: rgba(255, 245, 236, 0.48);
  --accent: #ef6c72;
}

body[data-phase="night"] {
  --bg-a: #172447;
  --bg-b: #54448f;
  --bg-c: #c381a9;
  --panel: rgba(255, 255, 255, 0.35);
  --panel-strong: rgba(255, 255, 255, 0.64);
  --ink: #24152a;
  --muted: rgba(36, 21, 42, 0.64);
}

body[data-mood="happy"] {
  --heart: #f05283;
  --accent: #ff7f9c;
}

body[data-mood="angry"] {
  --heart: #ee5c4f;
  --accent: #ff684e;
}

body[data-mood="cute"] {
  --heart: #bd72ee;
  --accent: #d584ef;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.screen.is-hidden {
  display: none !important;
}

.start-screen {
  display: grid;
  place-items: center;
  padding: calc(22px + var(--safe-top)) 22px calc(22px + var(--safe-bottom));
}

.ambient-clock {
  position: absolute;
  top: calc(14px + var(--safe-top));
  right: 18px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 8px rgba(70, 35, 72, 0.22);
}

.start-content {
  position: relative;
  width: min(100%, 330px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 34px;
  padding: 34px 22px 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
  box-shadow: 0 24px 80px rgba(36, 17, 60, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(18px);
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 18px rgba(52, 18, 48, 0.28);
}

.start-kicker {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.82;
}

.start-content h1 {
  margin: 0;
  font-size: 46px;
  line-height: 1.08;
  letter-spacing: 0;
}

.start-desc {
  margin: 14px auto 0;
  max-width: 250px;
  font-size: 15px;
  line-height: 1.65;
  opacity: 0.92;
}

.version {
  margin: 18px 0 28px;
  font-size: 13px;
  font-weight: 800;
  opacity: 0.78;
}

.primary-button,
.send-button,
.small-button {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--heart));
  box-shadow: 0 12px 26px rgba(135, 40, 82, 0.24);
}

.primary-button {
  min-width: 180px;
  min-height: 48px;
  border-radius: 999px;
  padding: 0 28px;
  font-size: 16px;
  font-weight: 800;
}

.game-screen {
  display: grid;
  grid-template-rows: auto minmax(198px, 1.08fr) auto minmax(112px, 0.72fr) auto auto;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 14px calc(10px + var(--safe-bottom));
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  color: #fff;
  text-shadow: 0 2px 14px rgba(49, 24, 56, 0.3);
}

.time-block {
  min-width: 0;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.clock-text {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 850;
  line-height: 1.05;
}

.date-text {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
}

.small-button {
  flex: 0 0 auto;
  min-width: 62px;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
}

.icon-button {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 0;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 10px 24px rgba(72, 24, 65, 0.16);
  backdrop-filter: blur(16px);
}

.icon-button img {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

.music-button.is-muted {
  opacity: 0.72;
}

.music-button.is-muted::after {
  position: absolute;
  width: 25px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 6px rgba(55, 22, 54, 0.24);
  content: "";
  transform: rotate(-38deg);
}

.companion-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: center;
  min-height: 0;
}

.mood-line {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 8px;
  color: #fff;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 2px 14px rgba(53, 21, 58, 0.32);
}

.photo-card {
  position: relative;
  justify-self: center;
  width: min(78vw, 330px);
  aspect-ratio: 1;
  min-width: 210px;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 34px;
  padding: 0;
  background: rgba(255, 255, 255, 0.24);
  box-shadow:
    0 26px 70px rgba(50, 20, 62, 0.26),
    0 0 0 10px rgba(255, 255, 255, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateZ(0);
  animation: breathe 4.8s ease-in-out infinite;
}

.photo-card::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  content: "";
  background:
    url("images/heart-medal-v03.svg?v=20260519-004") right 10px top 10px / 54px 54px no-repeat,
    radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.36), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 54%, rgba(81, 24, 54, 0.1));
}

.photo-card::before {
  position: absolute;
  inset: -12px;
  z-index: -1;
  border-radius: 44px;
  background:
    conic-gradient(from 160deg, rgba(255, 255, 255, 0), rgba(255, 225, 236, 0.42), rgba(255, 224, 166, 0.34), rgba(255, 255, 255, 0));
  filter: blur(8px);
  opacity: 0.76;
  content: "";
}

body[data-mood="angry"] .photo-card {
  animation: tinyShake 520ms ease-in-out 1, breathe 4.8s ease-in-out infinite 520ms;
  box-shadow:
    0 22px 52px rgba(143, 47, 50, 0.24),
    0 0 0 10px rgba(255, 113, 87, 0.13);
}

body[data-mood="cute"] .photo-card {
  animation: cuddle 1.2s ease-in-out 1, breathe 4.8s ease-in-out infinite 1.2s;
  box-shadow:
    0 22px 52px rgba(105, 55, 143, 0.24),
    0 0 0 10px rgba(230, 193, 255, 0.18);
}

.mate-strip {
  position: absolute;
  top: 0;
  left: 0;
  width: 300%;
  height: 100%;
  object-fit: cover;
  transition: transform 360ms cubic-bezier(0.2, 0.9, 0.2, 1), opacity 220ms ease;
  will-change: transform;
}

body[data-mood="happy"] .mate-strip {
  transform: translateX(0);
}

body[data-mood="angry"] .mate-strip {
  transform: translateX(-33.333333%);
}

body[data-mood="cute"] .mate-strip {
  transform: translateX(-66.666667%);
}

.tap-note {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  max-width: calc(100% - 24px);
  border-radius: 999px;
  padding: 7px 11px;
  color: #fff;
  background: rgba(44, 22, 40, 0.38);
  backdrop-filter: blur(14px);
  font-size: 12px;
  font-weight: 850;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 240ms ease, transform 240ms ease;
}

.tap-note.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 20px;
  padding: 9px 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.22)),
    var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 34px rgba(68, 30, 65, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

#heartScore {
  display: block;
  margin-top: 2px;
  color: var(--heart);
  font-size: 23px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#moodText {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-panel {
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.22));
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 44px rgba(68, 30, 65, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.messages {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 10px;
  scrollbar-width: none;
}

.messages::-webkit-scrollbar {
  display: none;
}

.message {
  display: flex;
  margin-bottom: 9px;
}

.message:last-child {
  margin-bottom: 0;
}

.bubble {
  max-width: min(82%, 280px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 18px;
  padding: 9px 11px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 18px rgba(75, 26, 66, 0.08);
}

.message.her {
  justify-content: flex-start;
}

.message.her .bubble {
  border-bottom-left-radius: 7px;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(255, 241, 247, 0.68));
}

.message.me {
  justify-content: flex-end;
}

.message.me .bubble {
  border-bottom-right-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--heart));
}

.message.system .bubble {
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(42, 25, 47, 0.22);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  min-height: 34px;
}

.quick-actions button {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  padding: 0 8px;
  color: #fff;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.1));
  box-shadow: 0 10px 22px rgba(74, 28, 66, 0.12);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  text-shadow: 0 1px 8px rgba(46, 20, 52, 0.24);
}

.quick-actions button:active {
  transform: translateY(1px) scale(0.98);
}

.input-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  min-height: 48px;
}

#messageInput {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  outline: 0;
  box-shadow: 0 8px 20px rgba(75, 26, 66, 0.1);
}

#messageInput::placeholder {
  color: rgba(49, 29, 45, 0.48);
}

#messageInput:focus {
  border-color: rgba(255, 255, 255, 0.96);
  background: rgba(255, 255, 255, 0.9);
}

.send-button {
  min-width: 0;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 850;
}

.send-button:disabled {
  cursor: default;
  opacity: 0.68;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 380px) {
  .game-screen {
    gap: 8px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .clock-text {
    font-size: 21px;
  }

  .date-text {
    max-width: 176px;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-button {
    width: 35px;
    height: 35px;
  }

  .small-button {
    min-width: 55px;
    min-height: 33px;
    padding-right: 9px;
    padding-left: 9px;
  }

  .photo-card {
    width: min(74vw, 292px);
    border-radius: 25px;
  }

  .bubble {
    max-width: 84%;
    font-size: 13px;
  }

  .status-row {
    border-radius: 18px;
  }

  .quick-actions {
    gap: 5px;
  }

  .quick-actions button {
    padding-right: 5px;
    padding-left: 5px;
    font-size: 11px;
  }
}

@media (max-height: 680px) {
  .game-screen {
    grid-template-rows: auto minmax(176px, 1fr) auto minmax(90px, 0.5fr) auto auto;
    gap: 6px;
  }

  .mood-line {
    min-height: 26px;
    font-size: 13px;
  }

  .photo-card {
    width: min(61vw, 210px);
    min-width: 0;
    border-radius: 22px;
  }

  .status-row {
    min-height: 44px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .messages {
    padding: 9px 8px;
  }

  .bubble {
    padding: 8px 10px;
  }

  .input-bar {
    min-height: 44px;
  }

  .quick-actions {
    min-height: 31px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-4px) scale(1.012);
  }
}

@keyframes cuddle {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.035);
  }
}

@keyframes tinyShake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-3px);
  }

  75% {
    transform: translateX(3px);
  }
}

@keyframes drift {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(18px);
  }
}
