:root { --bg:#05060a; --panel:rgba(12,12,20,.78); --line:#2a2a38; --text:#ece6d6; --muted:#9a937f; --gold:#e8b44a; }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); overflow:hidden;
  font:14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; touch-action:none;
  -webkit-user-select:none; user-select:none; -webkit-tap-highlight-color:transparent; }
#game { position:fixed; inset:0; }
#game canvas { display:block; image-rendering:pixelated; image-rendering:crisp-edges; }
.hidden { display:none !important; }

.card { position:fixed; left:50%; top:50%; transform:translate(-50%,-50%); width:min(92vw,380px); padding:22px;
  background:var(--panel); border:1px solid var(--line); border-radius:10px; z-index:20; backdrop-filter:blur(4px); }
.card h1 { margin:0 0 6px; font-size:22px; color:var(--gold); letter-spacing:.5px; }
.card p { color:var(--muted); margin:6px 0 14px; }
.card form { display:flex; gap:8px; }
input { flex:1; min-width:0; background:#0b0b12; color:var(--text); border:1px solid var(--line); border-radius:6px;
  padding:9px 10px; font:inherit; font-size:16px; -webkit-user-select:text; user-select:text; outline:none; }
input:focus { border-color:#5a5040; }
button { background:var(--gold); color:#1b1408; border:0; border-radius:6px; padding:9px 14px; font:inherit; font-weight:600; cursor:pointer; }
.err { color:#ff7b6b !important; min-height:1em; }

#hud { position:fixed; top:calc(8px + env(safe-area-inset-top,0px)); left:8px; display:flex; gap:6px; z-index:5; pointer-events:none; }
#topRight { position:fixed; top:calc(8px + env(safe-area-inset-top,0px)); right:8px; z-index:5; display:flex; gap:6px; align-items:center;
  flex-wrap:wrap; justify-content:flex-end; max-width:calc(100vw - 16px); }
#perf { flex:0 0 auto; pointer-events:none; white-space:nowrap; max-width:100%; overflow:hidden; text-overflow:ellipsis; }
/* speaker = mute everything (also key N); note = music only */
.iconBtn { display:flex; align-items:center; justify-content:center; min-width:30px; height:24px; padding:0 8px; color:var(--text);
  cursor:pointer; font-weight:400; }
.iconBtn.off { color:#ff8a7a; }
#soundBtn .x, #musicBtn .slash { display:none; }
#soundBtn.off .w { display:none; }
#soundBtn.off .x, #musicBtn.off .slash { display:inline; }
#musicBtn.off { color:var(--muted); }
body.touch .iconBtn { min-width:40px; height:32px; }
#soundHint { position:fixed; left:50%; transform:translateX(-50%); bottom:calc(14px + env(safe-area-inset-bottom,0px)); z-index:5;
  pointer-events:none; opacity:.8; transition:opacity .6s; }
#soundHint.gone { opacity:0; }

/* ---------------------------------------------------------------- HUD chrome (vitals, action bars; target frame in social.css)
   Glass-dark panels: soft gradient, thin warm-gold hairline, inner glow, rounded. Pixel icons stay crisp. */
:root { --hud-glass:linear-gradient(180deg, rgba(40,32,26,.84), rgba(13,10,9,.9));
  --hud-line:rgba(232,190,110,.34); --hud-line-hi:rgba(255,214,140,.85);
  --hud-shadow:0 8px 22px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,236,196,.12), inset 0 0 14px rgba(255,190,100,.05); }

/* ---------------------------------------------------------------- menu theme (all DOM panels: settings, bag, skills, sheet,
   quest log, merchant, social, guild). Same family as the HUD: dark wood glass, warm gold hairline, inner glow, rounded. */
:root { --ui-font:Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "Noto Serif", "Times New Roman", serif;
  --ui-wood:linear-gradient(180deg, rgba(48,35,24,.97), rgba(22,16,11,.97) 60%, rgba(17,12,8,.98));
  --ui-rim:0 0 0 1px rgba(8,5,2,.9), inset 0 0 0 1px rgba(232,190,110,.42), inset 0 1px 0 rgba(255,236,196,.18), inset 0 0 28px rgba(255,180,90,.06);
  --ui-box:inset 0 0 0 1px rgba(232,190,110,.24), inset 0 1px 0 rgba(255,236,196,.07), 0 1px 2px rgba(0,0,0,.45);
  --ui-box-sel:inset 0 0 0 1px rgba(255,214,140,.9), inset 0 0 12px rgba(255,190,90,.2);
  --ui-slot:inset 0 0 0 1px rgba(232,190,110,.2), inset 0 2px 7px rgba(0,0,0,.7), 0 1px 0 rgba(255,236,196,.06);
  --ui-slot-bg:radial-gradient(circle at 50% 38%, #2a2018, #0f0b08 80%);
  --ui-btn:linear-gradient(180deg, #3a2a1c, #2a1d13); --ui-btn-hover:linear-gradient(180deg, #4a3624, #33241a);
  --ui-r:8px; --ui-r-panel:14px; }
/* menu lettering (uitext.js): smooth serif in normal case; headings in small caps */
.ut { font-family:var(--ui-font); font-weight:400; line-height:1.15; letter-spacing:.01em; text-shadow:0 1px 2px rgba(0,0,0,.75);
  white-space:nowrap; }
.ut1 { font-size:12px; } .ut2 { font-size:15px; } .ut3 { font-size:21px; } .ut4 { font-size:27px; } .ut5 { font-size:34px; }
h2 > .ut, h3 > .ut, h3 > span > .ut, .ctitle .ut, .sgroup > .ut { font-variant:small-caps; letter-spacing:.06em; font-weight:600; }
h2 > .ut { font-size:20px; text-shadow:0 1px 0 rgba(0,0,0,.6), 0 0 12px rgba(255,180,80,.25); }
.pxbtn:not(.dark) .ut { text-shadow:0 1px 0 rgba(255,244,214,.55); font-weight:600; }
/* key hint chips: "Skills [K]" on panel titles and HUD buttons (hidden on touch-only screens) */
.khint { display:inline-block; margin-left:6px; padding:0 5px; min-width:9px; border-radius:5px; font:600 11px/15px system-ui, sans-serif;
  text-align:center; vertical-align:2px; color:#f3dca6; background:rgba(0,0,0,.4); box-shadow:inset 0 0 0 1px rgba(232,190,110,.4);
  text-shadow:none; font-variant:normal; letter-spacing:0; }
body.touch .khint { display:none; }

/* vitals: HP, stamina, class resource, XP (progress.js), buffs; top left under the name */
#vitals { position:fixed; top:calc(36px + env(safe-area-inset-top,0px)); left:8px; z-index:5; pointer-events:none; width:156px;
  display:flex; flex-direction:column; gap:4px; padding:6px 7px 7px; border-radius:12px; background:var(--hud-glass);
  border:1px solid var(--hud-line); box-shadow:var(--hud-shadow); }
.bar { position:relative; overflow:hidden; background:rgba(4,3,6,.72); border:1px solid rgba(255,226,170,.14); border-radius:999px;
  box-shadow:inset 0 1px 3px rgba(0,0,0,.7); }
.bar i { position:absolute; inset:0; transform-origin:left center; border-radius:inherit; }
.bar > i:not(.tfdmg)::after { content:''; position:absolute; inset:0 0 50%; border-radius:inherit;      /* glossy top half */
  background:linear-gradient(rgba(255,255,255,.22), rgba(255,255,255,0)); }
#hpBar { height:17px; }
#hpBar i { background:linear-gradient(90deg, #8a2620, #d24a3c); transition:transform .18s ease-out; }
#hpBar span { position:relative; display:block; text-align:center; font:700 11px/15px system-ui, -apple-system, "Segoe UI", sans-serif;
  color:#fff4e6; font-variant-numeric:tabular-nums; text-shadow:0 1px 2px #000; }
#stBar { height:7px; width:86%; }
@media (max-width: 760px) { #vitals { top:calc(80px + env(safe-area-inset-top,0px)); } }   /* perf pill wraps to a 2nd row */
@media (max-width: 430px) { body:not(.noperf) #vitals { top:calc(112px + env(safe-area-inset-top,0px)); } }   /* phones: it wraps to a 3rd row */
#stBar i { background:linear-gradient(90deg, #4f8a2e, #a6dc6e); transition:background .2s; }
#stBar.exhausted i { background:linear-gradient(90deg, #9a6f2a, #e0b860); }
#stBar.flash { animation:stflash .35s; }
@keyframes stflash { 0%,100% { border-color:rgba(255,226,170,.14); } 30% { border-color:#ff8a6a; box-shadow:0 0 8px #ff6a4a; } }

/* touch action buttons (right thumb) */
#actions { position:fixed; right:12px; bottom:calc(58px + env(safe-area-inset-bottom,0px)); z-index:6; width:170px; height:150px; }
#actions .act { position:absolute; border-radius:50%; padding:0; color:#f3e6d6; font-weight:700; font-size:13px; touch-action:none;
  background:rgba(20,18,28,.55); border:2px solid rgba(255,230,180,.35); }
#actions .act:active { background:rgba(232,180,74,.45); }
#btnAttack { right:0; bottom:0; width:76px; height:76px; font-size:14px; border-color:rgba(255,200,120,.6) !important; }
#btnDash { right:86px; bottom:4px; width:58px; height:58px; }
#btnSheathe { right:16px; bottom:88px; width:44px; height:44px; }
#btnBlock { right:72px; bottom:74px; width:54px; height:54px; border-color:rgba(150,190,255,.55) !important; }
.pill { background:var(--panel); border:1px solid var(--line); border-radius:999px; padding:3px 10px; font-size:12px;
  color:var(--muted); font-variant-numeric:tabular-nums; }
.pill.gold { color:var(--gold); }
.pill.ok { color:#8fd18b; } .pill.bad { color:#ff8a7a; }

#chat { position:fixed; left:8px; bottom:calc(8px + env(safe-area-inset-bottom,0px)); width:min(360px, calc(100vw - 16px)); z-index:6; }
#chatLog { max-height:26vh; overflow-y:auto; padding:6px 8px; background:var(--panel); border:1px solid var(--line);
  border-bottom:0; border-radius:8px 8px 0 0; font-size:13px; scrollbar-width:thin; }
#chatLog:empty { display:none; }
#chatLog:empty + form input { border-radius:8px; }
#chatLog div { margin:2px 0; word-wrap:break-word; }
#chatLog .name { color:var(--gold); font-weight:600; }
#chatLog .sys { color:var(--muted); font-style:italic; }
#chatLog .dtag { display:inline-block; margin-right:4px; padding:0 4px; border-radius:3px; background:#5865f2; color:#fff;
  font-size:10px; font-weight:700; line-height:14px; vertical-align:1px; }
#chatForm input { width:100%; border-radius:0 0 8px 8px; font-size:14px; padding:7px 9px; background:rgba(8,8,14,.85); }
#chat:not(.typing) #chatForm input { opacity:.75; }
#chatBtn { position:fixed; right:8px; bottom:calc(10px + env(safe-area-inset-bottom,0px)); z-index:7; font-size:14px;
  padding:8px 14px; pointer-events:auto; color:var(--text); }

/* touch screens: chat opens with the Chat button, the left part of the screen is the move stick */
body.touch #chat { display:none; }
body.touch #chat.open { display:block; bottom:auto; top:calc(40px + env(safe-area-inset-top,0px)); }
body.touch #chatForm input { font-size:16px; }
#stick { position:fixed; width:110px; height:110px; margin:-55px 0 0 -55px; border-radius:50%; z-index:4; pointer-events:none;
  background:rgba(255,255,255,.07); border:2px solid rgba(255,255,255,.18); }
#stickKnob { position:absolute; left:50%; top:50%; width:46px; height:46px; margin:-23px 0 0 -23px; border-radius:50%;
  background:rgba(232,180,74,.45); border:2px solid rgba(255,230,180,.6); }
/* inside Discord's phone app, Discord's own bar covers the top ~60px */
body.touch.indiscord #hud, body.touch.indiscord #topRight { top:calc(64px + env(safe-area-inset-top,0px)); }
body.touch.indiscord #vitals { top:calc(92px + env(safe-area-inset-top,0px)); }
body.touch.indiscord #chat.open { top:calc(96px + env(safe-area-inset-top,0px)); }

/* ---------------------------------------------------------------- action bars (actionbar.js): skills 1-5, items Q E R F */
#bars { position:fixed; left:50%; bottom:calc(10px + env(safe-area-inset-bottom,0px)); transform:translateX(-50%); z-index:5;
  display:flex; gap:12px; align-items:flex-end; pointer-events:none; }
