:root {
  --panel: rgba(34, 20, 48, 0.74);     /* dusk plum glass, the same family as the chat and the Town Menu */
  --panel-solid: #251733;
  --text: #f4f6ff;
  --dim: #a9b0d6;
  --accent: #ff7ab8;
  --accent2: #7cc8ff;
  --gold: #ffd25e;
  --radius: 14px;
}
* { box-sizing: border-box; }
/* dusk plum, like the docked chat: whatever peeks out beside the 3D view (mid-resize, a hidden chat panel) stays cozy */
html, body { margin: 0; height: 100%; overflow: hidden; background: linear-gradient(180deg, #2e1b3a 0%, #25172f 40%, #1d1329 100%) fixed #25172f;
  color: var(--text); font-family: 'Baloo 2', system-ui, sans-serif; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
button, input, select, textarea { font: inherit; }
/* native pickers (event time, durations, crew home, coaching rooms) in the town's dusk colours, not a white OS popup */
select, input[type=datetime-local], input[type=date], input[type=time] { color-scheme: dark; }
select option { background: #251733; color: #f4f6ff; }
button { background: rgba(40, 24, 56, 0.74); color: var(--text); border: 1px solid rgba(255,255,255,0.22);
  border-radius: 10px; padding: 6px 14px; cursor: pointer; backdrop-filter: blur(6px); font-weight: 600; }
button:hover { background: rgba(68, 40, 88, 0.88); }
button.primary { background: linear-gradient(135deg, var(--accent), #ff9f6b); border: none; font-weight: 700; }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,0.14); border-radius: var(--radius);
  backdrop-filter: blur(10px); box-shadow: 0 8px 30px rgba(0,0,0,0.25); }
.center { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 28px 32px; text-align: center; z-index: 5; }
.wide { width: min(560px, calc(100vw - 32px)); text-align: left; }
h1 { margin: 0; font-size: 46px; letter-spacing: 1px;
  background: linear-gradient(90deg, #ff9ad1, #ffd25e, #7cc8ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0 0 4px; }
.sub { color: var(--dim); margin: 4px 0 14px; }
.small { font-size: 13px; }
.hint { color: var(--dim); font-size: 13px; margin: 14px 0 0; }
#join input { display: block; width: 100%; margin: 6px 0 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.25); color: var(--text); text-align: center; }
#join button { width: 100%; padding: 10px; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#hud > * { pointer-events: auto; }
#me { position: absolute; left: 16px; top: 16px; padding: 10px 14px; min-width: 190px; }
#meName { font-weight: 800; font-size: 20px; line-height: 1.1; }
.badge { display: inline-block; margin-top: 4px; padding: 0 10px; border-radius: 999px; font-weight: 700; font-size: 14px; color: #111; }
.pbline { color: var(--gold); font-size: 14px; margin-top: 4px; }
.dim { color: var(--dim); font-size: 12px; }
#buttons { position: absolute; right: 16px; top: 16px; display: flex; gap: 8px; align-items: center; }
/* ---- town chat (chat.js): docked beside the 3D view on desktop, warm dusk glass ---- */
#chat { position: absolute; left: 16px; bottom: 16px; width: min(440px, calc(100vw - 32px)); padding: 0 0 6px; display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(58,30,62,0.8), rgba(30,20,46,0.9)); border: 1px solid rgba(255,206,170,0.2);
  border-radius: 20px; box-shadow: 0 10px 34px rgba(30,8,40,0.35), inset 0 1px 0 rgba(255,236,210,0.12);
  backdrop-filter: blur(12px) saturate(1.25); -webkit-backdrop-filter: blur(12px) saturate(1.25); color: #f3eefc;
  font-family: 'Baloo 2', 'Noto Color Emoji', system-ui, sans-serif; --fs: 16px; --avs: 36px; --gut: 60px; }
#chat[data-size="S"] { --fs: 14.5px; --avs: 32px; --gut: 54px; }
#chat[data-size="L"] { --fs: 18px; --avs: 40px; --gut: 66px; }
/* docked: a full-height side panel; the canvas shrinks beside it (--view-left / --view-right, set by chat.js) */
#chat.docked { position: fixed; top: 0; bottom: 0; right: 0; left: auto; width: 30vw; padding: 0; border: none; border-radius: 0;
  border-left: 1px solid rgba(255,206,170,0.2); backdrop-filter: none; -webkit-backdrop-filter: none;
  background: radial-gradient(120% 30% at 50% -4%, rgba(255,168,108,0.17), transparent 64%),
    linear-gradient(180deg, #2e1b3a 0%, #25172f 40%, #1d1329 100%);
  box-shadow: -16px 0 44px rgba(16,4,26,0.42), inset 1px 0 0 rgba(255,236,210,0.06); }
#chat.docked[data-dock="left"] { left: 0; right: auto; border-left: none; border-right: 1px solid rgba(255,206,170,0.2);
  box-shadow: 16px 0 44px rgba(16,4,26,0.42), inset -1px 0 0 rgba(255,236,210,0.06); }
.chatGrip { display: none; }
#chat.docked .chatGrip { display: block; position: absolute; top: 0; bottom: 0; left: -5px; width: 10px; cursor: ew-resize; z-index: 6; touch-action: none; }
#chat.docked[data-dock="left"] .chatGrip { left: auto; right: -5px; }
#chat.docked .chatGrip::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; background: transparent; transition: background .15s; }
#chat.docked .chatGrip:hover::after, #chat.resizing .chatGrip::after { background: linear-gradient(180deg, transparent, #ff9ad1 20%, #ffd25e 80%, transparent); }
#chat.resizing, #chat.resizing * { user-select: none; cursor: ew-resize; }
/* collapsed: a slim tab on the panel's edge */
.chatTab { display: none; }
#chat.docked.collapsed { top: 50%; bottom: auto; width: auto; transform: translateY(-50%); border-radius: 18px 0 0 18px; border: 1px solid rgba(255,206,170,0.24); border-right: none; }
#chat.docked.collapsed[data-dock="left"] { border-radius: 0 18px 18px 0; border: 1px solid rgba(255,206,170,0.24); border-left: none; }
#chat.docked.collapsed > :not(.chatTab) { display: none !important; }
#chat.docked.collapsed .chatTab { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; border: none; border-radius: inherit;
  background: none; font-size: 24px; backdrop-filter: none; }
#chat.docked.collapsed .chatTab:hover { background: rgba(255,255,255,0.06); }
#chat:not(.docked).collapsed #chatLogWrap, #chat:not(.docked).collapsed #chatQuick, #chat:not(.docked).collapsed #chatChans,
#chat:not(.docked).collapsed #chatTopic, #chat:not(.docked).collapsed #chatTyping { display: none; }

/* header, channels, topic */
#chatHead { display: flex; align-items: center; gap: 6px; padding: 6px 8px 4px 14px; cursor: pointer; user-select: none; flex: none; }
#chat.docked #chatHead { padding: 12px 12px 8px 18px; }
#chatHead .chatTitle { font-weight: 800; letter-spacing: .02em; color: #ffe2c4; font-size: 16px; }
#chat.docked #chatHead .chatTitle { font-size: 18px; }
#chatHead .chatOnline { color: var(--dim); font-size: 13px; }
#chatHead .grow { flex: 1; }
.chatBadge { background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.chatIcon { padding: 0 8px; min-width: 30px; height: 28px; border-radius: 999px; font-size: 14px; background: rgba(255,255,255,0.06); backdrop-filter: none; }
.chatIcon.on { background: rgba(255,210,94,0.22); border-color: rgba(255,210,94,0.55); }
.chatIcon[hidden] { display: none; }
#chatChans { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 12px 8px; flex: none; }
#chat:not(.docked) #chatChans { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 0 10px 6px; }
.chCh { display: inline-flex; align-items: center; gap: 1px; flex: none; height: 28px; padding: 0 9px 0 7px; border-radius: 999px; font-size: 14px; font-weight: 700;
  color: #cbbfe0; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); backdrop-filter: none; white-space: nowrap; }
.chCh .hash { color: #988bb3; font-weight: 800; margin-right: 1px; font-family: 'Baloo 2', 'Noto Color Emoji', system-ui; }
.chCh:hover { background: rgba(255,255,255,0.1); color: #fff; }
.chCh.on { background: linear-gradient(135deg, rgba(255,122,184,0.34), rgba(255,159,107,0.26)); border-color: rgba(255,150,190,0.65); color: #fff; }
.chCh.on .hash { color: #ffd2e6; }
.chCh.unread { color: #fff; }
.chCh.unread::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #fff; margin-right: 4px; }
.chCh .n { min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; margin-left: 5px; border-radius: 999px; background: rgba(255,255,255,0.2);
  font-size: 11px; font-weight: 800; text-align: center; }
.chCh .n.ping { background: var(--accent); color: #fff; }
.chCh .pin { font-family: 'Noto Color Emoji', system-ui; font-size: 12px; margin-left: 4px; }
.chCh.zone:not(.on) { border-color: rgba(255,210,94,0.6); }
#chatTopic { display: none; }
#chat.docked #chatTopic { display: block; flex: none; padding: 0 18px 9px; font-size: 13px; color: #b6aacd; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-bottom: 1px solid rgba(255,214,180,0.1); }
#chatTopic b { color: #ffe2c4; }
#chatTopic .emo { font-size: 14px; }

/* the log: Discord-style groups (avatar dot · name in rank colour + crest · time, then the lines) */
#chatLogWrap { position: relative; min-height: 0; display: flex; flex-direction: column; }
#chat.docked #chatLogWrap { flex: 1 1 0; }
#chatLog { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; font-size: var(--fs); line-height: 1.42; padding: 4px 0 10px;
  scrollbar-width: thin; scrollbar-color: rgba(255,210,180,0.3) transparent; overflow-anchor: auto; }
#chat[data-size="L"] #chatLog { max-height: 360px; }
#chat.docked #chatLog { flex: 1 1 0; min-height: 0; max-height: none; }
#chatLog .msg { position: relative; padding: 1px 46px 1px var(--gut); overflow-wrap: anywhere; color: #efe9f8; animation: msgIn .26s ease-out; }
#chatLog .msg:hover { background: rgba(255,255,255,0.045); }
#chatLog .msg.head { margin-top: 10px; padding-top: 3px; min-height: calc(var(--avs) + 8px); }
#chatLog .msg.head:first-child, #chatLog .sep + .msg.head { margin-top: 4px; }
#chatLog .av { position: absolute; left: 12px; top: 5px; width: var(--avs); height: var(--avs); border-radius: 50%; display: grid; place-items: center;
  cursor: pointer; user-select: none; color: #2a1838; font-weight: 800; font-size: calc(var(--avs) * 0.46); line-height: 1;
  background: radial-gradient(circle at 30% 26%, rgba(255,255,255,0.42), rgba(255,255,255,0) 36%), var(--av, #c9a7ff);
  box-shadow: inset 0 -3px 0 rgba(40,10,50,0.16), 0 0 0 2px #25172f, 0 0 0 3.5px var(--ring, rgba(255,255,255,0.16)), 0 3px 8px rgba(0,0,0,0.35);
  text-shadow: 0 1px 0 rgba(255,255,255,0.35); }
#chatLog .mh { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 6px; line-height: 1.3; }
#chatLog .nm { font-weight: 800; letter-spacing: .01em; cursor: pointer; }
#chatLog .nm:hover { text-decoration: underline; }
#chatLog .mh .rk { align-self: center; }
#chatLog .mh .ts { color: #9f93b8; font-size: .74em; font-weight: 600; margin-left: 2px; }
#chatLog .tx { color: #f1ecfa; font-weight: 500; }
#chatLog .msg:not(.head) > .ts { position: absolute; left: 0; width: calc(var(--gut) - 10px); text-align: right; top: .42em; font-size: .66em; font-weight: 600;
  color: #9f93b8; opacity: 0; white-space: nowrap; }
#chatLog .msg:not(.head):hover > .ts, #chatLog .msg.showTs > .ts { opacity: 1; }
#chatLog .msg.mine .tx { color: #fff6ea; }
#chatLog .msg.ping { background: rgba(255,122,184,0.13); box-shadow: inset 3px 0 0 var(--accent); }
#chatLog .msg.act { margin-top: 4px; font-style: italic; color: #ffe2f2; }
#chatLog .msg.act .tx { color: #ffe2f2; }
#chatLog .actStar { color: #ffb3d6; }
#chatLog .mention { color: #ffc2de; font-weight: 700; background: rgba(255,122,184,0.16); border-radius: 6px; padding: 0 3px; }
#chatLog .mention.me { color: #fff; background: var(--accent); }
#chatLog .tx.jumbo { font-size: 2.1em; line-height: 1.15; }
#chatLog .msg.act .tx.jumbo { display: inline-block; vertical-align: middle; }
/* system lines: compact and quieter than people; PBs / rank-ups stay as small gold highlights */
#chatLog .msg.sys { padding: 1px 16px 1px var(--gut); font-size: .82em; line-height: 1.35; color: #b9acd2; }
#chatLog .msg.sys::before { content: '•'; position: absolute; left: calc(var(--gut) - 16px); color: #7f7398; }
#chatLog .msg.sys.join { color: #9d91b6; font-size: .78em; }
#chatLog .msg.sys.hl { margin: 6px 10px 4px; padding: 3px 12px 3px calc(var(--gut) - 10px); border-radius: 10px; font-size: .88em; font-weight: 700;
  color: var(--gold); background: linear-gradient(90deg, rgba(255,210,94,0.15), rgba(255,210,94,0.02)); }
#chatLog .msg.sys.hl::before { content: none; }
#chatLog.noSys .msg.sys:not(.hl) { display: none; }
#chatLog .msg.sep { padding: 6px 0 2px; text-align: center; color: var(--dim); font-size: 12px; }
/* a channel nobody has spoken in yet (a zone room you just walked into): a friendly line instead of a blank panel */
#chat.docked #chatLog:empty::before, #tSheet #chatLog:empty::before { content: '🌙 Nothing here yet: say hi 👋';
  display: block; margin: 28px 24px 0; text-align: center; color: #9f93b8; font-size: 14px; line-height: 1.5; }
#chatLog .msg.sep:hover { background: none; }
#chatLog .chatNew { position: relative; height: 0; margin: 12px 14px 8px; border-top: 1.5px solid #ff6f9e; }
#chatLog .chatNew span { position: absolute; right: 0; top: -9px; background: #ff6f9e; color: #fff; font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; padding: 0 6px; border-radius: 4px; line-height: 17px; }
.reactBtn { position: absolute; right: 8px; top: 2px; opacity: 0; padding: 0 7px; height: 24px; font-size: 13px; border-radius: 999px;
  background: rgba(255,255,255,0.1); transition: opacity .15s; backdrop-filter: none; }
#chatLog .msg:hover .reactBtn { opacity: 1; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; }
.reacts:empty { display: none; }
.rchip { display: inline-flex; align-items: center; gap: 3px; padding: 0 8px 0 5px; height: 26px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); animation: chipIn .25s ease-out; backdrop-filter: none; }
.rchip.mine { background: rgba(255,122,184,0.22); border-color: rgba(255,122,184,0.6); }
.rchip .emo { width: 18px; height: 18px; }
#chatJump { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 3; margin: 0; padding: 0 14px; height: 30px; font-size: 13.5px;
  border-radius: 999px; background: linear-gradient(135deg, var(--accent), #ff9f6b); border: none; font-weight: 800; box-shadow: 0 6px 18px rgba(20,4,30,0.45); }
#chatJump[hidden] { display: none; }

/* rank crests (rankicon.js): shield / gem / crown in the tier colours; Celestial shimmers, founders get a ★ crown */
.rk { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -0.22em; flex: none; filter: drop-shadow(0 1px 1px rgba(10,0,20,0.45)); }
.rk svg { display: block; width: 100%; height: 100%; overflow: visible; }
.rk-crown { width: 1.3em; height: 1.3em; vertical-align: -0.26em; }
.rk-shimmer { filter: drop-shadow(0 0 3px rgba(150,215,255,0.9)); }
.rk-founder { filter: drop-shadow(0 0 3px rgba(255,200,80,0.75)); }
.rk-shimmer .rkSpark { transform-box: fill-box; transform-origin: center; animation: rkSpark 2.2s ease-in-out infinite; }
@keyframes rkSpark { 0%, 100% { opacity: .25; transform: scale(.55) rotate(0deg); } 50% { opacity: 1; transform: scale(1.35) rotate(45deg); } }
#chatLog .msg.settled .rkSpark, #chatAc .rkSpark { animation-play-state: paused; }
#chatLog .msg:hover .rkSpark { animation-play-state: running; }

/* composer */
#chatComposer { position: relative; padding: 0 8px; flex: none; }
#chat.docked #chatComposer { padding: 8px 14px 4px; border-top: 1px solid rgba(255,214,180,0.1); background: rgba(14,6,24,0.22); }
#chatQuick { display: flex; gap: 4px; padding: 2px 2px 6px; }
#chatQuick button { flex: 1; height: 30px; padding: 0; border-radius: 10px; font-weight: 800; font-size: 14px; background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1); transition: transform .12s; backdrop-filter: none; }
#chatQuick button:hover { transform: translateY(-2px) scale(1.08); background: rgba(255,255,255,0.12); }
#chatQuick .emo { font-size: 19px; line-height: 1; }
.chatRow { display: flex; gap: 6px; align-items: center; }
#chatInput { flex: 1; min-width: 0; padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(255,214,180,0.25);
  background: rgba(10,6,20,0.38); color: var(--text); font: inherit; font-size: var(--fs); }
#chat.docked #chatInput { padding: 10px 14px; border-radius: 14px; background: rgba(8,4,16,0.42); }
#chatInput:focus { outline: none; border-color: rgba(255,170,205,0.7); box-shadow: 0 0 0 3px rgba(255,122,184,0.18); }
#chatEmojiBtn, #chatSend { width: 38px; height: 38px; padding: 0; border-radius: 12px; font-size: 19px; flex: none; }
#chat.docked #chatEmojiBtn, #chat.docked #chatSend { width: 44px; height: 44px; }
#chatSend { background: linear-gradient(135deg, var(--accent), #ff9f6b); border: none; font-size: 16px; }
#chatTyping { display: flex; align-items: center; gap: 6px; height: 19px; padding: 1px 4px 0; font-size: 12.5px; color: #c9bde0; white-space: nowrap; overflow: hidden; }
#chatTyping > span:last-child { overflow: hidden; text-overflow: ellipsis; }
#chatTyping .dots { display: inline-flex; gap: 3px; }
#chatTyping .dots i { width: 5px; height: 5px; border-radius: 50%; background: #e2d6f5; animation: tyDot 1.2s infinite ease-in-out; }
#chatTyping .dots i:nth-child(2) { animation-delay: .15s; }
#chatTyping .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tyDot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-3px); opacity: 1; } }

/* the HUD follows the 3D view, never the chat panel (--view-left / --view-right / --view-cx from chat.js) */
#view { left: var(--view-left, 0px); right: auto; width: calc(100% - var(--view-left, 0px) - var(--view-right, 0px)); } /* a canvas is a replaced element: give it the width */
#me { left: calc(var(--view-left, 0px) + 16px); }
#buttons { right: calc(var(--view-right, 0px) + 16px); }
html:not(.touch) #buttons { flex-wrap: wrap; justify-content: flex-end;   /* wraps before it reaches the #me card */
  max-width: calc(100% - var(--view-left, 0px) - var(--view-right, 0px) - 270px); }
/* (#prompt, #prompt2, #banner, #toast, #fortune centre on --view-cx in their own rules below) */
/* centred panels (aura, look, tracker, community feed) sit over the 3D view, never over the docked chat */
html:not(.touch) .panel.center { left: var(--view-cx, 50%); max-width: calc(100vw - var(--view-left, 0px) - var(--view-right, 0px) - 32px);
  max-height: calc(100vh - 32px); overflow-y: auto; }

/* ---- the HUD cluster (top right of the view): 🎯 Play · 👤 me · 👥 people · 📰 news, plus status chips that only
   appear when something is live for you. Look / aura / charms / import / tracker live in Town Menu → 👤 Profile. ---- */
#hudChips { display: contents; }
#buttons #btnLook, #buttons #btnAvatar, #buttons #btnAura, #buttons #btnCharms, #buttons #btnTracker { display: none !important; }
#btnMenu { order: 1; } #btnMe { order: 2; } #btnSocial { order: 3; } #btnFeed { order: 4; }
#buttons > button, .hudChip { height: 40px; border-radius: 12px; font-family: 'Baloo 2', 'Noto Color Emoji', system-ui, sans-serif; }
#btnMe, #btnSocial, #btnFeed { position: relative; min-width: 42px; padding: 0 10px; font-size: 18px; line-height: 1; }
#btnMenu { padding: 0 16px; font-size: 16px; }
.hudChip { order: 0; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 800;
  white-space: nowrap; background: rgba(30,20,46,0.82); color: #fff3e8; border: 1.5px solid var(--chip, rgba(255,210,94,0.7));
  box-shadow: 0 4px 14px rgba(20,6,36,0.3), inset 0 0 12px color-mix(in srgb, var(--chip, #ffd25e) 18%, transparent); }
.hudChip:hover { background: rgba(52,34,74,0.92); }
.hudChip[hidden] { display: none !important; }
#btnWatch { --chip: #ff6f9e; } #btnCoach { --chip: #ffd25e; } #btnPractice { --chip: #7be0a0; } #chipCharms { --chip: #9fe870; }
/* the Town Menu / a review room cover the view's left side: the name card steps aside instead of peeking out above them */
html:not(.touch).tmOpen #me, html:not(.touch) body:has(> #reviewRoom) #me { visibility: hidden; }
html.touch body:has(> #watchPanel:not([hidden])) #me { visibility: hidden; }   /* phones: the party panel sits right there */
body:has(> #watchPop:not([hidden])) .wpInvite { visibility: hidden; }          /* the 🎬 list already says it: no card peeking out below */
/* your own card: click it for your profile, look, aura and charms */
html:not(.touch) #me { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
html:not(.touch) #me:hover { border-color: rgba(255,210,94,0.5); box-shadow: 0 8px 30px rgba(0,0,0,0.25), 0 0 0 3px rgba(255,210,94,0.12); }
/* a charm find and a PB / rank-up banner at the same moment: the find waits just below the banner */
#hud:has(> #banner:not([hidden])) > #charmToast { top: 158px; }
/* prompts / toasts never run under the docked chat: they wrap inside the view instead */
html:not(.touch) #prompt, html:not(.touch) #prompt2, html:not(.touch) #toast, html:not(.touch) #banner {
  max-width: calc(100vw - var(--view-left, 0px) - var(--view-right, 0px) - 32px); }
html:not(.touch) #prompt, html:not(.touch) #prompt2 { white-space: normal; text-align: center; width: max-content; }
html:not(.touch) #toast { width: max-content; text-align: center; }
html.touch #hud:has(> #banner:not([hidden])) > #charmToast { top: calc(env(safe-area-inset-top, 0px) + 142px); }
/* the software-GL warning (main.js): centred over the view, out of the way while the Town Menu is open */
#gfxBanner { left: var(--view-cx, 50%) !important; pointer-events: none; }   /* taps go through to the HUD under it */
#gfxBanner button, #gfxBanner a { pointer-events: auto; }
html.tmOpen #gfxBanner { display: none; }
html:not(.touch) #radioHud, html:not(.touch) #fishCard { right: calc(var(--view-right, 0px) + 18px); }
html.tmOpen #radioHud { visibility: hidden; }   /* the 🎧 radio pill (z 6) floated over the Town Menu; it's back when the menu closes */
html:not(.touch) #feedTicker { right: calc(var(--view-right, 0px) + 16px); }
html:not(.touch) #fishHud, html:not(.touch) #flowerPick, html:not(.touch) #lanternBox, html:not(.touch) #charmToast,
html:not(.touch) #socialPanel, html:not(.touch) #profileCard { left: var(--view-cx, 50%); }

/* emoji: animated Noto strips (frames stacked vertically), static Noto Color Emoji otherwise */
.emo { font-family: 'Noto Color Emoji', system-ui; font-style: normal; }
.emo.anim { display: inline-block; width: 1.35em; height: 1.35em; vertical-align: -0.32em; color: transparent; overflow: hidden;
  background-repeat: no-repeat; background-position: 0 0; animation: emoPlay var(--ms, 1600ms) steps(var(--n, 24), jump-none) infinite;
  animation-delay: calc(var(--ms, 1600ms) * -0.4);   /* start mid-loop: some animations (🎉) begin almost empty */
  user-select: text; }
.emo.anim::selection { color: transparent; }
.emo.anim.still { animation-play-state: paused; }
/* emoji play when they arrive, then settle (each running sprite strip costs paint work every frame);
   hovering a message replays them. Picker / autocomplete / react bar animate only under the pointer. */
.emo.anim.settled { animation-play-state: paused; }
#chatLog .msg:hover .emo.anim.settled:not(.still) { animation-play-state: running; }
#emojiPicker .emo.anim, #chatAc .emo.anim, #reactBar .emo.anim { animation-play-state: paused; }
#emojiPicker button:hover .emo.anim, #chatAc button.on .emo.anim, #reactBar button:hover .emo.anim { animation-play-state: running; }
@keyframes emoPlay { to { background-position: 0 100%; } }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes chipIn { from { transform: scale(0.6); opacity: 0; } }
/* town paused / hidden / KovaaK's in front: nothing animates, nothing transitions */
html.townPaused *, html.townPaused *::before, html.townPaused *::after { animation-play-state: paused !important; transition: none !important; }

/* autocomplete */
#chatAc { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 4px); z-index: 6; padding: 4px; border-radius: 14px;
  background: rgba(30,20,46,0.96); border: 1px solid rgba(255,206,170,0.22); box-shadow: 0 8px 26px rgba(0,0,0,0.35); }
#chatAc button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: none; background: none; padding: 4px 8px; border-radius: 9px; }
#chatAc button.on, #chatAc button:hover { background: rgba(255,122,184,0.2); }
#chatAc .acIcon { width: 26px; text-align: center; font-size: 18px; }
#chatAc .acSub { color: var(--dim); font-size: 12px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }

/* emoji picker */
#emojiPicker { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 7; display: flex; flex-direction: column;
  height: min(380px, 58vh); border-radius: 18px; overflow: hidden; background: rgba(30,20,46,0.97);
  border: 1px solid rgba(255,206,170,0.22); box-shadow: 0 12px 34px rgba(0,0,0,0.4); }
#emojiPicker[hidden] { display: none; }
.pickTop { display: flex; gap: 8px; align-items: center; padding: 8px 8px 4px; }
.pickSearch { flex: 1; min-width: 0; padding: 7px 12px; border-radius: 12px; border: 1px solid rgba(255,214,180,0.25);
  background: rgba(10,6,20,0.4); color: var(--text); font: inherit; }
.pickTones { display: flex; gap: 3px; }
.pickTones button { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.pickTones button.on { border-color: #fff; }
.pickTabs { display: flex; gap: 2px; padding: 0 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: 'Noto Color Emoji', system-ui; }
.pickTabs button { flex: 1; padding: 3px 0; border: none; background: none; font-size: 18px; border-radius: 8px; }
.pickTabs button:hover { background: rgba(255,255,255,0.08); }
.pickBody { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 8px; }
.pickHead { color: var(--dim); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin: 8px 2px 2px; }
.pickGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.pickGrid button { height: 38px; padding: 0; border: none; background: none; border-radius: 10px; font-size: 26px; line-height: 1;
  font-family: 'Noto Color Emoji', system-ui; transition: transform .1s; }
.pickGrid button:hover { background: rgba(255,255,255,0.1); transform: scale(1.18); }
.pickGrid .emo.anim { width: 30px; height: 30px; vertical-align: middle; }
.pickLoading { color: var(--dim); padding: 16px; text-align: center; }
.pickHint { color: var(--dim); font-size: 11px; padding: 3px 10px 6px; border-top: 1px solid rgba(255,255,255,0.06); }

/* small popovers: react bar, name menu, settings */
.chatPop { position: fixed; z-index: 20; padding: 6px; border-radius: 14px; background: rgba(30,20,46,0.97);
  border: 1px solid rgba(255,206,170,0.24); box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.chatPop[hidden], #reactBar[hidden], #chatMenu[hidden], #chatSettings[hidden] { display: none; } /* ids below set display */
#reactBar { display: flex; gap: 2px; }
#reactBar button { width: 40px; height: 40px; padding: 0; border: none; background: none; border-radius: 12px; transition: transform .12s; }
#reactBar button:hover { transform: scale(1.25); background: rgba(255,255,255,0.08); }
#reactBar .emo { width: 30px; height: 30px; }
#reactBar .more { font-size: 20px; color: var(--dim); }
#chatMenu, #chatSettings { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
#chatSettings { max-width: 300px; }
.chatPop .popTitle { font-weight: 800; padding: 2px 6px 4px; color: #ffe2c4; }
.chatPop .popNote { color: var(--dim); font-size: 13px; padding: 2px 6px; }
#chatMenu button { text-align: left; }
.setRow { display: flex; align-items: center; gap: 8px; padding: 3px 6px; font-size: 14px; cursor: pointer; }
.setRow button { padding: 0 10px; height: 26px; }
.setRow button.on { background: var(--accent); border-color: var(--accent); }
.setMuted { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
.setMuted button { height: 26px; padding: 0 10px; font-size: 13px; }
.chatPop .credits { color: var(--dim); font-size: 11px; padding: 6px 6px 2px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 4px; }
#prompt { position: absolute; left: var(--view-cx, 50%); bottom: 120px; transform: translateX(-50%); padding: 8px 18px;
  background: var(--panel); border-radius: 999px; border: 1px solid rgba(255,255,255,0.2); font-weight: 700; font-size: 18px; white-space: nowrap; }
#prompt kbd { background: #fff; color: #111; border-radius: 6px; padding: 0 8px; margin-right: 6px; }
/* world interactions (wishing well, cats) — same look as the portal prompt, sits just above it */
#prompt2 { position: absolute; left: var(--view-cx, 50%); bottom: 168px; transform: translateX(-50%); padding: 8px 18px;
  background: var(--panel); border-radius: 999px; border: 1px solid rgba(255,214,120,0.45); font-weight: 700; font-size: 18px; white-space: nowrap; }
#prompt2 kbd { background: #ffd25e; color: #1c1230; border-radius: 6px; padding: 0 8px; margin-right: 6px; }
#prompt2.dim { opacity: 0.55; transition: opacity .2s; }
/* town in the background (KovaaK's in front): freeze every CSS animation so the compositor has nothing to redraw */
body.paused *, body.paused *::before, body.paused *::after { animation-play-state: paused !important; transition: none !important; }
body.paused .emo.anim { animation: none !important; }
#fortune { position: absolute; left: var(--view-cx, 50%); top: 36%; transform: translateX(-50%); max-width: min(90vw, 560px); text-align: center;
  padding: 14px 26px; border-radius: 20px; font-size: 21px; font-weight: 700; color: #3a2440;
  background: linear-gradient(160deg, rgba(255,246,226,0.96), rgba(255,214,232,0.94)); border: 2px solid rgba(255,210,94,0.9);
  box-shadow: 0 12px 44px rgba(255,180,90,0.45); animation: fortune 4.6s ease both; pointer-events: none; }
#fortune small { display: block; font-size: 13px; font-weight: 800; letter-spacing: 0.12em; color: #b0742a; margin-bottom: 4px; }
@keyframes fortune { 0% { opacity: 0; transform: translate(-50%, 14px) scale(0.92); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  82% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -10px); } }
#banner { position: absolute; left: var(--view-cx, 50%); top: 64px; transform: translateX(-50%); text-align: center; padding: 12px 28px;
  border-radius: 18px; background: linear-gradient(135deg, rgba(255,210,94,0.95), rgba(255,122,184,0.95)); color: #1c1230;
  box-shadow: 0 10px 40px rgba(255,160,80,0.45); animation: pop 0.5s cubic-bezier(.2,1.6,.4,1); }
#banner.rank { background: linear-gradient(135deg, rgba(140,92,255,0.96), rgba(255,45,149,0.96)); color: #fff; box-shadow: 0 10px 50px rgba(160,80,255,0.6); }
#bannerTitle { font-size: 28px; font-weight: 800; line-height: 1.1; }
#bannerSub { font-size: 17px; font-weight: 600; }
#toast { position: absolute; left: var(--view-cx, 50%); bottom: 70px; transform: translateX(-50%); background: var(--panel-solid); padding: 8px 16px; border-radius: 10px; }
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.row label { width: 86px; color: var(--dim); }
.row input[type=color] { width: 44px; height: 32px; border: none; background: none; padding: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 3px 12px; border-radius: 999px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.locked, .lock { opacity: 0.45; }
.chip.locked::after { content: ' 🔒'; }
.tiers { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 12px; }
.tiers div { font-size: 11px; text-align: center; padding: 3px 0; border-radius: 6px; color: #111; font-weight: 700; opacity: 0.5; }
.tiers div.cur { opacity: 1; outline: 2px solid #fff; }
.tiers div.got { opacity: 0.9; }

/* "Make your look" picker */
#lookPanel { width: min(680px, calc(100vw - 24px)); max-height: 92vh; overflow-y: auto; }
.lookBody { display: flex; gap: 18px; align-items: stretch; }
.lookStage { position: relative; flex: 0 0 230px; border-radius: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 70%, rgba(255,190,220,0.55), rgba(124,110,200,0.25) 60%, rgba(30,24,60,0.35)); }
#lookCanvas { display: block; width: 230px; height: 274px; }
.lookName { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-weight: 800; font-size: 17px;
  text-shadow: 0 2px 6px rgba(20,10,40,0.7); }
.lookSide { flex: 1; min-width: 0; }
.lookLabel { color: var(--dim); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 2px 0 6px; }
.lookChars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.lookChar { padding: 3px 2px 2px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.lookChar img { width: 100%; aspect-ratio: 1; object-fit: cover; object-position: 50% 30%; border-radius: 9px; background: rgba(255,255,255,0.08); }
.lookChar img:not([src]) { visibility: hidden; }
.lookChar span { font-size: 12px; margin: 3px 0 2px; }
.lookChar.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset, 0 0 14px rgba(255,210,94,0.45); }
.lookTints { display: flex; gap: 8px; flex-wrap: wrap; }
.lookTint { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); }
.lookTint.on { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); transform: scale(1.08); }

@media (max-width: 640px) {
  .lookBody { flex-direction: column; align-items: center; }
  .lookStage { flex-basis: auto; }
  #lookCanvas { width: 170px; height: 202px; }
  .lookChars { grid-template-columns: repeat(6, 1fr); }
  #buttons { top: auto; bottom: 230px; right: 8px; flex-direction: column; }
  #me { left: 8px; top: 8px; }
  #chat { left: 8px; bottom: 8px; }
}
