:root {
  --bg: #1d1b26;
  --bg-raised: #262331;
  --bg-deep: #15131c;
  --line: #36324a;
  --text: #f5efe2;
  --muted: #a7a2b6;
  --fabric: #efe6d2;
  --fabric-line: #ddd0b4;
  --fabric-ink: #3b2f24;
  --fabric-muted: #6e5f4e;
  --hole: #221813;
  --hole-edge: #9c7a52;
  --orange: #e76f51;
  --amber: #f4a261;
  --gold: #ffd166;
  --teal: #2a9d8f;
  --sage: #8ab17d;
  --mauve: #b5838d;
  --blue: #457b9d;
  --danger: #e63946;
  --calm: #7ec8e3;
  --display: "Bungee", "Rubik", ui-sans-serif, system-ui, sans-serif;
  --body: "Rubik", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

/* --- Header ---------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.02em;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(239, 230, 210, 0.15), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.nav {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--amber);
}

main {
  overflow: hidden;
}

/* --- Shared type ----------------------------------------------------------- */

.eyebrow,
.section-kicker {
  margin: 0 0 16px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 720px;
  margin-bottom: 24px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(42px, 6.4vw, 78px);
  line-height: 1;
  letter-spacing: 0.01em;
}

/* The logo, same as the game's title screen: an orange "PATCH" patch with a smaller
   blue "HOLD IT TOGETHER" patch sewn on under it. Sizes are in em so the whole logo
   scales from the one font-size on .logo. */
.logo {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0 0 30px;
  font-size: clamp(38px, 5vw, 58px);
}

.logo-main,
.logo-sub {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1;
  color: #fff;
  box-shadow: 0 0.09em 0 rgba(0, 0, 0, 0.35);
}

.logo-main {
  padding: 0.3em 0.42em 0.24em;
  border-radius: 0.2em;
  letter-spacing: 0.02em;
  background: var(--orange);
  outline: 0.045em dashed rgba(255, 255, 255, 0.8);
  outline-offset: -0.14em;
  transform: rotate(-3deg);
}

.logo-sub {
  position: relative;
  margin: -0.08em 0 0 0.95em;
  padding: 0.44em 0.66em 0.38em;
  border-radius: 0.32em;
  font-size: 0.32em;
  letter-spacing: 0.03em;
  background: var(--blue);
  outline: 0.09em dashed rgba(255, 255, 255, 0.8);
  outline-offset: -0.24em;
  transform: rotate(2.5deg);
}

.closer {
  text-align: center;
}

.closer-line {
  margin-bottom: 18px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 7vw, 88px);
  line-height: 1;
}

.closer-line span {
  color: var(--orange);
}

.closer p:last-child {
  margin: 0 auto;
  max-width: 560px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.6;
}

h1 .rip {
  color: var(--danger);
}

