:root {
  --bg: #14110d;
  --panel: #241d16;
  --panel2: #2e251c;
  --edge: #5a4630;
  --gold: #e8b64c;
  --gold2: #b8822a;
  --text: #f1e6d2;
  --muted: #b3a48b;
  --blue: #3d8bff;
  --red: #ff5a4a;
  --green: #6cc24a;
  --common: #c9c3b6;
  --rare: #4ea3ff;
  --epic: #b46cff;
  --legendary: #ffae2b;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #2c2418 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: 'Barlow Condensed', system-ui, sans-serif;
  font-size: 17px;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.center { text-align: center; }
h1, h2, h3 { font-family: 'Cinzel', serif; margin: 0; letter-spacing: .03em; }
h3 { font-size: 17px; color: var(--gold); margin-bottom: 10px; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

.panel {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--edge);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,220,160,.08) inset, 0 8px 24px rgba(0,0,0,.45);
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid #6b5640; background: linear-gradient(180deg, #4a3c2d, #33291f);
  border-radius: 8px; padding: 10px 16px; font-weight: 600; font-size: 18px; letter-spacing: .02em;
  cursor: pointer; transition: transform .08s, filter .15s; touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.gold { background: linear-gradient(180deg, #f6cd6a, #c98a26); color: #2a1a05; border-color: #ffe0a0; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.btn.blue { background: linear-gradient(180deg, #4d8fe8, #2a5bb0); border-color: #7fb0ff; }
.btn.danger { background: linear-gradient(180deg, #c8513f, #8a2a1f); border-color: #ff8a77; }
.btn.big { width: 100%; padding: 13px; font-size: 20px; }
.btn.huge { width: 100%; padding: 18px; font-size: 24px; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: 'Cinzel', serif; font-weight: 800; }
.btn.huge svg { width: 28px; height: 28px; }
.icon-btn { width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--edge); background: #2a2119; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 22px; height: 22px; }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; white-space: nowrap; }
input {
  background: #120e0a; border: 1px solid var(--edge); border-radius: 8px; padding: 11px 12px; width: 100%;
  font-size: 18px; outline: none; user-select: text; -webkit-user-select: text;
}
input:focus { border-color: var(--gold); }
.error { color: #ff8a77; min-height: 1.2em; margin: 6px 0; font-size: 16px; }
.hint { color: var(--muted); font-size: 15px; margin: 8px 0 0; }

/* ---------- Auth ---------- */
#auth { align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 24px 20px; }
.logo { text-align: center; margin-bottom: 18px; }
.logo-mark { width: 56px; height: 56px; color: var(--gold); }
.logo h1 { font-size: clamp(28px, 9vw, 40px); line-height: 1.05; letter-spacing: .02em; font-weight: 800; background: linear-gradient(180deg, #ffe7a8, #d89a34); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { color: var(--muted); margin: 4px 0 0; }
.tabs { display: flex; background: #120e0a; border-radius: 8px; padding: 3px; margin-bottom: 14px; }
.tab { flex: 1; border: 0; background: none; padding: 9px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: #3a2e22; color: var(--gold); }
#authForm label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 15px; }
#authForm input { margin-top: 4px; color: var(--text); }

/* ---------- Lobby ---------- */
#lobby { padding-top: var(--safe-t); }
.profile { margin: 12px 12px 0; padding: 10px; display: flex; align-items: center; gap: 12px; }
.crest {
  width: 52px; height: 58px; flex: none; display: grid; place-items: center; font-family: 'Cinzel'; font-weight: 800; font-size: 26px;
  background: linear-gradient(180deg, #4d8fe8, #1f4a94); clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
  color: #fff; text-shadow: 0 2px 2px rgba(0,0,0,.4);
}
.pinfo { flex: 1; min-width: 0; }
.pname { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 6px; min-width: 0; }
.pname #pName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pname .tagchip, .pname .lvl { flex: none; margin: 0; }
.lvl { font-size: 15px; background: var(--gold); color: #2a1a05; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }
.rankline { font-size: 14px; color: var(--muted, #b9a88f); margin-top: 4px; line-height: 1.2; }
.rankline b { color: var(--gold); }
.xpbar { position: relative; height: 18px; background: #120e0a; border-radius: 9px; overflow: hidden; margin-top: 5px; border: 1px solid #3a2e22; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, #6cc24a, #b6e35a); width: 0; transition: width .8s ease; }
.xpbar span { position: absolute; inset: 0; text-align: center; font-size: 13px; line-height: 17px; font-weight: 600; text-shadow: 0 1px 2px #000; }
.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 12px 0; }
.statrow div { background: rgba(0,0,0,.25); border: 1px solid #3a2e22; border-radius: 8px; text-align: center; padding: 6px 2px; }
.statrow b { display: block; font-size: 20px; color: var(--gold); }
.statrow span { font-size: 13px; color: var(--muted); }

.tabbody { flex: 1; overflow-y: auto; padding: 12px 12px 90px; -webkit-overflow-scrolling: touch; }
.tabpane { max-width: 560px; margin: 0 auto; }
.card { padding: 14px; margin-top: 12px; }
.online { text-align: center; color: var(--muted); margin: 8px 0 0; font-size: 15px; }
.online b { color: var(--green); }
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg button { flex: 1; padding: 9px; border-radius: 7px; border: 1px solid var(--edge); background: #1a140f; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.active { background: #3a2e22; color: var(--gold); border-color: var(--gold2); }
#practiceBtn { width: 100%; }
#joinCode { text-align: center; letter-spacing: .3em; max-width: 110px; }
.rules summary { cursor: pointer; font-family: 'Cinzel'; color: var(--gold); font-weight: 600; }
.rules ul { padding-left: 18px; margin: 10px 0 0; line-height: 1.35; }
.rules li { margin-bottom: 6px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; padding: 6px 8px calc(6px + var(--safe-b));
  background: linear-gradient(180deg, #221b14, #15110c); border-top: 1px solid var(--edge);
}
.bottomnav button { flex: 1; background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; cursor: pointer; font-weight: 600; position: relative; }
.bottomnav svg { width: 24px; height: 24px; }
.bottomnav button.active { color: var(--gold); }
.dot { position: absolute; top: 4px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* ---------- Armoury ---------- */
.bonus { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.bonus div { background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px 2px; }
.bonus b { display: block; font-size: 19px; color: var(--green); }
.bonus b.zero { color: var(--muted); }
.bonus span { font-size: 12px; color: var(--muted); }
.slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.slot { aspect-ratio: 1; border-radius: 10px; border: 2px dashed #4a3c2d; background: rgba(0,0,0,.25); display: grid; place-items: center; position: relative; cursor: pointer; }
.slot.filled { border-style: solid; }
.slot svg { width: 60%; height: 60%; opacity: .35; }
.slot.filled svg { opacity: 1; }
.slot small { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }
.invhead { display: flex; justify-content: space-between; align-items: baseline; margin-top: 30px; }
.invhead span { color: var(--muted); }
.inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.item { aspect-ratio: 1; border-radius: 9px; border: 2px solid; background: rgba(0,0,0,.3); display: grid; place-items: center; position: relative; cursor: pointer; }
.item svg { width: 62%; height: 62%; }
.item .worn { position: absolute; top: 2px; right: 3px; font-size: 11px; background: var(--green); color: #102; border-radius: 4px; padding: 0 3px; font-weight: 700; }
.r-common { border-color: var(--common); color: var(--common); }
.r-rare { border-color: var(--rare); color: var(--rare); box-shadow: 0 0 10px rgba(78,163,255,.25) inset; }
.r-epic { border-color: var(--epic); color: var(--epic); box-shadow: 0 0 12px rgba(180,108,255,.3) inset; }
.r-legendary { border-color: var(--legendary); color: var(--legendary); box-shadow: 0 0 14px rgba(255,174,43,.45) inset, 0 0 10px rgba(255,174,43,.3); }
.t-common { color: var(--common); } .t-rare { color: var(--rare); } .t-epic { color: var(--epic); } .t-legendary { color: var(--legendary); }

.itemhead { display: flex; gap: 12px; align-items: center; }
.itemicon { width: 64px; height: 64px; flex: none; }
.itemicon .item { width: 64px; cursor: default; }
.itemstats { list-style: none; padding: 0; margin: 14px 0; }
.itemstats li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #3a2e22; font-size: 18px; }
.itemstats b { color: var(--green); }

/* ---------- Leaderboard ---------- */
.lb { width: 100%; border-collapse: collapse; font-size: 16px; }
.lb th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px; border-bottom: 1px solid var(--edge); }
.lb td { padding: 7px 4px; border-bottom: 1px solid #2f261d; }
.lb tr.me td { background: rgba(232,182,76,.12); }
.lb td:first-child { color: var(--gold); width: 34px; font-weight: 700; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8,6,4,.7); display: grid; place-items: center; padding: 16px; z-index: 20; backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 360px; padding: 20px; }
.modal h3 { margin-bottom: 8px; }
.modal .row { margin-top: 14px; }
.spinner { width: 46px; height: 46px; border: 4px solid #3a2e22; border-top-color: var(--gold); border-radius: 50%; margin: 0 auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bigcode { font-family: 'Cinzel'; font-size: 48px; letter-spacing: .2em; color: var(--gold); margin: 10px 0; }

/* ---------- Game ---------- */
#game { background: #2f4a1f; touch-action: none; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; top: calc(6px + var(--safe-t)); left: 8px; right: 8px; display: flex; gap: 4px; z-index: 5; pointer-events: none; }
.hud .side { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 3px 8px; border-radius: 6px; background: rgba(16,20,30,.82); border: 1px solid rgba(255,255,255,.12); border-bottom: 3px solid var(--pb); min-width: 0; }
.hud .side.out { opacity: .45; text-decoration: line-through; }
.hud b { font-size: 22px; font-weight: 700; color: var(--pc); }
.hname { font-size: 13px; color: #cfd6e6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.clock { position: absolute; top: calc(48px + var(--safe-t)); left: 10px; z-index: 5; padding: 2px 9px; border-radius: 6px; background: rgba(16,20,30,.82); font-size: 17px; font-weight: 600; pointer-events: none; }
.flag { position: absolute; right: 10px; top: calc(52px + var(--safe-t)); z-index: 5; background: rgba(30,34,60,.85); border-color: #5866a8; }
.pctbar { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 4px 4px calc(4px + var(--safe-b)); background: rgba(10,10,12,.85); z-index: 5; }
.pctbar button { padding: 14px 0; border: 1px solid #333; background: linear-gradient(180deg, #2b2e36, #1b1d22); color: #d2a271; font-size: 21px; font-weight: 700; border-radius: 4px; cursor: pointer; touch-action: manipulation; }
.pctbar button.active { background: linear-gradient(180deg, #23345c, #142240); color: #fff; border-color: #5aa0ff; box-shadow: 0 0 12px rgba(90,160,255,.5) inset; }
.toast { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: 8px 14px; border-radius: 8px; z-index: 6; font-size: 17px; white-space: nowrap; }

.compare { width: 100%; max-width: 480px; padding: 0 0 16px; overflow: hidden; }
.compare h2 { text-align: center; padding: 14px; font-size: 22px; color: var(--text); background: rgba(0,0,0,.25); border-bottom: 1px solid var(--edge); }
.compare table { width: 100%; border-collapse: collapse; font-size: 18px; table-layout: fixed; }
.compare th:first-child, .compare td:first-child { width: 34%; }
.compare th { color: var(--muted); font-weight: 600; padding: 10px 2px 6px; font-size: 15px; }
.compare td { padding: 12px 2px; text-align: center; font-weight: 700; white-space: nowrap; }
.compare td:first-child { text-align: left; padding-left: 10px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.compare tr.me td { background: rgba(232,182,76,.13); }
.compare .gem { display: inline-block; width: 12px; height: 12px; transform: rotate(45deg); margin-right: 8px; border-radius: 2px; }
.compare .star { color: #ffd34a; font-size: 12px; vertical-align: super; margin-left: 1px; }
.compare.many table { font-size: 16px; }
.compare.many td { padding: 9px 2px; }
.objective { text-align: center; margin: 14px 0 4px; font-size: 18px; }
.count { text-align: center; font-family: 'Cinzel'; font-size: 54px; font-weight: 800; color: var(--gold); line-height: 1; }

.result { width: 100%; max-width: 380px; padding: 20px; text-align: center; }
.result h2 { font-size: 40px; }
.result h2.win { color: var(--gold); text-shadow: 0 0 20px rgba(232,182,76,.5); }
.result h2.lose { color: #c9b9a4; }
.reslines { margin: 14px 0 8px; display: grid; gap: 4px; font-size: 18px; }
.reslines .up { color: var(--green); font-weight: 700; }
.reslines .down { color: #ff8a77; font-weight: 700; }
.reslines .lvlup { color: var(--gold); font-family: 'Cinzel'; font-size: 22px; }
.drops { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }
.drop { width: 100px; text-align: center; animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
.drop .item { width: 72px; margin: 0 auto 4px; }
.drop small { display: block; font-size: 14px; line-height: 1.1; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.result .row { margin-top: 16px; }

@media (min-width: 700px) {
  .tabbody { padding-bottom: 100px; }
}

/* ---------- Campaign entry card ---------- */
.campaign-card { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.campaign-card:hover { filter: brightness(1.08); }
.cc-art { width: 92px; height: 62px; flex: none; border-radius: 8px; overflow: hidden; background: linear-gradient(160deg, #5f8a33, #3f5e22); border: 1px solid #6b5640; }
.cc-art svg { width: 100%; height: 100%; }
.cc-text { flex: 1; min-width: 0; }
.cc-text h3 { margin-bottom: 2px; }
.cc-text p { margin: 0; }
.cc-go { font-size: 34px; color: var(--gold); line-height: 1; }

/* ---------- Campaign screen ---------- */
#campaign { padding-top: var(--safe-t); background: radial-gradient(120% 70% at 50% 0%, #3a2a17 0%, #120e0a 70%); }
.camp-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; position: relative; z-index: 3; }
.camp-top h2 { font-size: 22px; color: var(--text); text-align: center; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.ghost { visibility: hidden; }

.region-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.region-strip { flex: 1; display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px calc(50% - min(40vw, 170px)) 18px; scrollbar-width: none; min-height: 0; }
.region-strip::-webkit-scrollbar { display: none; }
.region-card {
  flex: none; width: min(80vw, 340px); scroll-snap-align: center; position: relative; border-radius: 14px; display: flex; flex-direction: column;
  border: 2px solid #8a6a3a; box-shadow: 0 0 0 1px #2a1f12, 0 14px 30px rgba(0,0,0,.6), inset 0 0 0 2px rgba(255,215,140,.15); overflow: hidden; max-height: 600px;
}
.rc-name { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(30,24,18,.85); border: 1px solid #8a6a3a; border-radius: 6px; padding: 5px 18px; font-family: 'Cinzel'; font-weight: 600; font-size: 18px; white-space: nowrap; z-index: 2; }
.rc-map { flex: 1; position: relative; min-height: 180px; }
.rc-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rc-blurb { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; font-size: 15px; color: rgba(255,255,255,.9); text-shadow: 0 1px 3px #000; }
.rc-bottom { background: rgba(20,16,12,.95); border-top: 1px solid #5a4630; padding: 12px 10px 14px; position: relative; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.rc-bottom .rc-diffs { width: 100%; }
.rc-diffs { display: flex; justify-content: space-around; }
.helm { background: none; border: 0; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 0; font: inherit; position: relative; }
.helm .disc { width: 66px; height: 66px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #2c3340, #12151b); border: 2px solid #3b3f48; display: grid; place-items: center; transition: box-shadow .2s, border-color .2s; }
.helm .disc svg { width: 52px; height: 52px; }
.helm.active .disc { border-color: #ffc94a; box-shadow: 0 0 0 2px #7a4d10, 0 0 16px rgba(255,190,60,.7); }
.helm .lbl { font-weight: 600; font-size: 16px; }
.helm .stars { font-size: 16px; font-weight: 700; }
.helm .stars b { color: #ffd34a; }
.helm.locked .disc { filter: grayscale(1) brightness(.5); }
.helm.locked .stars { color: var(--muted); }
.helm .lock { position: absolute; top: 22px; width: 22px; height: 22px; color: #e8dcc0; }
.rc-enter { min-width: 180px; font-family: 'Cinzel'; font-weight: 800; }
.region-card .rc-lockveil { position: absolute; inset: 0; background: rgba(10,8,6,.72); display: grid; place-items: center; text-align: center; padding: 24px; z-index: 4; }
.rc-lockveil svg { width: 44px; height: 44px; color: var(--gold); margin: 0 auto 8px; display: block; }
.region-dots { display: flex; justify-content: center; gap: 8px; padding: 4px 0 calc(16px + var(--safe-b)); }
.region-dots i { width: 9px; height: 9px; border-radius: 50%; background: #4a3c2d; }
.region-dots i.on { background: var(--gold); }

/* Themed terrain */
.theme-grass { background:
  radial-gradient(ellipse 30% 14% at 72% 62%, rgba(30,50,60,.75) 60%, transparent 62%),
  radial-gradient(ellipse 22% 10% at 18% 30%, rgba(30,50,60,.6) 60%, transparent 62%),
  radial-gradient(circle at 30% 70%, rgba(120,160,60,.35), transparent 40%),
  radial-gradient(circle at 80% 20%, rgba(40,70,25,.5), transparent 45%),
  linear-gradient(170deg, #5d8634, #3e5f24 60%, #2f4a1c); }
.theme-sand { background:
  radial-gradient(ellipse 50% 8% at 30% 40%, rgba(160,110,60,.35), transparent 70%),
  radial-gradient(ellipse 50% 8% at 70% 70%, rgba(160,110,60,.35), transparent 70%),
  radial-gradient(circle at 75% 25%, rgba(255,235,190,.35), transparent 40%),
  linear-gradient(170deg, #e2c189, #c99f5f 60%, #a97e45); }
.theme-snow { background:
  radial-gradient(ellipse 40% 12% at 50% 78%, rgba(90,110,130,.45), transparent 70%),
  radial-gradient(circle at 25% 30%, rgba(255,255,255,.7), transparent 40%),
  radial-gradient(circle at 80% 55%, rgba(180,205,225,.6), transparent 45%),
  linear-gradient(170deg, #eef4f8, #c9d8e3 60%, #9fb4c4); }

/* Route */
.route-view { flex: 1; position: relative; min-height: 0; }
.route-map { position: absolute; inset: 0 0 0 0; overflow: hidden; }
.route-map > svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; }
.node { position: absolute; transform: translate(-50%, -60%); background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; font: inherit; color: #fff; }
.node svg.keep { width: 64px; height: 58px; filter: drop-shadow(0 6px 4px rgba(0,0,0,.45)); }
.node .num { margin-top: -6px; background: rgba(20,16,12,.85); border: 1px solid #8a6a3a; border-radius: 10px; padding: 0 9px; font-weight: 700; font-size: 15px; }
.node .star { position: absolute; top: -22px; width: 30px; height: 30px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.node.locked { cursor: default; }
.node.locked svg.keep { filter: grayscale(1) brightness(.75) drop-shadow(0 6px 4px rgba(0,0,0,.45)); }
.node.next svg.keep { animation: bob 1.4s ease-in-out infinite; }
.node.next::before { content: ''; position: absolute; top: 28px; width: 86px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,214,90,.9); box-shadow: 0 0 14px rgba(255,200,70,.8); animation: pulse 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes pulse { 50% { opacity: .35; transform: scale(1.1); } }
.chest { position: absolute; transform: translate(-50%, -50%); text-align: center; font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px #000; width: 110px; }
.chest svg { width: 54px; height: 46px; display: block; margin: 0 auto 2px; filter: drop-shadow(0 4px 4px rgba(0,0,0,.5)); }
.chest.claimed svg { filter: grayscale(.6) brightness(.8); }
.route-legend { position: absolute; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b)); display: flex; justify-content: space-between; gap: 8px; align-items: center; background: rgba(20,16,12,.82); border: 1px solid #5a4630; border-radius: 10px; padding: 8px 12px; font-size: 16px; }
.route-legend b { color: #ffd34a; }

.sheet { position: fixed; inset: 0; background: rgba(8,6,4,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; padding: 12px 12px calc(12px + var(--safe-b)); }
.sheet-card { width: 100%; max-width: 420px; padding: 16px; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-card h3 { font-size: 22px; margin: 2px 0 8px; }
.sheet-card .hint:first-child { margin: 0; }
.stage-facts { list-style: none; padding: 0; margin: 0; }
.stage-facts li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #3a2e22; font-size: 17px; }
.stage-facts b { color: var(--gold); }
.sheet-card .row { margin-top: 14px; }
.reslines .gift { color: var(--gold); font-family: 'Cinzel'; font-size: 20px; }

/* ---------- Castle upgrades (in battle) ---------- */
.upgrades { position: absolute; left: 8px; right: 8px; bottom: calc(66px + var(--safe-b)); z-index: 6; background: rgba(20,16,12,.92); border: 1px solid #8a6a3a; border-radius: 10px; padding: 6px; max-width: 420px; margin: 0 auto; }
.upgrades.at-top { bottom: auto; top: calc(80px + var(--safe-t)); }
.up-title { font-size: 13px; color: var(--muted); margin: 0 0 5px 2px; line-height: 1.2; }
.up-title .hint { font-size: 14px; margin-left: 6px; }
.up-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.up-note { grid-column: span 2; margin: 0; font-size: 13px; align-self: center; }
.up-btn.conv { border-color: #3a7a72; background: linear-gradient(180deg, #1d3a3a, #122424); }
.up-title b { color: var(--gold); }
.up-btn { display: flex; align-items: center; gap: 5px; padding: 5px 6px; min-width: 0; border-radius: 8px; border: 1px solid #4a5a7a; background: linear-gradient(180deg, #24304a, #161d2e); cursor: pointer; text-align: left; font: inherit; color: var(--text); touch-action: manipulation; }
.up-btn.atk { border-color: #7a5a3a; background: linear-gradient(180deg, #4a3220, #2a1c12); }
.up-btn svg { width: 26px; height: 26px; flex: none; }
.up-btn b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-btn span { min-width: 0; }
.up-btn small { display: block; font-size: 13px; color: var(--muted); line-height: 1.1; white-space: nowrap; }
.up-btn svg { width: 22px; height: 22px; }
.up-btn:disabled { opacity: .45; }
.up-btn .pips { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: 1px; }
.up-btn .pips i { width: 7px; height: 7px; border-radius: 2px; background: #3a3a3a; transform: rotate(45deg); }
.up-btn .pips i.on { background: #ffd34a; }

/* ---------- Clans ---------- */
.clan-head { display: flex; align-items: center; gap: 12px; }
.clan-badge { width: 58px; height: 64px; flex: none; display: grid; place-items: center; font-family: 'Cinzel'; font-weight: 800; font-size: 17px; color: #2a1a05;
  background: linear-gradient(180deg, #f6cd6a, #c98a26); clip-path: polygon(0 0, 100% 0, 100% 65%, 50% 100%, 0 65%); }
.clan-head h3 { margin: 0; font-size: 20px; }
.clan-head p { margin: 2px 0 0; }
.clan-form label { display: block; color: var(--muted); font-size: 15px; margin-bottom: 10px; }
.clan-form input { margin-top: 4px; color: var(--text); display: block; width: 100%; }
.clan-form .row { gap: 8px; }
.clan-form .row label { white-space: normal; min-width: 0; }
.clan-form .row input { flex: 1; }
.list { list-style: none; padding: 0; margin: 8px 0 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid #2f261d; }
.list li .grow { flex: 1; min-width: 0; }
.list li .grow b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .grow small { color: var(--muted); font-size: 14px; }
.list .btn { padding: 6px 12px; font-size: 16px; flex: none; }
.tagchip { display: inline-block; font-size: 13px; font-weight: 700; color: var(--gold); border: 1px solid var(--gold2); border-radius: 4px; padding: 0 4px; margin-right: 4px; vertical-align: 1px; }
.crown { color: var(--gold); }
.search { margin-bottom: 4px; }

/* ---------- Clan season & leaderboard ---------- */
.seg.small button { padding: 7px 4px; font-size: 15px; }
.season { background: radial-gradient(120% 120% at 100% 0%, rgba(232,182,76,.18), transparent 55%), linear-gradient(180deg, var(--panel2), var(--panel)); }
.season-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.season-top h3 { margin: 0 0 6px; }
.countdown { font-size: 14px; color: var(--gold); background: rgba(0,0,0,.35); border: 1px solid #5a4630; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.champ { margin-top: 10px; display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.3); border: 1px solid var(--gold2); border-radius: 8px; padding: 8px 10px; }
.champ .cup { font-size: 26px; }
.clanboard { list-style: none; padding: 0; margin: 0; }
.clanboard li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 10px 2px; border-bottom: 1px solid #2f261d; cursor: pointer; }
.clanboard li.mine { background: rgba(232,182,76,.12); border-radius: 6px; }
.clanboard .rk { font-family: 'Cinzel'; font-weight: 800; font-size: 18px; color: var(--muted); text-align: center; }
.clanboard li:nth-child(1) .rk { color: #ffd34a; } .clanboard li:nth-child(2) .rk { color: #d9dde3; } .clanboard li:nth-child(3) .rk { color: #e0a06a; }
.clanboard .nm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clanboard .nm small { color: var(--muted); font-size: 14px; }
.clanboard .pts { text-align: right; }
.clanboard .pts b { font-size: 22px; color: var(--gold); display: block; line-height: 1; }
.clanboard .pts small { font-size: 12px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.stat-grid div { background: rgba(0,0,0,.28); border: 1px solid #3a2e22; border-radius: 8px; padding: 7px 4px; text-align: center; }
.stat-grid b { display: block; font-size: 21px; color: var(--gold); line-height: 1.1; }
.stat-grid span { font-size: 12px; color: var(--muted); }
.highlights { list-style: none; padding: 0; margin: 10px 0 0; }
.highlights li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #2f261d; font-size: 16px; }
.highlights b { color: var(--text); text-align: right; }
.chase { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(108,194,74,.12); border: 1px solid rgba(108,194,74,.4); color: #cfe9bf; font-size: 15px; }
.trophies { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.trophies span { font-size: 13px; background: rgba(232,182,76,.15); border: 1px solid var(--gold2); color: var(--gold); border-radius: 999px; padding: 2px 8px; }
.clan-modal { max-height: 86vh; overflow-y: auto; }
.mpts { font-weight: 700; color: var(--gold); flex: none; text-align: right; font-size: 15px; }
.mpts small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- Tiers, gems, durability, collection ---------- */
.r-0 { border-color: #b9b4aa; color: #b9b4aa; }
.r-1 { border-color: #4ea3ff; color: #4ea3ff; box-shadow: 0 0 10px rgba(78,163,255,.25) inset; }
.r-2 { border-color: #55d16a; color: #55d16a; box-shadow: 0 0 10px rgba(85,209,106,.25) inset; }
.r-3 { border-color: #b46cff; color: #b46cff; box-shadow: 0 0 12px rgba(180,108,255,.3) inset; }
.r-4 { border-color: #ffc531; color: #ffc531; box-shadow: 0 0 14px rgba(255,197,49,.45) inset, 0 0 10px rgba(255,197,49,.3); }
.t-0 { color: #b9b4aa; } .t-1 { color: #4ea3ff; } .t-2 { color: #55d16a; } .t-3 { color: #b46cff; } .t-4 { color: #ffc531; }
.bonus { grid-template-columns: repeat(5, 1fr); }
.bonus b.debuff { color: #ff9a6a; }
.setline { margin-top: 8px; font-size: 15px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gemrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gem { background: rgba(0,0,0,.28); border: 1px solid #3a2e22; border-radius: 8px; padding: 6px 2px; text-align: center; }
.gem svg { width: 26px; height: 26px; display: block; margin: 0 auto 2px; }
.gem b { font-size: 18px; display: block; line-height: 1; }
.gem small { font-size: 11px; color: var(--muted); }
.gemchip { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; white-space: nowrap; font-weight: 700; }
.gemchip svg { width: 16px; height: 16px; }
.gemchip.short { color: #ff8a77; }
.durbar { position: absolute; left: 6px; right: 6px; bottom: 5px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.6); overflow: hidden; }
.durbar i { display: block; height: 100%; background: #6cc24a; }
.durbar i.low { background: #e8b64c; } .durbar i.crit { background: #ff5a4a; }
.item.broken::after, .slot.broken::after { content: 'BROKEN'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(40,0,0,.65); color: #ff8a77; font-size: 11px; font-weight: 800; border-radius: 7px; }
.durline { margin: 10px 0 0; }
.durline .xpbar > div { background: linear-gradient(90deg, #6cc24a, #b6e35a); }
.durline .xpbar.crit > div { background: linear-gradient(90deg, #c8513f, #ff8a77); }
.colhead { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 2px 6px; }
.colhead h3 { margin: 0; }
.colprog { height: 8px; border-radius: 4px; background: #120e0a; overflow: hidden; margin: 4px 0 10px; border: 1px solid #3a2e22; }
.colprog i { display: block; height: 100%; background: linear-gradient(90deg, #4ea3ff, #b46cff, #ffc531); }
.coltier { margin-top: 12px; }
.coltier h4 { margin: 0 0 6px; font-family: 'Cinzel'; font-size: 16px; display: flex; justify-content: space-between; }
.colset { display: grid; grid-template-columns: 74px repeat(5, 1fr); gap: 6px; align-items: center; margin-bottom: 6px; }
.colset .sname { font-size: 13px; line-height: 1.1; color: var(--muted); }
.colset .sname b { display: block; font-size: 14px; color: var(--text); }
.item.missing { border-style: dashed; opacity: .5; filter: grayscale(.85) brightness(.8); box-shadow: none; }
.item .own { position: absolute; bottom: 1px; right: 4px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.setbox { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.25); border: 1px solid #3a2e22; font-size: 15px; }
.setbox .on { color: var(--green); }
.costline { margin-top: 10px; font-size: 15px; }
.reslines .gemsline { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.reslines .warn { color: #ff8a77; }

.devgems { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; padding: 8px; border: 1px dashed #7a5a3a; border-radius: 8px; }
.devgems .btn { padding: 4px 8px; font-size: 14px; display: inline-flex; align-items: center; gap: 3px; }
.devgems .btn svg { width: 16px; height: 16px; }

/* ---------- Lobby chat ---------- */
.chat-head { display: flex; justify-content: space-between; align-items: baseline; }
.chat-head h3 { margin-bottom: 6px; }
.chat-log { height: 230px; overflow-y: auto; background: rgba(0,0,0,.3); border: 1px solid #3a2e22; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text; }
.chat-log .msg { font-size: 16px; line-height: 1.25; word-wrap: break-word; position: relative; }
.chat-log .msg .who { font-weight: 700; color: #9cc4ff; cursor: default; }
.chat-log .msg.mine .who { color: var(--gold); }
.chat-log .msg .lv { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chat-log .msg .time { font-size: 11px; color: #6f6455; margin-left: 4px; }
.chat-log .msg.system { color: var(--gold); font-style: italic; font-size: 15px; }
.chat-log .adminbadge { font-size: 10px; font-weight: 800; background: #c8513f; color: #fff; border-radius: 3px; padding: 0 3px; margin-right: 3px; vertical-align: 2px; }
.chat-log .del { background: none; border: 0; color: #ff8a77; cursor: pointer; font-size: 13px; padding: 0 4px; }
.chat-log .who.clickable { text-decoration: underline dotted; cursor: pointer; }
.chat-log .empty { color: var(--muted); text-align: center; margin: auto; font-size: 15px; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { flex: 1; color: var(--text); }
.chat-form .btn { flex: none; }
.rally-btn { width: 100%; margin-top: 8px; }
.rally { margin-bottom: 8px; padding: 10px; border-radius: 8px; border: 1px solid var(--gold2); background: linear-gradient(90deg, rgba(232,182,76,.18), rgba(232,182,76,.05)); }
.rally .rtop { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.rally .rtime { font-family: 'Cinzel'; font-weight: 800; color: var(--gold); font-size: 20px; }
.rally .rnames { font-size: 15px; margin: 4px 0 8px; }
.rally .row .btn { padding: 8px; }

/* ---------- Admin ---------- */
.adm-modal { max-width: 440px; max-height: 88vh; overflow-y: auto; }
.adm-modal h4 { margin: 14px 0 6px; font-family: 'Cinzel'; color: var(--gold); font-size: 15px; }
.adm-status { padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.3); border: 1px solid #3a2e22; font-size: 15px; margin-top: 8px; }
.adm-status .bad { color: #ff8a77; font-weight: 700; }
.adm-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-btns .btn { padding: 7px 10px; font-size: 15px; flex: none; }
.adm-gems { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.adm-gems label { text-align: center; font-size: 11px; color: var(--muted); }
.adm-gems input { padding: 6px 2px; text-align: center; font-size: 16px; color: var(--text); margin-top: 2px; }
.adm-modal select { width: 100%; background: #120e0a; border: 1px solid var(--edge); border-radius: 8px; padding: 9px; color: var(--text); font: inherit; }
.adm-items { list-style: none; padding: 0; margin: 0; max-height: 180px; overflow-y: auto; }
.adm-items li { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid #2f261d; font-size: 15px; }
.adm-items .btn { padding: 2px 8px; font-size: 13px; }
.pill { font-size: 11px; font-weight: 800; border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 2px; }
.pill.on { background: #2c6b2a; color: #c8f5b8; } .pill.ban { background: #7a2018; color: #ffd0c8; } .pill.mute { background: #5a4a18; color: #ffe9a8; }
.adm-gems svg { width: 20px; height: 20px; }

/* ---------- Admin shortcut & lobby list ---------- */
.admin-btn { position: relative; color: #ff8a77; border-color: #7a3a2a; }
.admin-btn .badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: #2c6b2a; color: #c8f5b8; font-size: 12px; font-weight: 800; display: grid; place-items: center; padding: 0 5px; border: 1px solid #14110d; }
.chat-head { flex-wrap: wrap; gap: 6px; }
.lobby-count { margin-left: auto; background: rgba(0,0,0,.35); border: 1px solid #5a4630; color: var(--text); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 15px; cursor: pointer; }
.lobby-count b { color: var(--green); }
.lobby-list { max-height: 210px; overflow-y: auto; margin: 0 0 8px; background: rgba(0,0,0,.35); border: 1px solid #3a2e22; border-radius: 8px; padding: 4px 8px; }
.lobby-list .lp { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #2a2119; font-size: 16px; }
.lobby-list .lp:last-child { border-bottom: 0; }
.lobby-list .lp .dot { position: static; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.lobby-list .lp.battle .dot { background: #e8b64c; }
.lobby-list .lp small { color: var(--muted); margin-left: auto; font-size: 13px; }
.lobby-list .lp.clickable { cursor: pointer; }
.lobby-list .lp.clickable:hover { background: rgba(255,255,255,.04); }
.lobby-list h5 { margin: 6px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.adm-history { list-style: none; padding: 0; margin: 0; }
.adm-history li { padding: 8px 0; border-bottom: 1px solid #2f261d; }
.adm-history .hrow { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.adm-history .won { color: var(--green); } .adm-history .lost { color: #ff8a77; }
.adm-history .hplayers { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; font-size: 15px; }
.adm-history .hplayers span.won { color: var(--gold); font-weight: 700; }
.adm-history small { color: var(--muted); font-size: 12px; }

.adm-battles { margin-top: 12px; }
.adm-battles > summary { list-style: none; display: block; width: 100%; text-align: center; }
.adm-battles > summary::-webkit-details-marker { display: none; }
.adm-battles[open] > summary { margin-bottom: 6px; border-color: var(--gold2); color: var(--gold); }

.pill.admin { background: #c8513f; color: #fff; }

.pill.filler { background: #3a3f55; color: #c9d2ff; }

/* Item window: buttons wrap into two rows on narrow phones instead of spilling off the side */
#itemBtns { flex-wrap: wrap; }
#itemBtns > * { flex: 1 1 calc(50% - 4px); min-width: 0; }
.overlay > * { min-width: 0; max-width: 100%; }
.modal { box-sizing: border-box; overflow-wrap: anywhere; }

/* ---------- Shop & looks ---------- */
.bottomnav button { font-size: 13px; padding: 6px 2px; min-width: 0; }
.crest.has { font-size: 30px; background: var(--cb); background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(0,0,0,.25)); }
.mini-crest { display: inline-grid; place-items: center; width: 20px; height: 22px; flex: none; font-size: 12px; margin-right: 4px; vertical-align: -5px;
  background: var(--cb); background-image: linear-gradient(180deg, rgba(255,255,255,.2), rgba(0,0,0,.25)); clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%); }
.clan-badge.crest-badge { font-size: 30px; background: var(--cb); background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(0,0,0,.25)); }
/* name styles (7 days) */
.ns.name-ruby { color: #ff5a5a !important; }
.ns.name-emerald { color: #4fdc7a !important; }
.ns.name-sapphire { color: #5aa8ff !important; }
.ns.name-amethyst { color: #c58bff !important; }
.ns.name-gold { color: #ffc93c !important; }
.ns.name-glow-gold { color: #ffe08a !important; text-shadow: 0 0 6px #ffb800, 0 0 12px rgba(255,184,0,.7); }
.ns.name-glow-ice { color: #e6f7ff !important; text-shadow: 0 0 6px #5cd0ff, 0 0 12px rgba(92,208,255,.7); }
.ns.name-glow-fire { color: #ffd0a0 !important; text-shadow: 0 0 6px #ff5a1f, 0 0 12px rgba(255,90,31,.75); }
.ns.name-rainbow { background: linear-gradient(90deg, #ff5a5a, #ffc93c, #4fdc7a, #5aa8ff, #c58bff, #ff5a5a); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent !important; animation: rainbow 4s linear infinite; filter: drop-shadow(0 0 4px rgba(255,255,255,.35)); }
@keyframes rainbow { to { background-position: 200% 0; } }
.shop-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crowns { display: flex; align-items: baseline; gap: 6px; }
.crowns .cicon { font-size: 26px; align-self: center; }
.crowns b { font-size: 30px; color: var(--gold); }
.crowns small { color: var(--muted); font-size: 15px; }
.shop-sec h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.shop-sec h3 small { font-family: inherit; font-size: 13px; font-weight: 500; color: var(--muted); }
.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sitem { background: #1b1510; border: 1px solid #3a2e22; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.sitem.using { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.sitem .sname { font-weight: 700; font-size: 15px; line-height: 1.15; }
.sitem .sdesc { font-size: 12px; color: var(--muted); line-height: 1.2; }
.sitem .btn { width: 100%; padding: 6px 4px; font-size: 15px; margin-top: auto; }
.sitem canvas { width: 100%; height: 92px; display: block; }
.sitem .big-crest { width: 56px; height: 62px; display: grid; place-items: center; font-size: 30px; clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
  background: var(--cb); background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(0,0,0,.25)); margin: 6px 0; }
.sitem .name-prev { font-size: 22px; font-weight: 700; padding: 14px 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitem .left { font-size: 12px; color: var(--green); }
.price { white-space: nowrap; }
.shop-note { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.devcrowns { margin-top: 6px; }

/* ---------- Patron ---------- */
.subbadge { font-size: .8em; margin-left: 3px; filter: drop-shadow(0 0 3px rgba(255,200,80,.6)); -webkit-text-fill-color: initial; }
.patron { border-color: #8a6a1e; background: linear-gradient(160deg, rgba(122,90,18,.35), rgba(30,22,14,.9) 60%); }
.patron.on { box-shadow: 0 0 0 1px #e8b64c inset, 0 0 18px rgba(232,182,76,.18); }
.patron .ptop { display: flex; align-items: center; gap: 10px; }
.patron .pbadge { font-size: 34px; filter: drop-shadow(0 0 6px rgba(255,200,80,.6)); }
.patron .ptop b { font-family: 'Cinzel', serif; font-size: 22px; color: var(--gold); display: block; }
.patron .ptop small { color: var(--muted); }
.patron .pstate { margin-left: auto; font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: #2a2119; color: var(--muted); white-space: nowrap; }
.patron.on .pstate { background: #2f4a1f; color: #b6f08a; }
.patron .perks { list-style: none; padding: 0; margin: 10px 0 6px; display: grid; gap: 4px; font-size: 15px; }
.patron .perks li { line-height: 1.25; }
.patron .row { margin-top: 8px; flex-wrap: wrap; }
.patron .row > .btn { flex: 1 1 140px; }
.rename-form { display: flex; gap: 6px; margin-top: 8px; }
.rename-form input { flex: 1; min-width: 0; }
.sitem.locked { opacity: .5; filter: grayscale(.85); }
.sitem .ribbon { font-size: 11px; font-weight: 800; letter-spacing: .04em; color: #2a1a05; background: var(--gold); border-radius: 4px; padding: 1px 6px; }
.gearsets h3 { display: flex; justify-content: space-between; align-items: baseline; }
.gearsets h3 small { font-size: 13px; color: var(--gold); font-family: inherit; }
.gearsets .setrow { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #2f261d; }
.gearsets .setrow:last-child { border-bottom: 0; }
.gearsets .setrow .grow { flex: 1; min-width: 0; }
.gearsets .setrow .btn { padding: 6px 10px; font-size: 15px; flex: none; }

/* Battle top bar: small clan tag above the name so both fit, smaller troop number */
.hud .side { padding: 2px 6px; }
.hud b { font-size: 18px; flex: none; }
.hname { font-size: 12px; display: flex; flex-direction: column; line-height: 1.1; }
.hname .hn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud .htag { color: var(--gold); font-weight: 800; font-size: 10px; letter-spacing: .03em; }
/* Pre-battle comparison: name on its own row, stats underneath */
.compare th:first-child, .compare td:first-child { width: auto; }
.compare tr.pname-row td { text-align: left; padding: 10px 12px 0; font-weight: 700; white-space: normal; overflow: visible; }
.compare tr.pname-row small { color: var(--muted); font-weight: 500; }
.compare tr.pstat-row td { padding-top: 4px; border-bottom: 1px solid rgba(255,255,255,.06); }
.compare tr.pstat-row td:first-child { text-align: center; padding-left: 2px; font-weight: 700; }
.compare.many tr.pname-row td { padding-top: 8px; }
.setline { display: block; }
.setline .setneed { font-size: 13px; color: #e8a33c; }
.setline .setb { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 14px; }
.setline .setb span { margin: 0; }
.setline .setneed.on { color: var(--green); }
.hud { gap: 3px; }
.hud .side { padding: 2px 5px; gap: 3px; }
.hud b { font-size: 17px; }

/* Crown packs */
.crown-packs h3 { margin-bottom: 4px; }
.pack-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.pack { position: relative; background: #1b1510; border: 1px solid #3a2e22; border-radius: 10px; padding: 12px 8px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.pack.hot { border-color: var(--gold); }
.pack .pk-icon { font-size: 28px; }
.pack .pk-amt { font-size: 22px; font-weight: 800; color: var(--gold); line-height: 1; }
.pack .pk-bonus { font-size: 12px; color: var(--green); font-weight: 700; min-height: 15px; }
.pack .btn { width: 100%; padding: 7px 4px; font-size: 16px; margin-top: 4px; }
.pack .pk-tag { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 800; color: #2a1a05; background: var(--gold); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }

.list .mbtns { display: flex; flex-direction: column; gap: 4px; flex: none; }
.list .mbtns .btn { padding: 5px 9px; font-size: 14px; }

/* ---------- Gear sockets & runes ---------- */
.bonus b.neg { color: #ff8a6a; }
.slots { margin-top: 12px; }
.slotcol { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.slotcol .slot { width: 100%; }
.slotlbl { font-size: 12px; color: var(--muted); }
.sock { width: 100%; border: 1px dashed #5a4a36; background: rgba(0,0,0,.3); color: var(--muted); border-radius: 8px; padding: 3px 0; font-size: 13px; cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.sock.on { border-style: solid; color: var(--text); font-size: 17px; }
.sock.on.lv2 { border-color: #4ea3ff; } .sock.on.lv3 { border-color: #ffc531; box-shadow: 0 0 8px rgba(255,197,49,.35); }
.sock i { font-style: normal; font-size: 8px; letter-spacing: 1px; color: #8fd16a; }
.pips { color: #8fd16a; letter-spacing: 1px; font-size: 12px; }
.runechip { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: #2a2119; border: 1px solid #4a3c2d; white-space: nowrap; }
.runechip.lv2 { border-color: #4ea3ff; } .runechip.lv3 { border-color: #ffc531; color: #ffe08a; }
.activerunes { margin-top: 10px; font-size: 15px; }
.activerunes .arow { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.activerunes .arow .hint { margin: 0; font-size: 13px; }
.activerunes .pips { margin-left: auto; }
.runecard .rhead { display: flex; gap: 10px; align-items: flex-start; }
.runecard .ricon { font-size: 28px; line-height: 1; }
.rlevels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.rlv { background: rgba(0,0,0,.25); border: 1px solid #3a2e22; border-radius: 8px; padding: 5px; text-align: center; display: flex; flex-direction: column; gap: 1px; }
.rlv b { font-family: 'Cinzel', serif; color: var(--gold); }
.rlv span { font-size: 12px; color: var(--muted); }
.rlv em { font-style: normal; font-weight: 800; font-size: 16px; }
.rlv em small { font-weight: 500; font-size: 11px; color: var(--muted); }
.rlv.none { opacity: .55; }
.rbtns { display: flex; flex-direction: column; gap: 6px; }
.rbtns .btn { padding: 7px 8px; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.rbtns .gemchip { font-size: 12px; }
.runecol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.runecol .rc { display: grid; grid-template-columns: auto repeat(3, 1fr); grid-template-rows: auto auto; align-items: center; gap: 2px; background: rgba(0,0,0,.25); border-radius: 8px; padding: 5px; }
.runecol .rc span { font-size: 18px; grid-row: span 1; }
.runecol .rc b { font-size: 11px; text-align: center; color: #5a4a36; border: 1px dashed #4a3c2d; border-radius: 4px; }
.runecol .rc b.got { color: var(--text); border-style: solid; }
.runecol .rc b.got.lv2 { border-color: #4ea3ff; } .runecol .rc b.got.lv3 { border-color: #ffc531; color: #ffe08a; }
.runecol .rc small { grid-column: 1 / -1; font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.altmark { position: absolute; top: 1px; left: 3px; font-size: 11px; }
.warnline { color: #ffb36a; font-size: 14px; margin: 8px 0 0; }
.runepick li { gap: 6px; }
.runepick small { display: block; margin-top: 3px; }
.runeline { font-size: 14px; line-height: 1.6; }
.rreplace { padding: 3px 10px; font-size: 14px; margin-left: 4px; }
.itemstats b.neg { color: #ff8a6a; }

/* Long windows scroll on small phones */
.modal { max-height: calc(100dvh - 32px); max-height: calc(100vh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@supports (height: 100dvh) { .modal { max-height: calc(100dvh - 32px); } }
.rexplain { display: block; font-size: 13px; color: #d8c9a8; line-height: 1.3; margin: 4px 0 0; }
.activerunes .arow .rexplain { flex-basis: 100%; margin-top: 0; }

.lb tr.lbgap td { text-align: center; color: var(--muted); letter-spacing: 4px; padding: 2px; border-bottom: 0; }
.lb .lbnote { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* Rune explanation bubble (press and hold a rune in the Collection) */
.runecol .rc { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.runetip { position: fixed; z-index: 60; background: #1b1510; border: 1px solid var(--gold); border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.6); font-size: 14px; line-height: 1.3; pointer-events: none; }
.runetip b { display: block; font-size: 16px; color: var(--gold); margin-bottom: 4px; }
.runetip .tl { display: flex; gap: 8px; margin-top: 5px; color: var(--muted); }
.runetip .tl.got { color: var(--text); }
.runetip .tl em { font-style: normal; font-family: 'Cinzel', serif; font-weight: 800; color: var(--gold); min-width: 26px; }
.runetip small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }

.rlv .partrow { display: block; font-size: 11px; }
.rlv .partrow .pips { font-size: 10px; letter-spacing: 0; }
.rlv .parthead { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.rlv em { font-size: 14px; }
.ingear { font-size: 13px; margin: 0 0 6px; color: var(--text); }

.partlist li{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:6px 0}
#campToast{white-space:normal;max-width:calc(100vw - 32px);width:max-content;left:50%;transform:translateX(-50%);text-align:center;box-sizing:border-box}
.partlist li{flex-wrap:nowrap}.partlist .pu{display:flex;flex-direction:column;margin-left:auto;text-align:right;line-height:1.2}.partlist .pux{min-width:34px;text-align:right;font-size:18px}
.rc{position:relative}.rc .own{position:absolute;top:3px;right:5px;font-size:12px;font-weight:700;color:var(--gold,#e8b84a)}
.mklv{padding:8px 0;border-top:1px solid rgba(255,255,255,.08)}.mklv .mkh{display:flex;justify-content:space-between;gap:8px;align-items:baseline}
.rc{cursor:pointer}
.rc .rown{position:absolute;top:-6px;left:-4px;font-style:normal;font-size:11px;font-weight:800;color:var(--gold,#e8b84a);background:rgba(0,0,0,.6);border-radius:6px;padding:0 4px;line-height:15px}.partlist .pu small{white-space:nowrap}#armRunes a{color:var(--gold,#e8b84a)}
.rgwrap{overflow-x:auto}
.rgrid{width:100%;border-collapse:collapse;font-size:14px}
.rgrid th{font-weight:800;color:var(--gold,#e8b84a);padding:4px 2px;text-align:center;line-height:1}
.rgrid th small{display:block;font-size:9px;font-weight:600;opacity:.8;margin-top:2px}
.rgrid thead th{position:sticky;top:0;background:#2a2119;z-index:1}
.rgrid td{text-align:center;padding:5px 2px;border-top:1px solid rgba(255,255,255,.06);color:rgba(255,255,255,.28);font-variant-numeric:tabular-nums}
.rgrid td.has{color:#fff;font-weight:800}
.rgrid td.newc.has{color:#7ee07e}
.rgrid .rgname{text-align:left;width:1%;white-space:nowrap;padding-right:6px}
.rgrid .rgname .runechip{font-size:13px;padding:1px 5px}
.rgrid tr.none .runechip{opacity:.45}
.rgrid tr.rglv th{text-align:left;font-size:12px;letter-spacing:.06em;text-transform:uppercase;padding-top:10px;color:rgba(255,255,255,.55)}

/* ---------- Forum ---------- */
.bottomnav:has(#navAdmin:not(.hidden)) button { font-size: 11px; }
.bottomnav:has(#navAdmin:not(.hidden)) svg { width: 22px; height: 22px; }
.fnewbtn { padding: 6px 12px; font-size: 15px; width: auto; }
.fwarnbtn { margin-top: 8px; width: 100%; border-color: #c8513f; color: #ffb3a6; }
.fcats { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.fcats::-webkit-scrollbar { display: none; }
.fcats button { flex: none; background: #2a2119; border: 1px solid var(--edge); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.fcats button.active { background: var(--gold); color: #2a1d08; border-color: var(--gold); }
.fcats button small { opacity: .7; font-weight: 700; margin-left: 2px; }
.fcats.inmodal { flex-wrap: wrap; overflow: visible; }
.flist .fthread { display: block; padding: 10px 2px; cursor: pointer; }
.flist .fthread + .fthread { border-top: 1px solid rgba(255,255,255,.07); }
.fthread .ftop { display: flex; align-items: baseline; gap: 6px; }
.fthread .ftitle { font-size: 17px; line-height: 1.25; color: var(--text); font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fthread.unread .ftitle { font-weight: 800; color: #fff; }
.fnew { flex: none; font-size: 10px; font-weight: 800; background: var(--gold); color: #2a1d08; border-radius: 4px; padding: 1px 5px; }
.fflag { flex: none; }
.fmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; }
.fmeta.hint { margin: 2px 0 0; font-size: 13px; }
.fcat { font-size: 12px; font-weight: 700; color: var(--muted); background: rgba(255,255,255,.06); border-radius: 4px; padding: 1px 6px; display: inline-block; }
.fwho { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.fwho .adminbadge { font-size: 10px; font-weight: 800; background: #c8513f; color: #fff; border-radius: 3px; padding: 0 3px; margin-right: 3px; }
.fwho .lv { color: var(--muted); font-size: 13px; margin-left: 4px; }
.fpager { justify-content: space-between; align-items: center; margin-top: 10px; }
.fpager .btn { width: auto; padding: 6px 12px; }
.fback { width: auto; padding: 6px 14px; margin-bottom: 10px; }
.fthreadcard .fttl { margin: 6px 0 8px; font-size: 21px; line-height: 1.25; overflow-wrap: anywhere; }
.fadmin { gap: 8px; margin-bottom: 8px; }
.fadmin .btn { padding: 6px 10px; font-size: 14px; }
.fpost { padding: 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.fpost.first { border-top: 0; }
.fpost.first .fptext { font-size: 17px; }
.fphead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ftime { margin: 0; font-size: 12px; flex: none; }
.fptext { margin: 6px 0 2px; line-height: 1.45; overflow-wrap: anywhere; }
.fptext.small { font-size: 14px; color: var(--muted); margin: 4px 0 0; }
.fpost.mine { background: linear-gradient(90deg, rgba(232,184,74,.07), transparent); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 6px; }
.fpbtns { display: flex; gap: 12px; justify-content: flex-end; align-items: center; min-height: 4px; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 2px 0; cursor: pointer; text-decoration: underline; }
.linkbtn.danger { color: #e2786a; }
.freport { color: #ffb3a6; font-size: 13px; font-weight: 700; }
.freply { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 10px; }
.freply textarea, #forumBody textarea, #forumBody input { width: 100%; box-sizing: border-box; background: #15110c; color: var(--text); border: 1px solid var(--edge); border-radius: 8px; padding: 10px; font: inherit; font-size: 16px; resize: vertical; }
.flabel { display: block; font-weight: 700; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }

/* ---------- Account ---------- */
#accountBtn { position: relative; }
#accountBtn .dot { top: 2px; right: 2px; }
.forgot { display: block; margin: 10px auto 0; }
#regNote { margin: 10px 0 0; text-align: center; }
.acct-name { font-size: 20px; font-weight: 800; margin: 2px 0 6px; }
.acct-sec { border-top: 1px solid rgba(255,255,255,.08); padding: 10px 0; }
.acct-sec h4 { margin: 0 0 6px; }
.acct-ok { margin: 0 0 4px; color: #8fe08f; overflow-wrap: anywhere; }
.acct-msg { background: rgba(126,224,126,.12); border: 1px solid rgba(126,224,126,.35); color: #bff0bf; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-weight: 700; }
.acct-row { gap: 8px; margin-top: 8px; }
#accountBody input { width: 100%; box-sizing: border-box; background: #15110c; color: var(--text); border: 1px solid var(--edge); border-radius: 8px; padding: 10px; font: inherit; font-size: 16px; margin-top: 6px; min-width: 0; }
.acct-row input { flex: 1; margin-top: 0 !important; }
.acct-row .btn { width: auto; flex: none; padding: 8px 14px; }
#accountBody details summary { cursor: pointer; font-weight: 700; color: var(--gold); padding: 4px 0; }
#accountBody details .btn { margin-top: 8px; }
.privacy { margin: 0; padding-left: 18px; line-height: 1.4; }
.privacy li { margin-bottom: 6px; }
.temppw { font-family: ui-monospace, Menlo, monospace; font-size: 18px; user-select: all; white-space: nowrap; display: inline-block; }

/* ---------- Clan wars ---------- */
.warcard { border-color: #b8862f; background: linear-gradient(180deg, rgba(232,184,74,.10), rgba(0,0,0,0)) , var(--panel, #2a2119); }
.warcard.compact { margin-bottom: 12px; }
.warhead { display: flex; justify-content: space-between; align-items: center; font-family: var(--display, serif); font-weight: 800; color: var(--gold); font-size: 18px; }
.warchip { font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 9px; background: rgba(255,255,255,.1); color: var(--text); font-family: inherit; }
.warchip.open { background: #3fae4a; color: #fff; } .warchip.live { background: #e2483b; color: #fff; } .warchip.scheduled { background: #3d7ff0; color: #fff; }
.warvs { margin: 6px 0 2px; font-size: 16px; overflow-wrap: anywhere; } .warvs .vs { color: var(--muted); font-size: 13px; margin: 0 4px; }
.warwhen { margin: 2px 0 0; color: var(--muted); }
.warwhen b { color: var(--text); font-variant-numeric: tabular-nums; }
.warroster { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.wside { background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px 8px; min-width: 0; }
.wside.mine { outline: 1px solid var(--gold2, #b8862f); }
.wside h4 { margin: 0 0 4px; font-size: 14px; }
.wside ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.wside li { display: flex; align-items: center; gap: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wside li.me { font-weight: 800; }
.odot { width: 7px; height: 7px; border-radius: 50%; background: #666; flex: none; display: inline-block; } .odot.on { background: #4cd964; }
.warform { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.warform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 700; min-width: 0; }
.warform select, .warform input { background: #15110c; color: var(--text); border: 1px solid var(--edge); border-radius: 8px; padding: 8px 6px; font: inherit; font-size: 14px; min-width: 0; width: 100%; box-sizing: border-box; }
.warform .btn { grid-column: 1 / -1; }
#admWarList .warcard { margin-top: 10px; }
.wartro li { display: flex; align-items: center; gap: 10px; } .wartro .tro { font-size: 22px; }
.hud .warside .hn { font-size: 13px; color: var(--muted); }
.warbar { position: absolute; left: 50%; transform: translateX(-50%); top: 52px; z-index: 6; background: rgba(120,20,10,.85); color: #fff; font-weight: 700; padding: 3px 10px; border-radius: 6px; font-size: 13px; max-width: calc(100% - 140px); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.warnames { text-align: left !important; font-size: 13px; line-height: 1.6; }
.compare.war thead { display: none; }
.compare .warrules { text-align: left !important; padding-top: 8px; white-space: normal !important; overflow: visible !important; text-overflow: clip !important; line-height: 1.35; font-size: 13px; }
.compare .warnames { white-space: normal !important; }
.netbar { position: absolute; left: 50%; transform: translateX(-50%); top: 84px; z-index: 7; background: rgba(20,20,20,.92); border: 1px solid #ffd34d; color: #ffe8a0; font-weight: 700; padding: 6px 12px; border-radius: 8px; font-size: 13px; max-width: calc(100% - 24px); text-align: center; pointer-events: none; }
