/* The same castings appear on the log, the home tablet and the source register. */
:is(body[data-game="osrs"], .door--osrs, .table-wrap[data-game="osrs"]) {
  --paper: #151110;
  font-family: var(--serif);
  --paper-2: #1f1916;
  --card: #28201b;
  --ink: #faedd1;
  --ink-2: #e2cdb0;
  --muted: #c6b198;
  --line: #725b46;
  --water: #ffac4f;
  --red: #ff9790;
  --red-soft: #391e1c;
  --lit: #ebb549;
  --board: #24180c;
  --edit: #ff981f;
  --edit-text: var(--board);
  --edit-bg: #3b2417;
  --edit-ink: #fff0cb;
  --edit-border: #ff981f;
  --edit-badge-bg: #ff981f;
  --edit-badge-ink: var(--board);
  --edit-ring: rgb(255 152 31 / .2);
  --edit-glow: rgb(255 107 43 / .25);
  --completion: #52d462;
  --heading: #ffe2a1;
  --iron: #5a4534;
  --iron-shadow: #392c21;
  --crimson: #b92b2f;
  --ember: #ff6b2b;
  --bevel: inset 2px 2px 0 rgb(255 215 150 / .18), inset -2px -2px 0 rgb(0 0 0 / .55);
  --pin: linear-gradient(135deg, #fff0ad, #ebb549 46%, #936326 50%, #60391a);
  --casting: var(--pin) left 7px top 7px / 5px 5px no-repeat,
    var(--pin) right 7px top 7px / 5px 5px no-repeat,
    var(--pin) left 7px bottom 7px / 5px 5px no-repeat,
    var(--pin) right 7px bottom 7px / 5px 5px no-repeat,
    linear-gradient(115deg, var(--paper-2), var(--card) 45% 65%, var(--paper-2));
}

:where(:root[data-theme="light"]) :is(body[data-game="osrs"], .door--osrs, .table-wrap[data-game="osrs"]) {
  --paper: #efe3c8;
  --paper-2: #e3d3b0;
  --card: #f7efd9;
  --ink: #22180e;
  --ink-2: #473521;
  --muted: #59452e;
  --line: #99805c;
  --water: #85370e;
  --heading: #552e12;
  --iron: #856340;
  --iron-shadow: #513d2c;
  --red: #8e282b;
  --red-soft: #f3d9ca;
  --completion: #1b6e2a;
  --edit-bg: #ffe4a8;
  --edit-ink: #45250b;
  --edit-border: #87500e;
  --bevel: inset 2px 2px 0 rgb(255 255 242 / .78), inset -2px -2px 0 rgb(72 45 21 / .32);
}

/* Forged cap and pegged stone face. The cut feet belong to the shared door silhouette. */
.door--osrs {
  --ground-text: var(--ink);
  --ground-muted: var(--muted);
}
.door--osrs::before {
  background: var(--casting);
  border: 3px solid var(--iron);
  box-shadow: var(--bevel);
}
.door--osrs::after { background: var(--iron); opacity: .85; }
.door--osrs .door-slate {
  background: linear-gradient(90deg, var(--iron-shadow) 4%, var(--lit) 4% 5%, var(--crimson) 5% 9%,
    var(--lit) 9% 10%, var(--iron) 10% 90%, var(--lit) 90% 91%, var(--crimson) 91% 95%, var(--lit) 95% 96%, var(--iron-shadow) 96%);
  box-shadow: var(--bevel);
}
.door--osrs .door-name { color: var(--heading); }
.door--osrs .door-go { color: var(--water); }
.door--osrs .door-meter { border-radius: 0; background: var(--line); }
.door--osrs .door-meter-fill { background: var(--completion); border-radius: 0; }
:root[data-theme="light"] .door--osrs .door-meter {
  background: #ead8b1;
  outline: 1px solid var(--iron);
  outline-offset: 0;
}
.door--osrs .door-community {
  background: var(--card);
  color: var(--heading);
  border: 1px solid var(--iron);
  border-radius: 1px;
  padding: 4px 10px;
  font-size: 15px;
}

body[data-game="osrs"] .guide-content {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
}
body[data-game="osrs"] :is(.guide-content h2, .guide-content h3, .guide-content h4,
  .billing-open-source, .billing-names .count, .billing-facts dt, .billing-kicker, .card-by::before) {
  font-family: var(--serif);
}
body[data-game="osrs"] :is(.log-head h1, .guide-head h1), .door--osrs .door-name {
  letter-spacing: -.025em;
  font-weight: 750;
}
body[data-game="osrs"] :is(.billing, .log-head) {
  border: 3px solid var(--iron);
  border-block-start-color: var(--crimson);
  border-radius: 0;
  background: var(--casting);
  box-shadow: var(--bevel), 0 2px 0 var(--iron-shadow);
}
body[data-game="osrs"] .billing::before {
  inset: 0 18% auto;
  height: 3px;
  background: linear-gradient(90deg, var(--crimson), var(--ember) 18%, var(--lit) 40% 60%, var(--ember) 82%, var(--crimson));
}
body[data-game="osrs"] :is(.billing-org, .card-by, .log-head h1, .pane-head h3, .guide-head h1, .guide-content :is(h2, h3, h4)) {
  color: var(--heading);
}
body[data-game="osrs"] .billing-org { text-wrap: balance; }
body[data-game="osrs"] .billing-open-source {
  min-height: 44px;
  border-radius: 2px;
  box-shadow: var(--bevel);
}
body[data-game="osrs"] .card-credit { padding-block: 5px; font-size: 15px; }
body[data-game="osrs"] .tabs { gap: 3px; border-bottom-color: var(--iron); background: var(--paper-2); }
body[data-game="osrs"] .tab {
  border: 2px solid var(--iron);
  border-radius: 1px;
  box-shadow: var(--bevel);
}
body[data-game="osrs"] .tab[aria-selected="true"] { color: var(--board); background: var(--lit); }
body[data-game="osrs"] .tab[aria-selected="true"] .count { opacity: 1; }
body[data-game="osrs"] .tab::after { height: 3px; background: var(--board); }
body[data-game="osrs"] .entries {
  padding: 6px;
  gap: 2px;
  border: 2px solid var(--iron);
  background: var(--paper-2);
  box-shadow: inset 2px 2px 0 rgb(0 0 0 / .32);
}
body[data-game="osrs"] .entry { border-radius: 0; }
body[data-game="osrs"] .entry:hover { background: var(--card); }
body[data-game="osrs"] .entry[aria-current="true"] {
  background: var(--card);
  color: var(--heading);
  box-shadow: var(--bevel);
  font-weight: 750;
}
body[data-game="osrs"] :is(.entry--hosted .mark-shape, .mark--hosted),
.table-wrap[data-game="osrs"] .mark--hosted { color: var(--completion); }
:root[data-theme="light"] body[data-game="osrs"] .entry--hosted .mark-shape { color: #166324; }
body[data-game="osrs"] :is(.pane, .card) { min-width: 0; border-radius: 2px; box-shadow: var(--bevel); }
body[data-game="osrs"] .detail { min-width: 0; }
body[data-game="osrs"] .pane-head { border-color: var(--iron); }
body[data-game="osrs"] .pane-head::after { height: 2px; bottom: -3px; }
body[data-game="osrs"] :is(.mark, .topnav a, .theme-picker select, .tool-list a,
  .status, .guide-update-age, .suggest-edit, .copy-wiki, .edit-dock, .edit-dock button, .guide-ca-links) { border-radius: 2px; }
body[data-game="osrs"] :is(.theme-picker select, .topnav a, .tool-list a, .edit-dock button) { min-height: 44px; }
body[data-game="osrs"] .guide-update-age.guide-update-age--known {
  background: var(--iron-shadow);
  color: #faedd1;
}
body[data-game="osrs"] .guide-update-age--known small { color: #e2cdb0; }
body[data-game="osrs"] .suggest-edit .edit-icon { box-shadow: var(--bevel); }
body[data-game="osrs"] .guide-ca-list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}
body[data-game="osrs"] .guide-content :is(details, .admonition, .embed-rich, .tabbed-set) {
  border-radius: 1px;
  border-left-color: var(--iron);
}
body[data-game="osrs"] .guide-content td { background: var(--card); }
body[data-game="osrs"] .guide-content th { color: var(--heading); }
.table-wrap[data-game="osrs"] {
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--iron);
  border-radius: 1px;
}
.table-wrap[data-game="osrs"]::before { height: 3px; background: var(--crimson); }
.table-wrap[data-game="osrs"] thead th { color: var(--heading); box-shadow: var(--bevel); }

:is(body[data-game="osrs"], .door--osrs, .os-inferno, .motion-pointer[data-world="osrs"]) {
  --osrs-molten: repeating-radial-gradient(ellipse 110% 150% at -20% 110%, transparent 0 13%, #802d20 14% 17%, #4b2323 18% 22%, transparent 25% 47%),
    repeating-radial-gradient(ellipse 150% 110% at 120% -15%, transparent 0 18%, #ed7a2b 19% 22%, #ffbd51 23% 25%, transparent 27% 52%),
    repeating-linear-gradient(132deg, #713129 0 8%, #b74624 14% 22%, #ff9a32 28% 36%, #de702b 39%, #bc4c25 49%, #77402d 60%);
}

/* The cape's lava runs through narrow metal inlays, away from the text. */
@media screen and (forced-colors: none) {
  body[data-game="osrs"] .tab[aria-selected="true"]::after,
  body[data-game="osrs"] .billing::before {
    background-color: #aa4d27;
    background-image: var(--osrs-molten);
    background-size: 26px 12px, 39px 13px, 39px 13px;
    height: 4px;
  }
}

/* The hit lands on the metal edge. A flake jumps from that spot one beat later. */
@media screen and (prefers-reduced-motion: no-preference) and (forced-colors: none) {
  :root:not([data-ambient-paused]) body[data-game="osrs"] .tab[aria-selected="true"]::after,
  :root:not([data-ambient-paused]) body[data-game="osrs"] .billing::before {
    animation: osrs-molten-inlay 11.4s steps(26, end) infinite;
  }
  body[data-game="osrs"] .log-head { position: relative; }
  :root:not([data-ambient-paused]) :is(.door--osrs .door-slate, body[data-game="osrs"] .log-head)::before,
  :root:not([data-ambient-paused]) :is(.door--osrs .door-slate, body[data-game="osrs"] .log-head)::after {
    content: "";
    position: absolute;
    pointer-events: none;
    inset: 5px 14% auto auto;
    background: var(--lit);
  }
  :root:not([data-ambient-paused]) :is(.door--osrs .door-slate, body[data-game="osrs"] .log-head)::before {
    width: 22px;
    height: 3px;
    border-right: 5px solid var(--ember);
    transform-origin: right center;
    animation: osrs-metal-strike 7.2s steps(4, end) -4.8s infinite;
  }
  :root:not([data-ambient-paused]) :is(.door--osrs .door-slate, body[data-game="osrs"] .log-head)::after {
    width: 3px;
    height: 2px;
    box-shadow: 4px 2px var(--ember);
    animation: osrs-metal-flake 7.2s steps(5, end) -4.8s infinite;
  }
  /* A low, uneven reflection runs along a short length of the brass trim. */
  :root:not([data-ambient-paused]) body[data-game="osrs"] :is(.billing, .topbar)::after {
    content: "";
    position: absolute;
    pointer-events: none;
    top: 0;
    left: 22%;
    width: min(84px, 22%);
    height: 4px;
    background: radial-gradient(ellipse closest-side, #fff0bf, #f3b85b 46%, transparent);
    transform-origin: 35% center;
    animation: osrs-candle-reflection 8.4s ease-in-out -2.4s infinite;
  }
  :root:not([data-ambient-paused]) body[data-game="osrs"] .topbar::after { top: 5px; }
}
@keyframes osrs-molten-inlay {
  to { background-position: 26px -12px, -39px 13px, 39px -13px; }
}
@keyframes osrs-metal-strike {
  0%, 66%, 82%, 100% { transform: scaleX(.19); opacity: .35; }
  69% { transform: scaleX(.5) translateY(-1px); opacity: .65; }
  71%, 74% { transform: scaleX(1); opacity: .96; }
}
@keyframes osrs-metal-flake {
  0%, 70%, 82%, 100% { opacity: 0; }
  71% { transform: translate(0,0); opacity: .85; }
  75% { transform: translate(6px,-4px); opacity: .8; }
  81% { transform: translate(11px,2px); opacity: 0; }
}
@keyframes osrs-candle-reflection {
  0%, 30%, 68%, 100% { transform: scaleX(.56); opacity: .26; }
  39%, 57% { transform: scaleX(.96); opacity: .84; }
  45% { transform: scaleX(.69); opacity: .48; }
  83% { transform: scaleX(.72); opacity: .51; }
}

.motion-pointer[data-world="osrs"] i, .motion-pointer[data-world="osrs"] b {
  position: absolute;
  display: block;
  left: 0;
  top: 0;
}
.motion-pointer[data-world="osrs"] i {
  width: 16px;
  height: 19px;
  background: linear-gradient(135deg, #ffdf8d 12%, #e9af55 31%, #613723 68%, #382323 78%);
  clip-path: polygon(2% 0, 24% 12%, 27% 29%, 45% 21%, 57% 42%, 78% 42%, 100% 71%, 85% 94%, 56% 100%, 32% 85%, 15% 59%, 13% 33%);
}
.motion-pointer[data-world="osrs"] i::before {
  content: "";
  position: absolute;
  inset: 3px 2px 2px 3px;
  clip-path: inherit;
  background-color: #fb8e2e;
  background-image: var(--osrs-molten);
  background-size: 16px 10px, 20px 14px, 20px 14px;
}
.motion-pointer[data-world="osrs"] b {
  top: 2px;
  left: 10px;
  width: 3px;
  height: 3px;
  background: #f8be65;
  box-shadow: 5px 5px 0 -0.5px #c07437;
}

@media (forced-colors: active) {
  body[data-game="osrs"] :is(.entry[aria-current="true"], .tab[aria-selected="true"]) {
    outline: 2px solid Highlight;
    outline-offset: -4px;
    text-decoration: underline;
  }
  .door--osrs { border: 2px solid LinkText; }
  .door--osrs .door-meter-fill { border-bottom: 6px solid Highlight; }
}
@media print {
  :is(body[data-game="osrs"], .door--osrs, .table-wrap[data-game="osrs"]) {
    --ink: black;
    --ink-2: black;
    --heading: black;
    --water: black;
    --muted: #333;
    --card: white;
    --paper: white;
    --paper-2: white;
    --completion: black;
    --casting: white;
    --bevel: none;
  }
  body[data-game="osrs"] :is(.billing-kicker, .guide-update-age[class], .guide-update-age[class] small) {
    background: white;
    color: black;
  }
}
