/* circleranks.com/play: the Rank Five board, matching the app's screen.
   Every class is r5- prefixed (or scoped under .r5) so site.css's own
   .row/.poster/.cta/.steps never reach the game, and the game never reaches
   the rest of the site. Colors are site.css's tokens plus the app's lock green. */
.r5 {
  --r5-card: var(--card); --r5-raised: var(--raised); --r5-hair: var(--line);
  --r5-muted: #6B7A8D; --r5-faint: #3D4A5A; --r5-soft: #C9D2DC; --r5-off: #3A4352;
  --r5-lockbg: #10241A;
  line-height: normal;
}
.r5 [hidden] { display: none !important; }
.r5 :focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* One phone screen under the site header; the board takes the leftover
   height, but never less than five 44px rows (the page scrolls instead). */
.r5-app {
  min-height: calc(100dvh - 64px); max-width: 440px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}

/* Loading / get-the-app gate */
.r5-gate { justify-content: center; text-align: center; }
.r5-gate-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 0 40px; }
.r5-kicker { color: var(--red); font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.r5-h1 { margin: 0; font-size: clamp(30px, 8vw, 44px); line-height: 1.05; letter-spacing: -.03em; font-weight: 900; }
.r5-lede { margin: 0; color: var(--text-2); font-size: 16px; line-height: 1.5; max-width: 400px; }
.r5-gate .stores { justify-content: center; margin-top: 6px; }
.r5-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; margin-top: 10px; }
.r5-loading small { color: var(--text-3); font-size: 13px; font-weight: 600; }
.r5-track { width: 70%; max-width: 260px; height: 6px; border-radius: 999px; background: #1E242D; overflow: hidden; }
.r5-fill { height: 100%; width: 90%; border-radius: 999px; background: linear-gradient(90deg, #A81E1E, var(--red));
  transform-origin: left; animation: r5-load 6s cubic-bezier(.1,.7,.2,1) both; }
@keyframes r5-load { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Theme card */
.r5-theme { display: flex; align-items: center; gap: 10px; flex: none; background: var(--r5-card); border: 1px solid var(--r5-hair); border-radius: 14px; padding: 10px 8px 10px 14px; }
.r5-theme .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r5-theme b { color: var(--red); font-size: 15px; font-weight: 800; }
.r5-theme span { color: var(--r5-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r5-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--text); border-radius: 10px; border: 0; background: none; cursor: pointer; padding: 0; flex: none; }

.r5-status { font-size: 15px; font-weight: 600; min-height: 20px; flex: none; }
.r5-edge { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--r5-muted); padding-left: 26px; flex: none; }

/* Board: rows are absolutely placed by rank-five.js so they can glide. */
.r5-board { position: relative; flex: 1; min-height: 252px; }
.r5-num { position: absolute; left: 0; width: 20px; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--r5-faint); }
.r5-row {
  position: absolute; left: 26px; right: 0;
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 8px;
  background: var(--r5-card); border: 1px solid var(--r5-hair); border-radius: 14px;
  touch-action: none; cursor: grab;
  transition: top .22s cubic-bezier(.2,.8,.2,1), transform .15s, box-shadow .15s, background .2s, border-color .2s;
}
.r5-row.drag { transition: transform .15s, box-shadow .15s; z-index: 5; transform: scale(1.03); background: var(--r5-raised); border-color: var(--red); box-shadow: 0 14px 30px rgba(0,0,0,.6); cursor: grabbing; }
.r5-row.locked { background: var(--r5-lockbg); border-color: var(--green); cursor: default; }
.r5-row.right { border-color: var(--green); }
.r5-row.done { cursor: default; }
.r5-row.justlocked { animation: r5-lockpulse 1.4s ease 2; }
@keyframes r5-lockpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(52,199,123,0); } 50% { box-shadow: 0 0 0 6px rgba(52,199,123,.45); } }
.r5-poster { flex: none; border-radius: 5px; background: var(--r5-raised) center / cover no-repeat; display: grid; place-items: center; font-weight: 900; font-size: 13px; color: rgba(255,255,255,.85); overflow: hidden; }
.r5-meta { flex: 1; min-width: 0; }
.r5-meta .t { font-size: clamp(15px, 4.2vw, 17px); font-weight: 700; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.r5-meta .y { font-size: 12px; color: var(--r5-muted); }
.r5-side { flex: none; text-align: right; color: var(--r5-muted); font-size: 18px; }
.r5-side .avg { color: var(--text); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.r5-side .n { font-size: 10px; }
.r5-side .lock { color: var(--green); font-size: 16px; }
.r5-side .locktag { font-size: 10px; font-weight: 900; letter-spacing: 1px; color: var(--green); }

.r5-bottom { flex: none; display: flex; flex-direction: column; gap: 12px; }
.r5-check { height: 50px; border: 0; border-radius: 14px; background: var(--red); color: #fff; font: 800 16px Inter, system-ui, sans-serif; cursor: pointer; }
.r5-check:disabled { opacity: .5; cursor: default; }
.r5-check.secondary { background: var(--r5-raised); }
/* Checks side by side in one short line. */
.r5-history { display: flex; justify-content: center; gap: 12px; }
.r5-history .chk { display: flex; gap: 3px; }
.r5-sq { width: 13px; height: 13px; border-radius: 3px; border: 1.5px solid var(--r5-off); }
.r5-history .chk.now .r5-sq { border-color: var(--r5-muted); }
.r5-sq.g { background: var(--green); border-color: var(--green); }
.r5-sq.x { background: var(--r5-off); border-color: var(--r5-off); }
.r5-sq.flip { animation: r5-flip .32s ease both; }
@keyframes r5-flip { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
.r5-webnote { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.r5-webnote .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex: none; }
.r5-webnote a { margin-left: 6px; color: var(--red); font-weight: 800; white-space: nowrap; }

/* Playing a past day (practice): back link above the card, gold tag. */
.r5-back { align-self: flex-start; flex: none; background: none; border: 0; padding: 2px 0; color: var(--text-2); font: 700 13px Inter, system-ui, sans-serif; cursor: pointer; }
.r5-back:hover { color: var(--text); }
.r5-theme .prac { color: var(--gold); font-weight: 800; }

/* Past 3 days: under the game on phones, beside the board on desktop. */
.r5-past { max-width: 440px; margin: 8px auto 0; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.r5-pasth { margin: 0 0 8px 2px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 11px; letter-spacing: 1.5px; color: var(--r5-muted); font-weight: 800; }
.r5-pasth span { letter-spacing: 0; font-weight: 600; font-size: 12px; }
.r5-pastlist { background: var(--r5-card); border: 1px solid var(--r5-hair); border-radius: 16px; overflow: hidden; }
.r5-day { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; background: none; border: 0; border-bottom: 1px solid var(--r5-hair); color: var(--text); font-family: Inter, system-ui, sans-serif; text-align: left; cursor: pointer; }
.r5-day:last-child { border-bottom: 0; }
.r5-day.on { background: rgba(227,66,52,.1); cursor: default; }
.r5-day:disabled { cursor: default; }
.r5-pastlist.loading .r5-day:not(.on) { opacity: .55; }
.r5-day .d { width: 52px; flex: none; }
.r5-day .d b { display: block; font-size: 14px; font-weight: 800; }
.r5-day .d small { color: var(--r5-muted); font-size: 12px; }
.r5-day .t { flex: 1; min-width: 0; font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r5-chip { flex: none; font-size: 12.5px; font-weight: 800; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.r5-chip.play { background: var(--red); color: #fff; }
.r5-chip.done { background: rgba(52,199,123,.14); color: var(--green); }
.r5-chip.now { background: var(--r5-raised); color: var(--text); }
.r5-pastmore { margin-top: 10px; border-radius: 14px; padding: 12px 14px; background: linear-gradient(180deg, rgba(227,66,52,.14), rgba(227,66,52,.04)); border: 1px solid rgba(227,66,52,.32); font-size: 13.5px; line-height: 1.4; color: var(--r5-soft); }
.r5-pastmore b { color: var(--text); }
.r5-pastmore a { display: inline-block; margin-top: 6px; color: var(--red); font-weight: 800; }
/* Desktop: board and list sit side by side, centered as a pair; the list
   stays in view below the sticky site header. */
@media (min-width: 900px) {
  .r5-play.has-past { display: grid; grid-template-columns: 440px 300px; gap: 22px; justify-content: center; align-items: start; }
  .r5-play.has-past .r5-app { margin: 0; }
  .r5-play.has-past .r5-past { position: sticky; top: 80px; margin: 12px 0 0; padding: 0; max-width: none; }
}

/* Pop-ups */
/* Auto margins center the card but fall back to 0 when it is taller than
   the screen, so its top can always be scrolled to. */
.r5-dim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72); display: flex; padding: 24px; animation: r5-fade .2s ease both; overflow-y: auto; }
.r5-card { margin: auto; width: 100%; max-width: 320px; background: var(--r5-card); border: 1px solid var(--r5-hair); border-radius: 20px; padding: 22px 18px 18px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.7); animation: r5-pop .25s ease both; }
@keyframes r5-pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes r5-fade { from { opacity: 0; } to { opacity: 1; } }
.r5-gotit { margin-top: 14px; width: 100%; height: 44px; border: 0; border-radius: 12px; background: var(--text); color: var(--bg); font: 800 15px Inter, system-ui, sans-serif; cursor: pointer; }
.r5-result { cursor: pointer; }
.r5-result .big, .r5-end .big { font-size: 30px; font-weight: 900; }
.r5-result .squares { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.r5-result .squares i { width: 22px; height: 22px; border-radius: 5px; background: var(--r5-off); }
.r5-result .squares i.g { background: var(--green); }
.r5-result .lockline { font-size: 15px; font-weight: 700; color: var(--green); }
.r5-result .lockline span { color: var(--text); }
.r5-result .more { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--r5-muted); }
.r5-result .more:empty { display: none; }
.r5-result .tip { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(52,199,123,.12); font-size: 14px; font-weight: 600; line-height: 1.35; text-align: left; }

.r5-end { max-width: 380px; padding: 24px 20px 20px; }
.r5-end .lbl2 { color: var(--text-2); font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.r5-end .big { margin-top: 6px; }
.r5-end .sub { margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--r5-muted); }
.r5-end .grid { display: grid; gap: 5px; justify-content: center; margin: 14px 0 4px; }
.r5-end .grid div { display: flex; gap: 5px; }
.r5-end .grid i { width: 20px; height: 20px; border-radius: 4px; background: var(--r5-off); }
.r5-end .grid i.g { background: var(--green); }
.r5-end .share { margin-top: 14px; width: 100%; height: 46px; border: 0; border-radius: 12px; background: var(--text); color: var(--bg); font: 800 15px Inter, system-ui, sans-serif; cursor: pointer; }
.r5-end .getapp { margin-top: 16px; padding: 16px 14px 14px; border-radius: 16px; background: linear-gradient(180deg, rgba(227,66,52,.16), rgba(227,66,52,.04)); border: 1px solid rgba(227,66,52,.35); }
.r5-end .getapp h3 { margin: 0; font-size: 17px; font-weight: 900; }
.r5-end .getapp p { margin: 6px 0 12px; font-size: 13.5px; color: var(--r5-soft); line-height: 1.4; }
.r5-end .stores { justify-content: center; gap: 8px; }
/* Stacked full width so "Download on the" / "Google Play" never wrap. */
.r5-end .store { height: 50px; padding: 0 16px; border-radius: 12px; gap: 10px; flex: 1 1 100%; justify-content: center; }
.r5-end .store b { font-size: 15px; }
.r5-end .store svg { width: 20px; height: 20px; }
.r5 .store small, .r5 .store b { white-space: nowrap; }
.r5-end .later { margin-top: 12px; font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.r5-end .r5-endtoday { margin-top: 8px; width: 100%; height: 44px; border: 0; border-radius: 12px; background: var(--red); color: #fff; font: 800 15px Inter, system-ui, sans-serif; cursor: pointer; }
.r5-end .close { margin-top: 6px; background: none; border: 0; color: var(--text-2); font: 700 13px Inter, system-ui, sans-serif; cursor: pointer; padding: 8px; }
.r5-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 14px; z-index: 80; max-width: calc(100vw - 32px); text-align: center; }

.r5-getband { text-align: center; padding: 48px 24px 56px; }
.r5-getband h2 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -.02em; line-height: 1.15; }
.r5-getband p { color: var(--text-2); margin: 8px auto 22px; max-width: 440px; }
.r5-getband .stores { justify-content: center; }

/* Tutorial */
.r5-tutcard { max-width: 340px; text-align: left; position: relative; }
.r5-tutx { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 999px; border: 0; background: var(--r5-raised); color: #8392A5; font: 800 15px Inter, system-ui, sans-serif; cursor: pointer; }
.r5-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.r5-dots i { width: 22px; height: 4px; border-radius: 4px; background: var(--r5-raised); }
.r5-dots i.on { background: var(--red); }
.r5-tutpic { background: var(--bg); border: 1px solid var(--r5-hair); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.r5-tuth { font-size: 20px; font-weight: 900; margin-bottom: 6px; text-wrap: balance; }
.r5-tutb { font-size: 15px; line-height: 1.45; color: var(--r5-soft); }
.r5-tutb b { color: var(--text); }
#tutNext { position: relative; overflow: hidden; }
#tutNext:disabled { background: var(--r5-off); color: #8392A5; cursor: default; }
#tutNext.wait::before { content: ''; position: absolute; inset: 0; background: rgba(252,252,252,.18); transform-origin: left; animation: r5-fillbar 1.5s linear both; }
#tutNext:not(:disabled).wait::before { display: none; }
@keyframes r5-fillbar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.r5 .mbig { font-size: 22px; font-weight: 900; text-align: center; }
.r5 .mdots { display: flex; gap: 5px; justify-content: center; }
.r5 .mdots i { width: 18px; height: 18px; border-radius: 4px; background: var(--r5-off); }
.r5 .mdots i.g { background: var(--green); }
.r5 .pts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.r5 .pts div { background: var(--r5-card); border-radius: 10px; padding: 8px 4px; font-size: 12px; color: var(--r5-muted); font-weight: 700; animation: r5-pop3 1s ease both; }
.r5 .pts b { display: block; font-size: 20px; color: var(--text); }
/* Lesson 1: a hand drags Movie C from the bottom to the top. 3.6s loop. */
.r5 .anim1 { position: relative; height: 120px; }
.r5 .a1row { position: absolute; left: 0; right: 0; height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 9px; background: var(--r5-card); border: 1px solid var(--r5-hair); font-size: 13px; font-weight: 700; }
.r5 .a1row.r1 { animation: r5-a1r1 3.6s ease-in-out infinite; }
.r5 .a1row.r2 { animation: r5-a1r2 3.6s ease-in-out infinite; }
.r5 .a1row.r3 { animation: r5-a1r3 3.6s ease-in-out infinite; z-index: 2; }
@keyframes r5-a1r1 { 0%,35% { top: 0; } 60%,100% { top: 40px; } }
@keyframes r5-a1r2 { 0%,40% { top: 40px; } 65%,100% { top: 80px; } }
@keyframes r5-a1r3 { 0%,15% { top: 80px; transform: none; background: var(--r5-card); border-color: var(--r5-hair); box-shadow: none; }
  22% { top: 80px; transform: scale(1.04); background: var(--r5-raised); border-color: var(--red); box-shadow: 0 8px 18px rgba(0,0,0,.5); }
  62% { top: 0; transform: scale(1.04); background: var(--r5-raised); border-color: var(--red); box-shadow: 0 8px 18px rgba(0,0,0,.5); }
  72%,100% { top: 0; transform: none; background: var(--r5-card); border-color: var(--r5-hair); box-shadow: none; } }
.r5 .hand { position: absolute; right: 18px; font-size: 22px; z-index: 3; animation: r5-hand 3.6s ease-in-out infinite; }
@keyframes r5-hand { 0% { top: 110px; opacity: 0; } 12% { top: 84px; opacity: 1; } 18% { top: 86px; transform: scale(.85); } 62% { top: 6px; transform: scale(.85); opacity: 1; } 72% { top: 2px; transform: scale(1); opacity: 0; } 100% { top: 2px; opacity: 0; } }
/* Lesson 2: tap Check, squares flip in, the count appears. 4s loop. */
.r5 .anim2 { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 4px 0; }
.r5 .a2btn { background: var(--red); color: #fff; font-weight: 800; font-size: 13px; border-radius: 10px; padding: 8px 16px; animation: r5-tap 4s ease infinite; }
@keyframes r5-tap { 0%,10% { transform: scale(1); } 15% { transform: scale(.9); } 22%,100% { transform: scale(1); } }
.r5 .anim2 .mdots i { animation: r5-flipin 4s ease infinite both; }
.r5 .anim2 .mdots i.g { animation-name: r5-flipg; }
@keyframes r5-flipin { 0%,20% { transform: rotateX(90deg); background: #1E242D; } 30%,100% { transform: rotateX(0); background: var(--r5-off); } }
@keyframes r5-flipg { 0%,20% { transform: rotateX(90deg); background: #1E242D; } 30%,100% { transform: rotateX(0); background: var(--green); } }
.r5 .a2big { animation: r5-showbig 4s ease infinite; }
@keyframes r5-showbig { 0%,55% { opacity: 0; transform: translateY(4px); } 65%,100% { opacity: 1; transform: none; } }
/* Lesson 3: one row locks, two get a "right, hidden" mark. 4.5s loop. */
.r5 .anim3 { display: flex; flex-direction: column; gap: 5px; }
.r5 .a3row { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: 8px; background: var(--r5-card); border: 1px solid var(--r5-hair); font-size: 12px; font-weight: 700; }
.r5 .a3row .n { color: var(--r5-faint); width: 10px; font-weight: 800; }
.r5 .badge { margin-left: auto; font-size: 10px; font-weight: 800; border-radius: 999px; padding: 2px 8px; }
.r5 .badge.lk { color: var(--green); background: rgba(52,199,123,.15); animation: r5-pop3 4.5s ease infinite; }
.r5 .badge.q { color: var(--r5-soft); border: 1px dashed var(--r5-muted); animation: r5-pop3b 4.5s ease infinite; }
.r5 .a3row.lockme { animation: r5-lockrow 4.5s ease infinite; }
.r5 .a3row.hid { animation: r5-hidrow 4.5s ease infinite; }
@keyframes r5-lockrow { 0%,15% { background: var(--r5-card); border-color: var(--r5-hair); } 25%,100% { background: var(--r5-lockbg); border-color: var(--green); } }
@keyframes r5-hidrow { 0%,40% { border-style: solid; border-color: var(--r5-hair); } 50%,100% { border-style: dashed; border-color: var(--r5-muted); } }
@keyframes r5-pop3 { 0%,15% { opacity: 0; transform: scale(.6); } 25%,100% { opacity: 1; transform: none; } }
@keyframes r5-pop3b { 0%,40% { opacity: 0; transform: scale(.6); } 50%,100% { opacity: 1; transform: none; } }

@media (max-width: 560px) {
  .r5-getband .store { flex: 1 1 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .r5-row { transition: none; }
  .r5-fill { animation: none; transform: scaleX(.4); }
  .r5 .anim1 *, .r5 .anim2 *, .r5 .anim3 *, .r5 .pts div { animation: none !important; }
}
