/* TROLLEY. — paper, ink, one rose accent. Shantell speaks, Space Mono keeps the record. */

:root {
  --gutter: clamp(16px, 4vw, 44px);
  --paper: #f2ecdd;
  --paper-raise: rgba(255, 255, 255, 0.35);
  --ink: #2c2a25;
  --faded: #6d675c;
  --rose: #c05a48;
  --rose-deep: #a34a3a;
  --sky: #a8bfce;
  --sage: #adbfa5;
  --mustard: #d9b959;
  --blush: #dcb0b4;
  --lilac: #b3a9c9;
  --hand: 'Shantell Sans', 'Trebuchet MS', sans-serif;
  --mono: 'Space Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: clip; }

/* A canvas is sized in JS; this guarantees it can never widen the page even
   if a measurement is stale. */
canvas { max-width: 100%; }

body {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.17 0 0 0 0 0.16 0 0 0 0 0.13 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--mono);
  min-height: 100vh;
}

.rose { color: var(--rose); }
.vs { font-size: 0.72em; color: var(--faded); font-family: var(--hand); }
.fine { font-size: 11px; letter-spacing: 1.5px; color: var(--faded); }
.center { text-align: center; }
.mono-note { font-size: 12px; letter-spacing: 2px; color: var(--faded); }

a { color: var(--rose); text-decoration: none; }
.navlink { color: var(--ink); font-size: 13px; letter-spacing: 1px; border-bottom: 2px solid rgba(192, 90, 72, 0.4); padding-bottom: 1px; }

/* ------------------------------------------------------------- chrome */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 44px) 8px;
  max-width: 1280px; margin: 0 auto;
}
.wordmark { font-family: var(--hand); font-weight: 700; font-size: 26px; letter-spacing: 0.5px; color: var(--ink); }
.topnav { display: flex; align-items: center; gap: 24px; }

.page { max-width: 1280px; margin: 0 auto; padding: 8px var(--gutter) 40px; }

.foot {
  text-align: center; font-size: 10px; letter-spacing: 1.5px; color: var(--faded);
  padding: 18px 16px 26px;
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--hand); font-weight: 700; font-size: 16px;
  border: 2.4px solid var(--ink); border-radius: 14px;
  background: var(--paper); color: var(--ink);
  padding: 11px 26px; cursor: pointer;
  transform: rotate(-0.4deg);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:nth-child(even) { transform: rotate(0.4deg); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: rotate(0deg) translateY(-1px); }
  .card:hover { box-shadow: 3px 4px 0 rgba(44, 42, 37, 0.5); }
    }
.btn:active { transform: scale(0.97); }
.card:active { box-shadow: 3px 4px 0 rgba(44, 42, 37, 0.5); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; }

.btn-rose { background: var(--rose); color: var(--paper); box-shadow: 3px 4px 0 rgba(44, 42, 37, 0.85); }
.btn-ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-ghost { background: var(--paper); }
.btn-big { font-size: 19px; padding: 13px 30px; }
.btn-small { font-size: 14px; padding: 8px 18px; border-radius: 12px; flex-direction: row; }
.btn .icon { width: 18px; height: 18px; margin-right: 8px; }
.btn-rose .icon, .btn-ghost .icon { vertical-align: -3px; }
.btn { flex-direction: row; }
.btn-decide { flex-direction: column; min-width: 220px; padding: 13px 30px; }
.btn-decide .btn-title { font-size: 19px; }
.btn-decide .btn-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; font-weight: 400; opacity: 0.8; }

/* --------------------------------------------------------------- home */

.hero { display: flex; align-items: center; gap: 40px; padding-top: 12px; }
.hero-copy { flex: 1; min-width: 280px; }
.hero h1 { font-family: var(--hand); font-weight: 700; font-size: clamp(34px, 4.6vw, 52px); line-height: 1.12; margin: 0 0 14px; }
.hero .mono-note { line-height: 2; }
.hero-ctas { display: flex; gap: 16px; margin-top: 22px; flex-wrap: wrap; }
.hero .fine { margin-top: 12px; }
.hero-art { flex: 1.1; min-width: 0; }
.hero-art canvas { display: block; width: 100%; }

