/* How to play (rules/how-to-play/): a designed page for new players, on top of static.css */

.s-main:has(.r-page) { max-width: 1120px; }
.r-page { --r-radius: 18px; --r-shadow: 0 1px 2px #0000000d, 0 10px 30px #00000014; }
.r-page h2 { margin: 0 0 10px; font-size: 26px; line-height: 1.25; }
.r-page h3 { margin: 0 0 6px; font-size: 17px; }
.r-page p { margin: 0 0 10px; line-height: 1.75; }
.r-muted { color: var(--muted); font-size: 14px; }
.r-section { margin: 56px 0; }
.r-cardlink { display: block; }
/* Base styles static.css gives the static page; the app's own page (#page=rules) has none of them */
.r-page img { display: block; max-width: 100%; height: auto; border-radius: 10px; }
.r-page a:not([class]) { color: var(--accent); } /* plain text links only, not the buttons */
.r-page h1 { margin: 0 0 8px; }
.r-page ul, .r-page ol { line-height: 1.65; }

/* Hero */
.r-hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); align-items: center; gap: 24px;
  margin-top: 8px; padding: 44px 44px 40px; border-radius: 26px; overflow: hidden; color: #fff;
  background: radial-gradient(circle at 80% 30%, #7c4d9f 0, transparent 55%), linear-gradient(135deg, #1b1530, #3a2766 70%, #4b2f7d);
}
.r-kicker { display: inline-block; margin: 0 0 12px !important; padding: 4px 12px; border-radius: 999px; background: #ffffff1f; font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.r-hero h1 { margin: 0 0 14px; font-size: clamp(30px, 4.2vw, 46px); line-height: 1.15; }
.r-lead { font-size: 17px; color: #e7e2f5; }
.r-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; padding: 0; list-style: none; }
.r-stats li { flex: 1 1 110px; padding: 12px 14px; border-radius: 14px; background: #ffffff14; border: 1px solid #ffffff22; }
.r-stats b { display: block; font-size: 30px; line-height: 1.1; color: #d9c8ff; }
.r-stats span { font-size: 13px; color: #d8d2ea; }
.r-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 !important; }
.r-btn { display: inline-block; padding: 11px 20px; border-radius: 12px; background: #fff; color: #3a2766; font-weight: 700; text-decoration: none; }
.r-btn.ghost { background: transparent; color: #fff; border: 1px solid #ffffff66; }
.r-btn:hover { filter: brightness(1.05); }
.r-hero-cards { position: relative; height: 340px; }
.r-hero-cards img {
  position: absolute; top: 20px; width: 190px; border-radius: 12px; box-shadow: 0 18px 40px #00000066;
}
.r-hero-cards img:nth-child(1) { left: 8%; transform: rotate(-12deg); top: 40px; }
.r-hero-cards img:nth-child(2) { left: 30%; transform: rotate(0deg); z-index: 1; }
.r-hero-cards img:nth-child(3) { left: 52%; transform: rotate(12deg); top: 40px; }

/* Quick cards */
.r-quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.r-quick-card { padding: 20px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--r-shadow); }
.r-emoji { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-bottom: 10px; border-radius: 12px; background: var(--surface-2); font-size: 22px; }
.r-quick-card p { color: var(--muted); font-size: 15px; margin: 0; }

/* Card anatomy */
.r-anatomy-wrap { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 32px; align-items: start; }
.r-anatomy-card { position: relative; margin: 0; }
.r-anatomy-card img { width: 100%; border-radius: 16px; box-shadow: var(--r-shadow); }
.r-pin {
  position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700; box-shadow: 0 0 0 3px #fff, 0 4px 10px #0006;
}
.r-legend { margin: 0; padding: 0; list-style: none; counter-reset: pin; }
.r-legend li { counter-increment: pin; position: relative; padding: 10px 0 10px 44px; border-bottom: 1px solid var(--border); }
.r-legend li::before {
  content: counter(pin); position: absolute; left: 10px; top: 10px; display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
}
.r-legend b { display: block; }
.r-legend span { color: var(--muted); font-size: 15px; }

/* Setup steps */
.r-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.r-steps li { counter-increment: step; padding: 18px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); line-height: 1.7; }
.r-steps li::before { content: counter(step); display: block; margin-bottom: 6px; font-size: 26px; font-weight: 800; color: var(--accent); }

/* Turn */
.r-turn { display: flex; align-items: stretch; gap: 10px; }
.r-phase { flex: 1; padding: 20px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--r-shadow); }
.r-phase-no { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: 0 0 8px !important; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800; }
.r-phase ul { margin: 0; padding: 0; list-style: none; }
.r-phase li { padding: 8px 0; border-top: 1px dashed var(--border); }
.r-phase li b { display: block; }
.r-phase li span { color: var(--muted); font-size: 14px; }
.r-arrow { align-self: center; color: var(--muted); font-size: 22px; }

/* Two columns: text + picture */
.r-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: center; }
.r-inkwell { padding: 28px; border-radius: var(--r-radius); background: linear-gradient(135deg, #2a1f47, #43307a); color: #e7e2f5; text-align: center; }
.r-inkwell-cards { display: flex; justify-content: center; gap: 10px; margin-bottom: 12px; }
.r-back {
  width: 62px; height: 86px; border-radius: 8px; border: 2px solid #c9a85a;
  background: radial-gradient(circle at 50% 45%, #8a6bd1 0 22%, transparent 23%), linear-gradient(135deg, #3b2a6b, #1f1838);
}
.r-back.used { transform: rotate(90deg); margin: 0 12px; opacity: .6; }
.r-inkwell p { margin: 0; font-weight: 700; letter-spacing: .06em; }
.r-dry { display: flex; align-items: center; justify-content: center; gap: 14px; padding-bottom: 18px; }
.r-dry figure { position: relative; margin: 0; width: 150px; }
.r-dry figcaption {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); padding: 3px 12px; border-radius: 999px;
  background: #16a34a; color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.r-dry figcaption.wet { background: #0ea5e9; }
.r-dry figure:first-child img { filter: saturate(.6) brightness(.9); }

/* Quest and challenge */
.r-qc { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 20px; }
.r-quest, .r-challenge { padding: 24px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--r-shadow); }
.r-quest-demo { display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 230px; }
.r-quest-demo img { width: 130px; }
.r-lore { padding: 8px 14px; border-radius: 12px; background: #7c4d9f; color: #fff; font-size: 22px; font-weight: 800; }
img.exerted { transform: rotate(90deg); margin: 20px 0; }
.r-fight { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 0 14px; }
.r-fight figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 180px; text-align: center; }
.r-fight img { width: 120px; }
.r-fight figcaption { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.r-fight figcaption b { font-size: 13px; color: var(--muted); font-weight: 600; }
.r-vs { font-size: 26px; }
.r-dmg { color: #e5484d; font-weight: 700; }
.r-ok, .r-out { align-self: center; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; }
.r-ok { background: #16a34a; }
.r-out { background: #e5484d; }

/* Card types */
.r-types { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.r-type { padding: 16px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); }
.r-type .r-cardlink { display: grid; place-items: center; height: 200px; margin-bottom: 12px; }
.r-type img { max-height: 200px; width: auto; }
.r-type img.landscape { transform: rotate(90deg); max-height: 140px; }
.r-type p { color: var(--muted); font-size: 14px; margin: 0; }

/* Keywords */
.r-kw { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.r-kw-item { padding: 12px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.r-kw-item b { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); }
.r-kw-item span { font-size: 15px; line-height: 1.7; }

/* Notes, glossary, next steps, FAQ */
.r-notes { align-items: stretch; }
.r-box { padding: 22px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); }
.r-box h2 { font-size: 20px; }
.r-box ul { margin: 0; padding-left: 20px; line-height: 1.75; }
.r-gloss { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.r-gloss div { display: flex; justify-content: space-between; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.r-gloss span { color: var(--muted); }
.r-next { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.r-next-card { padding: 22px; border-radius: var(--r-radius); background: linear-gradient(135deg, #3a2766, #6246c4); color: #fff; text-decoration: none; box-shadow: var(--r-shadow); }
.r-next-card p { color: #e7e2f5; font-size: 15px; margin: 0; }
.r-next-card:hover { filter: brightness(1.08); }
.r-faq details { padding: 14px 18px; margin-bottom: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.r-faq summary { cursor: pointer; font-weight: 700; }
.r-faq details p { margin: 10px 0 0; color: var(--muted); }

/* Narrow screens */
@media (max-width: 900px) {
  .r-hero { grid-template-columns: minmax(0, 1fr); padding: 30px 22px; }
  .r-hero-cards { height: 230px; }
  .r-hero-cards img { width: 130px; }
  .r-quick, .r-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .r-anatomy-wrap, .r-two, .r-qc { grid-template-columns: minmax(0, 1fr); }
  .r-anatomy-card { max-width: 380px; margin: 0 auto; }
  .r-turn { flex-direction: column; }
  .r-arrow { transform: rotate(90deg); }
  .r-types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .r-kw, .r-next { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .r-section { margin: 40px 0; }
  .r-page h2 { font-size: 22px; }
  .r-quick { grid-template-columns: minmax(0, 1fr); }
  .r-fight figure { width: 130px; }
  .r-fight img { width: 90px; }
}

/* ---------- Interactive demos (app/rules.js) ---------- */
html:not(.r-js) [data-js] { display: none; }
.r-hint { margin: 0 0 8px !important; color: var(--accent); font-size: 14px; font-weight: 600; }
.r-hint.shake { animation: r-shake .4s; }
@keyframes r-shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.r-btn.small { padding: 8px 16px; font-size: 14px; background: var(--accent); color: #fff; border: 0; cursor: pointer; }

/* Anatomy */
.r-pin { border: 0; padding: 0; cursor: pointer; transition: transform .15s, background .15s; }
.r-pin:hover, .r-pin.on { transform: translate(-50%, -50%) scale(1.25); background: #f59e0b; }
.r-pin.on { animation: r-pulse 1s ease-out; }
@keyframes r-pulse { 0% { box-shadow: 0 0 0 3px #fff, 0 0 0 0 #f59e0bcc; } 100% { box-shadow: 0 0 0 3px #fff, 0 0 0 14px #f59e0b00; } }
.r-legend li { cursor: pointer; border-radius: 10px; transition: background .15s; }
.r-legend li.on { background: var(--surface); box-shadow: inset 3px 0 0 #f59e0b; }
.r-legend li.on::before { background: #f59e0b; }

/* Drying */
.r-dry.live .r-dry-after, .r-dry.live .r-arrow { display: none; }
.r-dry.live { flex-direction: column; }
.r-dry figure img { transition: filter .4s; }
.r-dry figure.dried img { filter: none !important; }
.r-dry .r-btn { margin-top: 14px; }

/* Questing */
.r-quest-card { padding: 0; border: 0; background: none; cursor: pointer; }
.r-quest-card img { transition: transform .35s; transform: none; margin: 20px 0; }
.r-quest-card img.exerted { transform: rotate(90deg); }
.r-lore { opacity: .35; transition: opacity .2s; }
.r-lore.pop { animation: r-pop .7s; }
@keyframes r-pop { 0% { transform: scale(.6); opacity: 0; } 40% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(1); opacity: .35; } }
.r-quest-panel { text-align: center; }
.r-meter { height: 12px; margin: 8px 0 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.r-meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7c4d9f, #f59e0b); transition: width .5s; }
.r-meter-n { font-weight: 700; font-size: 14px; }

/* Challenge simulator */
.r-sim { margin-top: 20px; padding: 24px; border-radius: var(--r-radius); border: 2px dashed var(--accent); background: var(--surface); }
.r-sim h3 { font-size: 20px; }
.r-sim-board { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 14px 0; }
.r-sim-side { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 200px; }
.r-sim-card { position: relative; display: grid; place-items: center; width: 180px; height: 180px; padding: 0; border: 0; background: none; transition: transform .35s; }
.r-sim-card img { transition: transform .35s, opacity .4s; }
.r-sim-card img { width: 120px; transition: transform .35s; }
.r-sim-toggle { cursor: pointer; }
.r-sim-toggle.exerted img { transform: rotate(90deg); }
.r-sim-card.lunge { animation: r-lunge .35s; }
@keyframes r-lunge { 50% { transform: translateX(40px); } }
.r-sim-card.hit img { animation: r-hit .4s; }
@keyframes r-hit { 30% { filter: brightness(1.8) saturate(0); } }
.r-sim-card.gone img { opacity: .25; }
.r-sim-dmg { position: absolute; top: 6px; right: 14px; padding: 2px 8px; border-radius: 8px; background: #e5484d; color: #fff; font-weight: 800; animation: r-dmg .5s; }
@keyframes r-dmg { 0% { transform: scale(.4) translateY(8px); opacity: 0; } 60% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); } }
.r-sim-name { margin: 0 !important; font-weight: 700; font-size: 14px; }
.r-sim-state { margin: 0 !important; color: var(--muted); font-size: 13px; }
.r-sim-stats { display: grid; gap: 6px; width: 100%; }
.r-step { display: grid; grid-template-columns: 1fr 32px 28px 32px; align-items: center; gap: 4px; font-size: 14px; }
.r-step button { height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 18px; cursor: pointer; }
.r-step b { text-align: center; font-size: 18px; }
.r-sim-go { font-size: 18px; padding: 14px 26px; background: #e5484d; color: #fff; border: 0; cursor: pointer; }
.r-sim-result { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; min-height: 28px; margin: 0 !important; text-align: center; }
.r-bad { color: #e5484d; font-weight: 700; }

/* Quiz */
.r-q { margin: 14px 0; padding: 18px; border-radius: var(--r-radius); background: var(--surface); border: 1px solid var(--border); }
.r-q-title { display: flex; gap: 10px; font-weight: 700; }
.r-q-title span { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 14px; }
.r-q-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.r-q-opts button { padding: 9px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 15px; cursor: pointer; transition: transform .1s; }
.r-q-opts button:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.r-q-opts button:disabled { cursor: default; opacity: .6; }
.r-q-opts button.right { background: #16a34a; border-color: #16a34a; color: #fff; opacity: 1; }
.r-q-opts button.wrong { background: #e5484d; border-color: #e5484d; color: #fff; opacity: 1; }
.r-q-why { margin: 10px 0 0 !important; color: #e5484d; font-size: 15px; }
.r-q-why.right { color: #16a34a; }
.r-q-score { font-size: 18px; font-weight: 700; text-align: center; }
.r-q-score .r-btn { margin-left: 8px; }
@media (max-width: 600px) {
  .r-sim-board { flex-direction: column; }
}
@media (max-width: 480px) {
  .r-sim-side { width: 200px; }
  .r-sim-card { width: 140px; height: 140px; }
  .r-sim-card img { width: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  .r-page *, .r-page *::before { animation: none !important; transition: none !important; }
}

/* Symbols ({S}, {E}, {I}…) in keyword text: a small label that never breaks across lines */
.r-ic {
  display: inline-block; margin: 0 2px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); color: var(--text);
  font-size: .85em; font-weight: 600; line-height: 1.6; white-space: nowrap; vertical-align: baseline;
}