h2 {
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.lead {
  max-width: 640px;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.55;
}

.lead strong {
  color: var(--text);
}

/* --- Buttons ---------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  color: #fff;
  background: var(--orange);
  box-shadow: 0 4px 0 #a9472f, 0 16px 30px rgba(231, 111, 81, 0.25);
}

.button.primary:hover {
  background: #ec7d61;
}

.button.primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a9472f;
}

.button.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button.secondary {
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.button.secondary:hover {
  border-color: var(--amber);
}

/* --- Hero ------------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 64px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}

.hero-actions,
.store-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.store-badges {
  gap: 12px;
  margin-top: 28px;
}

.store-badges a {
  display: block;
  line-height: 0;
  border-radius: 8px;
  transition: transform 0.15s ease;
}

.store-badges a:hover {
  transform: translateY(-2px);
}

.store-badges img {
  height: 48px;
  width: auto;
}

/* The little live board in the hero. */
.demo {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(100%, 380px);
  margin: 0 auto;
  padding: 18px;
  border-radius: 36px;
  background: var(--bg-deep);
  box-shadow: 0 0 0 10px #0d0c12, 0 40px 80px rgba(0, 0, 0, 0.45);
}

.demo-hud {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* Matches the in-game HUD: big score left, BEST right, one bar underneath. */
.demo-hud .score {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.demo-hud .best {
  font-size: 13px;
  font-weight: 700;
  color: #8f8a9e;
}

.meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width 0.25s ease;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: #8f8a9e;
}

.demo.calm .meter-labels {
  color: var(--calm);
}

/* The board itself is drawn on a canvas by demo.js, the same way the app draws it. */
.board {
  position: relative;
  aspect-ratio: 8.2222 / 10.2222;
}

.board canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.board-banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-family: var(--display);
  font-size: 30px;
  text-align: center;
  line-height: 1.05;
  color: #fff;
  background: rgba(230, 57, 70, 0.82);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.board-banner.show {
  opacity: 1;
}

.board-banner.calm-banner {
  background: rgba(69, 123, 157, 0.75);
}

.demo-caption {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* --- Sections --------------------------------------------------------------- */

.section,
.legal-page {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.section {
  padding-top: 80px;
  padding-bottom: 80px;
  border-top: 1px solid var(--line);
}

.section-head {
  max-width: 760px;
  margin-bottom: 40px;
}

.section-head p {
  color: var(--muted);
  font-size: 19px;
  line-height: 1.6;
}

/* Fabric cards: the cream, gridded cloth from the game. */
.fabric {
  color: var(--fabric-ink);
  background-color: var(--fabric);
  background-image:
    linear-gradient(var(--fabric-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--fabric-line) 1px, transparent 1px);
  background-size: 24px 24px;
  border-radius: 14px;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.how-grid li {
  position: relative;
  padding: 26px 24px 28px;
  counter-increment: step;
}

.how-grid li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 22px;
  border-radius: 8px;
  font-family: var(--display);
  font-size: 18px;
  color: #fff;
  background: var(--chip, var(--orange));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55);
}

.how-grid li:nth-child(2) {
  --chip: var(--amber);
}

.how-grid li:nth-child(3) {
  --chip: var(--teal);
}

.how-grid li:nth-child(4) {
  --chip: var(--blue);
}

.how-grid li:nth-child(5) {
  --chip: var(--danger);
}

.how-grid h3 {
  margin-bottom: 10px;
  font-size: 21px;
  font-weight: 800;
}

.how-grid p {
  margin: 0;
  color: var(--fabric-muted);
  line-height: 1.55;
}

/* Panic list */
.panic {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.panic-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.panic-list li {
  display: grid;
  gap: 6px;
  padding: 20px 22px;
  border-radius: 12px;
  background: var(--bg-raised);
  border-left: 5px solid var(--danger);
}

.panic-list li:nth-child(odd) {
  transform: rotate(-0.4deg);
}

.panic-list li:nth-child(even) {
  transform: rotate(0.35deg);
}

.panic-list strong {
  font-size: 19px;
}

.panic-list span {
  color: var(--muted);
  line-height: 1.5;
}

/* Calm callout */
.calm-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 40px;
  align-items: center;
  padding: 40px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(126, 200, 227, 0.16), rgba(69, 123, 157, 0.12));
  border: 1px solid rgba(126, 200, 227, 0.35);
}

.calm-card h2 {
  color: var(--calm);
}

.calm-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.ladder {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ladder li {
  display: grid;
  place-items: end center;
  width: 64px;
  padding-bottom: 10px;
  border-radius: 8px 8px 4px 4px;
  font-weight: 800;
  font-size: 15px;
  color: #10202a;
  background: var(--calm);
}

.ladder li span {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(16, 32, 42, 0.7);
  text-align: center;
}

/* Credits */
/* Achievements and leaderboards (Game Center / Google Play Games). */
.boards,
.achievements {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.boards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.achievements {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.boards li,
.achievements li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.boards li {
  border-color: rgba(255, 209, 102, 0.35);
}

.boards img,
.achievements img,
.secret-icon {
  flex: none;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--line);
}

.boards img {
  width: 64px;
  height: 64px;
}

.achievements img,
.secret-icon {
  width: 72px;
  height: 72px;
}

.boards div,
.achievements li > div:last-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.boards strong,
.achievements strong {
  font-size: 17px;
  font-weight: 800;
}

.boards span,
.achievements span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.achievements em {
  justify-self: start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255, 209, 102, 0.12);
}

.secret-icon {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 34px;
  color: var(--muted);
  background: var(--bg-deep);
  border: 2px dashed var(--line);
  box-shadow: none;
}

.credits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.credits article {
  padding: 30px;
}

.credits article.wide {
  grid-column: 1 / -1;
}

.credits h3 {
  margin-bottom: 18px;
  font-size: 22px;
  font-weight: 800;
}

.credit-list {
  display: grid;
  gap: 14px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.credit-list li {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 1px var(--fabric-line);
}

.credit-list strong {
  font-size: 17px;
}

.credit-list span {
  color: var(--fabric-muted);
  font-size: 14px;
}

.credits p {
  margin: 0;
  color: var(--fabric-muted);
  font-size: 14px;
  line-height: 1.6;
}

.credits a {
  color: #b14a30;
  font-weight: 700;
}

.credits a:hover {
  text-decoration: underline;
}

/* --- Footer ----------------------------------------------------------------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 42px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  border-top: 1px solid var(--line);
}

.site-footer a {
  color: var(--amber);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

/* --- Legal / support pages ---------------------------------------------------- */

.legal-page {
  padding-top: 48px;
  padding-bottom: 86px;
}

.legal-hero {
  max-width: 860px;
  margin-bottom: 32px;
}

.legal-hero h1 {
  font-size: clamp(36px, 5vw, 60px);
}

.legal-hero .lead {
  font-size: 19px;
  line-height: 1.65;
}

.updated {
  color: var(--muted);
  font-weight: 700;
}

.legal-card {
  max-width: 900px;
  margin: 18px 0;
  padding: 30px;
  border-radius: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
}

.legal-card h2 {
  margin-bottom: 14px;
  font-size: 25px;
}

.legal-card p,
.legal-card li {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.legal-card ul {
  margin: 0 0 16px;
  padding-left: 22px;
}

.legal-card p:last-child {
  margin-bottom: 0;
}

.legal-card strong {
  color: var(--text);
}

.legal-card a,
.inline-link {
  color: var(--amber);
  font-weight: 700;
}

.legal-card a:hover,
.inline-link:hover {
  text-decoration: underline;
}

/* Support form */
.support-form {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg-deep);
}

.field textarea {
  resize: vertical;
  min-height: 150px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
  border-color: transparent;
}

.field-hint {
  color: var(--muted);
  font-size: 14px;
}

.support-form .button {
  justify-self: start;
}

.form-status {
  min-height: 1.5em;
  margin: 0;
  font-weight: 700;
}

.form-status.success {
  color: var(--sage);
}

.form-status.error {
  color: #ff7b85;
}

.legal-card .form-legal {
  font-size: 14px;
}

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

/* --- Responsive ----------------------------------------------------------------- */

@media (max-width: 920px) {
  .hero,
  .panic {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .calm-card {
    grid-template-columns: 1fr;
  }

  .achievements {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .how-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .credits {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .boards,
  .achievements {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 16px;
  }

  .nav {
    flex-wrap: wrap;
    gap: 16px;
  }

  .hero {
    padding: 28px 16px 64px;
  }

  .how-grid {
    grid-template-columns: 1fr;
  }

  .section,
  .legal-page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .section {
    padding-top: 56px;
    padding-bottom: 56px;
  }

  .lead {
    font-size: 18px;
  }

  .calm-card,
  .legal-card,
  .credits article {
    padding: 22px;
  }

  .ladder li {
    width: 52px;
  }

  .site-footer {
    padding: 24px 16px 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Licenses page ------------------------------------------------------------ */

.license-text {
  max-height: 360px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 16px;
  border-radius: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--muted);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.legal-card details {
  margin: 10px 0;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.legal-card summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.legal-card details[open] summary {
  margin-bottom: 4px;
}

.component-list {
  display: grid;
  gap: 14px;
  list-style: none;
  padding-left: 0 !important;
}

.component-list strong {
  display: block;
}

.copyright-lines {
  margin: 4px 0 2px !important;
  padding-left: 0 !important;
  list-style: none;
}

.copyright-lines li,
.license-id {
  margin: 0;
  font-size: 14px !important;
  line-height: 1.5 !important;
  overflow-wrap: anywhere;
}

.legal-card details.all-notices {
  padding: 16px 20px;
}

.all-notices .component-list {
  margin-top: 18px;
}

.all-notices h3 {
  margin: 28px 0 8px;
  font-size: 20px;
}
