:root {
  --ink: #111111;
  --yellow: #ffe600;
  --pink: #ff1f8f;
  --cyan: #00e5ff;
  --lime: #d4ff00;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", Verdana, system-ui, sans-serif;
  color: var(--ink);
  background: repeating-linear-gradient(
    -45deg,
    #ff9500 0 28px,
    #ff1e8a 28px 56px
  );
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}

button,
select,
textarea {
  touch-action: manipulation;
}

/* Only allow text selection on real user/info text */
#message,
.message-text,
.safety-notice,
.error,
.dialog__box p,
.dialog__box li {
  -webkit-user-select: text;
  user-select: text;
}

/* Decorative layers never catch clicks or drags */
.ticker,
.mascot,
.hero-art,
.orbit,
.sparkle,
.header__sticker--star,
.header__sticker--bolt {
  pointer-events: none;
  -webkit-user-drag: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell {
  max-width: 560px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-left: 4px solid var(--ink);
  border-right: 4px solid var(--ink);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.18), 0 20px 50px rgba(0, 0, 0, 0.45);
  background: var(--ink);
  overflow-x: clip;
}

/* Calm Marquee Ticker */
.ticker {
  overflow: hidden;
  background: var(--ink);
  color: var(--lime);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: max(6px, env(safe-area-inset-top)) 0 6px;
  border-bottom: 2px solid #2b2b2b;
  display: flex;
}
.ticker span {
  white-space: nowrap;
  flex-shrink: 0;
  animation: marquee 42s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
  background: var(--yellow);
  border-bottom: 4px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.brand__text {
  min-width: 0;
}

.mascot {
  position: relative;
  flex-shrink: 0;
  transform: rotate(-6deg);
}
.mascot--sm { width: 48px; height: 48px; }
.mascot--lg {
  width: 112px;
  height: 112px;
  filter: drop-shadow(5px 6px 0 var(--ink));
}
.mascot__svg { width: 100%; height: 100%; display: block; }

.acc { display: none; }
body[data-persona="billy"] .acc--billy,
body[data-persona="emma"]  .acc--emma,
body[data-persona="jason"] .acc--jason { display: inline; }

.header__sticker--star,
.header__sticker--bolt {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--cyan);
  -webkit-text-stroke: 1.5px var(--ink);
  z-index: 2;
}
.header__sticker--star { top: -8px; right: -6px; }
.header__sticker--bolt { bottom: -8px; left: -6px; }

.logo {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 0.95;
  color: var(--yellow);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--pink), 5px 5px 0 var(--ink);
}

.header__tag {
  margin: 4px 0 0;
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--ink);
  color: var(--yellow);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ctrl {
  font: inherit;
  font-weight: 900;
  font-size: 0.8rem;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 2px 3px 0 var(--ink);
  cursor: pointer;
  height: 38px;
  padding: 0 10px;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.ctrl:active { transform: translate(2px, 2px); box-shadow: none; }
.ctrl--select {
  appearance: none;
  background-color: var(--cyan);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 52%,
    calc(100% - 9px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  border-radius: 999px;
  padding: 0 24px 0 10px;
}
.ctrl--help { background: var(--yellow); width: 38px; padding: 0; font-size: 1rem; }
.ctrl--reset { background: var(--pink); color: #fff; width: 38px; padding: 0; font-size: 1.05rem; }

/* Rainbow Memphis Stage */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px calc(14px + env(safe-area-inset-right)) 20px calc(14px + env(safe-area-inset-left));
  background-image:
    url("/confetti.svg"),
    linear-gradient(168deg, #a815ff 0%, #ff2985 44%, #ff7b29 78%, #b8ef35 100%);
  background-size: 180px 180px, 100% 100%;
  overflow-x: clip;
}

.welcome {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.hero-art {
  position: relative;
  padding: 12px 28px;
}

.sparkle {
  position: absolute;
  color: var(--yellow);
  font-size: 1.6rem;
  -webkit-text-stroke: 2px var(--ink);
  z-index: 2;
}
.sparkle--tr { top: -8px; right: -8px; }
.sparkle--bl { bottom: -6px; left: -10px; }

.orbit {
  position: absolute;
  font-size: 1.45rem;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.55));
}
.orbit--1 { top: -2px; left: 2px; }
.orbit--2 { top: 8px; right: -4px; }
.orbit--3 { bottom: 4px; left: -4px; }
.orbit--4 { bottom: -4px; right: 2px; }

/* Fighter-Select Persona Pills */
.persona-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}

.tab {
  font: inherit;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  padding: 7px 11px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 80ms ease;
}
.tab:active { transform: translate(1px, 2px); box-shadow: none; }
.tab[aria-pressed="true"] {
  background: var(--yellow);
  transform: translate(-1px, -2px) rotate(-2deg);
  box-shadow: 3px 4px 0 var(--ink);
}

.welcome__title {
  margin: 2px 0 0;
  font-size: clamp(1.65rem, 7vw, 2.55rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--yellow);
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 var(--ink);
  transform: rotate(-2deg);
}

.arcade-card {
  background: var(--ink);
  border: 3px solid #fff;
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--cyan), 8px 8px 0 var(--ink);
  padding: 12px 16px;
  max-width: min(390px, calc(100% - 12px));
  transform: rotate(1deg);
}

.welcome__sub {
  margin: 0;
  color: var(--lime);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.42;
}

.chips-wrap {
  margin-top: 4px;
  width: 100%;
  max-width: 440px;
}