.today {
  display: flex; align-items: center; gap: 22px; margin: 26px 0 6px;
  border: 2.4px solid var(--ink); border-radius: 16px; padding: 14px 22px;
  background: rgba(217, 185, 89, 0.16); transform: rotate(-0.2deg); color: var(--ink);
}
.today-tag { font-size: 10px; letter-spacing: 2px; font-weight: 700; color: var(--rose); line-height: 1.5; }
.today-line { font-family: var(--hand); font-size: 20px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.faceit { font-family: var(--hand); font-weight: 700; font-size: 14px; color: var(--rose); }

.feed { margin-top: 26px; }
.feed-head { display: flex; align-items: baseline; gap: 14px; margin: 22px 0 12px; }
.feed-head h2 { font-size: 12px; letter-spacing: 3px; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.card {
  border: 2.4px solid var(--ink); border-radius: 16px; padding: 16px 18px;
  background: var(--paper-raise); color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
}
.card-glyph { display: block; }
.card-line { font-family: var(--hand); font-size: 17px; line-height: 1.35; flex: 1; overflow-wrap: anywhere; }
.card-meta { display: flex; justify-content: space-between; align-items: baseline; }
.chip-rose { font-size: 10px; letter-spacing: 1px; color: var(--rose); border: 1.6px solid var(--rose); border-radius: 8px; padding: 2px 8px; }

/* --------------------------------------------------------------- play */

.play { display: flex; flex-direction: column; }
.prompt { text-align: center; padding: 4px 12px 0; }
.prompt-line { font-family: var(--hand); font-weight: 500; font-size: clamp(19px, 2.4vw, 26px); margin: 0 0 6px; overflow-wrap: anywhere; }
.scene-wrap { width: 100%; }
.scene-wrap canvas { display: block; touch-action: pan-y; }

.decide {
  display: flex; align-items: center; justify-content: center; gap: 24px;
  padding: 8px 0 10px; flex-wrap: wrap;
}
.decide-note { text-align: center; }
.decide.decided { opacity: 0.45; }

.results { max-width: 720px; margin: 18px auto 0; padding-top: 8px; }
.stamp {
  display: inline-block; transform: rotate(-2deg);
  border: 3px solid var(--rose); outline: 2px solid rgba(192, 90, 72, 0.45); outline-offset: 5px;
  border-radius: 10px; padding: 10px 22px; margin: 6px 6px 14px;
  font-family: var(--hand); font-weight: 700; font-size: clamp(22px, 3vw, 30px); color: var(--rose); letter-spacing: 1px;
}
.bars { margin: 18px 0 8px; display: flex; flex-direction: column; gap: 16px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 12px; }
.bar-label { font-size: 11px; letter-spacing: 2px; font-weight: 700; }
.youre-here { font-family: var(--hand); color: var(--rose); font-weight: 500; letter-spacing: 0; text-transform: none; }
.bar-track { border: 2.4px solid var(--ink); border-radius: 12px; height: 34px; padding: 3px; background: var(--paper-raise); }
.bar-fill {
  height: 100%; width: 0; border-radius: 8px; min-width: 12px;
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar-rose { background: repeating-linear-gradient(-65deg, var(--rose) 0 3px, transparent 3px 7px); }
.bar-ink { background: repeating-linear-gradient(-65deg, rgba(109, 103, 92, 0.9) 0 2px, transparent 2px 9px); }
.bar-pct { font-family: var(--hand); font-weight: 700; font-size: 24px; }
.majority { font-family: var(--hand); font-weight: 500; font-size: 22px; margin: 14px 0 4px; }
.pred { margin-top: 6px; line-height: 1.8; }
.result-actions { display: flex; align-items: center; gap: 18px; margin-top: 18px; flex-wrap: wrap; }
.me-link { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.me-avatar { flex-shrink: 0; }
.me-name { font-size: 12px; letter-spacing: 1px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.onboard { display: flex; align-items: center; justify-content: center; gap: 40px; padding: 32px 0 20px; flex-wrap: wrap; }
.onboard-art { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.onboard-art canvas { display: block; }
.onboard-form { width: 400px; max-width: 100%; }
.onboard-form h1 { font-family: var(--hand); font-weight: 700; font-size: clamp(30px, 4.4vw, 46px); line-height: 1.15; margin: 0 0 14px; }
.onboard-form .mono-note { line-height: 2; }
.name-field { margin-top: 4px; }
.name-field input {
  width: 100%; font-family: var(--hand); font-size: 24px; color: var(--ink);
  background: #fdfaf1; border: 2.4px solid var(--ink); border-radius: 14px; padding: 12px 18px;
}
.name-field input:focus { outline: 2px solid var(--rose); outline-offset: 3px; }
.name-field input::placeholder { color: var(--faded); opacity: 0.7; }
.onboard-form > .fine { margin-top: 8px; display: block; }
.onboard-actions { display: flex; align-items: center; gap: 18px; margin-top: 24px; flex-wrap: wrap; }
.onboard-actions .fine { line-height: 1.8; }
.me-status { margin-top: 10px; min-height: 16px; }
.onboard-foot { margin-top: 22px; display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.email-panel { margin-top: 16px; width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.email-row { display: flex; gap: 10px; width: 100%; }
.email-row input {
  flex: 1 1 0; width: 0; font-family: var(--hand); font-size: 16px; color: var(--ink);
  background: #fdfaf1; border: 2px solid var(--ink); border-radius: 12px; padding: 9px 14px;
}
.email-row input:focus { outline: 2px solid var(--rose); outline-offset: 2px; }
.onboard-form { display: flex; flex-direction: column; align-items: center; }
.onboard-form .name-field, .onboard-form .onboard-actions { width: 100%; }
.onboard-actions { justify-content: center; }

.who { border: 2.4px solid var(--ink); border-radius: 16px; padding: 16px 20px; background: var(--paper-raise); margin-top: 20px; }
.who-head { font-size: 11px; letter-spacing: 2.5px; font-weight: 700; margin-bottom: 12px; }
.who-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.who-col > .fine { margin-bottom: 8px; }
.who-list { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.who-empty { padding: 6px 0; }
.who-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 64px; }
.who-chip span { font-size: 10px; letter-spacing: 0.5px; color: var(--ink); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; border-top: 2px dashed rgba(109,103,92,.5); padding-top: 14px; }
.identity-row canvas { flex-shrink: 0; }
.identity-row input {
  flex: 1 1 0; min-width: 0; width: 0; font-family: var(--hand); font-size: 16px; color: var(--ink);
  background: #fdfaf1; border: 2px solid var(--ink); border-radius: 12px; padding: 9px 14px;
}
.identity-row input:focus { outline: 2px solid var(--rose); outline-offset: 2px; }

.report-row { margin-top: 22px; }
.report-link { color: var(--faded); border-bottom: 1px dotted var(--faded); }
.report-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-form input {
  flex: 1 1 0; width: 0; min-width: 160px; font-family: var(--hand); font-size: 16px; color: var(--ink);
  background: #fdfaf1; border: 2px solid var(--ink); border-radius: 10px; padding: 7px 12px;
}

.notfound { text-align: center; padding: 60px 0; }
.notfound h1 { font-family: var(--hand); font-size: 40px; }
.notfound .btn { margin-top: 18px; }

/* ------------------------------------------------------------- create */

.create-head h1 { font-family: var(--hand); font-weight: 700; font-size: clamp(26px, 3.4vw, 34px); margin: 4px 0 4px; }
.create-grid { display: flex; gap: 28px; margin-top: 16px; align-items: flex-start; }
.preview-panel {
  flex: 1.3; min-width: 0; border: 2.4px solid var(--ink); border-radius: 18px;
  background: var(--paper-raise); padding: 12px 14px 6px; position: sticky; top: 12px;
}
.preview-tag { margin-bottom: 4px; }
.preview-panel canvas { display: block; width: 100%; }
.hand-note { font-family: var(--hand); font-size: 13px; letter-spacing: 0; text-align: center; padding: 6px 0 8px; }

.composer { flex: 1; min-width: 300px; display: flex; flex-direction: column; gap: 16px; }
.track-panel { border: 2.4px solid var(--ink); border-radius: 16px; padding: 14px 18px; background: var(--paper-raise); }
.track-panel-rose { border-color: var(--rose); background: rgba(192, 90, 72, 0.06); }
.panel-title { font-size: 11px; letter-spacing: 2.5px; font-weight: 700; margin-bottom: 10px; }
.entity-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.empty-track { padding: 2px 0; }
.entity-chip {
  display: flex; align-items: center; gap: 12px;
  border: 2px solid var(--ink); border-radius: 12px; padding: 7px 12px; background: var(--paper);
}
.entity-chip:nth-child(odd) { transform: rotate(-0.3deg); }
.entity-chip:nth-child(even) { transform: rotate(0.3deg); }
.entity-dot { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; opacity: 0.9; }
.entity-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.entity-label { font-family: var(--hand); font-size: 15px; overflow-wrap: anywhere; }
.entity-x {
  background: none; border: none; font-size: 20px; color: var(--faded); cursor: pointer;
  font-family: var(--mono); min-width: 44px; min-height: 44px; margin: -8px -6px -8px 0;
  display: flex; align-items: center; justify-content: center;
}
.add-row { display: flex; gap: 10px; }
.add-row input, .name-row input {
  flex: 1 1 0; min-width: 0; width: 0; font-family: var(--hand); font-size: 16px; color: var(--ink);
  background: #fdfaf1; border: 2px solid var(--ink); border-radius: 12px; padding: 9px 14px;
}
.add-row input::placeholder, .name-row input::placeholder { color: var(--faded); opacity: 0.8; }
.add-row input:focus, .name-row input:focus { outline: 2px solid var(--rose); outline-offset: 2px; }

.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.slider-row input[type='range'] { flex: 1; accent-color: var(--rose); }
.slider-val { font-family: var(--hand); font-weight: 700; font-size: 17px; min-width: 44px; text-align: right; }
.name-row { margin-top: 12px; display: flex; }
.unlisted-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; }
.unlisted-row input { accent-color: var(--rose); width: 15px; height: 15px; }

.publish-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 22px; flex-wrap: wrap;
}
#btn-publish { box-shadow: 3px 4px 0 rgba(192, 90, 72, 0.9); }

.live { text-align: center; padding: 40px 0; }
.live .mono-note { margin: 10px 0 22px; }
.link-box {
  display: inline-flex; align-items: center; gap: 14px;
  border: 2.4px solid var(--ink); border-radius: 14px; padding: 10px 16px; background: #fdfaf1;
  max-width: 100%;
}
.link-text { font-size: 13px; letter-spacing: 0.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live .result-actions { justify-content: center; margin-top: 26px; }
.live .fine { margin-top: 26px; }

/* --------------------------------------------------------- responsive */

@media (max-width: 900px) {
  /* copy leads at every width below desktop — the art supports it */
  .hero { flex-direction: column; gap: 10px; }
  .create-grid { flex-direction: column; }
  .preview-panel { position: static; width: 100%; }
}

@media (max-width: 640px) {
  /* Header: the wordmark keeps the line to itself; actions sit beside it,
     each a real 44px target rather than a cramped text link. */
  .topbar { padding: 14px 16px 6px; gap: 10px; }
  .wordmark { font-size: 22px; }
  .topnav { gap: 12px; }
  .topnav .navlink {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px;
    border-bottom: none; font-size: 12px; letter-spacing: 1.5px;
  }
  .topnav .btn-small { padding: 12px 14px; font-size: 13px; white-space: nowrap; min-height: 44px; }
  .wordmark { display: inline-flex; align-items: center; min-height: 44px; }

  /* comfortable targets for the small controls */
  .unlisted-row { min-height: 44px; }
  .unlisted-row input { width: 22px; height: 22px; }
  .slider-row input[type='range'] { height: 44px; }
  .report-link, .result-actions .navlink {
    display: inline-block; padding: 12px 2px;
  }

  .page { --gutter: 16px; padding: 6px var(--gutter) 32px; }

  /* Lead with the words on a phone — the art follows, not the other way round. */
  .hero { flex-direction: column; gap: 6px; }
  .hero-copy { width: 100%; }
  .hero h1 { font-size: 34px; }
  .hero-ctas { gap: 10px; }
  .hero-ctas .btn { flex: 1; min-width: 0; padding: 14px 12px; text-align: center; }
  .hero-art { width: 100%; }

  .today { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .today-line { font-size: 18px; flex-basis: 100%; }
  .cards { grid-template-columns: 1fr; gap: 14px; }

  .prompt-line { font-size: 20px; }
  .decide { gap: 10px; flex-direction: column; }
  .btn-decide { min-width: 0; width: 100%; min-height: 56px; }
  .decide-note { order: 3; }
  .bar-row { grid-template-columns: 84px 1fr 48px; gap: 8px; }
  .bar-label { font-size: 10px; letter-spacing: 1px; }
  .stamp { font-size: 22px; padding: 9px 16px; margin-left: 0; }
  .result-actions { gap: 12px; }
  .result-actions .btn { flex: 1; justify-content: center; }
  .publish-bar { flex-direction: column; align-items: stretch; gap: 12px; }
  .publish-bar .btn { width: 100%; justify-content: center; }
  .link-box { width: 100%; }
  .add-row .btn-small { min-height: 44px; }
  .onboard { gap: 24px; padding: 16px 0; }
  .onboard-actions .btn { flex: 1; justify-content: center; }
  .me-name { display: none; }
  .preview-panel { padding: 10px 10px 2px; }
  .create-grid { gap: 16px; }
  .hand-note { font-size: 12px; padding: 4px 0 6px; }
}

/* Keep the last controls clear of the home indicator on notched phones. */
@supports (padding: max(0px)) {
  .foot { padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 12px)); }
  .page { padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
  .btn { transition: none; }
}