@media (max-width: 1400px) { #bars { left:auto; right:12px; transform:none; } }     /* keep clear of the chat box */
@media (max-width: 1060px) { #bars { flex-direction:column; gap:6px; align-items:flex-end; } }   /* 6 skills + ult: items on top */
.abar { display:flex; gap:6px; align-items:flex-end; padding:6px; pointer-events:auto; border-radius:16px;
  background:var(--hud-glass); border:1px solid var(--hud-line); box-shadow:var(--hud-shadow); }
.slot { position:relative; width:52px; height:52px; padding:0; border-radius:12px; overflow:hidden; cursor:pointer; flex:none;
  background:radial-gradient(circle at 50% 38%, #2c231b, #0d0a08 78%); touch-action:none;
  box-shadow:inset 0 0 0 1px rgba(232,190,110,.3), inset 0 2px 8px rgba(0,0,0,.75), 0 1px 2px rgba(0,0,0,.6);
  transition:box-shadow .15s, transform .1s; }
.slot:hover { box-shadow:inset 0 0 0 1px var(--hud-line-hi), inset 0 0 12px rgba(255,190,90,.22), 0 0 10px rgba(255,190,90,.3); }
.slot:active { transform:scale(.94); }
.slot.ult { width:60px; height:60px; border-radius:14px;            /* ornate gold ring: bright rim, dark inner band, outer glow */
  background:radial-gradient(circle at 50% 38%, #3a2816, #120b06 78%);
  box-shadow:inset 0 0 0 1.5px #f2c66c, inset 0 0 0 3px rgba(48,28,10,.95), inset 0 0 0 4px rgba(242,198,108,.35),
    inset 0 0 16px rgba(255,170,60,.28), 0 0 0 1px rgba(255,200,110,.3), 0 0 14px rgba(255,170,60,.35); }
.slot.ult:hover { box-shadow:inset 0 0 0 1.5px #ffe2a0, inset 0 0 0 3px rgba(48,28,10,.95), inset 0 0 0 4px rgba(255,226,160,.5),
  inset 0 0 18px rgba(255,190,80,.4), 0 0 0 1px rgba(255,220,140,.5), 0 0 18px rgba(255,180,70,.5); }
.slot.ult::before { content:''; position:absolute; inset:0; border-radius:inherit; pointer-events:none; opacity:0;   /* ready: breathing glow */
  box-shadow:inset 0 0 14px rgba(255,206,110,.75); }
.slot.ult:not(.cd):not(.nores):not(.locked)::before { animation:ultGlow 2.4s ease-in-out infinite; }
@keyframes ultGlow { 50% { opacity:1; } }
.slot.item { width:40px; height:40px; border-radius:10px; }
.abar .slot.ult { margin-left:6px; }                                   /* the ultimate stands a little apart */
.slot .ico { position:absolute; left:11%; top:11%; width:78%; height:78%; image-rendering:pixelated; image-rendering:crisp-edges;
  filter:drop-shadow(0 1px 1px rgba(0,0,0,.7)); transition:filter .2s, opacity .2s; }
/* cooldown: a radial sweep with a bright leading edge, seconds on top */
.slot .sweep { position:absolute; inset:0; border-radius:inherit; pointer-events:none;
  background:conic-gradient(rgba(5,4,3,.74) 0 calc(var(--p, 0) * 360deg),
    rgba(255,222,150,.55) 0 calc(var(--p, 0) * 360deg + min(var(--p, 0) * 400, 3) * 1deg), transparent 0); }
.slot.cd .ico { filter:saturate(.55) drop-shadow(0 1px 1px rgba(0,0,0,.7)); }
.slot .cdn { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; pointer-events:none;
  font:800 18px/1 system-ui, -apple-system, "Segoe UI", sans-serif; color:#fff; font-variant-numeric:tabular-nums;
  text-shadow:0 0 3px #000, 0 1px 2px #000, 0 0 8px rgba(0,0,0,.8); }
.slot.ult .cdn { font-size:20px; }
.slot.item .cdn { font-size:14px; }
.slot .key { position:absolute; left:3px; top:3px; z-index:1; min-width:16px; padding:0 5px; border-radius:999px; pointer-events:none;
  font:700 10px/13px system-ui, -apple-system, "Segoe UI", sans-serif; color:#f8dc98; text-align:center; white-space:nowrap;
  background:rgba(10,8,6,.82); border:1px solid rgba(232,190,110,.45); box-shadow:0 1px 2px rgba(0,0,0,.6); }
.slot.item .key { left:2px; top:2px; min-width:13px; padding:0 4px; font-size:9px; line-height:11px; }
.slot .cnt { position:absolute; right:2px; bottom:2px; z-index:1; padding:0 4px; border-radius:999px; pointer-events:none;
  font:700 10px/12px system-ui, -apple-system, "Segoe UI", sans-serif; color:#f3e2b4; background:rgba(10,8,6,.72); text-shadow:0 1px 1px #000; }
/* no mana / stamina: blue tint + desaturated icon */
.slot.nores .ico { filter:grayscale(.85) brightness(.55); }
.slot.nores::after { content:''; position:absolute; inset:0; border-radius:inherit; pointer-events:none;
  background:linear-gradient(rgba(60,100,230,.22), rgba(30,60,170,.4)); box-shadow:inset 0 0 0 1px rgba(120,160,255,.55); }
.slot.locked { cursor:default; background:#0b0908; }
.slot.locked .ico { opacity:.3; filter:grayscale(1); }
.slot.locked:hover { box-shadow:inset 0 0 0 1px rgba(232,190,110,.3), inset 0 2px 8px rgba(0,0,0,.75); }
.slot.flash { animation:slotReady .5s ease-out; }
@keyframes slotReady { 0% { filter:brightness(1.9); box-shadow:inset 0 0 0 2px #fff3c4, inset 0 0 14px rgba(255,230,160,.8), 0 0 16px #ffd27a; }
  100% { filter:none; } }
.slot.deny { animation:slotDeny .3s; }
@keyframes slotDeny { 0%,100% { transform:none; } 20% { transform:translateX(-3px); box-shadow:inset 0 0 0 2px #ff5a3a, 0 0 10px rgba(255,80,50,.6); }
  50% { transform:translateX(3px); box-shadow:inset 0 0 0 2px #ff5a3a, 0 0 10px rgba(255,80,50,.6); } 80% { transform:translateX(-1px); } }
#mpBar { height:7px; width:86%; }
#mpBar i { background:linear-gradient(90deg, #2c4fb8, #6aa4ff); }
#mpBar.focus i { background:linear-gradient(90deg, #c0862a, #ffe8a0); }           /* Ranger: Focus (gold, not stamina green) */
#mpBar.grace i { background:linear-gradient(90deg, #8ec4ea, #e6c46a 45%, #fffbe8); } /* Oracle: Grace (dawn white-gold, moon blue) */
#mpBar.flash { animation:stflash .35s; }
/* Shade: Edge = 5 pips (violet fill, 4 dark gaps), glowing when full */
#mpBar.edge { position:relative; height:8px; }
#mpBar.edge i { background:linear-gradient(90deg, #6a34c0, #d8b8ff); transition:transform .08s steps(1); }
#mpBar.edge::after { content:''; position:absolute; inset:0; pointer-events:none;
  background:repeating-linear-gradient(90deg, transparent 0 calc(20% - 2px), #0c0812 calc(20% - 2px) 20%); }
#mpBar.edge.full { box-shadow:0 0 6px #b07cff; }
#mpBar.tempo i { background:linear-gradient(90deg, #6a1020, #d83040 45%, #ffcc55); }   /* Bard: Tempo (crimson to gold) */
#mpBar.tempo.beat { box-shadow:0 0 5px #ffcc55; }                                      /* the beat (bard.js) */
#mpBar.resolve i { background:linear-gradient(90deg, #5a86b4, #c8902a 50%, #ffe8a0); }    /* Warden: Resolve (gold over steel) */
#mpBar.resolve.full { box-shadow:0 0 5px #ffcf6a; }                                  /* enough for Judgement */
#mpBar.resolve.bulwark { box-shadow:0 0 8px #fff2b0; animation:stflash .5s infinite; }   /* War Cry's Bulwark is up */
/* the buff bar (actionbar.js setBuffs): a row of icons on top of the skill bar; touch: above the button rings */
#buffs { position:absolute; right:0; bottom:calc(100% + 8px); display:flex; flex-wrap:wrap-reverse; justify-content:flex-end;
  gap:5px; max-width:min(420px, 90vw); pointer-events:none; }
#buffs:empty { display:none; }
#buffs .buff { position:relative; width:30px; height:30px; flex:none; pointer-events:auto; cursor:default; border-radius:5px;
  background:radial-gradient(circle at 50% 38%, #2c231b, #0d0a08 78%); box-shadow:0 0 0 1px #000, inset 0 0 0 1px rgba(120,220,140,.55); }
#buffs .buff.bad { box-shadow:0 0 0 1px #000, inset 0 0 0 1px rgba(255,90,70,.7); }
#buffs .buff .ico { position:absolute; left:3px; top:3px; width:24px; height:24px; image-rendering:pixelated; filter:drop-shadow(0 1px 1px rgba(0,0,0,.7)); }
#buffs .buff > i { position:absolute; inset:0; border-radius:inherit; pointer-events:none;     /* time spent: a dark sweep */
  background:conic-gradient(rgba(5,4,3,.62) 0 calc(var(--p, 0) * 360deg), transparent 0); }
#buffs .buff > b { position:absolute; left:0; right:0; bottom:-3px; text-align:center; font:700 10px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color:#fff4dc; text-shadow:0 0 2px #000, 0 1px 1px #000, 1px 0 1px #000, -1px 0 1px #000; font-variant-numeric:tabular-nums; pointer-events:none; }
#buffs .buff > u { position:absolute; right:1px; top:0; text-decoration:none; font:700 10px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  color:#fff; text-shadow:0 0 2px #000, 0 1px 1px #000, 1px 0 1px #000; pointer-events:none; }
#buffs .buff:not(.bad) + .buff.bad { margin-left:7px; }                    /* debuffs: a small gap after the buffs */
#buffs .buff.ending { animation:buffEnd .5s ease-in-out infinite alternate; }
@keyframes buffEnd { to { opacity:.45; } }
#actions #buffs { right:0; bottom:calc(100% + 6px); max-width:min(260px, 70vw); }
#actions #buffs.lh { right:auto; left:0; justify-content:flex-start; }
#buffTip { position:fixed; z-index:40; max-width:220px; padding:6px 9px 7px; pointer-events:none; border-radius:4px;
  background:rgba(14,10,7,.94); box-shadow:0 0 0 1px #000, inset 0 0 0 1px rgba(232,190,110,.45), 0 4px 12px rgba(0,0,0,.5);
  font:12px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; color:#eadcc0; display:flex; flex-direction:column; gap:2px; }
#buffTip b { color:#9ef0a8; font-weight:700; }
#buffTip.bad b { color:#ff8a70; }
#buffTip em { color:#b39b78; font-style:normal; font-size:11px; }
/* touch: the slots live in #actions, positioned around the Attack button by layoutTouch() */
#actions .slot { position:absolute; border-radius:14px; }
#actions .slot.item { opacity:.92; border-radius:12px; }
#actions .slot .key { display:none; }

/* ---------------------------------------------------------------- loading bar, title screen, character creator */
.loadbar { height:6px; background:#0b0b12; border:1px solid var(--line); border-radius:999px; margin-top:4px; overflow:hidden; }
.loadbar i { display:block; height:100%; background:linear-gradient(#f6d27a, #c98a2e); transform:scaleX(0); transform-origin:left; transition:transform .15s; }
canvas.px { display:block; image-rendering:pixelated; image-rendering:crisp-edges; }

/* z-index 4: above the game canvas, below the sound buttons / perf pill (5) */
#title { position:fixed; inset:0; z-index:4; display:flex; align-items:center; justify-content:center;
  font-family:var(--ui-font); }
#titleShade { position:absolute; inset:0; pointer-events:none;
  background:radial-gradient(ellipse 75% 70% at 50% 45%, rgba(5,6,10,.12) 0%, rgba(5,6,10,.5) 62%, rgba(3,3,6,.92) 100%),
             linear-gradient(rgba(5,6,10,.25), rgba(5,6,10,.25)); }
.tscreen { position:relative; display:flex; flex-direction:column; align-items:center; max-height:100%; width:100%;
  padding:calc(12px + env(safe-area-inset-top,0px)) 16px calc(12px + env(safe-area-inset-bottom,0px)); }
#titleMain { gap:clamp(8px, 2.4vh, 22px); }
#logo canvas { filter:drop-shadow(0 0 10px rgba(0,0,0,.75)) drop-shadow(0 0 26px rgba(255,160,60,.22)); }
#subtitle canvas { filter:drop-shadow(0 0 6px rgba(0,0,0,.9)); }
#subtitle { margin-top:-4px; opacity:.92; }
.tpanel { display:flex; flex-direction:column; align-items:center; gap:10px; width:min(320px, 92vw); margin-top:clamp(4px, 2vh, 18px); }
.tlabel { display:block; }
#tName { width:100%; flex:none; text-align:center; font-family:inherit; font-size:18px; color:#f6e7c1; letter-spacing:.5px;
  background:rgba(14,10,6,.82); border:1px solid rgba(232,190,110,.42); border-radius:10px; padding:10px 12px;
  box-shadow:0 0 0 1px #120a05, inset 0 2px 6px rgba(0,0,0,.5); }
#tName:focus { border-color:#d9a548; }
#tName::placeholder { color:#7d6a4c; }
#title .err { margin:0; min-height:1.2em; font-size:14px; text-align:center; text-shadow:0 1px 2px #000; }

/* menu buttons: rounded gold (primary) or dark wood (.dark), soft bevel, pressed = sinks a little */
.pxbtn { --face1:#f6d27e; --face2:#d9993c; --lip:rgba(110,60,16,.9); --hi:rgba(255,246,210,.75);
  display:inline-flex; align-items:center; justify-content:center; gap:4px; min-height:46px; min-width:140px; padding:10px 22px; margin:4px;
  border:0; border-radius:10px; cursor:pointer; color:#2a1606; font-family:var(--ui-font); background:linear-gradient(180deg, var(--face1), var(--face2));
  box-shadow:0 0 0 1px rgba(30,15,5,.9), inset 0 1px 0 var(--hi), inset 0 -2px 0 var(--lip), 0 3px 8px rgba(0,0,0,.45);
  transition:transform .06s, filter .1s, box-shadow .1s; touch-action:manipulation; }
.pxbtn:hover { filter:brightness(1.1); }
.pxbtn:focus-visible { outline:2px solid #fff3c4; outline-offset:3px; }
.pxbtn:active { transform:translateY(1px); box-shadow:0 0 0 1px rgba(30,15,5,.9), inset 0 2px 4px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.4); }
.pxbtn:disabled { filter:grayscale(.6) brightness(.7); cursor:default; }
.pxbtn.big { min-width:min(220px, 70vw); min-height:54px; padding:14px 34px; border-radius:12px; }
.pxbtn.big .ut { font-size:18px; }
.pxbtn.dark { --face1:#4a3624; --face2:#2e2015; --lip:rgba(10,6,3,.6); --hi:rgba(255,226,170,.16); min-width:96px; color:#f3e2b4;
  box-shadow:0 0 0 1px rgba(8,5,2,.9), inset 0 0 0 1px rgba(232,190,110,.3), inset 0 1px 0 var(--hi), 0 3px 8px rgba(0,0,0,.45); }
.linkbtn { background:none; color:#d6c193; font:inherit; font-size:15px; font-weight:400; text-decoration:underline; text-underline-offset:3px;
  padding:8px 10px; min-height:40px; text-shadow:0 1px 2px #000; }
.linkbtn:hover { color:#fff0c8; }

.cpanel { position:relative; width:min(920px, calc(100vw - 24px)); max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  overflow-y:auto; overscroll-behavior:contain; touch-action:pan-y; padding:18px 20px 0; color:#ecdfc2;
  background:var(--ui-wood); border-radius:var(--ui-r-panel); box-shadow:var(--ui-rim), 0 12px 40px rgba(0,0,0,.6);
  scrollbar-width:thin; scrollbar-color:#6b4a2a transparent; }
.cpanel h2 { margin:0 0 14px; display:flex; justify-content:center; }
.cgrid { display:grid; grid-template-columns:minmax(250px, auto) 1fr; gap:20px; align-items:start; }
.cpreview { display:flex; flex-direction:column; align-items:center; gap:6px; position:sticky; top:0; }
.pframe { padding:14px 20px 8px; background:radial-gradient(ellipse at 50% 80%, rgba(255,150,60,.22), rgba(0,0,0,0) 70%), #120c08;
  border-radius:12px; box-shadow:var(--ui-slot), inset 0 0 18px rgba(0,0,0,.6); }
.pname { color:#f3cf7a; font-size:17px; min-height:1.3em; text-shadow:0 1px 2px #000; }
.copts section { margin-bottom:14px; }
.copts h3 { display:flex; align-items:center; gap:10px; margin:0 0 8px; font-size:inherit; }
.copts h3 em { font-style:normal; color:#bda97f; font-size:14px; }
.cards { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; }
.ccard, .ctoggle { position:relative; display:flex; flex-direction:column; align-items:flex-start; gap:6px; text-align:left; border-radius:10px;
  padding:10px; min-height:44px; color:#e6d8b8; font:inherit; font-weight:400; font-size:13px; line-height:1.3; cursor:pointer;
  background:var(--ui-btn); box-shadow:var(--ui-box); }
.ccard:hover:not(:disabled), .ctoggle:hover:not(:disabled) { background:var(--ui-btn-hover); }
.ccard.sel, .ctoggle.sel { background:linear-gradient(180deg, #4c3519, #33230f); box-shadow:var(--ui-box-sel), 0 0 12px rgba(232,180,74,.3); }
.ccard:disabled, .ctoggle:disabled { cursor:not-allowed; color:#8d8370; background:#1c150f; }
.cdesc { opacity:.92; }
.soon { letter-spacing:.6px; font-variant:small-caps; font-size:13px; color:#e0a36a; background:#3a1f12; padding:1px 6px; border-radius:5px; }
.ctitle { display:flex; align-items:center; gap:4px 8px; flex-wrap:wrap; }
#creator { padding-top:calc(44px + env(safe-area-inset-top,0px)); }
#creator .cpanel { max-height:calc(100dvh - 56px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)); }
@media (max-width: 760px) and (min-height: 521px) {    /* the perf pill wraps to a 2nd row up there */
  #creator { padding-top:calc(76px + env(safe-area-inset-top,0px)); }
  #creator .cpanel { max-height:calc(100dvh - 88px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)); }
}
body.touch.indiscord #creator { padding-top:calc(110px + env(safe-area-inset-top,0px)); }
body.touch.indiscord #creator .cpanel { max-height:calc(100dvh - 122px - env(safe-area-inset-top,0px)); }
.toggles { display:flex; gap:8px; flex-wrap:wrap; }
.ctoggle { flex-direction:row; align-items:center; min-width:120px; justify-content:center; }
.swatches { display:flex; flex-wrap:wrap; gap:8px; }
.swatch { width:36px; height:36px; padding:0; border-radius:50%; cursor:pointer; box-shadow:0 0 0 2px #120a05, inset 0 0 0 1px rgba(255,255,255,.2), inset 0 -3px 5px rgba(0,0,0,.3); }
.swatch:hover { transform:translateY(-1px); }
.swatch.sel { box-shadow:0 0 0 2px #120a05, 0 0 0 4px #f6d488, 0 0 10px rgba(246,212,136,.5); }
.cfoot { position:sticky; bottom:0; display:flex; justify-content:space-between; align-items:center; gap:10px; margin:4px -20px 0;
  padding:12px 20px calc(12px + env(safe-area-inset-bottom,0px)); background:linear-gradient(rgba(19,13,9,0), rgba(19,13,9,.97) 30%); border-radius:0 0 var(--ui-r-panel) var(--ui-r-panel); }

body.touch .swatch { width:42px; height:42px; }
@media (max-width: 680px) {
  .cpanel { padding:14px 14px 0; }
  .cgrid { grid-template-columns:1fr; gap:12px; }
  .cpreview { position:static; }
  .cards { grid-template-columns:1fr; }
  .ccard { gap:4px; }
  .cfoot { margin:4px -14px 0; padding-left:14px; padding-right:14px; }
}
/* short screens (phones held sideways): room for the sound buttons up top, compact name + Play */
@media (max-height: 520px) {
  #titleMain { padding-top:calc(38px + env(safe-area-inset-top,0px)); gap:6px; }
  .tlabel { display:none; }
  .tpanel { gap:6px; margin-top:2px; }
  .pxbtn.big { min-height:48px; padding:10px 28px; }
  #title .err:empty { display:none; }
}
/* phones held sideways: short screen -> preview column narrower, compact cards */
@media (max-height: 520px) and (min-width: 681px) {
  .cgrid { grid-template-columns:minmax(170px, auto) 1fr; gap:14px; }
  .cpanel { padding-top:10px; }
  .cpanel h2 { margin-bottom:8px; }
  .copts section { margin-bottom:8px; }
  .ccard { padding:8px; }
  .cdesc { font-size:12px; }
  .cfoot { padding-top:6px; padding-bottom:calc(6px + env(safe-area-inset-bottom,0px)); }
  .cfoot .pxbtn { min-height:40px; padding:8px 18px; }
}

/* ---------------------------------------------------------------- Settings menu (settingsmenu.js) + its options */
body.noperf #perf { display:none !important; }
#hud, #vitals, #topRight, #bars, #chat, #chatBtn { zoom:var(--ui, 1); }           /* Settings > Video > Interface size */
#gearBtn svg { display:block; }
#settings { position:fixed; inset:0; z-index:40; display:flex; align-items:center; justify-content:center; background:rgba(3,3,6,.6);
  padding:calc(8px + env(safe-area-inset-top,0px)) 8px calc(8px + env(safe-area-inset-bottom,0px));
  font-family:var(--ui-font); }
.spanel { position:relative; display:flex; flex-direction:column; width:min(760px, 100%); max-height:100%; color:#ecdfc2;
  background:var(--ui-wood); border-radius:var(--ui-r-panel); box-shadow:var(--ui-rim), 0 12px 40px rgba(0,0,0,.6); }
.shead { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px 16px 8px; }
.shead h2 { margin:0; }
.sclose.pxbtn { min-width:40px; min-height:40px; padding:6px 10px; margin:2px; border-radius:50%; }
.sclose .ut { font-size:16px; }
.stabs { display:flex; flex-wrap:wrap; gap:8px; padding:0 16px 12px; border-bottom:1px solid rgba(232,190,110,.2); }
.stab, .seg button, .stog, .kbtn { display:inline-flex; align-items:center; justify-content:center; border-radius:var(--ui-r); padding:8px 12px;
  min-height:40px; color:#e6d8b8; font:inherit; font-weight:400; cursor:pointer; background:var(--ui-btn); box-shadow:var(--ui-box); }
.stab:hover, .seg button:hover, .stog:hover, .kbtn:hover { background:var(--ui-btn-hover); }
.stab { border-radius:999px; padding:6px 16px; }
.stab.sel { background:linear-gradient(180deg, #4c3519, #33230f); box-shadow:var(--ui-box-sel), 0 0 10px rgba(232,180,74,.3); }
.stab.sel .ut { color:#ffe2a0; }
.seg { display:flex; flex-wrap:wrap; gap:6px; }
.seg button.sel, .stog.on { background:linear-gradient(180deg, #f6d27e, #d9993c); box-shadow:0 0 0 1px rgba(30,15,5,.9), inset 0 1px 0 rgba(255,246,210,.7), inset 0 -2px 0 rgba(110,60,16,.9); }
.seg button.sel .ut, .stog.on .ut { text-shadow:0 1px 0 rgba(255,244,214,.5); }
.stog { min-width:72px; }
.sbody { flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; touch-action:pan-y; padding:4px 16px 16px;
  scrollbar-width:thin; scrollbar-color:#6b4a2a transparent; }
.srow { display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; min-height:46px; padding:4px 6px; border-bottom:1px solid rgba(232,190,110,.1); }
.srow.stop { margin-top:8px; }
.slabel { flex:1 0 auto; }                       /* never squeezed under a slider: the row wraps instead */
.sgroup { display:flex; align-items:center; justify-content:space-between; margin:14px 0 2px; padding:0 6px; }
.kbtn { min-width:118px; min-height:34px; padding:5px 10px; background:var(--ui-slot-bg); box-shadow:var(--ui-slot); }
.kbtn .ut { font-family:system-ui, sans-serif; font-size:13px; font-weight:600; letter-spacing:.04em; }
.kbtn.cap { box-shadow:var(--ui-box-sel); animation:kcap 1s ease-in-out infinite; }
@keyframes kcap { 50% { box-shadow:var(--ui-box-sel), 0 0 12px rgba(246,212,136,.6); } }
.pxbtn.smallbtn { min-width:0; min-height:34px; padding:5px 14px; margin:4px; border-radius:8px; }
.pxbtn.smallbtn .ut { font-size:14px; }
.ssel { flex:0 1 auto; max-width:100%; min-height:40px; padding:6px 8px; font:inherit; font-size:15px; color:#f3e2b4; background:#2a1d12;
  border:1px solid rgba(232,190,110,.42); border-radius:var(--ui-r); cursor:pointer; }
.ssel option { background:#2a1d12; color:#f3e2b4; }
.srange { flex:0 1 240px; min-width:120px; height:30px; padding:0; border:0; background:none; accent-color:#e8b44a; cursor:pointer; touch-action:pan-x; }
.sval { min-width:52px; display:flex; justify-content:flex-end; }
.shint { margin:8px 6px; color:#bda97f; font-size:14px; }
.sask { position:sticky; top:0; z-index:2; margin:8px 0; padding:10px 12px 4px; background:#3a2410; border-radius:10px;
  box-shadow:var(--ui-box-sel), 0 6px 16px rgba(0,0,0,.6); }
.sask p { margin:0 0 6px; color:#fff0c8; font-size:15px; }
.sask .shint { margin:0 0 4px; font-size:13px; }
.sbtns { display:flex; flex-wrap:wrap; }
.sfoot { display:flex; justify-content:flex-end; margin-top:10px; }
body.touch .srow { min-height:56px; }
body.touch .seg button, body.touch .stog, body.touch .stab { min-height:46px; padding:8px 14px; }
@media (max-width: 520px) {
  .shead { padding:10px 12px 6px; } .stabs { padding:0 12px 10px; gap:6px; } .sbody { padding:4px 10px 14px; }
  .kbtn { min-width:92px; }
  .srange { flex:1 1 140px; }
}

/* ---------------------------------------------------------------- HUD menu (gamemenu.js): every window + its key */
#menuBtn svg { display:block; }
.gmenu { position:fixed; z-index:39; min-width:200px; padding:6px; display:flex; flex-direction:column; font-family:var(--ui-font);
  background:var(--ui-wood); border-radius:12px; box-shadow:var(--ui-rim), 0 10px 28px rgba(0,0,0,.6); animation:gmin .12s ease-out; }
@keyframes gmin { from { opacity:0; transform:translateY(-4px); } }
.gmhead { padding:2px 8px 6px; color:#f6d488; font-size:16px; font-weight:600; font-variant:small-caps; letter-spacing:.06em; }
.gmrow { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:32px; padding:4px 8px; border-radius:8px;
  background:none; color:#ecdfc2; font:15px var(--ui-font); text-align:left; }
.gmrow:hover, .gmrow:focus-visible { background:rgba(255,200,120,.12); color:#fff0c8; outline:none; }
.gmenu hr { width:100%; border:0; border-top:1px solid rgba(232,190,110,.2); margin:4px 0; }
body.touch .gmrow { min-height:42px; font-size:16px; }

/* cast bar (cast times of strong skills: casting.js) - above the action bar; on phones under the top HUD */
#castBar { position:fixed; left:50%; bottom:calc(118px + env(safe-area-inset-bottom,0px)); transform:translateX(-50%); z-index:8;
  width:220px; height:16px; border-radius:999px; overflow:hidden; pointer-events:none; background:rgba(16,11,7,.88);
  box-shadow:0 0 0 1px rgba(8,5,2,.9), inset 0 0 0 1px rgba(232,190,110,.5), 0 3px 10px rgba(0,0,0,.45); }
#castBar[hidden] { display:none; }
#castBar i { position:absolute; inset:0 auto 0 0; width:0; background:linear-gradient(180deg, #ffe3a0, #e0a040 55%, #b07020);
  box-shadow:0 0 8px rgba(255,200,110,.7); }
#castBar span { position:relative; display:block; text-align:center; font:600 11px/16px var(--ui-font); color:#fff3da;
  text-shadow:0 1px 2px #000, 0 0 3px #000; }
#castBar.broken i { width:100% !important; background:linear-gradient(180deg, #d06050, #7a2018); box-shadow:none; }
body.touch #castBar { bottom:auto; top:26%; width:180px; }

/* ---------------------------------------------------------------- HUD layout edit mode (hudlayout.js) */
#hudEdit { position:fixed; inset:0; z-index:60; background:rgba(4,4,8,.35); touch-action:none; }
#hudEdit .hebox { position:fixed; box-sizing:border-box; border:2px dashed rgba(240,197,106,.85); border-radius:4px; cursor:grab;
  background:rgba(240,197,106,.10); touch-action:none; display:flex; align-items:flex-start; justify-content:center; }
#hudEdit .hebox.moved { border-style:solid; }
#hudEdit .hebox.drag { cursor:grabbing; background:rgba(240,197,106,.22); border-color:#fff0d4; }
#hudEdit .hebox b { margin-top:-11px; padding:1px 7px; font:700 11px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color:#2a1606;
  background:#f0c56a; border-radius:3px; white-space:nowrap; pointer-events:none; box-shadow:0 0 0 1px #22120a; }
#hudEdit .hebar { position:fixed; left:50%; top:calc(42% - 24px); transform:translateX(-50%); display:flex; align-items:center; gap:6px;
  padding:6px 8px 6px 14px; border-radius:6px; background:rgba(20,13,8,.94); box-shadow:0 0 0 1px #000, inset 0 0 0 1px rgba(232,190,110,.5), 0 6px 18px rgba(0,0,0,.6);
  font:13px system-ui, -apple-system, "Segoe UI", sans-serif; color:#eadcc0; max-width:calc(100vw - 24px); flex-wrap:wrap; justify-content:center;
  cursor:move; touch-action:none; transition:opacity .15s; }
#hudEdit .hebox > i { display:none; position:absolute; left:0; right:0; top:50%; transform:translateY(-50%); text-align:center;
  font:italic 11px system-ui, -apple-system, "Segoe UI", sans-serif; color:rgba(240,220,180,.75); pointer-events:none; }
#hudEdit .hebox.ghost { border-style:dotted; background:repeating-linear-gradient(45deg, rgba(240,197,106,.08) 0 6px, rgba(240,197,106,.02) 6px 12px); }
#hudEdit .hebox.ghost > i { display:block; }
/* a hidden panel while the HUD is edited: laid out at its own spot with a stand-in size, never seen */
.hud-ghost { display:block !important; visibility:hidden !important; min-width:var(--hg-w); min-height:var(--hg-h); }
#hudEdit.dragging .hebar { opacity:.15; pointer-events:none; }
