/* Risky Text — palette aligned to chat mockup (plum footer, light chat, magenta accents) */

:root {
  --plum: #4b1d52;
  --plum-dark: #3a1540;
  --plum-footer: #4b1d52;
  --peach-cream: #fff8f5;
  --peach-soft: #fef3ef;
  --lavender-chat: #f5e3ef;
  --lavender-mid: #ebcfe0;
  --ink: #1c1917;
  --ink-soft: #3f3f46;
  --magenta: #db2777;
  --magenta-muted: #c02673;
  --bubble-in: #ebe2e8;
  --bubble-in-edge: #e0d4dc;
  --player-mauve: #b8557a;
  --player-mauve-deep: #963c5f;
  --orange-accent: #ea580c;
  --white: #ffffff;
}

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

html {
  height: 100%;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--plum-dark);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Landscape hint on small devices */
.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--plum-dark);
  color: var(--lavender-chat);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  font-size: 1.1rem;
}

@media screen and (max-width: 900px) and (orientation: landscape) {
  .rotate-hint {
    display: flex;
  }
}

.phone-shell {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--plum);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.2),
    0 24px 80px rgba(0, 0, 0, 0.45);
}

@media (min-width: 480px) {
  .phone-shell {
    margin: 12px auto;
    border-radius: 36px;
    height: min(100dvh - 24px, 820px);
  }
}

.status-bar {
  flex-shrink: 0;
  height: max(8px, env(safe-area-inset-top, 0px));
  min-height: 8px;
  background: var(--plum-dark);
}

.header,
.chat-panel,
.choice-panel {
  position: relative;
  z-index: 1;
}

/* Header — light profile strip */
.header {
  flex-shrink: 0;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--peach-cream) 0%, var(--peach-soft) 100%);
  border-bottom: 1px solid rgba(219, 39, 119, 0.12);
}

.header-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fbcfe8;
  background: #fce7f3;
}

.header-name-pill {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: rgba(233, 213, 255, 0.85);
  padding: 6px 16px;
  border-radius: 999px;
  max-width: 92%;
  text-align: center;
  line-height: 1.25;
  border: 1px solid rgba(219, 39, 119, 0.15);
}

/* Chat — pale peach → warm lavender-pink */
.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  background: linear-gradient(
    180deg,
    #fffaf8 0%,
    var(--peach-soft) 28%,
    var(--lavender-chat) 72%,
    var(--lavender-mid) 100%
  );
}

.chat-panel::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 120% 80% at 50% 100%,
    rgba(255, 255, 255, 0.35) 0%,
    transparent 55%
  );
  z-index: 0;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 4px 12px;
  position: relative;
  z-index: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(190, 24, 93, 0.35) transparent;
}

.chat-scroll::-webkit-scrollbar {
  width: 4px;
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: rgba(190, 24, 93, 0.35);
  border-radius: 4px;
}

.date-divider {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--magenta);
  margin: 6px 0 14px;
  position: relative;
}

.date-divider::before,
.date-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 28%;
  height: 1px;
  background: rgba(219, 39, 119, 0.55);
}

.date-divider::before {
  left: 4%;
}

.date-divider::after {
  right: 4%;
}

.message-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
  max-width: 100%;
}

.message-row.ex {
  align-items: flex-start;
}

.message-row.player {
  align-items: flex-end;
}

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.45;
  position: relative;
}

/* Incoming — pale lavender / gray-pink, dark text */
.bubble-ex {
  color: var(--ink);
  background: linear-gradient(160deg, var(--bubble-in) 0%, #f5eef3 100%);
  border: 1px solid var(--bubble-in-edge);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(75, 29, 82, 0.08);
}

/* Outgoing — mauve-pink, white text, tail */
.bubble-player {
  color: var(--white);
  background: linear-gradient(155deg, #c96b88 0%, var(--player-mauve) 40%, var(--player-mauve-deep) 100%);
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 10px rgba(75, 29, 82, 0.18);
}

.bubble-player::after {
  content: "";
  position: absolute;
  bottom: 5px;
  right: -5px;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-left-color: var(--player-mauve-deep);
  border-bottom: 0;
  transform: rotate(-12deg);
}

.image-caption {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--magenta);
  margin-bottom: 6px;
  padding-left: 4px;
}

.image-bubble {
  max-width: 78%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(75, 29, 82, 0.15);
  border: 1px solid rgba(219, 39, 119, 0.12);
}

.image-bubble img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.typing-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 8px;
}

.typing-indicator {
  background: linear-gradient(160deg, var(--bubble-in), #f8f0f5);
  border: 1px solid var(--bubble-in-edge);
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--magenta-muted);
  animation: bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Choices — solid plum panel, gradient pill buttons */
.choice-panel {
  flex-shrink: 0;
  padding: 18px 16px max(22px, env(safe-area-inset-bottom, 0px));
  background: var(--plum-footer);
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
}

.choice-panel[hidden] {
  display: none !important;
}

.choice-prompt {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, sans-serif;
  font-style: italic;
  font-weight: 500;
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 14px;
  color: var(--white);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-btn {
  appearance: none;
  border: 2px solid rgba(15, 3, 20, 0.65);
  border-radius: 999px;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(
    90deg,
    #9d174d 0%,
    var(--magenta) 38%,
    #e11d48 62%,
    var(--orange-accent) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 4px 0 #2d0a18,
    0 6px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.choice-btn:hover:not(:disabled) {
  filter: brightness(1.05) saturate(1.05);
}

.choice-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 2px 0 #2d0a18,
    0 3px 10px rgba(0, 0, 0, 0.3);
}

.choice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Ending overlay */
.ending-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(26, 5, 32, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.ending-overlay[hidden] {
  display: none !important;
}

.ending-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 100%;
}

#ending-canvas {
  width: min(360px, 92vw);
  height: auto;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.play-again {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--plum);
  background: linear-gradient(90deg, #fce7f3, #fda4af);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(251, 113, 133, 0.35);
}

.play-again:focus-visible {
  outline: 2px solid #fda4af;
  outline-offset: 3px;
}
