:root {
  --ink: #3b2550;
  --ink-soft: #6b5580;
  --bg1: #fff1f7;
  --bg2: #eaf4ff;
  --card-r: 22px;
  --gap: 10px;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, #ffe2f0 0, transparent 38%),
    radial-gradient(circle at 92% 30%, #dff0ff 0, transparent 40%),
    radial-gradient(circle at 30% 95%, #fff3d6 0, transparent 40%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  min-height: 100dvh;
}
.ttp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- picker ---------- */
random-express-nav { position: relative; z-index: 10000; }
.ttp-home {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 10px) calc(var(--sab) + 10px) calc(var(--sal) + 10px);
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ttp-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  /* Leave room for the floating Random.Express buttons on the left. */
  padding-left: 112px;
}
.ttp-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font: 700 clamp(18px, 4.6vw, 26px)/1 Fredoka, Nunito, sans-serif;
  color: var(--ink);
  letter-spacing: .01em;
  min-width: 0;
  flex: 1;
  position: relative;
}
.ttp-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttp-logo { width: 30px; height: 30px; flex: none; }
.ttp-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.ttp-ctl {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 2px 0 rgba(90, 50, 120, .12), 0 6px 16px rgba(90, 50, 120, .1);
  color: var(--ink);
  font: 700 15px/1 Nunito, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
.ttp-ctl svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ttp-ctl:focus-visible, .ttp-card:focus-visible, .ttp-exit:focus-visible, .ttp-vol input:focus-visible { outline: 3px solid #7a4cff; outline-offset: 3px; }
.ttp-mute .spk { fill: currentColor; stroke: none; }
.ttp-mute .cross { display: none; }
.ttp-mute[data-muted="true"] .wave { display: none; }
.ttp-mute[data-muted="true"] .cross { display: inline; }
.ttp-mute[data-muted="true"] { background: #ffe4ea; }
.ttp-vol { display: inline-flex; align-items: center; height: 48px; padding: 0 4px; }
.ttp-vol input { width: clamp(64px, 16vw, 130px); accent-color: #ff6fae; height: 44px; margin: 0; cursor: pointer; }
.ttp-fs[aria-pressed="true"] { background: #e8ddff; }
.ttp-fs[hidden] { display: none; }

.ttp-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr));
  gap: var(--gap);
}
.ttp-card {
  position: relative;
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  min-height: 0;
  border-radius: var(--card-r);
  overflow: hidden;
  cursor: pointer;
  background: var(--accent, #ffd);
  box-shadow: 0 3px 0 rgba(70, 30, 100, .14), 0 10px 22px rgba(70, 30, 100, .14), inset 0 0 0 3px rgba(255, 255, 255, .55);
  transition: transform .16s cubic-bezier(.3, 1.6, .5, 1), box-shadow .16s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  isolation: isolate;
}
.ttp-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .6); pointer-events: none; }
.ttp-card:hover { transform: translateY(-2px) scale(1.012); }
.ttp-card:active { transform: scale(.965); }
.ttp-card-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: -1; }
.ttp-card-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 5px 10px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  font: 700 clamp(13px, 3.6vw, 17px)/1.05 Fredoka, Nunito, sans-serif;
  box-shadow: 0 2px 6px rgba(60, 20, 90, .14);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ttp-tip {
  position: fixed;
  z-index: 30;
  left: calc(var(--sal) + 12px);
  right: calc(var(--sar) + 12px);
  bottom: calc(var(--sab) + 12px);
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 30px rgba(60, 20, 90, .22);
  font-size: 14px;
  line-height: 1.35;
}
.ttp-tip p { margin: 0; flex: 1; }
.ttp-tip button { flex: none; min-width: 56px; height: 44px; border: 0; border-radius: 999px; background: #7a4cff; color: #fff; font: 700 15px Nunito, sans-serif; }
.ttp-tip[hidden] { display: none; }

/* Short or very small screens: tighter chrome so all eight cards fit. */
@media (max-height: 600px), (max-width: 360px) {
  :root { --gap: 8px; --card-r: 18px; }
  .ttp-home { gap: 6px; padding-top: calc(var(--sat) + 6px); padding-bottom: calc(var(--sab) + 8px); }
  .ttp-bar { min-height: 48px; }
}
@media (max-width: 400px) {
  .ttp-fs-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ttp-fs { width: 48px; padding: 0; }
  .ttp-title { font-size: 18px; }
  .ttp-logo { width: 26px; height: 26px; }
}
@media (max-width: 480px) {
  .ttp-title span { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
/* Enlarged text / 200% zoom on phones: let the controls wrap under the site buttons. */
@media (max-width: 300px) {
  .ttp-bar { flex-wrap: wrap; padding-left: 0; padding-top: 50px; min-height: 0; }
  .ttp-title { display: none; }
  .ttp-controls { width: 100%; justify-content: space-between; }
  .ttp-vol input { width: 70px; }
}
@media (max-width: 340px) {
  .ttp-logo { display: none; }
  .ttp-vol input { width: 60px; }
}
@media (min-width: 900px) {
  :root { --gap: 16px; --card-r: 28px; }
  .ttp-home { padding-left: calc(var(--sal) + 20px); padding-right: calc(var(--sar) + 20px); padding-bottom: calc(var(--sab) + 18px); gap: 12px; }
}

/* ---------- play ---------- */
html[data-mode="play"], html[data-mode="play"] body { overflow: hidden; height: 100%; overscroll-behavior: none; }
html[data-mode="play"] .ttp-home { visibility: hidden; }
html[data-mode="play"] random-express-nav,
html[data-mode="play"] .ttp-about,
html[data-mode="play"] .ttp-tip,
html[data-mode="play"] random-express-activity { display: none !important; }
html[data-immersive="true"] random-express-nav { display: none; }
html[data-immersive="true"] .ttp-bar { padding-left: 0; }
html[data-standalone="true"] random-express-nav { display: none; }
html[data-standalone="true"] .ttp-bar { padding-left: 0; }
.ttp-play {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #9fd8ff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
.ttp-play[hidden] { display: none; }
#ttp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.ttp-exit {
  position: absolute;
  top: calc(var(--sat) + 8px);
  left: calc(var(--sal) + 8px);
  width: 56px;
  height: 56px;
  padding: 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  opacity: .55;
  transition: opacity .2s, transform .2s;
}
.ttp-exit svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ttp-exit-bg { fill: rgba(255, 255, 255, .55); stroke: rgba(80, 50, 110, .18); stroke-width: 1.5; }
.ttp-exit-ring { fill: none; stroke: #7a4cff; stroke-width: 4.5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 26px 26px; }
.ttp-exit-house { fill: none; stroke: #4b2f66; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.ttp-exit.is-holding { opacity: 1; transform: scale(1.08); }
.ttp-hint {
  position: absolute;
  top: calc(var(--sat) + 20px);
  left: calc(var(--sal) + 72px);
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  font: 700 14px/1 Nunito, sans-serif;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .25s, transform .25s;
}
.ttp-hint.is-on { opacity: 1; transform: none; }

/* ---------- adult copy below the fold ---------- */
.ttp-about {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px calc(var(--sar) + 20px) calc(var(--sab) + 40px) calc(var(--sal) + 20px);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
}
.ttp-about h2 { font: 700 clamp(22px, 5vw, 30px)/1.2 Fredoka, Nunito, sans-serif; margin: 0 0 10px; }
.ttp-about h3 { font: 700 19px/1.3 Fredoka, Nunito, sans-serif; margin: 22px 0 6px; }
.ttp-about ul { padding-left: 20px; margin: 6px 0; }
.ttp-about li { margin: 4px 0; }
.ttp-about-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 800; color: #6a35d9; }
.ttp-noscript { text-align: center; padding: 20px; }

@media (prefers-reduced-motion: reduce) {
  .ttp-card, .ttp-exit, .ttp-hint { transition: none; }
}
