/* The realm pages: the Codex, Deeds and the guild halls. */
.realm-top { padding-top: clamp(110px, 13vw, 150px); }
.realm-h { font-size: clamp(2rem, 4.4vw, 3.1rem); margin-top: 10px; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--silver-dim); font-size: 0.86rem; text-decoration: none; }
.back-link:hover { color: var(--gold-bright); }

/* ---------- Codex ---------- */
.cx { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.cx-search { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 6px 0 18px; border: 1px solid var(--line-strong); background: rgba(4, 7, 14, 0.7); color: var(--silver-dim); margin-bottom: 14px; }
.cx-search:focus-within { border-color: var(--gold); }
.cx-search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; color: #fff; font: inherit; font-size: 1rem; outline: none; }
.cx-search button { height: 38px; padding: 0 16px; font: inherit; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--abyss); background: var(--gold); border: 0; cursor: pointer; }
.cx-chips { margin-bottom: 16px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.cx-chips::-webkit-scrollbar { display: none; }
.cx-chips .chip { flex: none; white-space: nowrap; }
.cx-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cx-card { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); background: linear-gradient(160deg, rgba(23, 33, 58, 0.75), rgba(6, 10, 20, 0.85)); text-decoration: none; color: inherit; transition: border-color 0.15s ease, transform 0.15s ease; }
.cx-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.cx-card.on { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201, 165, 92, 0.3), 0 10px 30px -12px rgba(201, 165, 92, 0.45); }
.cx-ico { grid-row: 1 / span 2; width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--line-strong); background: #04070e; }
.cx-ico img { image-rendering: pixelated; }
.cx-txt { min-width: 0; }
.cx-txt b { display: block; color: #fff; font-size: 0.88rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-txt small { color: var(--steel); font-size: 0.72rem; letter-spacing: 0.04em; }
.cx-grade { font-family: var(--font-label); color: var(--gold-bright); font-size: 0.85rem; }
.cx-own { grid-column: 2 / span 2; font-size: 0.7rem; color: var(--silver-dim); }
.cx-detail { position: sticky; top: 96px; padding: 26px 26px 22px; text-align: center; }
.cx-big { width: 84px; height: 84px; margin: 0 auto 14px; display: grid; place-items: center; border: 1px solid var(--gold); background: radial-gradient(circle, rgba(201, 165, 92, 0.18), #04070e 70%); box-shadow: 0 0 40px -8px rgba(201, 165, 92, 0.6); }
.cx-big img { width: 64px; height: 64px; image-rendering: pixelated; }
.cx-name { font-family: var(--font-display); font-size: 1.7rem; font-weight: 500; color: #fff; line-height: 1.1; }
.cx-kind { color: var(--steel); letter-spacing: 0.18em; font-size: 0.72rem; text-transform: uppercase; margin: 6px 0 14px; }
.cx-rows { text-align: left; }
.cx-pair { display: flex; justify-content: space-between; gap: 12px; font-size: 0.86rem; padding: 2px 0; }
.cx-pair span { color: var(--silver-dim); }
.cx-pair b { font-weight: 500; color: #fff; text-align: right; }
.cx-pair b.up { color: var(--arcane); }
.cx-pair b.eb { color: #ff7a6b; }
.cx-rows hr { border: 0; height: 1px; background: var(--line); margin: 10px 0; }
.cx-rows .tip-line { font-size: 0.84rem; color: #c79bff; margin: 2px 0; }
.cx-rows .tip-line.muted { color: var(--silver-dim); }
.cx-rows .tip-line.warn { color: var(--ember); }
.cx-desc { margin: 10px 0 0; color: var(--silver-dim); font-size: 0.84rem; }
.cx-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-around; gap: 10px; }
.cx-foot b { display: block; font-family: var(--font-display); font-size: 1.5rem; color: var(--gold-bright); font-weight: 500; }
.cx-foot small { color: var(--steel); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- Deeds ---------- */
.deeds { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.deed { text-align: center; padding: 22px 14px 18px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(15, 25, 48, 0.85), rgba(5, 9, 18, 0.9)); position: relative; overflow: hidden; }
.deed::before { content: ""; position: absolute; inset: -40% -20% auto; height: 70%; background: radial-gradient(circle, var(--tc, transparent) 0, transparent 60%); opacity: 0.22; pointer-events: none; }
.deed-medal { position: relative; display: block; width: 74px; height: 82px; margin: 0 auto 12px; color: var(--tc); }
.deed-medal .hex { position: absolute; inset: 0; width: 100%; height: 100%; fill: rgba(4, 7, 14, 0.9); stroke: currentColor; stroke-width: 2.5; filter: drop-shadow(0 0 10px var(--tc)); }
.deed-medal .gl { position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; transform: translate(-50%, -50%); }
.deed b { display: block; font-family: var(--font-label); font-weight: 400; letter-spacing: 0.06em; color: #fff; font-size: 1rem; }
.deed small { display: block; color: var(--silver-dim); font-size: 0.78rem; margin: 4px 0 12px; min-height: 2.4em; }
.deed .rar { display: block; height: 3px; background: rgba(176, 196, 230, 0.12); }
.deed .rar i { display: block; height: 100%; background: var(--tc); }
.deed em { display: block; font-style: normal; margin-top: 8px; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tc); }
.t-common { --tc: #a9b6cf; } .t-rare { --tc: #74b4ff; } .t-epic { --tc: #c79bff; } .t-legendary { --tc: #ffb15a; }
.deed-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 22px; font-size: 0.78rem; color: var(--silver-dim); }
.deed-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 7px; transform: rotate(45deg); background: var(--tc); }
/* small medals on character pages */
.deed-row { display: flex; flex-wrap: wrap; gap: 10px; }
.deed-chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); background: rgba(5, 9, 18, 0.6); }
.deed-chip .deed-medal { width: 34px; height: 38px; margin: 0; }
.deed-chip .deed-medal .gl { width: 15px; height: 15px; }
.deed-chip .deed-medal .hex { stroke-width: 3.5; filter: drop-shadow(0 0 5px var(--tc)); }
.deed-chip b { display: block; color: #fff; font-size: 0.84rem; font-weight: 500; }
.deed-chip small { display: block; color: var(--tc); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; }

/* ---------- Guild halls ---------- */
.gl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.gl-card { display: flex; align-items: center; gap: 16px; padding: 18px 20px; text-decoration: none; color: inherit; position: relative; transition: transform 0.15s ease; }
.gl-card:hover { transform: translateY(-2px); }
.gl-card.castle { border-color: var(--gold); }
.gl-card .crest { flex: none; }
.gl-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gl-name { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; color: #fff; line-height: 1.1; }
.gl-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.78rem; color: var(--silver-dim); }
.gl-facts b { color: #fff; font-weight: 500; }
.gl-motto { font-family: var(--font-display); font-style: italic; color: var(--silver-dim); font-size: 0.98rem; }
.gl-card .gh-recruit { position: absolute; top: 14px; right: 14px; margin: 0; }
.gh { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); padding: 0; overflow: hidden; }
.gh-banner { position: relative; padding: 36px 32px; border-right: 1px solid var(--line);
  background: linear-gradient(160deg, hsl(var(--gh, 40) 50% 40% / 0.22), rgba(5, 9, 18, 0.25) 60%), url('../img/background-image.jpg') center / cover; }
.gh-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(5, 9, 18, 0.55), rgba(5, 9, 18, 0.9)); }
.gh-banner > * { position: relative; z-index: 1; }
.gh-crest { margin-bottom: 16px; }
.gh-crest .crest { filter: drop-shadow(0 0 18px hsl(var(--gh, 40) 70% 60% / 0.45)); }
.gh-crown { display: inline-flex; align-items: center; gap: 8px; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--abyss); background: var(--gold-bright); padding: 4px 10px; }
.gh-crown.sm { font-size: 0.6rem; padding: 2px 7px; align-self: flex-start; }
.gh-name { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.2rem, 4vw, 3rem); color: #fff; line-height: 1; margin: 12px 0 8px; overflow-wrap: anywhere; }
.gh-motto { color: var(--silver); font-style: italic; font-family: var(--font-display); font-size: 1.15rem; margin: 0; }
.gh-leader { margin: 10px 0 0; color: var(--silver-dim); font-size: 0.86rem; }
.gh-leader b { color: var(--gold-bright); font-weight: 500; }
.gh-recruit { margin-top: 20px; display: inline-flex; gap: 8px; align-items: center; border: 1px solid #4fbf8c; color: #7fe3b0; padding: 6px 12px; font-size: 0.76rem; letter-spacing: 0.1em; text-transform: uppercase; background: rgba(5, 9, 18, 0.6); }
.gh-recruit.sm { padding: 3px 8px; font-size: 0.62rem; }
.gh-recruit i { width: 8px; height: 8px; border-radius: 50%; background: #4fbf8c; box-shadow: 0 0 8px #4fbf8c; }
.gh-body { padding: 28px 30px; }
.gh-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); margin-bottom: 20px; }
.gh-stats div { padding: 12px 14px; border-left: 1px solid var(--line); min-width: 0; }
.gh-stats div:first-child { border-left: 0; }
.gh-stats b { display: block; font-family: var(--font-display); font-size: 1.6rem; color: #fff; font-weight: 500; }
.gh-stats span { font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--steel); }
.gh-sub { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.gh-mix { display: flex; height: 8px; margin: 8px 0; background: rgba(176, 196, 230, 0.1); }
.gh-mix i { display: block; height: 100%; }
.gh-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.76rem; color: var(--silver-dim); margin-bottom: 20px; }
.gh-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; }
.gh-legend b { color: #fff; font-weight: 500; }
.gh-top { list-style: none; margin: 0; padding: 0; }
.gh-top li { display: grid; grid-template-columns: 22px 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.gh-pos { font-family: var(--font-display); color: var(--gold); }
.gh-who b { display: block; color: #fff; font-size: 0.9rem; font-weight: 500; }
.gh-who small { color: var(--steel); font-size: 0.74rem; }
.gh-lv { font-family: var(--font-display); font-size: 1.3rem; color: var(--gold-bright); }

@media (max-width: 980px) {
  .cx, .gh { grid-template-columns: minmax(0, 1fr); }
  .cx-detail { position: static; }
  .gh-banner { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .cx-list { grid-template-columns: minmax(0, 1fr); }
  .gh-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gh-stats div:nth-child(3) { border-left: 0; }
  .gh-stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .gl-grid { grid-template-columns: minmax(0, 1fr); }
  .gh-banner, .gh-body { padding: 24px 20px; }
}
/* phones: the filters wrap instead of hiding off the edge */
@media (max-width: 640px) { .cx-chips { flex-wrap: wrap; overflow: visible; gap: 6px; } .cx-chips .chip { padding: 6px 11px; font-size: 0.8rem; } }
@media (max-width: 640px) {
  .deeds { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .deed { padding: 16px 10px 14px; }
  .deed-medal { width: 54px; height: 60px; margin-bottom: 8px; }
  .deed-medal .gl { width: 24px; height: 24px; }
  .deed b { font-size: 0.9rem; }
  .deed small { font-size: 0.72rem; margin-bottom: 10px; }
  .deed em { font-size: 0.6rem; letter-spacing: 0.06em; }
  .deed-legend { gap: 8px 14px; font-size: 0.72rem; }
}
.mk-public-rules { margin-top: 18px; color: var(--steel); font-size: 0.84rem; }
