/* Forever Class Lab.
   The page around the game (header, builder panel, footer) wears the Tinker Lab look: warm dark browns, brass, Eczar,
   Jost, the paint texture. Everything that belongs to the game (talent trees, spellbook, HUD, tooltips, arena) follows
   the WoW: Forever UI as the MangiUI preset reads it: flat black boxes at 75%, 1px black lines, square corners,
   white text with an outline, Marcellus (a free stand-in for Friz Quadrata), Barlow Condensed for numbers. */
:root {
  color-scheme: dark;
  /* page (Tinker Lab) */
  --page: #1b1613;
  --page-2: #241d17;
  --page-3: #2e251d;
  --line: rgba(212, 161, 60, 0.14);
  --line-strong: rgba(212, 161, 60, 0.34);
  --parchment: #ead9b6;
  --body: #d3c6b4;
  --muted: #a2947f;
  --brass: #d4a13c;
  --brass-lit: #f0cd7e;
  --paint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.018' numOctaves='4' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='600' height='600' filter='url(%23p)' opacity='.85'/%3E%3C/svg%3E");
  /* game (Forever, MangiUI) */
  --hud: rgba(0, 0, 0, 0.75);
  /* Status bars, version 2 (default, from MangiUI): a horizontal fade over the whole bar, lighter toward the center of
     the screen and darker going out, with only a little dark at the outer end. The player's bars light toward the
     right, the target's toward the left, centered bars (cast, swing, nameplates) in the middle. */
  --fade-out: rgba(0, 0, 0, 0.32);
  --fade-in: rgba(0, 0, 0, 0.08);
  --fade-to-right: linear-gradient(90deg, var(--fade-out), var(--fade-in));
  --fade-to-left: linear-gradient(270deg, var(--fade-out), var(--fade-in));
  --fade-to-center: linear-gradient(90deg, var(--fade-out), var(--fade-in) 50%, var(--fade-out));
  /* Status bars, version 1 (kept to compare: ?bars=v1): a soft vertical light, a 1px highlight on top and a bright edge
     where the bar ends, over a dark track. */
  --bar-light: linear-gradient(180deg, rgba(255,255,255,0.34) 0%, rgba(255,255,255,0.08) 42%, rgba(0,0,0,0.06) 58%, rgba(0,0,0,0.38) 100%);
  --bar-edge: inset 0 1px 0 rgba(255,255,255,0.32), inset -1px 0 0 rgba(255,255,255,0.55);
  --bar-track: linear-gradient(180deg, rgba(0,0,0,0.88) 0%, rgba(22,22,22,0.78) 100%);
  --hud-soft: rgba(0, 0, 0, 0.5);
  --hud-line: #000;
  --game-text: #ffffff;
  --game-dim: #b9b4aa;
  --game-yellow: #ffd100;
  --game-green: #3ee040;
  --game-red: #ff3b2f;
  --hostile: #c8281e;
  --neutral: #e0c030;
  --cls: #69ccf0;
  --mana: #2f6fd6;
  --tal: 34px;
  --slot: 42px;
  --f-display: "Eczar", Georgia, serif;
  --f-ui: "Jost", "Century Gothic", system-ui, sans-serif;
  --f-game: "Marcellus", Georgia, serif;
  --f-num: "Barlow Condensed", "Arial Narrow", sans-serif;
  --outline: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000, 0 1px 0 #000, 0 -1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 0 3px #000;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--body); font-family: var(--f-ui); font-size: 15px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible, a:focus-visible { outline: 2px solid var(--brass-lit); outline-offset: 2px; }
a { color: var(--brass-lit); }
kbd { font-family: var(--f-num); font-weight: 600; font-size: 0.85em; padding: 0 4px; border: 1px solid rgba(255,255,255,0.22); border-radius: 2px; background: rgba(0,0,0,0.5); color: var(--game-text); }
.label { font-family: var(--f-display); font-size: 16px; font-weight: 500; color: var(--parchment); margin: 18px 0 8px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 10px; line-height: 1.4; }
.ghost { background: transparent; border: 0; padding: 4px 2px; color: var(--muted); }
.ghost:hover, .ghost.on { color: var(--parchment); }
.ghost.small { font-size: 13px; padding: 2px 4px; }
.link { background: none; border: 0; color: var(--brass-lit); padding: 0; font-size: 12px; }
.link:hover { text-decoration: underline; }

/* header: one line. Wordmark, the nine classes, the spec tabs, the actions. */
.top { display: flex; align-items: center; gap: 18px 22px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(rgba(36, 29, 23, 0.94), rgba(36, 29, 23, 0.94)), var(--paint); background-size: auto, 900px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none; }
.brand-title { font-family: var(--f-display); font-weight: 500; font-size: 22px; color: var(--parchment); line-height: 1; }
.brand-tag { font-size: 11px; color: var(--brass); border: 1px solid var(--line-strong); border-radius: 2px; padding: 0 5px; line-height: 16px; }
.class-pick { display: flex; align-items: center; gap: 2px; }
.class-btn { width: 32px; height: 32px; padding: 2px; background: transparent; border: 1px solid transparent; border-radius: 2px; }
.class-btn img { width: 26px; height: 26px; display: block; border-radius: 2px; filter: brightness(0.62) saturate(0.7); transition: filter 0.12s; }
.class-btn:hover img { filter: none; }
.class-btn.on { border-color: var(--c); box-shadow: inset 0 -2px 0 var(--c); }
.class-btn.on img { filter: none; }
.class-name { font-family: var(--f-display); font-size: 18px; margin-left: 8px; min-width: 64px; }
.class-icon { width: 26px; height: 26px; flex: none; }
.spec-icon { width: 20px; height: 20px; border-radius: 2px; }
.builds { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.builds-class { display: none; }
.build-btn { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 4px 8px 3px; font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.build-btn img { filter: brightness(0.7); }
.build-btn:hover { color: var(--parchment); }
.build-btn:hover img, .build-btn.on img { filter: none; }
.build-btn.on { color: var(--parchment); border-bottom-color: var(--cls); }
.build-btn.blank { color: var(--muted); font-size: 13px; }

/* windows (feedback) */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(10, 8, 6, 0.72); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--page-2); border: 1px solid var(--line-strong); border-radius: 2px; padding: 20px 22px 22px; max-width: 720px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-title { font-family: var(--f-display); color: var(--parchment); font-weight: 500; font-size: 24px; margin: 0 0 4px; }
.modal-sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

/* layout */
.layout { display: grid; grid-template-columns: 620px 1fr; min-height: 0; }
.panel { background: linear-gradient(color-mix(in srgb, var(--cls) 9%, rgba(36, 29, 23, 0.95)), color-mix(in srgb, var(--cls) 9%, rgba(36, 29, 23, 0.95))), var(--paint); /* the same hint of the class as the tabs */ background-size: auto, 900px; border-right: 1px solid var(--line); min-height: 0; overflow: auto; }
.builder { padding: 0 16px 24px; }
.tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 4px; background: color-mix(in srgb, var(--cls) 9%, var(--page-2)); /* a hint of the class, apart from the top bar */ padding-top: 8px; border-bottom: 1px solid var(--line); margin: 0 -16px 12px; padding-left: 12px; }
.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px 10px; color: var(--muted); font-size: 15px; font-weight: 500; }
.tab:hover { color: var(--parchment); }
.tab[aria-selected="true"] { color: var(--parchment); border-bottom-color: var(--cls); }
.foot { font-size: 11.5px; color: var(--muted); padding: 5px 16px; border-top: 1px solid var(--line); background: var(--page); display: flex; flex-wrap: wrap; gap: 2px 14px; line-height: 1.4; }
.foot .link { font-size: inherit; }

