:root {
  --bg: #0f1320;
  --bg-2: #171c2e;
  --card: #1e2538;
  --line: #2c3450;
  --text: #eef1f8;
  --muted: #9aa6c4;
  --accent: #ff5a36;
  --accent-2: #ffb020;
  --good: #46c18c;
  --radius: 16px;
  --frame: 96px;
}

* { box-sizing: border-box; }

/* Make the `hidden` attribute reliable even on elements that set `display`. */
[hidden] { display: none !important; }

/* One uniform base colour for the whole frame: it fills the top/bottom edges,
   the iOS status-bar tint (theme-color in views/layout.php — keep the two in
   sync) and the overscroll. The glow is centred so it fades out before reaching
   any edge, leaving nothing for a flat status-bar/overscroll colour to mismatch
   against. */
html {
  min-height: 100%;
  background-color: #141a2b;
  background-image:
    radial-gradient(1100px 700px at 50% 42%, rgba(36, 48, 86, 0.5) 0%, transparent 65%);
  background-repeat: no-repeat;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  text-align: center;
}

.masthead {
  margin-bottom: 32px;
}

.masthead h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--muted);
  margin: 0 auto 28px;
  max-width: 44ch;
  line-height: 1.5;
}

.tagline a { color: var(--accent-2); text-decoration: none; }
.tagline a:hover { text-decoration: underline; }

.controls {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

/* Both controls read as matching, equal-height panels. */
.cutoff,
.toggle {
  background: #161b2c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.cutoff {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

/* Hide the real checkbox but keep it focusable/accessible. */
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px #0006;
  transition: transform 0.2s ease;
}

.toggle input:checked + .switch {
  background: var(--accent);
}

.toggle input:checked + .switch::after {
  transform: translateX(20px);
}

.toggle input:focus-visible + .switch {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.toggle:hover .switch {
  filter: brightness(1.1);
}

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

.cutoff-readout {
  white-space: nowrap;
  margin-bottom: 10px;
}

.cutoff-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cutoff-row input[type="range"] {
  width: min(320px, 68vw);
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.cutoff-end {
  font-size: 0.75rem;
  color: var(--muted);
}

.reel-stage { margin: 28px 0; }

.reel-window {
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  width: min(560px, 92vw);
  height: 128px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #11162400, #0c0f1a55);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 40px #0008;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.reel {
  display: flex;
  gap: 8px;
  height: 100%;
  align-items: center;
  padding: 16px 0;
  will-change: transform, opacity;
  opacity: 0; /* avatars are hidden until a roll fades them in */
}

.reel-frame {
  position: relative;
  flex: 0 0 var(--frame);
  width: var(--frame);
  height: var(--frame);
  border-radius: 12px;
  overflow: hidden;
  background: #111626;
  border: 1px solid var(--line);
}

.reel-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reel-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 4px 4px;
  font-size: 0.62rem;
  font-weight: 600;
  text-align: center;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(180deg, transparent, #000b 65%);
  text-shadow: 0 1px 2px #000;
}

.reel-pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 1.6rem;
  text-shadow: 0 2px 8px #000a;
  pointer-events: none;
}

.roll-btn {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 18px 56px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 10px 30px #ff5a3640, 0 2px 0 #0003;
  transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.roll-btn:hover { filter: brightness(1.07); box-shadow: 0 14px 40px #ff5a3660; }
.roll-btn:active { transform: translateY(2px) scale(0.99); }
.roll-btn:disabled { filter: grayscale(0.5) brightness(0.8); cursor: progress; }

.status {
  min-height: 1.4em;
  margin: 18px 0 0;
  color: var(--muted);
}

/* After a roll lands the status text is cleared. Collapse the empty line so the
   result card sits close to the reel instead of leaving a tall gap. */
.status:empty {
  min-height: 0;
  margin: 0;
}

.card {
  margin: 24px auto 0;
  max-width: 460px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 20px 50px #0006;
}

.card.pop { animation: pop 0.35s cubic-bezier(0.2, 1.2, 0.4, 1); }
@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.card-head {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.card-avatar {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  object-fit: cover;
  background: #111626;
  border: 1px solid var(--line);
}

.card-username {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
}
.card-username:hover { color: var(--accent-2); }

.card-country {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.cake-badge {
  display: inline-block;
  margin-top: 6px;
  margin-right: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #3a1d00;
  background: linear-gradient(135deg, var(--accent-2), #ffd47a);
  box-shadow: 0 2px 8px #ffb02040;
}

.card-bio {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--line);
  background: #161b2c;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  font-style: italic;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 20px;
}

.card-stats > div {
  background: #161b2c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.card-stats dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 4px;
}

.card-stats dd {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action {
  flex: 1 1 0;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 10px;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.08s ease;
}
.action:active { transform: translateY(1px); }

.action.wishlist { background: var(--good); color: #06241a; }
.action.intro { background: #2c3450; color: var(--text); }
.action:hover { filter: brightness(1.08); }

@media (max-width: 420px) {
  .card-stats { grid-template-columns: 1fr; }
}
