:root {
  --imessage-blue: #007aff;
  --friend-gray: #e9e9eb;
  --screen: #f6f6f7;
  --ink: #111;
  --muted: #777;
  --line: #dedee3;
  --danger: #ff3b30;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 18px;
  color: var(--ink);
  background: #d7d9df;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(100%, 980px);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 430px);
  align-items: center;
  gap: 52px;
}

.story-panel {
  max-width: 440px;
}

.logo-note {
  margin: 0 0 20px;
}

.story-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 7px;
  border-radius: 8px;
  background: #fff;
}

.logo-note figcaption {
  color: #5c616b;
  font-size: 0.78rem;
  line-height: 1.3;
}

.story-kicker {
  margin: 0 0 10px;
  color: #5c616b;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.story-panel h1 {
  margin: 0 0 18px;
  font-size: 2.35rem;
  line-height: 1;
  letter-spacing: 0;
}

.story-panel p {
  margin: 0 0 14px;
  color: #33363d;
  font-size: 1.03rem;
  line-height: 1.55;
}

.phone-shell {
  width: min(100%, 430px);
  min-height: min(760px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: var(--screen);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
}

.chat-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: 36px 42px 1fr 36px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 249, 249, 0.92);
  backdrop-filter: blur(18px);
}

.back-button,
.reset-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  color: var(--imessage-blue);
  background: transparent;
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.reset-button {
  font-size: 1.1rem;
}

.friend-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  background: #fff;
}

.friend-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.chat-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.messages {
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 10px;
  padding: 16px 10px 18px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hidden {
  display: none;
}

.bubble {
  width: fit-content;
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.28;
  word-break: break-word;
}

.friend {
  align-self: flex-start;
  background: var(--friend-gray);
  color: var(--ink);
}

.you {
  align-self: flex-end;
  background: var(--imessage-blue);
  color: #fff;
}

textarea {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  padding: 8px 0 0;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0;
  outline: none;
  resize: none;
  color: var(--ink);
  background: transparent;
}

textarea::placeholder {
  color: #8e8e93;
}

.picker-bubble,
.number-bubble {
  width: 100%;
  max-width: 100%;
}

.odds-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.odds-line span,
.mini-label {
  opacity: 0.88;
  font-size: 0.82rem;
  font-weight: 700;
}

.odds-line strong {
  font-size: 1.5rem;
}

input[type="range"] {
  width: 100%;
  height: 24px;
  margin-top: 4px;
  padding: 0;
  accent-color: #fff;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin-top: 7px;
}

.number-grid button {
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.number-grid button[aria-pressed="true"] {
  color: var(--imessage-blue);
  background: #fff;
}

.number-grid button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.send-button,
.plain-button {
  align-self: flex-end;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

.send-button {
  color: #fff;
  background: var(--imessage-blue);
}

.plain-button {
  color: var(--imessage-blue);
  background: transparent;
}

.small-note {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}

.result-bubble {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}

.result-bubble img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

#result-title {
  font-size: 1rem;
}

#result-values {
  opacity: 0.9;
  font-size: 0.82rem;
}

.confetti {
  position: absolute;
  top: -10px;
  width: 7px;
  height: 10px;
  border-radius: 2px;
  opacity: 0;
  animation: fall 1500ms ease-in forwards;
}

@keyframes fall {
  0% {
    transform: translateY(-12px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(160px) rotate(240deg);
    opacity: 0;
  }
}

@media (max-width: 760px) {
  .page-shell {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 22px;
  }

  .story-panel {
    max-width: 560px;
    padding-top: 10px;
  }

  .phone-shell {
    justify-self: center;
  }
}

@media (max-width: 430px) {
  body {
    padding: 0;
    background: var(--screen);
  }

  .page-shell {
    min-height: 100vh;
    display: block;
  }

  .story-panel {
    padding: 28px 18px 22px;
    background: #d7d9df;
  }

  .story-panel h1 {
    font-size: 2rem;
  }

  .phone-shell {
    min-height: 100vh;
    border: 0;
    box-shadow: none;
  }

  .bubble {
    max-width: 88%;
  }

  .picker-bubble,
  .number-bubble {
    max-width: 100%;
  }
}