/* talents: the Forever talent window, made compact for a side column */
.tal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.tal-sum { display: flex; align-items: center; gap: 10px; font-family: var(--f-game); color: var(--game-text); font-size: 14px; }
.tal-sum b { font-family: var(--f-num); font-weight: 600; font-size: 22px; color: var(--game-green); background: #000; border: 1px solid #3a3a3a; padding: 0 8px; line-height: 28px; min-width: 34px; text-align: center; }
.tal-sum span { font-family: var(--f-num); font-size: 15px; color: var(--game-dim); }
.tal-head > .ghost { margin-left: auto; }
.tal-trees { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tal-tree { position: relative; background-color: #0d0c0b; border: 1px solid #000; padding: 8px 6px 12px; overflow: hidden; isolation: isolate; }
/* The tree's own icon, large and faded behind the grid (no Blizzard art: the site only uses icons). */
.tal-tree::before { content: ""; position: absolute; inset: 30% -20% -10% -20%; z-index: -1; background: var(--tree-icon) center / contain no-repeat; filter: grayscale(0.6) blur(1px); opacity: 0.09; }
.tal-tree::after { content: ""; position: absolute; inset: 0; z-index: -2; background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--cls) 10%, transparent), transparent 70%); }
.tal-tree header { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, transparent, rgba(212, 161, 60, 0.5), transparent) 1; }
.tal-tree-icon { width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(212, 161, 60, 0.55); }
.tal-tree-name { font-family: var(--f-game); font-size: 14px; color: var(--game-text); line-height: 1.1; }
.tal-tree-pts { font-family: var(--f-num); font-weight: 600; font-size: 14px; color: var(--game-yellow); background: #000; border: 1px solid #3a3a3a; padding: 0 5px; line-height: 18px; margin-left: auto; }
.tal-tree header .link { color: var(--game-dim); font-size: 11px; opacity: 0.7; }
.tal-tree header .link:hover { opacity: 1; color: var(--game-text); text-decoration: none; }
.tal-grid { position: relative; display: grid; grid-template-columns: repeat(4, var(--tal)); gap: 8px; width: max-content; margin: 0 auto; }
.tal-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.tal-arrows path { fill: none; stroke: #4a4a4a; vector-effect: non-scaling-stroke; stroke-width: 2; }
.tal-arrows path.on { stroke: var(--game-yellow); }
.tal { position: relative; width: var(--tal); height: var(--tal); padding: 0; border: 1px solid #000; border-radius: 2px; background: #000; z-index: 1; box-shadow: 0 0 0 1px #2c2c2c; }
.tal img { width: 100%; height: 100%; display: block; border-radius: 1px; }
.tal.locked img { filter: grayscale(1) brightness(0.4); }
.tal.locked { box-shadow: 0 0 0 1px #262626; }
.tal.open { box-shadow: 0 0 0 2px var(--game-green); }
.tal.maxed { box-shadow: 0 0 0 2px var(--game-yellow); }
.tal.sim-off::after { content: ""; position: absolute; left: 2px; top: 2px; width: 6px; height: 6px; border-radius: 50%; background: #8b8f99; box-shadow: 0 0 0 1px #000; }
.tal-rank { position: absolute; right: -6px; bottom: -6px; font-family: var(--f-num); font-size: 11px; font-weight: 600; line-height: 1; padding: 1px 3px; background: #000; border: 1px solid #3a3a3a; color: var(--game-dim); }
.tal.open .tal-rank { color: var(--game-green); }
.tal.maxed .tal-rank { color: var(--game-yellow); }
/* A talent that lost a requirement after a game update: kept, but it does not count until the tree is fixed. */
.tal.broken { box-shadow: 0 0 0 2px var(--game-red); }
.tal.broken img { filter: grayscale(0.7) brightness(0.7); }
.tal.broken .tal-rank { color: var(--game-red); border-color: var(--game-red); }
.tal-notice { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 10px; padding: 8px 10px; background: rgba(0, 0, 0, 0.75); border: 1px solid #000; box-shadow: inset 3px 0 0 var(--game-red); }
.tal-notice[hidden] { display: none; }
.tal-notice-text { margin: 0; flex: 1; font-size: 13.5px; line-height: 1.4; color: var(--game-text); }
.tal-notice .ghost { flex: none; }
.tal:hover { filter: brightness(1.15); }

/* spellbook */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px; }
.book-spell { display: flex; align-items: center; gap: 8px; padding: 3px; background: rgba(0,0,0,0.35); border: 1px solid #000; border-radius: 2px; text-align: left; }
.book-spell img { width: 32px; height: 32px; border-radius: 1px; flex: none; box-shadow: 0 0 0 1px #000; }
.book-spell:hover { background: rgba(0,0,0,0.6); box-shadow: 0 0 0 1px var(--game-yellow); }
.book-spell.unknown { opacity: 0.45; cursor: default; }
.book-spell.unknown img { filter: grayscale(1); }
.book-spell.on-bar { box-shadow: inset 2px 0 0 var(--cls); }
.book-name { font-family: var(--f-game); font-size: 13px; line-height: 1.15; color: var(--game-text); }

/* gear and options */
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg-btn { background: rgba(0,0,0,0.3); border: 1px solid var(--line); border-radius: 2px; padding: 4px 10px; font-size: 13.5px; color: var(--body); }
.seg-btn:hover { border-color: var(--line-strong); }
.seg-btn.on { border-color: var(--brass); color: var(--parchment); background: rgba(212, 161, 60, 0.1); }
.gear-fields { display: grid; gap: 6px; }
.gear-field { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 10px; font-size: 14px; }
.gear-field sup { color: var(--muted); }
.gear-field input { width: 100%; accent-color: var(--brass); }
.gear-field output { font-family: var(--f-num); font-size: 16px; text-align: right; }
.opt-list { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.opt span { min-width: 110px; }
.opt select { background: var(--page-3); color: var(--body); border: 1px solid var(--line-strong); border-radius: 2px; padding: 4px 8px; font: inherit; }
.opt input[type=checkbox] { accent-color: var(--brass); width: 16px; height: 16px; }
.sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 14px; }
.sheet div { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--line); padding: 3px 0; }
.sheet span { color: var(--muted); }
.sheet b { font-family: var(--f-num); font-size: 16px; font-weight: 600; text-align: right; color: var(--parchment); }
.sheet .sheet-head { grid-column: 1 / -1; margin-top: 8px; font-family: var(--f-display); font-size: 15px; border-bottom: 1px solid var(--line); }
.sheet .sheet-head span { color: var(--parchment); }

/* stage: the game */
.stage { position: relative; min-height: 0; overflow: hidden; container: stage / size; background: #121110; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--f-game); color: var(--game-text); }
.hud > * { pointer-events: auto; }
.keys-hint, .sim-note { position: absolute; bottom: 8px; margin: 0; font-family: var(--f-ui); font-size: 11.5px; color: var(--game-dim); opacity: 0.8; line-height: 1.4; }
.keys-hint { left: 16px; max-width: 52%; }
.sim-note { right: 16px; max-width: 44%; text-align: right; }
.sim-note a { color: var(--game-dim); }
.sim-note a:hover { color: var(--game-text); }

/* The test: tabs over the arena, its options in one line under them. */
.meter { position: absolute; top: 0; left: 0; right: 0; z-index: 3; background: rgba(0, 0, 0, 0.55); border-bottom: 1px solid #000; padding: 6px 16px 7px; font-family: var(--f-ui); }
.test-row { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
.test-row.sub { margin-top: 3px; }
.test-pick { display: flex; gap: 2px; }
.test-btn { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 3px 10px 2px; font-family: var(--f-game); font-size: 16px; color: var(--game-dim); }
.test-btn:hover { color: var(--game-text); }
.test-btn.on { color: var(--game-text); border-bottom-color: var(--game-text); }
.reset-btn { margin-left: auto; color: var(--game-dim); }
.reset-btn:hover { color: var(--game-text); }
.test-blurb { margin: 0; font-size: 12.5px; color: var(--game-dim); }
.test-opts { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.test-opt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--game-text); }
.test-opt input[type=checkbox] { accent-color: var(--game-yellow); width: 14px; height: 14px; margin: 0; }
.test-opt .seg-btn { padding: 1px 8px; font-size: 12.5px; background: var(--hud-soft); border-color: #000; color: var(--game-dim); }
.test-opt .seg-btn.on { color: var(--game-text); border-color: var(--game-dim); background: var(--hud); }
details.advanced { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 13.5px; }

/* HUD block at the bottom center (MangiUI): cast zone, unit frames side by side, action bar. */
.bars { position: absolute; left: 16px; right: 16px; bottom: 46px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.hud > .bars { pointer-events: none; }
.bars > * { pointer-events: auto; }
.bars-mid { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cast-zone { pointer-events: none; width: 100%; height: 34px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 3px; }
.unit-row { display: grid; grid-template-columns: 216px 216px; gap: 10px; align-items: start; }
.frame { display: flex; flex-direction: column; gap: 2px; }
.frame-target.empty > * { visibility: hidden; }
.frame-name { order: 9; font-size: 13px; text-align: center; color: var(--game-text); text-shadow: var(--outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-name small { font-family: var(--f-num); font-size: 12px; color: var(--game-dim); }
.bar { position: relative; height: 22px; background: var(--hud); border: 1px solid var(--hud-line); overflow: hidden; }
/* v2: the fade sits over the whole bar (filled and empty), so it stays put while the bar drains, like a texture */
.bar::after, .castbar::after, .swing::after, .threat::after, .rf::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: var(--fade-to-center); box-shadow: inset 0 1px 0 rgba(0,0,0,0.14), inset 0 -1px 0 rgba(0,0,0,0.14); }
.frame-player .bar::after, .rf::after { background: var(--fade-to-right); }
.frame-target .bar::after, .threat::after { background: var(--fade-to-left); }
.bar span, .castbar span, .threat span, .rf .rf-name, .rf .rf-def, .rf .rf-hots { z-index: 2; }
/* v1 (?bars=v1): the vertical light on the filled part, a dark track */
body.bars-v1 .bar::after, body.bars-v1 .castbar::after, body.bars-v1 .swing::after, body.bars-v1 .threat::after, body.bars-v1 .rf::after { display: none; }
body.bars-v1 .bar i, body.bars-v1 .castbar i, body.bars-v1 .swing i, body.bars-v1 .threat i, body.bars-v1 .rf .rf-hp { background-image: var(--bar-light); box-shadow: var(--bar-edge); }
body.bars-v1 .bar, body.bars-v1 .castbar, body.bars-v1 .swing, body.bars-v1 .threat, body.bars-v1 .rf { background: var(--bar-track); }
.bar i { position: absolute; inset: 0 auto 0 0; background-color: var(--cls); }
.frame-target .bar.hp i { background-color: var(--neutral); }
.frame-target.hostile .bar.hp i { background-color: var(--hostile); }
.bar.power { height: 11px; }
.bar.power i { background-color: var(--fill, var(--mana)); }
.bar span { position: relative; display: block; text-align: center; font-family: var(--f-num); font-weight: 600; font-size: 14px; line-height: 20px; color: var(--game-text); }
.bar.power span { font-size: 11px; line-height: 9px; }
/* The power bar is too thin for a comma's tail: let the number spill a pixel below the bar instead of clipping it, or "6,658" reads "6.658". The fill and the fade stay inside. */
.bar.power { overflow: visible; }
.auras { display: flex; flex-wrap: wrap; align-content: flex-end; gap: 2px; min-height: 31px; }
.frame-player .auras { justify-content: flex-start; }
.aura { position: relative; width: 22px; height: 31px; text-align: center; }
.aura img { width: 22px; height: 22px; border: 1px solid #000; display: block; }
.aura.debuff img { border-color: #b3261e; }
.aura b { position: absolute; right: 0; top: 9px; font-family: var(--f-num); font-size: 12px; font-weight: 600; }
.aura small { font-family: var(--f-num); font-size: 10.5px; color: var(--game-text); line-height: 1; display: block; margin-top: 1px; }
.castbar { position: relative; width: 300px; max-width: 70vw; height: 16px; background: var(--hud); border: 1px solid var(--hud-line); overflow: hidden; }
.castbar i { position: absolute; inset: 0 auto 0 0; background-color: #d9a92e; }
.castbar.channel i { background-color: #4ea83c; }
.castbar span { position: absolute; top: 0; line-height: 14px; font-size: 12px; color: var(--game-text); }
.cast-name { left: 6px; } .cast-time { right: 6px; font-family: var(--f-num); font-weight: 600; }
.swings { display: grid; gap: 2px; width: 300px; max-width: 70vw; }
.swing { position: relative; height: 5px; background: var(--hud); border: 1px solid var(--hud-line); overflow: visible; }
.swing i { display: block; height: 100%; background-color: #bfbfbf; }
.swing.idle i { background-color: #555; }
.swing[data-hand='ranged'] i { background-color: #b5d98a; }
.swing::before { position: absolute; right: calc(100% + 5px); top: -5px; font-family: var(--f-num); font-size: 10.5px; color: var(--game-dim); }
.swing[data-hand='main']::before { content: "MH"; } .swing[data-hand='off']::before { content: "OH"; } .swing[data-hand='ranged']::before { content: "Ranged"; }
.error-text { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); color: var(--game-red); font-size: 17px; text-shadow: var(--outline); opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap; }
.error-text.on { opacity: 1; transition: none; }

/* action bar: two rows of six, dark see-through squares, the key dim in the corner */
.actionbar { display: grid; grid-template-columns: repeat(6, var(--slot)); gap: 2px; }
.slot { position: relative; width: var(--slot); height: var(--slot); padding: 0; border: 1px solid #000; border-radius: 0; background: var(--hud); overflow: hidden; }
.slot img { width: 100%; height: 100%; display: block; }
.slot.empty { background: rgba(58, 58, 58, 0.8); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14); }
/* Touch: an empty slot says it can be filled */
body.touch .slot.empty::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-ui); font-size: 22px; line-height: 1; color: rgba(255,255,255,0.4); }
.slot-key { position: absolute; right: 3px; top: 1px; z-index: 2; font-family: var(--f-num); font-size: 11px; font-weight: 600; color: #d6d6d6; }
.slot-cd { position: absolute; inset: 0; z-index: 1; background: conic-gradient(rgba(0,0,0,0.72) var(--cd, 0deg), transparent 0); pointer-events: none; }
.slot-cd-text { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; font-family: var(--f-num); font-size: 17px; font-weight: 700; color: #fff; pointer-events: none; }
.slot.unknown img { filter: grayscale(1) brightness(0.4); }
.slot.blocked img { filter: grayscale(1) brightness(0.55); }
.slot.nomana img { filter: saturate(0.4) brightness(0.55) sepia(1) hue-rotate(190deg); }
.slot.oor img { filter: brightness(0.6) sepia(1) hue-rotate(-50deg) saturate(3); }
.slot.free { box-shadow: inset 0 0 0 2px var(--game-yellow); }
.slot.queued { box-shadow: inset 0 0 0 2px #fff; }
.slot.active { box-shadow: inset 0 0 0 2px var(--game-green); }
.slot.drop { box-shadow: inset 0 0 0 2px var(--game-yellow); }
/* Heroic Strike or Cleave queued for the next swing: lit border over the icon, like the in-game highlight. */
.slot.armed::after { content: ''; position: absolute; inset: 0; z-index: 3; border: 2px solid #ffd100; box-shadow: inset 0 0 8px rgba(255, 209, 0, 0.7); pointer-events: none; animation: armed-pulse 0.9s ease-in-out infinite alternate; }
@keyframes armed-pulse { from { opacity: 0.65; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .slot.armed::after { animation: none; } }

/* Stance bar: beside the action bar, on its left */
.stancebar { justify-self: end; display: flex; gap: 2px; --slot-s: calc(var(--slot) * 0.8); }
.stancebar .slot { width: var(--slot-s); height: var(--slot-s); }
.stancebar .slot[hidden] { display: none; }
.stancebar .slot-key { font-size: 10px; }
.stancebar .slot.on { box-shadow: inset 0 0 0 2px var(--game-yellow); }
.stancebar .slot:not(.on) img { filter: brightness(0.65); }
.slot-tag { position: absolute; left: 2px; bottom: 1px; z-index: 2; font-family: var(--f-num); font-size: 10px; font-weight: 700; color: var(--game-yellow); }

/* combo points, totems, reagents, threat */
.combo { order: 3; display: flex; gap: 3px; justify-content: center; margin: 1px 0; }
.combo i { width: 12px; height: 12px; border-radius: 50%; background: var(--hud); border: 1px solid #000; }
.combo i.on { background: radial-gradient(circle at 40% 30%, #ffc27a, #e8701e 55%, #a6400c); box-shadow: inset 0 0 0 1px rgba(255,190,120,0.7); }
.bar-hint { position: absolute; left: 50%; bottom: calc(2 * var(--slot) + 196px); transform: translateX(-50%); max-width: min(380px, 86%); text-align: center; font-family: var(--f-ui); font-size: 13.5px; color: var(--game-text); background: var(--hud); border: 1px solid #000; padding: 7px 12px; pointer-events: none; }
.reagent { display: flex; align-items: center; gap: 5px; font-family: var(--f-num); font-size: 12px; color: var(--game-dim); }
.reagent img { width: 16px; height: 16px; border: 1px solid #000; }
.power-others { font-family: var(--f-num); font-size: 11.5px; color: var(--game-dim); min-height: 1em; text-align: center; }
.swing[hidden] { display: none; }
.totems { display: flex; gap: 2px; justify-content: center; }
.totem-slot { position: relative; width: 22px; height: 22px; border: 1px solid #000; background: var(--hud); opacity: 0.45; }
.totem-slot.on { opacity: 1; }
.totem-slot img { width: 100%; height: 100%; display: block; }
.totem-slot img:not([src]) { visibility: hidden; }
.totem-slot small { position: absolute; left: 0; right: 0; bottom: -1px; text-align: center; font-family: var(--f-num); font-size: 10px; color: #fff; }
.totem-slot.el-fire { border-bottom: 2px solid #a8502a; } .totem-slot.el-earth { border-bottom: 2px solid #7d6236; }
.totem-slot.el-water { border-bottom: 2px solid #2f6aa8; } .totem-slot.el-air { border-bottom: 2px solid #8aa3b8; }
.threat { order: 4; position: relative; height: 12px; background: var(--hud); border: 1px solid #000; overflow: hidden; }
.threat i { position: absolute; inset: 0 auto 0 0; background-color: #3f9b5b; transition: width 0.2s; }
.threat.close i { background-color: #d08a2a; }
.threat.lost i { background-color: #c0392b; }
.threat span { position: relative; display: block; font-family: var(--f-ui); font-size: 10.5px; line-height: 10px; padding: 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.death-note { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); background: var(--hud); border: 1px solid #000; color: var(--game-red); padding: 9px 16px; font-size: 16px; text-shadow: var(--outline); pointer-events: none; }
.frame-player.dead { opacity: 0.6; }

/* raid frames (Healing test), left of the arena */
.raid-frames { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); max-height: calc(100% - 300px); overflow: auto; display: grid; grid-template-columns: repeat(2, 132px); gap: 6px 8px; background: var(--hud-soft); border: 1px solid #000; padding: 4px; }
.raid-group { display: grid; gap: 2px; }
.raid-group-name { font-family: var(--f-ui); font-size: 11px; color: var(--game-dim); }
.rf { position: relative; height: 30px; padding: 0 4px; border: 1px solid #000; border-radius: 0; background: var(--hud); overflow: hidden; text-align: left; cursor: pointer; }
.rf .rf-hp { position: absolute; inset: 0 auto 0 0; background-color: var(--c); opacity: 0.7; transition: width 0.15s; }
.rf .rf-shield { position: absolute; inset: auto auto 0 0; height: 3px; background: #e8f0ff; opacity: 0.85; }
.rf .rf-name { position: relative; display: block; font-family: var(--f-game); font-size: 12px; line-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.rf .rf-def { position: absolute; right: 3px; bottom: 1px; font-family: var(--f-num); font-size: 11px; color: #ffb3a8; }
.rf .rf-hots { position: absolute; left: 3px; bottom: 2px; display: flex; gap: 1px; }
.rf .rf-hots img { width: 10px; height: 10px; }
.rf.sel { box-shadow: inset 0 0 0 2px #fff; }
.rf.low { border-color: var(--game-red); }
.rf.dead { opacity: 0.45; }
.rf.dead .rf-hp { width: 0 !important; }
.rf.far { opacity: 0.55; }
.rf.me .rf-name { color: var(--game-yellow); }
@container stage (max-width: 980px) { .raid-frames { grid-template-columns: repeat(2, 110px); } }
.raid-frames.one { grid-template-columns: 150px; }
@container stage (max-width: 980px) { .raid-frames.one { grid-template-columns: 120px; } }

/* tooltip: MangiUI box (1px black border, black at 75%), with the game's fonts and order */
.tooltip { position: fixed; z-index: 60; max-width: 320px; background: rgba(0, 0, 0, 0.75); border: 1px solid #000; border-radius: 0; padding: 7px 9px; font-family: var(--f-game); font-size: 13.5px; line-height: 1.35; color: var(--game-text); pointer-events: none; }
.tt-title { font-size: 15px; color: var(--game-text); }
.tt-sub { color: var(--game-text); font-size: 13px; }
.tt-row { display: flex; justify-content: space-between; gap: 16px; }
.tt-text { color: var(--game-yellow); margin-top: 4px; }
.tt-next { margin-top: 6px; }
.tt-req { color: var(--game-red); margin-top: 4px; }
.tt-note { color: var(--game-dim); margin-top: 6px; font-style: italic; }
.tt-hint { color: var(--game-green); margin-top: 6px; font-size: 12.5px; }
.tt-req-line { color: var(--game-text); font-size: 13px; }
.tt-notsim { color: #9d9d9d; margin-top: 6px; font-size: 12.5px; }
.tt-notes { color: #c9a227; margin-top: 6px; font-size: 12.5px; }
/* An ability named in a tooltip's text, with its icon (as on ForeverChanges). */
.spell-ref { white-space: nowrap; }
.spell-ref img { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; border: 1px solid #000; }
.icon-missing { background: #2a2f3a; }

/* start: the arena dimmed until Start; the HUD and the test tabs stay above it */
.start-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 16px; }
.start-box { text-align: center; max-width: 340px; background: var(--hud); border: 1px solid #000; padding: 16px 22px 18px; position: relative; z-index: 4; }
/* On short stages the HUD block can reach the Start window: the window sits above the HUD, and the HUD's middle column
   only catches clicks on its own pieces. */
.bars-mid { pointer-events: none; }
.bars-mid > :not(.cast-zone) { pointer-events: auto; }
.start-kicker { margin: 0 0 6px; font-family: var(--f-game); color: var(--game-text); font-size: 22px; text-shadow: var(--outline); }
.start-text { margin: 0 0 14px; font-family: var(--f-ui); font-size: 14px; line-height: 1.45; color: var(--game-dim); }
.start-btn { font-family: var(--f-game); font-size: 18px; color: var(--game-text); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--cls); border-radius: 0; padding: 7px 28px; display: inline-flex; align-items: center; gap: 10px; }
.start-btn:hover { background: color-mix(in srgb, var(--cls) 22%, transparent); }
.start-btn kbd { font-size: 12px; }
.start-note { display: none; }

/* Text on bars, frames and slots: a black outline, readable on any color under it */
.bar span, .castbar span, .threat span, .rf .rf-name, .rf .rf-def, .slot-key, .slot-cd-text, .aura b, .aura small, .tal-rank, .totem-slot small, .reagent span, .slot-tag, .tt-title { text-shadow: var(--outline); }

/* header links: Import / Export, Copy link, Feedback */
.links { margin-left: auto; position: relative; display: flex; gap: 14px; }
/* Ko-fi button: the lab's own, no third-party script. Bronze keeps white text readable (4.9:1). */
.kofi { display: inline-flex; align-items: center; gap: 6px; background: #9c6422; color: #fff; border-radius: 999px; padding: 4px 12px 4px 9px; font-size: 13px; font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap; transition: background .15s; }
.kofi:hover { background: #b0742a; }
.kofi svg { width: 15px; height: 15px; flex: none; }
.link-box { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(420px, 92vw); background: var(--page-2); border: 1px solid var(--line-strong); border-radius: 2px; padding: 12px; display: grid; gap: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.link-box[hidden] { display: none; }
.link-box label, .link-row span { font-size: 13px; color: var(--muted); }
.link-row { display: flex; gap: 6px; align-items: center; }
.link-row input { flex: 1; min-width: 0; padding: 6px 8px; background: var(--page); border: 1px solid var(--line-strong); border-radius: 2px; color: inherit; font: inherit; font-size: 13px; }
.link-row span { flex: 1; }
.link-row a.ghost { text-decoration: none; color: inherit; }
.link-row .ghost { border: 1px solid var(--line-strong); border-radius: 2px; padding: 4px 10px; }
.link-box label.link-check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#codeOut { font-family: var(--f-num); letter-spacing: 0.02em; }
.link-note { margin: 0; font-size: 13px; color: var(--brass-lit); min-height: 1em; overflow-wrap: anywhere; }

/* Shaman's Totem Bar (Gear and options): calls in rows, elements in columns */
.totem-grid { display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: 4px 6px; align-items: center; margin-bottom: 12px; }
.totem-grid select { width: 100%; min-width: 0; font-size: 12px; }
.totem-call { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.seg-rows { display: grid; gap: 6px; }
.seg-row { display: grid; grid-template-columns: 4.5em 1fr; align-items: center; gap: 8px; }
.seg-label { font-size: 12px; color: var(--muted); }

/* Feedback window */
.fb { max-width: 560px; display: grid; gap: 10px; }
.fb .modal-sub { margin: 0; }
.fb-field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.fb textarea, .fb input[type="text"], .fb select { font: inherit; font-size: 14px; color: var(--body); background: var(--page); border: 1px solid var(--line-strong); border-radius: 2px; padding: 7px 9px; width: 100%; }
.fb textarea { resize: vertical; min-height: 110px; }
.fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .fb-row { grid-template-columns: 1fr; } }
.fb-attached { margin: 0; font-size: 12.5px; color: var(--muted); }
.fb-actions { display: flex; gap: 8px; }
.fb-actions .ghost { border: 1px solid var(--line-strong); border-radius: 2px; padding: 5px 12px; }
.fb-actions .ghost.on { border-color: var(--brass); color: var(--parchment); }
.fb-actions .ghost.on:disabled { opacity: 0.5; cursor: default; }
.fb-status { margin: 0; min-height: 1em; font-size: 13px; color: var(--brass-lit); }
.fb-status.is-error { color: var(--game-red); }
.fb-privacy { margin: 0; font-size: 11.5px; color: var(--muted); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* sizes */
@container stage (max-width: 1000px) { .hud { --slot: 38px; } .unit-row { grid-template-columns: 190px 190px; } }
@container stage (max-width: 790px) { .hud { --slot: 34px; } .unit-row { grid-template-columns: 170px 170px; } }
@media (max-width: 1500px) and (min-width: 1101px) {
  :root { --tal: 30px; }
  .layout { grid-template-columns: 540px 1fr; }
}

/* narrow screens: the builder under the arena */
@media (max-width: 1100px) {
  body { overflow: auto; display: block; }
  .layout { display: flex; flex-direction: column-reverse; }
  .stage { height: 82vh; min-height: 600px; }
  .panel { overflow: visible; border-right: 0; }
}
@media (max-width: 720px) {
  :root { --tal: 34px; }
  .tal-trees { grid-template-columns: 1fr; }
  .unit-row { grid-template-columns: 1fr 1fr; width: 100%; }
  .bars-mid { width: 100%; }
  .bars { bottom: 44px; display: flex; flex-direction: column; align-items: center; }
  .bars > span:empty { display: none; }
  .stancebar { justify-self: auto; }
  .error-text { top: 110px; font-size: 15px; }
  .keys-hint { display: none; }
  .sim-note { left: 16px; max-width: none; text-align: center; }
}

/* Touch: a switch between adding and removing talent points (no right click) */
.tal-touch { display: none; }
.touch-nav { display: none; }

/* ---------- Touch layout (phones and tablets; body.touch, set by app.js) ----------
   Portrait first: one view at a time, switched by the bar at the bottom. Play: the class row, the test tabs, the arena,
   then the HUD block (frames, cast bar, stance bar, action bar 2 x 6) near the thumbs. Talents, Spellbook and Gear:
   the builder's tabs, full screen. */
body.touch { display: grid; height: 100dvh; grid-template-rows: auto 1fr auto auto; overflow: hidden; -webkit-touch-callout: none; }
body.touch button, body.touch .slot, body.touch .tal { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body.touch .hud, body.touch .bars, body.touch .tal-trees { user-select: none; -webkit-user-select: none; }
body.touch #arena { touch-action: none; cursor: default; }
/* header: one row that scrolls sideways */
/* header on a phone: everything in reach, one thing per row (classes, then the class's specs, then the actions) */
body.touch .top { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 6px; padding: 6px 12px 4px; }
body.touch .brand-title { font-size: 18px; }
body.touch .class-pick { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
body.touch .class-btn { width: 100%; height: auto; aspect-ratio: 1; max-height: 44px; padding: 2px; display: grid; place-items: center; }
body.touch .class-btn img { width: 100%; height: 100%; max-width: 38px; max-height: 38px; }
body.touch .class-name { display: none; }
body.touch .builds { flex-wrap: wrap; gap: 0 2px; align-items: center; }
body.touch .builds-class { display: inline; font-family: var(--f-display); font-size: 16px; margin-right: 6px; }
body.touch .build-btn { padding: 7px 8px 6px; }
body.touch .links { margin-left: 0; gap: 18px; border-top: 1px solid var(--line); padding-top: 3px; flex-wrap: wrap; }
body.touch .links > .ghost { padding: 6px 0; font-size: 13.5px; }
body.touch .links > .kofi { font-size: 13.5px; padding: 5px 12px 5px 9px; }
body.touch .link-box { position: static; width: 100%; flex-basis: 100%; margin: 2px 0 6px; box-shadow: none; }
/* iOS zooms the page into any field under 16px */
body.touch input[type="text"], body.touch select, body.touch textarea { font-size: 16px; }
body.touch .modal-back { align-items: start; overflow: auto; }
body.touch .modal { padding: 16px; }
/* views */
body.touch .layout { display: block; min-height: 0; height: 100%; }
body.touch .stage { height: 100%; min-height: 0; }
body.touch .panel { height: 100%; overflow: auto; border-right: 0; }
body.touch[data-view="play"] .panel { display: none; }
body.touch:not([data-view="play"]) .stage { display: none; }
body.touch .tabs { display: none; }
body.touch:not([data-view="gear"]) .foot { display: none; }
body.touch .top { order: -1; } body.touch .foot { order: 1; } body.touch .touch-nav { order: 2; }
body.touch[data-view="play"] .brand { display: none; }
body.touch .foot { font-size: 11px; }
body.touch .touch-nav { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--page-2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
body.touch .touch-nav button { background: transparent; border: 0; border-top: 2px solid transparent; padding: 12px 4px 13px; font-size: 14px; color: var(--muted); }
body.touch .touch-nav button[aria-current="true"] { color: var(--parchment); border-top-color: var(--brass); }
/* the test bar: tabs, then the options; the blurb is shorter on a phone */
body.touch .meter { padding: 4px 12px 6px; }
body.touch .reset-btn { font-size: 13px; }
body.touch .test-blurb { display: none; }
body.touch .test-btn { font-size: 15px; padding: 6px 10px 5px; }
body.touch .test-opt { padding: 4px 0; font-size: 13.5px; }
body.touch .test-opt input[type=checkbox] { width: 18px; height: 18px; }
body.touch .test-opt .seg-btn { padding: 5px 10px; font-size: 13px; }
/* HUD block: full width, slots sized to the screen (6 per row, up to 56px) */
body.touch .hud { --slot: min(50px, calc((var(--vw, 100vw) - 24px - 10px) / 6)); }
body.touch .bars { left: 12px; right: 12px; bottom: 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
body.touch .bars > span:empty { display: none; }
body.touch .bars-mid { width: 100%; }
body.touch .stancebar { order: 2; justify-self: auto; --slot-s: calc(var(--slot) * 0.64); }
body.touch .unit-row { grid-template-columns: 1fr 1fr; width: 100%; gap: 8px; }
body.touch .cast-zone { height: 30px; }
body.touch .castbar, body.touch .swings { width: 100%; max-width: 360px; }
body.touch .swing::before { display: none; }
body.touch .slot-key, body.touch .stancebar .slot-key { display: none; }
body.touch .actionbar { gap: 2px; }
body.touch .keys-hint { display: none; }
body.touch .sim-note { display: none; }
body.touch .error-text { top: calc(var(--meter-h, 64px) + var(--raid-h, 0px) + 40px); font-size: 15px; }
body.touch .bar-hint { bottom: calc(2 * var(--slot) + 170px); }
body.touch .start-btn kbd { display: none; }
body.touch .start-text { display: none; }
body.touch .start-kicker { font-size: 20px; margin-bottom: 10px; }
body.touch .start-box { padding: 12px 16px 14px; }
.start-hint-touch { display: none; }
body.touch .start-hint-touch { display: block; margin: 10px 0 0; font-size: 12px; line-height: 1.4; color: var(--game-text); }
/* auras: the time left inside the icon's bottom, to save a row */
body.touch .aura { height: 22px; }
body.touch .aura small { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; font-size: 10px; }
body.touch .auras { min-height: 22px; }
body.touch .start-box { max-width: 300px; }
body.touch .start-overlay { place-items: start center; padding-top: calc(var(--meter-h, 64px) + var(--raid-h, 0px) + 14px); }
/* Healing test: the three frames as a row under the test tabs, tall enough to tap */
body.touch .raid-frames { top: calc(var(--meter-h, 64px) + 6px); left: 12px; right: 12px; transform: none; max-height: none; grid-template-columns: 1fr; padding: 3px; }
body.touch .raid-frames .raid-group { grid-template-columns: repeat(3, 1fr); gap: 4px; }
body.touch .raid-frames .raid-group-name { display: none; }
body.touch .rf { height: 40px; }
body.touch .rf .rf-name { font-size: 13px; line-height: 18px; }
/* builder views */
body.touch .builder { padding: 12px 12px 24px; }
body.touch .tal-head { flex-wrap: wrap; gap: 8px; }
body.touch .tal-touch { display: flex; flex-wrap: nowrap; order: 3; width: 100%; }
body.touch .tal-touch .seg-btn { flex: 1; padding: 8px 10px; }
body.touch .tal-trees { grid-template-columns: 1fr; gap: 8px; }
body.touch { --tal: 40px; }
body.touch .tal-grid { gap: 10px; }
body.touch .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
body.touch .book-spell { padding: 5px; }
/* the spellbook's bar (touch) */
.bar-edit { position: sticky; top: -12px; z-index: 3; margin: -12px -12px 8px; padding: 10px 12px 2px; background: var(--page-2); border-bottom: 1px solid var(--line); }
.bar-edit-head { display: flex; align-items: center; justify-content: space-between; }
.bar-edit-head .label { margin: 0 0 6px; }
.bar-edit-head .ghost { color: var(--brass-lit); }
.bar-edit-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.bar-edit-slots .slot { width: auto; height: auto; aspect-ratio: 1; }
.bar-edit-slots .slot-key { display: block !important; }
.bar-edit-slots .slot.picked { box-shadow: inset 0 0 0 2px var(--game-yellow); }
.bar-edit .hint { margin: 6px 0 4px; }


/* ---------- Phones, part 2 (src/ui/mobile.js does what the CSS cannot) ---------- */
.top-pick { display: contents; }
.top-mini, .link-close { display: none; }

/* Compact header in Play (m-compact, set by mobile.js): the class and the spec, each opening its own menu over the
   arena, the Ko-fi cup and "..." with Import / Export, Copy link and Feedback. */
body.touch.m-compact .top { position: relative; z-index: 30; padding: 2px 10px; gap: 0; }
body.touch.m-compact .top-mini { display: flex; align-items: center; gap: 8px; min-height: 40px; min-width: 0; }
body.touch.m-compact .top-pick { display: none; }
body.touch.m-compact .links { position: absolute; visibility: hidden; pointer-events: none; }
body.touch.m-compact .links > .kofi { display: none; }
body.touch.m-compact .links .link-box:not([hidden]) { visibility: visible; pointer-events: auto; }
body.touch.m-compact.top-cls-open .top-pick, body.touch.m-compact.top-spec-open .top-pick, body.touch.m-compact.top-more-open .links { display: flex; flex-direction: column; gap: 8px; position: absolute; left: 0; right: 0; top: 100%; z-index: 31; visibility: visible; pointer-events: auto; margin: 0; padding: 10px 12px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); background: linear-gradient(rgba(36, 29, 23, 0.98), rgba(36, 29, 23, 0.98)), var(--paint); background-size: auto, 900px; box-shadow: 0 14px 30px rgba(0, 0, 0, 0.6); }
body.touch.m-compact.top-more-open .links { align-items: flex-start; gap: 2px; }
body.touch.m-compact.top-more-open .links > .ghost { font-size: 15px; padding: 9px 0; }
/* One menu at a time: the classes, or the specs. */
body.touch.m-compact.top-cls-open .top-pick .builds, body.touch.m-compact.top-spec-open .top-pick .class-pick { display: none; }
/* The class and the spec: two buttons. The spec gives way first on a narrow screen. */
.mini-cls { flex: none; min-width: 0; display: flex; align-items: center; gap: 6px; background: transparent; border: 0; padding: 4px 2px; text-align: left; white-space: nowrap; }
.mini-spec-btn { flex: 0 1 auto; overflow: hidden; margin-right: auto; }
.mini-cls .class-icon { width: 28px; height: 28px; border-radius: 2px; flex: none; }
.mini-cls .spec-icon { flex: none; }
.mini-name { font-family: var(--f-display); font-size: 17px; }
.mini-spec { min-width: 0; color: var(--parchment); font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.mini-caret { flex: none; color: var(--muted); font-size: 11px; }
.mini-more { flex: none; background: transparent; border: 1px solid var(--line-strong); border-radius: 2px; color: var(--parchment); font-size: 20px; line-height: 1; width: 40px; height: 34px; padding: 0; }
body.top-cls-open #miniCls .mini-caret, body.top-spec-open #miniSpec .mini-caret, body.top-more-open .mini-more { color: var(--brass-lit); border-color: var(--brass); }
/* Ko-fi on the compact line: only the cup, so a long class and spec still fit. */
.top-mini .mini-kofi { display: inline-flex; flex: none; width: 34px; height: 34px; padding: 0; justify-content: center; }
.top-mini .mini-kofi span { display: none; }
.top-mini .mini-kofi svg { width: 17px; height: 17px; }
/* Talents, Spellbook and Gear (the full header): Ko-fi on the title line, on the right, clear of the classes. */
body.touch .top { position: relative; }
body.touch .links { position: static; }
body.touch:not([data-view="play"]) .brand { min-height: 44px; align-items: center; white-space: nowrap; padding-right: 146px; }
body.touch:not([data-view="play"]) .links > .kofi { position: absolute; top: 11px; right: 12px; height: 34px; padding: 0 12px 0 10px; }

/* The test's options only before Start; in the fight only Reset is left, floating at the top right. */
body.touch.fighting .meter .test-row.sub { display: none; }
body.touch.fighting .meter { left: auto; background: transparent; border: 0; padding: 6px 8px; }
body.touch.fighting .test-pick { display: none; }
/* Reset as a clear button, without the R key */
body.touch .reset-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--game-dim); border-radius: 2px; background: rgba(255, 255, 255, 0.06); color: var(--game-text); font-size: 14px; padding: 5px 12px; }
body.touch.fighting .reset-btn { background: var(--hud); }
body.touch .reset-btn::before { content: "↻"; font-size: 16px; line-height: 1; }
body.touch .reset-btn kbd { display: none; }

/* HUD: no empty slots in the fight, the names inside the health bars, the stance bar as a column at the left edge
   (sizes and the action bar's shift from mobile.js). */
body.touch.fighting .actionbar .slot.empty { display: none; }
body.touch .bar.hp .frame-name { position: absolute; left: 6px; top: 0; z-index: 2; max-width: 58%; line-height: 20px; font-size: 12px; text-align: left; }
body.touch .bar.hp > span { text-align: right; padding-right: 6px; }
body.touch .stancebar { position: absolute; left: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--stance-rows, 3), var(--slot-s)); gap: 2px; --slot-s: var(--stance-s, 30px); }
body.touch .actionbar { position: relative; left: var(--bar-shift, 0px); }

/* The stage as a column: the arena in its own box between the test bar (and frames) and the HUD (mobile.js). */
body.touch #arena { inset: auto; top: var(--cv-top, 0px); left: 0; width: 100%; height: calc(100% - var(--cv-top, 0px) - var(--cv-bot, 0px)); }
body.touch .start-overlay { inset: auto; top: var(--cv-top, 0px); bottom: var(--cv-bot, 0px); left: 0; right: 0; padding: 8px; place-items: center; }
body.touch .start-box { max-height: 100%; overflow: auto; }

/* Import / Export in a window */
body.touch .link-box { position: fixed; left: 12px; right: 12px; top: 12%; width: auto; z-index: 70; margin: 0; box-shadow: 0 0 0 100vmax rgba(10, 8, 6, 0.72), 0 20px 60px rgba(0, 0, 0, 0.6); }
body.touch .link-close { display: block; justify-self: end; border: 1px solid var(--line-strong); border-radius: 2px; padding: 6px 14px; font-size: 14px; }

/* In Talents, Spellbook and Gear the header scrolls away with the page: the body scrolls itself (so its overflow must
   not pass to the viewport), the views bar stays at the bottom. */
html:has(> body.touch) { overflow: hidden; }
body.touch:not([data-view="play"]) { display: flex; flex-direction: column; overflow-y: auto; }
body.touch:not([data-view="play"]) > * { flex-shrink: 0; }
body.touch:not([data-view="play"]) .layout, body.touch:not([data-view="play"]) .panel { height: auto; overflow: visible; }
body.touch:not([data-view="play"]) .touch-nav { position: sticky; bottom: 0; z-index: 20; }
body.touch:not([data-view="play"]) .bar-edit { top: 0; }

/* Gear's Advanced as a box of its own */
body.touch details.advanced { margin-top: 26px; padding: 0; border: 1px solid var(--line-strong); border-radius: 2px; background: rgba(0, 0, 0, 0.22); }
body.touch details.advanced summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; font-family: var(--f-display); font-size: 16px; color: var(--parchment); }
body.touch details.advanced summary::-webkit-details-marker { display: none; }
body.touch details.advanced summary::after { content: "▾"; color: var(--brass); font-size: 14px; transition: transform 0.15s; }
body.touch details.advanced[open] summary::after { transform: rotate(180deg); }
body.touch details.advanced[open] summary { border-bottom: 1px solid var(--line); }
body.touch details.advanced > :not(summary) { margin-left: 14px; margin-right: 14px; }
body.touch details.advanced > :last-child { margin-bottom: 14px; }

/* Talents: one tree at a time, picked from tabs (mobile.js) */
.tree-tabs { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 0 8px; padding: 4px 0; background: var(--page-2); }
.tree-tab { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 7px 6px; background: #0d0c0b; border: 1px solid #000; border-bottom: 2px solid transparent; color: var(--game-dim); font-family: var(--f-game); font-size: 13px; text-align: left; }
.tree-tab img { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px #000; }
.tree-tab-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-tab b { font-family: var(--f-num); font-weight: 600; font-size: 14px; color: var(--game-yellow); }
.tree-tab.on { color: var(--game-text); border-bottom-color: var(--cls); background: #1a1714; }

/* A phone on its side (body.land, set by mobile.js) has no room for the arena and the HUD: ask for portrait. */
body.touch.land::after { content: "Turn your phone upright to play the Forever Class Lab."; position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--page); color: var(--parchment); font-family: var(--f-display); font-size: 20px; }