.chips__kicker {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.chip {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 8px 13px;
  max-width: calc(100% - 8px);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 90ms ease, background 90ms ease;
}
.chip:nth-child(odd) { transform: rotate(-1deg); }
.chip:nth-child(even) { transform: rotate(1deg); }
.chip:active {
  background: var(--yellow);
  transform: translate(2px, 2px) rotate(0deg);
  box-shadow: none;
}

/* Conversation & Subtle Stamp Animation */
.conversation { flex: 1; display: flex; flex-direction: column; }
.conversation[hidden], .welcome[hidden], .error[hidden] { display: none; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-top: auto;
  padding: 10px 6px 26px 16px;
}

.message {
  align-self: flex-end;
  position: relative;
  max-width: min(84%, 430px);
  background: #fff;
  border: 3.5px solid var(--ink);
  border-radius: 20px 20px 4px 20px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 12px 16px 20px 18px;
  scroll-margin-bottom: 130px;
  animation: bubble-in 160ms ease-out;
}

@keyframes bubble-in {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.35;
}

.thinking,
.reaction {
  position: absolute;
  left: -10px;
  bottom: -22px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  line-height: 1.2;
}

/* Quiet breathing dots while waiting */
.thinking {
  background: #fff;
  color: var(--ink);
  padding: 4px 11px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  animation: pulse-dots 900ms ease-in-out infinite;
}

@keyframes pulse-dots {
  0%, 100% { opacity: 0.55; transform: scale(0.96); }
  50%      { opacity: 1; transform: scale(1); }
}

/* Single crisp pop when the emoji lands */
.reaction {
  background: var(--yellow);
  padding: 3px 11px;
  font-size: 1.35rem;
  cursor: help;
  transform: rotate(-5deg);
  animation: pop-in 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  from { transform: scale(0.55) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(-5deg); opacity: 1; }
}

.safety-notice {
  margin: 0;
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 14px;
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  scroll-margin-bottom: 130px;
}

.error {
  margin: 0;
  padding: 9px 14px;
  background: var(--yellow);
  color: var(--ink);
  border-top: 3px solid var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
  text-align: center;
}

/* Electric Cyan Composer Bar */
.composer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 10px calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  background: var(--cyan);
  border-top: 4px solid var(--ink);
}

.composer__row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#message {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem; /* >=16px prevents iOS Safari auto-zoom */
  font-weight: 700;
  line-height: 1.3;
  padding: 10px 14px;
  border: 3.5px solid var(--ink);
  border-radius: 22px;
  background: #fff;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.08);
  resize: none;
  field-sizing: content;
  max-height: 110px;
}
#message:focus {
  outline: none;
  background: #fffef5;
  box-shadow: 0 0 0 3px var(--yellow);
}

.send-btn {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--pink);
  border: 3.5px solid var(--ink);
  border-radius: 999px;
  padding: 11px 18px;
  box-shadow: 3px 4px 0 var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.send-btn:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: none; }
.send-btn:disabled { opacity: 0.65; cursor: wait; }

.privacy {
  margin: 8px auto 0;
  width: fit-content;
  max-width: 100%;
  background: var(--ink);
  color: var(--lime);
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1.3;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 14px;
  text-align: center;
}

/* Info Modal */
.dialog {
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 8px 8px 0 var(--cyan), 12px 12px 0 var(--ink);
  padding: 0;
  max-width: 420px;
  width: calc(100vw - 28px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.dialog__box { padding: 20px; background: var(--yellow); }
.dialog__title {
  margin: 0 0 10px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--pink);
}
.dialog__box p, .dialog__box ul { font-size: 0.9rem; font-weight: 700; line-height: 1.45; }
.dialog__box ul { padding-left: 18px; }

/* Hover effects strictly on devices with a real pointer */
@media (hover: hover) {
  .tab:hover { background: var(--cyan); }
  .chip:hover {
    background: var(--yellow);
    transform: scale(1.02) rotate(0deg);
  }
  .send-btn:hover:not(:disabled) { background: #ff0077; }
}

/* Full-bleed shell & compact proportions on phones */
@media (max-width: 560px) {
  .shell {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  .ctrl--select {
    font-size: 1rem; /* >=16px prevents iOS Safari zoom on <select> */
  }
  .stage {
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .welcome {
    gap: 10px;
  }
  .mascot--lg {
    width: 92px;
    height: 92px;
  }
}

@media (max-width: 400px) {
  .header {
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
    gap: 6px;
  }
  .brand { gap: 8px; }
  .logo { font-size: 1.32rem; }
  .mascot--sm { width: 38px; height: 38px; }
  .header__tag { font-size: 0.58rem; padding: 2px 6px; }
  .ctrl--select { font-size: 1rem; padding: 0 21px 0 8px; }
  .ctrl--help, .ctrl--reset { width: 36px; height: 36px; }
  .send-btn { padding: 11px 13px; font-size: 0.84rem; }
}

/* Keep welcome screen comfortable on shorter mobile viewports / in-app browsers */
@media (max-height: 720px) {
  .welcome { gap: 8px; }
  .hero-art { padding: 6px 24px; }
  .mascot--lg { width: 80px; height: 80px; }
  .arcade-card { padding: 9px 13px; }
  .welcome__sub { font-size: 0.82rem; line-height: 1.34; }
  .chip { padding: 6px 11px; font-size: 0.76rem; }
}

@media (prefers-reduced-motion: reduce) {
  .ticker,
  .header__sticker--star,
  .header__sticker--bolt {
    display: none !important;
  }
  .message, .thinking, .reaction {
    animation: none !important;
  }
}