:root{--ink:#2d261f;--muted:#8b7c68;--paper:#fffaf0;--line:#d8c6a5;--brown:#4a3324;--red:#8c3b2e}*{box-sizing:border-box}html,body,#app{height:100%;margin:0}body{font-family:Inter,Arial,sans-serif;color:var(--ink);background:#efe5d1}button,input,select{font:inherit}button{cursor:pointer}.hidden{display:none!important}.primary{background:var(--brown);color:#fff;border:0;border-radius:10px;padding:12px 18px}.secondary{background:#eee2cd;border:1px solid var(--line);border-radius:10px;padding:10px}.danger{color:#9b2e27}.error{color:#a22}.auth,.join{min-height:100%;display:flex;align-items:center;justify-content:center;padding:28px;background:linear-gradient(135deg,#ead8bc,#fff9ed)}.auth-card{width:min(430px,95vw);padding:28px;background:#fffaf0;border:1px solid var(--line);border-radius:22px;box-shadow:0 20px 60px #4d352333}.auth-logo{display:flex;gap:14px;align-items:center}.auth-logo img{width:56px}.auth-card label,.join-form label{display:grid;gap:6px;margin:14px 0;font-weight:700}.auth-card input,.join-form input{height:46px;border:1px solid var(--line);border-radius:10px;padding:0 12px}.join{align-items:flex-start}.join-shell{width:min(1420px,97vw);background:#fffaf0;padding:25px;border-radius:22px}.join-shell header{text-align:center}.character-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(225px,1fr));gap:15px}.character-card{padding:14px;border:2px solid #dccbad;border-radius:16px;background:#fffdf8;text-align:left;transition:.15s}.character-card:hover,.character-card.selected{border-color:#79523a;transform:translateY(-2px);box-shadow:0 12px 28px #56371e26}.character-card img{width:100%;height:190px;object-fit:contain;background:transparent}.character-card h3{margin:8px 0 3px;font-family:Georgia,serif;font-size:23px}.character-card code{color:#8b4638;font-weight:800}.character-card>p{min-height:55px}.power{display:grid;gap:5px;padding:9px;border-radius:10px;background:#f0e2ca}.power span{font-size:13px;line-height:1.3}.join-form{position:sticky;bottom:10px;display:grid;grid-template-columns:1fr 210px 210px 170px;gap:10px;align-items:end;margin-top:16px;padding:14px;background:#fff8e9;border:1px solid var(--line);border-radius:14px;box-shadow:0 10px 35px #3a261f33}.join-form #chosen{display:grid;gap:4px}.layout{height:100%;display:grid;grid-template-columns:330px 1fr;grid-template-rows:92px 1fr}.topbar{grid-column:1/3;display:flex;justify-content:space-between;align-items:center;padding:0 24px;background:#fffaf0;border-bottom:1px solid var(--line)}.brand,.profile{display:flex;align-items:center;gap:12px}.brand img{width:48px}.brand h1{margin:0;font-family:Georgia,serif}.brand p{margin:3px 0;color:var(--muted)}.profile>img{width:72px;height:72px;object-fit:contain;background:transparent;border:0}.profile div{display:grid}.profile span{color:var(--muted)}.profile button{border:0;background:transparent;font-size:23px}.sidebar{background:#fffaf0;border-right:1px solid var(--line);padding:18px;overflow:auto}.panel-title{display:flex;justify-content:space-between;margin-bottom:12px}.member{display:grid;grid-template-columns:62px 1fr 12px;align-items:center;gap:10px;min-height:76px}.member img{width:60px;height:60px;object-fit:contain;background:transparent;border:0}.member-copy{display:grid;gap:2px;min-width:0}.member-role{color:var(--muted)}.member-description{display:block;color:#6f6253;font-size:12px;line-height:1.25;margin-top:3px;max-width:210px}.presence{width:10px;height:10px;border-radius:50%;background:#bbb}.presence.online{background:#3aa553}.invite-main{width:100%;margin-top:15px;padding:12px;border:1px solid var(--line);border-radius:10px;background:#efe1ca}.chat{position:relative;overflow:hidden;display:grid;grid-template-rows:auto 1fr auto auto}.chat-bg{position:absolute;inset:0;background:url('/static/assets/chat-bg.png') center/cover no-repeat;z-index:0}.chat:after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,rgba(255,249,237,.88),rgba(255,249,237,.67));z-index:0}.chat>*:not(.chat-bg){position:relative;z-index:1}.pinned{display:flex;gap:8px;align-items:center;padding:11px 18px;background:#fff8e8dd;border-bottom:1px solid var(--line)}.pinned button{margin-left:auto;border:0;background:transparent}.messages{padding:22px;overflow:auto}.message{display:grid;grid-template-columns:72px minmax(0,720px);gap:12px;margin:13px 0;align-items:start}.message>img{width:70px;height:70px;object-fit:contain;background:transparent;border:0}.bubble{background:#fffaf1e8;border:1px solid #d6c4a3;border-radius:18px;padding:12px 15px;box-shadow:0 5px 18px #56391c1f}.bubble-head{display:flex;gap:10px;align-items:center}.bubble-head time{margin-left:auto;color:var(--muted);font-size:12px}.bubble p{line-height:1.45;margin:8px 0}.reply-quote{width:100%;display:grid;text-align:left;border:0;border-left:3px solid #8b5b3e;background:#f4e7d2;padding:7px 9px;border-radius:7px}.reply-quote span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.unique-reactions{display:flex;gap:6px}.unique-reactions span{padding:4px 9px;border:1px solid #d4bea0;border-radius:999px;background:#fff}.special-label{display:inline-block;margin-top:7px;padding:4px 8px;border-radius:8px;background:#ead6b7;font-weight:800}.poll-box{display:grid;gap:7px;margin-top:10px}.poll-box button,.challenge-box button{padding:9px;border:1px solid var(--line);border-radius:9px;background:#fff}.challenge-box{display:grid;gap:8px;padding:9px;background:#f5dfc8;border-radius:10px;margin-top:8px}.message.deleted .bubble{opacity:.62}.message.flash .bubble{outline:3px solid #d49850}.composer{display:grid;grid-template-columns:54px 54px 1fr 60px 68px;gap:8px;padding:12px 18px;background:#2d241f;border-top:1px solid #1b1512}.composer button{border:1px solid #f5ead0;border-radius:12px;background:#f8ead1;font-size:24px}.composer input{height:56px;border:0;border-radius:13px;padding:0 15px}.composer .power-btn{background:#33261d;color:#fff}.reply-bar{display:flex;justify-content:space-between;align-items:center;padding:9px 18px;background:#f6ead6;border-top:1px solid var(--line)}.reply-bar div{display:grid}.reply-bar span{color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:70vw}.reply-bar button{border:0;background:transparent;font-size:24px}.emoji-panel{position:absolute;left:18px;bottom:84px;z-index:30;width:max-content;max-width:calc(100% - 36px);padding:38px 10px 10px;background:#30241c;border:1px solid #5b4637;border-radius:12px;box-shadow:0 12px 35px #0008}.emoji-grid{display:grid;grid-template-columns:repeat(8,36px);gap:4px}.emoji-panel button{border:0;background:transparent;color:#fff;font-size:22px}.emoji-panel .emoji-close{position:absolute;right:8px;top:6px;width:28px;height:28px;border-radius:8px;background:#4a382d;font-size:20px;line-height:1}.emoji-panel .emoji-item{width:36px;height:36px;border-radius:8px}.emoji-panel .emoji-item:hover{background:#594236}.message-menu{position:fixed;z-index:20;display:grid;width:220px;padding:7px;background:#2d211a;border-radius:12px;box-shadow:0 15px 40px #0006}.message-menu button{padding:10px;text-align:left;border:0;border-radius:8px;background:transparent;color:#fff}.message-menu button:hover{background:#5a4130}.toast{position:fixed;z-index:100;left:50%;bottom:30px;transform:translateX(-50%);padding:11px 18px;border-radius:999px;background:#2c221b;color:#fff}.modal-overlay,.admin-overlay{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;padding:20px;background:#0008}.modal{width:min(620px,95vw);max-height:85vh;overflow:auto;padding:20px;border-radius:17px;background:#fffaf0}.user-choices{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:9px;margin:12px 0}.user-choices button{display:grid;justify-items:center;border:1px solid var(--line);border-radius:10px;background:#fff}.user-choices img{width:90px;height:90px;object-fit:contain}.admin{width:min(1200px,96vw);height:min(840px,93vh);display:grid;grid-template-rows:auto auto 1fr;background:#fffaf0;border-radius:18px;overflow:hidden}.admin>header{display:flex;justify-content:space-between;padding:18px 22px;border-bottom:1px solid var(--line)}.admin h2,.admin p{margin:0}.admin nav{display:flex;gap:8px;padding:10px 20px}.admin nav button{padding:9px 14px;border:0;border-radius:9px;background:#eadcc4}.admin nav button.active{background:#4a3324;color:#fff}.admin section{overflow:auto;padding:0 20px 20px}.admin-card table{width:100%;border-collapse:collapse}.admin-card th,.admin-card td{padding:9px;border-bottom:1px solid #e4d5bb;text-align:left;vertical-align:top}.admin-card td small{display:block;max-width:280px;color:var(--muted)}.admin-avatar{width:55px;height:55px;object-fit:contain;background:transparent}.create-row,.link-result{display:flex;gap:8px;margin:10px 0}.link-result input{flex:1}.admin-character-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}.admin-character-grid article{display:grid;grid-template-columns:130px 1fr;gap:12px;padding:12px;border:1px solid var(--line);border-radius:13px}.admin-character-grid img{width:130px;height:130px;object-fit:contain}.admin-character-grid article div{display:grid;gap:4px}.admin-character-grid h3{margin:0}.admin-character-grid small{color:var(--muted)}@media(max-width:900px){.layout{grid-template-columns:1fr;grid-template-rows:80px auto 1fr}.topbar{grid-column:1}.sidebar{display:none}.profile>img{width:58px;height:58px}.message{grid-template-columns:58px 1fr}.message>img{width:56px;height:56px}.join-form{position:static;grid-template-columns:1fr}.admin-character-grid{grid-template-columns:1fr}.composer{grid-template-columns:48px 48px 1fr 52px 58px}}

@media(max-width:700px){.emoji-grid{grid-template-columns:repeat(6,36px)}.member-description{max-width:190px}}

.admin-loading,.admin-error{margin:18px 0;padding:18px;border:1px solid var(--line);border-radius:12px;background:#fff7e8}.admin-error{display:grid;gap:9px;max-width:520px}.admin-error span{color:#8d342c}.admin-error button{justify-self:start}
.message{position:relative;cursor:pointer;border-radius:18px;transition:background .15s ease,box-shadow .15s ease,transform .15s ease}
.message:hover{background:rgba(255,250,240,.24)}
.message.selected-message{background:rgba(92,54,35,.16);box-shadow:0 0 0 3px #7b4932,0 10px 24px rgba(45,28,18,.2);transform:translateY(-1px)}
.message.selected-message::after{content:"Выбрано";position:absolute;right:8px;top:-10px;padding:3px 8px;border-radius:999px;background:#4a2d20;color:#fff;font-size:11px;font-weight:800;letter-spacing:.03em}
.message.selected-message .bubble{border-color:#6f402d;background:#fff8e8f5}

/* Inline actions for a selected message: always visible and usable. */
.message{position:relative}
.message-action-bar{display:flex;flex-wrap:wrap;gap:7px;margin-top:10px;padding-top:10px;border-top:1px solid #cfb997}
.message-action-bar button{border:1px solid #74513d;border-radius:9px;background:#3a2a22;color:#fff;padding:8px 11px;font-size:13px;font-weight:750;cursor:pointer}
.message-action-bar button:hover{background:#5a3d2d}
.message.selected-message .bubble{outline:3px solid #754832;outline-offset:2px}

/* 2026-08-03 polished selection + dark theme */
:root{
  --bg:#efe5d1;--panel:#fffaf0;--panel-2:#fff7e9;--text:#2d261f;--muted-2:#7b6d5c;
  --border:#d8c6a5;--accent:#6b3d2b;--accent-soft:#ead8bf;--shadow:rgba(60,35,20,.18)
}
:root[data-theme="dark"]{
  --ink:#f4ead9;--muted:#b9aa95;--paper:#211a17;--line:#5c4a3d;--brown:#6f4432;
  --bg:#171311;--panel:#211a17;--panel-2:#2a211d;--text:#f4ead9;--muted-2:#b9aa95;
  --border:#5c4a3d;--accent:#9b5e42;--accent-soft:#3a2b24;--shadow:rgba(0,0,0,.45)
}
body{background:var(--bg);color:var(--text);transition:background .18s ease,color .18s ease}
.topbar,.sidebar,.auth-card,.join-shell,.admin,.modal{background:var(--panel);color:var(--text)}
.topbar,.sidebar,.pinned,.reply-bar{border-color:var(--border)}
.profile{gap:14px}.profile>img{width:94px;height:94px}.profile-copy{min-width:122px}.profile-copy small{font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--muted)}.profile-copy b{font-size:19px}.profile-copy span{font-size:13px}
.profile button{color:var(--text);width:38px;height:38px;border-radius:10px}.profile button:hover{background:var(--accent-soft)}
:root[data-theme="dark"] .chat:after{background:linear-gradient(90deg,rgba(23,19,17,.9),rgba(23,19,17,.64))}
:root[data-theme="dark"] .pinned{background:rgba(34,27,23,.92);color:var(--text)}
:root[data-theme="dark"] .bubble{background:rgba(42,33,29,.92);border-color:var(--border);box-shadow:0 7px 22px var(--shadow);color:var(--text)}
:root[data-theme="dark"] .reply-quote{background:#332721;color:var(--text);border-left-color:#ad7558}
:root[data-theme="dark"] .special-label{background:#443126;color:#f6ead8}
:root[data-theme="dark"] .unique-reactions span{background:#2d231e;border-color:#6b5546;color:var(--text)}
:root[data-theme="dark"] .member-description,:root[data-theme="dark"] .member-role{color:var(--muted)}
:root[data-theme="dark"] .invite-main{background:#30241e;color:var(--text);border-color:var(--border)}
:root[data-theme="dark"] .reply-bar{background:#2a201b;color:var(--text)}
:root[data-theme="dark"] .composer{background:#17110f;border-color:#4c392f}
:root[data-theme="dark"] .composer input{background:#f8efe0;color:#211a17}
:root[data-theme="dark"] .admin nav button{background:#392b24;color:var(--text)}
:root[data-theme="dark"] .admin nav button.active{background:#7b4b35}
:root[data-theme="dark"] .admin-card th,:root[data-theme="dark"] .admin-card td{border-color:#4d3b31}

/* One calm selection treatment, no nested frames. */
.message{position:relative;border-radius:20px;transition:background .15s ease,transform .15s ease}
.message.selected-message{background:transparent!important;box-shadow:none!important;transform:none!important}
.message.selected-message::after{content:"✓";right:10px;top:8px;width:24px;height:24px;display:grid;place-items:center;padding:0;border-radius:50%;background:var(--accent);color:#fff;font-size:14px;box-shadow:0 4px 12px var(--shadow)}
.message.selected-message .bubble{outline:none!important;border:1px solid var(--accent)!important;background:color-mix(in srgb,var(--panel-2) 92%,var(--accent) 8%)!important;box-shadow:0 10px 28px var(--shadow)!important}
.message-action-bar{margin-top:10px;padding-top:0!important;border-top:0!important;gap:8px}
.message-action-bar button{border:1px solid var(--border);background:var(--accent-soft);color:var(--text);border-radius:10px;padding:9px 13px;font-weight:700}
.message-action-bar button:hover{filter:brightness(1.08)}
:root[data-theme="dark"] .message-action-bar button{background:#3a2a23;border-color:#6c5142;color:#f5ead9}

@media(max-width:900px){.profile>img{width:70px;height:70px}.profile-copy small{display:none}.profile-copy b{font-size:16px}}

/* Softer form surfaces: less glare in the dark theme and readable registration labels. */
:root[data-theme="dark"] .composer input{
  background:#e8dcc8;
  color:#241b17;
  border:1px solid #bca98e;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.45);
}
:root[data-theme="dark"] .composer input::placeholder{color:#776957;opacity:1}

:root[data-theme="dark"] .join-form{
  background:#e9ddc8;
  color:#2b211b;
  border-color:#b9a487;
}
:root[data-theme="dark"] .join-form label,
:root[data-theme="dark"] .join-form #chosen,
:root[data-theme="dark"] .join-form strong,
:root[data-theme="dark"] .join-form span{color:#2b211b}
:root[data-theme="dark"] .join-form input{
  background:#f2e8d7;
  color:#241b17;
  border-color:#a99273;
}
:root[data-theme="dark"] .join-form input::placeholder{color:#756653;opacity:1}
:root[data-theme="dark"] .join-form input:focus{
  outline:3px solid rgba(126,78,53,.24);
  border-color:#7e4e35;
}

/* 2026-08-03 final visual tune: milk inputs, content-width bubbles, readable challenge text, larger rose */
.brand img{
  width:68px;
  filter:drop-shadow(0 4px 10px rgba(76,42,26,.22)) saturate(1.05);
}
:root[data-theme="dark"] .topbar{
  background:#201916;
}
:root[data-theme="dark"] .brand p,
:root[data-theme="dark"] .profile-copy small,
:root[data-theme="dark"] .profile-copy span{
  color:#cab8a1;
}
.messages{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.message{
  display:flex !important;
  align-items:flex-start;
  gap:12px;
  width:100%;
  margin:0;
}
.message>img{
  flex:0 0 70px;
}
.message .bubble{
  width:-moz-fit-content;
  width:fit-content;
  max-width:min(70%, 720px);
  min-width:220px;
}
@media (max-width: 900px){
  .message .bubble{max-width:calc(100% - 10px);min-width:0}
}
:root[data-theme="dark"] .message .bubble{
  background:rgba(42,33,29,.95);
}
.message.selected-message .bubble{
  border-color:#946046 !important;
  box-shadow:0 12px 26px rgba(35,20,13,.28) !important;
}
.message.selected-message::after{
  right:12px;
  top:10px;
}
.challenge-box{
  color:#2a1d17;
  background:#ead8bf;
  border:1px solid #ceb18f;
}
.challenge-box b,
.challenge-box div,
.challenge-box span,
.challenge-box p{
  color:#2a1d17;
}
.challenge-box button{
  color:#2a1d17;
  background:#fff7e9;
  border:1px solid #a98b69;
  font-weight:700;
}
:root[data-theme="dark"] .challenge-box{
  color:#2b211b;
  background:#e4cfb0;
  border-color:#b99972;
}
:root[data-theme="dark"] .challenge-box b,
:root[data-theme="dark"] .challenge-box div,
:root[data-theme="dark"] .challenge-box span,
:root[data-theme="dark"] .challenge-box p,
:root[data-theme="dark"] .challenge-box button{
  color:#2b211b;
}
:root[data-theme="dark"] .challenge-box button{
  background:#f4ead8;
}
:root[data-theme="dark"] .composer input{
  background:#eadfce;
  color:#241b17;
}
:root[data-theme="dark"] .composer input::placeholder{color:#7b6b58}

/* 2026-08-03 hard fix: long unbroken text must wrap inside content-sized bubbles. */
.message{min-width:0}
.message .bubble{
  min-width:0 !important;
  max-width:min(70%,720px) !important;
  overflow:hidden;
}
.message .bubble p{
  max-width:100%;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  word-break:break-word;
  hyphens:auto;
}
.reply-quote,.reply-quote span,.special-label,.challenge-box{
  max-width:100%;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.brand img{
  width:78px !important;
  height:78px;
  object-fit:contain;
  flex:0 0 78px;
  filter:drop-shadow(0 5px 12px rgba(0,0,0,.35)) saturate(1.12) contrast(1.04);
}
@media(max-width:900px){
  .message .bubble{max-width:calc(100% - 4px) !important}
  .brand img{width:60px !important;height:60px;flex-basis:60px}
}

/* Detailed vintage PNG rose supplied by the user. */
.brand img{
  width:76px;
  height:76px;
  object-fit:contain;
  border-radius:18px;
}
.auth-logo img{
  width:76px;
  height:76px;
  object-fit:contain;
  border-radius:18px;
}
@media(max-width:900px){
  .brand img{width:62px;height:62px}
}

/* Personal profile and real names */
.profile-avatar-btn{border:0;background:transparent;padding:0;border-radius:14px;display:grid;place-items:center}
.profile-avatar-btn:hover{background:var(--accent-soft)}
.profile-avatar-btn img{width:94px;height:94px;object-fit:contain;background:transparent}
.profile-modal{position:relative;width:min(560px,95vw)}
.profile-close{position:absolute;right:14px;top:12px;border:0;background:transparent;color:var(--text);font-size:28px}
.profile-hero{display:flex;align-items:center;gap:18px;margin-bottom:18px;padding-right:36px}
.profile-hero img{width:120px;height:120px;object-fit:contain}
.profile-hero small{color:var(--muted);text-transform:uppercase;letter-spacing:.08em}
.profile-hero h2,.profile-hero p{margin:4px 0}
.profile-info{display:grid;gap:12px}
.profile-info label{display:grid;gap:6px;font-weight:700}
.profile-info input{height:44px;border:1px solid var(--border);border-radius:10px;padding:0 12px;background:#f3e8d5;color:#241b17}
.profile-readonly{display:grid;gap:3px;padding:11px 12px;border:1px solid var(--border);border-radius:10px;background:var(--panel-2)}
.profile-readonly span,.profile-readonly small{color:var(--muted)}
.profile-info hr{width:100%;border:0;border-top:1px solid var(--border)}
@media(max-width:900px){.profile-avatar-btn img{width:70px;height:70px}}


/* Profile discoverability and header alignment fix */
.profile .profile-avatar-btn{
  width:94px !important;
  height:94px !important;
  min-width:94px;
  padding:0 !important;
  overflow:visible;
}
.profile .profile-avatar-btn img{
  width:94px;
  height:94px;
}
.profile-copy{align-content:center}
.profile-open-text{
  width:auto !important;
  height:auto !important;
  justify-self:start;
  margin-top:4px;
  padding:3px 8px !important;
  border:1px solid var(--border) !important;
  border-radius:999px !important;
  background:var(--accent-soft) !important;
  color:var(--text) !important;
  font-size:12px !important;
  font-weight:700;
}
.profile-open-text:hover{filter:brightness(1.08)}
@media(max-width:900px){
  .profile .profile-avatar-btn{width:70px !important;height:70px !important;min-width:70px}
  .profile .profile-avatar-btn img{width:70px;height:70px}
}


/* Profile entry: only a large circular avatar and the character nickname. */
.topbar{min-height:104px}
.profile-entry{margin-left:auto;display:flex;align-items:center;gap:14px;border:0;background:transparent;color:var(--text);padding:6px 10px;border-radius:999px;cursor:pointer}
.profile-entry:hover{background:var(--accent-soft)}
.profile-entry b{font-family:Georgia,serif;font-size:22px;white-space:nowrap}
.profile-avatar-circle{width:88px;height:88px;min-width:88px;border-radius:50%;overflow:hidden;display:grid;place-items:center;background:#3b2a22;border:2px solid #a36b4c;box-shadow:0 6px 18px rgba(0,0,0,.28)}
.profile-avatar-circle img{width:100%;height:100%;object-fit:cover;object-position:center}
.profile-avatar-circle-large{width:116px;height:116px;min-width:116px}
.profile-hero{display:flex;align-items:center;gap:18px;margin-bottom:18px}
.profile-info{display:grid;gap:12px}
.profile-info label{display:grid;gap:6px}
.profile-info input{height:44px;border:1px solid var(--border);border-radius:10px;padding:0 12px;background:var(--panel-2);color:var(--text)}
.profile-readonly{display:grid;gap:3px;padding:11px 12px;border:1px solid var(--border);border-radius:10px;background:var(--panel-2)}
.profile-readonly span,.profile-readonly small{color:var(--muted)}
.profile-logout{border:1px solid #9a5147;border-radius:10px;background:#3b211f;padding:11px 14px;font-weight:700}
@media(max-width:700px){.profile-entry b{font-size:18px}.profile-avatar-circle{width:70px;height:70px;min-width:70px}.topbar{min-height:88px}}

/* 2026-08 multi-clan rooms + playful screen effects */
.room-tabs{display:flex;gap:8px;padding:10px 16px;background:rgba(255,250,240,.88);border-bottom:1px solid var(--line);overflow-x:auto}
.room-tabs button{border:1px solid var(--line);background:#f1e3cc;color:var(--ink);border-radius:999px;padding:8px 14px;white-space:nowrap;font-weight:800}
.room-tabs button.active{background:var(--brown);color:#fff;border-color:var(--brown)}
:root[data-theme="dark"] .room-tabs{background:rgba(31,24,21,.92);border-color:var(--border)}
:root[data-theme="dark"] .room-tabs button{background:#3a2c25;color:var(--text);border-color:var(--border)}
:root[data-theme="dark"] .room-tabs button.active{background:#8c5d44;color:#fff}
.decrypt-btn{width:100%;border:1px dashed #7f5bd2;border-radius:12px;padding:12px;background:rgba(82,48,128,.12);font-weight:800;color:inherit;text-align:left}
.screen-effect{position:fixed;inset:0;z-index:99999;pointer-events:auto;overflow:hidden;display:block;animation:effectIn .18s ease-out;background:rgba(0,0,0,.04)}
.screen-effect i{position:absolute;left:var(--x);top:var(--y);font-style:normal;font-size:calc(34px * var(--s));transform:rotate(var(--r));filter:drop-shadow(0 3px 4px rgba(0,0,0,.25));animation:effectPop .48s cubic-bezier(.2,.9,.25,1.2) both}
.screen-effect-paint i{font-size:calc(70px * var(--s));font-family:Georgia,serif;text-shadow:16px 7px 0 rgba(191,39,70,.72),-12px -6px 0 rgba(42,127,187,.72),6px -16px 0 rgba(237,167,37,.75);color:rgba(89,34,126,.82)}
.screen-effect-confetti i{color:#b33;font-size:calc(38px * var(--s));animation:confettiFall 6s ease-in forwards}
.screen-effect button{position:absolute;right:22px;bottom:22px;border:0;border-radius:999px;padding:12px 18px;background:#201815;color:#fff;font-weight:900;box-shadow:0 8px 26px rgba(0,0,0,.35)}
.effect-caption{position:absolute;top:18px;left:50%;transform:translateX(-50%);background:rgba(32,24,21,.88);color:#fff;padding:10px 16px;border-radius:999px;font-weight:900;box-shadow:0 8px 22px rgba(0,0,0,.25)}
@keyframes effectIn{from{opacity:0}to{opacity:1}}
@keyframes effectPop{from{opacity:0;transform:scale(.1) rotate(0)}to{opacity:1;transform:scale(1) rotate(var(--r))}}
@keyframes confettiFall{0%{transform:translateY(-80px) rotate(0);opacity:0}8%{opacity:1}100%{transform:translateY(85vh) rotate(720deg);opacity:.15}}
@media(max-width:900px){.room-tabs{padding:8px}.room-tabs button{padding:7px 11px}.effect-caption{max-width:86vw;text-align:center}}
.chat{grid-template-rows:auto auto 1fr auto auto}


/* 2026-08-09 clan identity polish, public doors, member cards */
.chat{grid-template-rows:auto auto auto 1fr auto auto}
.room-tabs{align-items:center}
.room-tabs button{display:flex;align-items:center;gap:7px;opacity:1;transition:opacity .16s ease,filter .16s ease,transform .16s ease}
.room-tabs button img{width:27px;height:27px;object-fit:contain;flex:0 0 27px}
.room-tabs button i{font-size:10px;font-style:normal;font-weight:700;opacity:.7;text-transform:uppercase;letter-spacing:.06em}
.room-tabs button.locked{opacity:.38;filter:saturate(.55)}
.room-tabs button.locked:hover{opacity:.62;transform:translateY(-1px)}
.room-heading{position:relative;z-index:2;display:flex;align-items:center;gap:12px;padding:10px 18px;background:rgba(241,227,204,.92);border-bottom:1px solid var(--line)}
.room-heading>img{width:52px;height:52px;object-fit:contain;flex:0 0 52px}
.room-heading h2{margin:0;font:700 21px/1.1 Georgia,serif;color:var(--ink)}
.room-heading p{margin:3px 0 0;color:var(--muted);font-size:12px;letter-spacing:.04em}
.common-room-heading{min-height:58px}
:root[data-theme="dark"] .room-heading{background:rgba(38,29,25,.94);border-color:var(--border)}
:root[data-theme="dark"] .room-heading h2{color:var(--text)}
.locked-room-modal{text-align:center;width:min(390px,92vw)}
.locked-room-emblem{width:116px;height:116px;object-fit:contain;margin:0 auto 4px;display:block}
.locked-room-modal h2{margin:4px 0}
.room-territory{font-family:Georgia,serif;font-style:italic;color:var(--muted)}
.locked-room-actions{display:flex;gap:10px;justify-content:center;margin-top:18px}
.member{cursor:pointer;border-radius:12px;transition:background .15s ease,transform .15s ease}
.member:hover{background:var(--accent-soft);transform:translateX(2px)}
.member:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.member-avatar-wrap{display:grid;place-items:center;overflow:visible;flex:0 0 auto}
.member-profile-modal{position:relative;width:min(540px,94vw);text-align:center;padding-top:24px}
.member-profile-avatar{height:min(300px,42vh);display:grid;place-items:center;overflow:visible;margin:0 auto 8px}
.member-profile-avatar img{width:100%;height:100%;max-width:320px;object-fit:contain;transform-origin:center}
.member-profile-modal h2{font:700 30px/1.05 Georgia,serif;margin:6px 0}
.member-real-name{margin:0 0 12px;color:var(--muted);font-weight:700}
.member-clan-block{display:flex;align-items:center;justify-content:center;gap:12px;padding:10px 14px;margin:14px auto;width:fit-content;max-width:100%;border:1px solid var(--border);border-radius:14px;background:var(--panel-2)}
.member-clan-block img{width:62px;height:62px;object-fit:contain}
.member-clan-block div{display:grid;text-align:left;gap:2px}.member-clan-block small{color:var(--muted)}.member-clan-block b{font-family:Georgia,serif;font-size:18px}
.member-profile-phrase{font-family:Georgia,serif;font-style:italic;font-size:17px;line-height:1.4;margin:16px auto;max-width:430px}
.member-power-card{display:flex;align-items:flex-start;gap:12px;text-align:left;padding:14px 16px;border:1px solid var(--border);border-radius:14px;background:var(--panel-2)}
.member-power-card>span{font-size:30px;line-height:1}.member-power-card b{font-size:17px}.member-power-card p{margin:5px 0 0;color:var(--muted);line-height:1.35}
.avatar-zoom-130{transform:scale(1.30);transform-origin:center}
.avatar-zoom-125{transform:scale(1.25);transform-origin:center}
.admin-avatar-wrap,.admin-character-avatar-wrap,.choice-avatar-wrap{display:grid;place-items:center;overflow:visible}
.admin-avatar-wrap{width:70px;height:70px}.admin-avatar-wrap .admin-avatar{width:70px;height:70px;object-fit:contain}
.admin-character-avatar-wrap{min-height:150px}.admin-character-avatar-wrap img{width:100%;height:150px;object-fit:contain}
.choice-avatar-wrap{width:58px;height:58px}.choice-avatar-wrap img{width:58px;height:58px;object-fit:contain}
.character-card{overflow:visible}.character-card>img{transform-origin:center}
.profile-avatar-circle{overflow:hidden}.profile-avatar-circle img.avatar-zoom-130{transform:scale(1.30)}.profile-avatar-circle img.avatar-zoom-125{transform:scale(1.25)}

/* Bombs stay playful without making the chat unusable. */
.screen-effect{pointer-events:none;background:transparent}
.screen-effect button{pointer-events:auto}
.screen-effect-paint i{opacity:.78}
.screen-effect-confetti i{animation-duration:5.2s}
.effect-caption{pointer-events:none}
@media(max-width:900px){.room-heading{padding:8px 10px}.room-heading>img{width:42px;height:42px;flex-basis:42px}.room-heading h2{font-size:18px}.room-tabs button i{display:none}.member-profile-avatar{height:min(250px,38vh)}}

/* 2026-08-10 confirmed clan-room update */
.chat{grid-template-rows:auto auto 1fr auto auto}
.chat-bg.common-bg{background-image:url('/static/assets/chat-bg.png')}
.chat-bg.clan-bg{background-image:url('/static/assets/clan-bg.png')}
.room-tabs{min-height:68px;padding:9px 16px}
.room-tabs button{padding:7px 15px;gap:10px}
.room-tabs button img{width:46px;height:46px;flex:0 0 46px;object-fit:contain}
.room-tabs button span{font-size:15px}
.member-clan-block img{width:82px;height:82px;flex:0 0 82px}
.locked-room-emblem{width:138px;height:138px}
#heartBtn .heart-glyph{display:inline-block;color:#c62828;font-size:31px;line-height:1}
#emojiBtn .emoji-glyph{display:inline-block;font-size:34px;line-height:1;transform:translateY(-1px)}
#heartBtn,#emojiBtn{font-size:inherit}
.admin-clan-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.admin-clan-card{display:grid;grid-template-columns:120px 1fr;gap:14px;align-items:center;padding:14px;border:1px solid var(--border);border-radius:14px;background:var(--panel-2)}
.admin-clan-card>img{width:120px;height:120px;object-fit:contain}
.admin-clan-card>div{display:grid;gap:8px}.admin-clan-card label{display:grid;gap:5px}.admin-clan-card input{height:42px;border:1px solid var(--border);border-radius:9px;padding:0 10px;background:var(--panel);color:var(--text)}
.ability-choice-list{display:grid;gap:10px;margin:14px 0}
@media(max-width:900px){.room-tabs{min-height:60px}.room-tabs button img{width:39px;height:39px;flex-basis:39px}.room-tabs button{padding:6px 10px}.member-clan-block img{width:72px;height:72px;flex-basis:72px}.admin-clan-grid{grid-template-columns:1fr}.admin-clan-card{grid-template-columns:90px 1fr}.admin-clan-card>img{width:90px;height:90px}}
\n\n/* 2026-08-10 compact header + brighter clan room refinement */
.layout{grid-template-rows:78px 1fr}
.topbar{min-height:78px;height:78px;padding:0 20px;overflow:visible;position:relative;z-index:20}
.brand{align-self:center}
.brand img{width:70px;height:70px;object-fit:contain}
.brand h1{font-size:30px;line-height:1.02}
.brand p{margin-top:2px;font-size:14px;line-height:1.1}
.profile-entry{position:relative;z-index:24;padding:0 8px;transform:translateY(9px)}
.profile-avatar-circle{width:98px;height:98px;min-width:98px}
.profile-entry b{font-size:22px}
.room-tabs{min-height:58px;padding:7px 16px}
.room-tabs button{padding:6px 14px;gap:8px}
.room-tabs button img{width:39px;height:39px;flex:0 0 39px}
.chat-bg.clan-bg{filter:brightness(1.40) saturate(1.05)}
:root[data-theme="dark"] .chat.clan-room:after{background:none}
.chat.clan-room:after{background:none}
@media(max-width:900px){
  .layout{grid-template-rows:70px auto 1fr}
  .topbar{min-height:70px;height:70px;padding:0 12px}
  .brand img{width:60px;height:60px}
  .brand h1{font-size:24px}
  .brand p{font-size:12px}
  .profile-entry{transform:translateY(7px);gap:8px}
  .profile-avatar-circle{width:78px;height:78px;min-width:78px}
  .room-tabs{min-height:52px;padding:6px 8px}
  .room-tabs button img{width:33px;height:33px;flex-basis:33px}
  .room-tabs button{padding:5px 9px;gap:6px}
}

/* 2026-08-10G final spacing correction */
/* Remove any leftover empty strip between the compact header and room tabs. */
.layout{grid-template-rows:78px minmax(0,1fr)}
.topbar{margin:0;padding-top:0;padding-bottom:0}
.chat{margin:0;padding:0;align-self:stretch}
.room-tabs{
  margin:0;
  min-height:0;
  padding:4px 8px;
  gap:5px;
  align-items:center;
}
.room-tabs button{
  width:auto;
  min-width:0;
  padding:3px 8px;
  gap:5px;
  line-height:1;
}
.room-tabs button img{
  width:52px;
  height:52px;
  flex:0 0 52px;
  object-fit:contain;
}
.room-tabs button span{font-size:15px;line-height:1}
/* Show more furniture/walls and less carpet, but only a slight shift. */
.chat-bg.clan-bg{
  background-position:center 44%;
}
@media(max-width:900px){
  .layout{grid-template-rows:70px auto minmax(0,1fr)}
  .room-tabs{padding:3px 6px;gap:4px}
  .room-tabs button{padding:2px 6px;gap:4px}
  .room-tabs button img{width:44px;height:44px;flex-basis:44px}
}

/* 2026-08-10H — compact clan tabs + PNG bomb overlays */
/* Keep tab capsules tight while making the actual clan art unmistakably large. */
.room-tabs{
  padding:3px 6px;
  gap:4px;
}
.room-tabs button{
  padding:2px 6px 2px 4px;
  gap:3px;
  width:max-content;
  min-width:0;
}
.room-tabs button img{
  width:66px;
  height:66px;
  flex:0 0 66px;
  object-fit:contain;
}
.room-tabs button span{
  font-size:15px;
  line-height:1;
}
/* A very small composition shift: less carpet, without pushing the lounge to the top. */
.chat-bg.clan-bg{background-position:center 44%}

/* Real PNG art replaces the old CSS dots/glyphs for bomb effects. */
.screen-effect{
  pointer-events:none;
  background:transparent;
  overflow:hidden;
}
.screen-effect .effect-art{
  position:absolute;
  inset:50% auto auto 50%;
  width:112vw;
  height:112vh;
  max-width:none;
  object-fit:cover;
  transform:translate(-50%,-50%) scale(1.03);
  transform-origin:center;
  pointer-events:none;
  user-select:none;
  -webkit-user-drag:none;
  filter:drop-shadow(0 4px 8px rgba(0,0,0,.18));
  animation:bombArtIn .28s cubic-bezier(.16,.88,.28,1.18) both;
}
.screen-effect .effect-art-echo{
  width:92vw;
  height:92vh;
  opacity:.42;
  transform:translate(-50%,-50%) rotate(9deg) scale(1.13);
  animation:bombArtEchoIn .38s cubic-bezier(.16,.88,.28,1.18) both;
}
.screen-effect-confetti .effect-art-main{
  width:118vw;
  height:118vh;
  animation:confettiBurstIn .34s cubic-bezier(.12,.86,.25,1.16) both;
}
.screen-effect-confetti .effect-art-echo{
  opacity:.5;
  transform:translate(-50%,-50%) rotate(-8deg) scale(1.18);
}
.screen-effect-paint .effect-art-main{opacity:.96}
.screen-effect-paint .effect-art-echo{opacity:.35}
.screen-effect button{pointer-events:auto;z-index:3}
.effect-caption{z-index:3}
@keyframes bombArtIn{from{opacity:0;transform:translate(-50%,-50%) scale(.55)}to{opacity:1;transform:translate(-50%,-50%) scale(1.03)}}
@keyframes bombArtEchoIn{from{opacity:0;transform:translate(-50%,-50%) rotate(9deg) scale(.62)}to{opacity:.42;transform:translate(-50%,-50%) rotate(9deg) scale(1.13)}}
@keyframes confettiBurstIn{from{opacity:0;transform:translate(-50%,-50%) scale(.45) rotate(-3deg)}to{opacity:1;transform:translate(-50%,-50%) scale(1.03) rotate(0)}}
@media(max-width:900px){
  .room-tabs{padding:2px 4px;gap:3px}
  .room-tabs button{padding:2px 5px 2px 3px;gap:2px}
  .room-tabs button img{width:56px;height:56px;flex-basis:56px}
  .room-tabs button span{font-size:14px}
}

/* 2026-08-10 MOBILE PREVIEW / future Capacitor shell */
.mobile-top-actions,.drawer-close{display:none}
@media(max-width:900px){
  html,body,#app{height:100%;min-height:100%;overflow:hidden}
  .layout{height:100dvh;grid-template-columns:1fr;grid-template-rows:72px minmax(0,1fr)}
  .topbar{grid-column:1;min-height:72px;height:72px;padding:0 8px 0 10px;display:flex;align-items:center;gap:6px}
  .brand{min-width:0;gap:4px}.brand img{width:50px;height:50px}.brand h1{font-size:20px;white-space:nowrap}
  .mobile-top-actions{display:flex;margin-left:auto;align-items:center}
  .members-toggle{height:40px;min-width:48px;border:1px solid var(--border);border-radius:12px;background:var(--panel-2);color:var(--text);font-size:19px;display:flex;align-items:center;justify-content:center;gap:3px;padding:0 7px}
  .members-toggle span{font-size:11px;font-weight:800}
  .profile-entry{margin-left:0;transform:translateY(5px);padding:0;gap:0}.profile-entry b{display:none}.profile-avatar-circle{width:64px;height:64px;min-width:64px}
  .sidebar{display:flex;position:fixed;z-index:80;top:0;bottom:0;left:0;width:min(86vw,330px);transform:translateX(-105%);transition:transform .2s ease;box-shadow:12px 0 35px #0008;background:var(--panel);padding-top:max(8px,env(safe-area-inset-top));}
  .sidebar.drawer-open{transform:translateX(0)}
  .sidebar .panel-title{position:sticky;top:0;z-index:2;background:var(--panel);display:grid;grid-template-columns:1fr auto auto;align-items:center;gap:8px}
  .drawer-close{display:grid;place-items:center;border:0;background:transparent;color:var(--text);font-size:32px;line-height:1;width:40px;height:40px;padding:0}
  .chat{grid-column:1;min-width:0;min-height:0;grid-template-rows:auto auto minmax(0,1fr) auto auto}
  .room-tabs{overflow-x:auto;overflow-y:hidden;flex-wrap:nowrap;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding:2px 4px;gap:3px}.room-tabs::-webkit-scrollbar{display:none}
  .room-tabs button{flex:0 0 auto;padding:2px 5px 2px 2px;gap:2px}.room-tabs button img{width:54px;height:54px;flex-basis:54px}.room-tabs button span{font-size:13px}
  .pinned{font-size:12px;padding:5px 8px;min-height:32px}
  .messages{padding:10px 8px 12px;min-height:0}
  .message{grid-template-columns:46px minmax(0,1fr);gap:7px}.message>img{width:44px;height:44px}.bubble{max-width:calc(100vw - 78px)}
  .composer{grid-template-columns:42px 42px minmax(0,1fr) 46px 48px;gap:5px;padding:7px 7px max(7px,env(safe-area-inset-bottom))}.composer input{min-width:0}
  .emoji-panel{left:6px;right:6px;bottom:70px;width:auto}
  .modal-overlay,.admin-overlay{padding:8px}.modal{width:100%;max-height:88dvh;border-radius:18px}
  .member-profile-modal{padding-top:38px}
  .chat-bg.clan-bg{background-position:center 44%}

  .mobile-join{height:100dvh;overflow:auto;padding:14px 10px 24px}
  .mobile-join-shell{width:min(100%,460px);margin:0 auto;padding:16px 12px;display:block}
  .mobile-join-shell header{text-align:center}.mobile-join-shell header h1{font-size:26px;margin-bottom:5px}.mobile-join-shell header p{font-size:13px}
  .character-carousel{display:grid;grid-template-columns:42px minmax(0,1fr) 42px;align-items:center;gap:4px;margin-top:8px}
  .carousel-arrow{width:42px;height:58px;border:1px solid var(--border);border-radius:14px;background:var(--panel-2);color:var(--text);font-size:38px;line-height:1}
  .carousel-character{width:100%;margin:0;border:0!important;background:transparent!important;box-shadow:none!important;text-align:center;padding:0 5px!important;display:block!important}
  .carousel-avatar{height:min(40dvh,330px);display:grid;place-items:center;overflow:visible}.carousel-avatar img{width:100%;height:100%;object-fit:contain}
  .carousel-character h3{font-size:25px;margin:2px 0 2px}.carousel-character code{font-size:13px}.carousel-character>p{font-size:13px;margin:7px auto;max-width:300px}
  .carousel-character .power{margin:8px auto 0;max-width:310px;padding:10px}.carousel-character .power span{font-size:12px}
  .carousel-count{text-align:center;font-weight:800;opacity:.65;margin:6px 0 8px}.choose-character{display:block;width:min(280px,88%);margin:0 auto}
  .mobile-join .join-form{position:static;margin:14px auto 0;max-width:340px}
}

/* Desktop browser device emulator: same mobile code, constrained to a phone viewport. */
html.mobile-preview body{background:#110e0c;display:grid;place-items:center;overflow:auto;padding:18px}
html.mobile-preview #app{width:var(--preview-w,390px);height:var(--preview-h,844px);max-width:100%;max-height:calc(100vh - 36px);overflow:hidden;border-radius:28px;box-shadow:0 22px 70px #000c;border:1px solid #5c4335;position:relative}
html.mobile-preview .layout{height:100%}
html.mobile-preview .auth,html.mobile-preview .join{height:100%;min-height:0;overflow:auto}
html.mobile-preview .layout{grid-template-columns:1fr;grid-template-rows:72px minmax(0,1fr)}
html.mobile-preview .topbar{grid-column:1;min-height:72px;height:72px;padding:0 8px 0 10px;display:flex;align-items:center;gap:6px}
html.mobile-preview .brand{min-width:0;gap:4px}html.mobile-preview .brand img{width:50px;height:50px}html.mobile-preview .brand h1{font-size:20px;white-space:nowrap}
html.mobile-preview .mobile-top-actions{display:flex;margin-left:auto}html.mobile-preview .members-toggle{height:40px;min-width:48px}
html.mobile-preview .profile-entry{margin-left:0;transform:translateY(5px);padding:0;gap:0}html.mobile-preview .profile-entry b{display:none}html.mobile-preview .profile-avatar-circle{width:64px;height:64px;min-width:64px}
html.mobile-preview .sidebar{display:flex;position:absolute;z-index:80;top:0;bottom:0;left:0;width:86%;transform:translateX(-105%);transition:transform .2s ease;box-shadow:12px 0 35px #0008;background:var(--panel)}
html.mobile-preview .sidebar.drawer-open{transform:translateX(0)}html.mobile-preview .drawer-close{display:grid;place-items:center}
html.mobile-preview .chat{grid-column:1;min-width:0;min-height:0;grid-template-rows:auto auto minmax(0,1fr) auto auto}
html.mobile-preview .room-tabs{overflow-x:auto;flex-wrap:nowrap;padding:2px 4px;gap:3px}html.mobile-preview .room-tabs button{flex:0 0 auto;padding:2px 5px 2px 2px;gap:2px}html.mobile-preview .room-tabs button img{width:54px;height:54px;flex-basis:54px}html.mobile-preview .room-tabs button span{font-size:13px}
html.mobile-preview .pinned{font-size:12px;padding:5px 8px;min-height:32px}html.mobile-preview .messages{padding:10px 8px 12px;min-height:0}html.mobile-preview .message{grid-template-columns:46px minmax(0,1fr);gap:7px}html.mobile-preview .message>img{width:44px;height:44px}html.mobile-preview .bubble{max-width:calc(var(--preview-w,390px) - 78px)}
html.mobile-preview .composer{grid-template-columns:42px 42px minmax(0,1fr) 46px 48px;gap:5px;padding:7px}html.mobile-preview .composer input{min-width:0}
html.mobile-preview .mobile-join{height:100%;overflow:auto;padding:14px 10px 24px}html.mobile-preview .mobile-join-shell{width:100%;padding:16px 12px;display:block}html.mobile-preview .character-carousel{display:grid;grid-template-columns:42px minmax(0,1fr) 42px;align-items:center;gap:4px}html.mobile-preview .carousel-avatar{height:min(330px,38vh)}

/* 2026-08-10 MOBILE PREVIEW B — profile/drawer/admin + avatar proportions */
@media(max-width:900px){
  /* Participants drawer: vertical, readable and self-contained. */
  .sidebar{
    display:block;
    overflow-y:auto;
    overflow-x:hidden;
    padding:8px 10px 18px;
  }
  .sidebar .panel-title{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    min-height:48px;
    padding:4px 0 8px;
    margin:0 0 6px;
  }
  .sidebar .panel-title strong{font-size:18px}
  .sidebar .panel-title>span{display:none}
  .member{
    width:100%;
    grid-template-columns:64px minmax(0,1fr) 12px;
    gap:9px;
    min-height:78px;
    padding:4px 2px;
  }
  .member img{width:62px;height:62px}
  .member-copy{min-width:0}
  .member-copy b,.member-role,.member-description{white-space:normal;overflow-wrap:anywhere}
  .member-description{max-width:none;font-size:11px;line-height:1.25}
  .invite-main{margin-top:10px}

  /* Profile becomes a real phone sheet instead of a desktop dialog. */
  .modal-overlay{align-items:stretch;justify-content:stretch;padding:8px}
  .profile-modal{
    width:100%;
    max-width:none;
    height:100%;
    max-height:none;
    overflow-y:auto;
    border-radius:18px;
    padding:52px 14px 18px;
  }
  .profile-close{position:absolute;right:10px;top:8px;width:40px;height:40px;font-size:30px}
  .profile-hero{align-items:center;gap:10px}
  .profile-avatar-circle-large{width:78px;height:78px;min-width:78px}
  .profile-hero h2{font-size:22px;margin:0}
  .profile-info{display:grid;gap:9px}
  .profile-info label{margin:0}
  .profile-info input{width:100%;min-width:0}
  .profile-readonly{padding:10px 11px}
  .profile-info .primary,.profile-info .secondary,.profile-logout{width:100%}

  /* Clan management is phone-sized and scrollable inside the app. */
  .admin-overlay{align-items:stretch;justify-content:stretch;padding:8px}
  .admin{
    width:100%;
    max-width:none;
    height:100%;
    max-height:none;
    border-radius:18px;
    grid-template-rows:auto auto minmax(0,1fr);
  }
  .admin>header{padding:12px 12px 10px;gap:8px;align-items:flex-start}
  .admin>header h2{font-size:22px}
  .admin>header p{font-size:12px;line-height:1.25}
  .admin>header button{flex:0 0 auto;padding:9px 10px}
  .admin nav{overflow-x:auto;flex-wrap:nowrap;padding:8px 10px;gap:6px;scrollbar-width:none}
  .admin nav::-webkit-scrollbar{display:none}
  .admin nav button{flex:0 0 auto;padding:8px 10px}
  .admin section{padding:0 10px 12px;min-width:0}
  .admin-clan-grid{grid-template-columns:1fr;gap:9px}
  .admin-clan-card{grid-template-columns:76px minmax(0,1fr);gap:9px;padding:10px}
  .admin-clan-card>img{width:76px;height:76px}
  .admin-clan-card input{width:100%;min-width:0}
  .admin-card{max-width:100%;overflow-x:auto}
  .admin-card table{min-width:680px}
  .create-row{min-width:0;grid-template-columns:1fr!important}
  .create-row>*{width:100%;min-width:0}
  .admin-character-grid{grid-template-columns:1fr!important}

  /* Requested mobile proportions: writer avatar x2, clan emblem /1.5. */
  .message{grid-template-columns:92px minmax(0,1fr);gap:8px}
  .message>img{width:88px;height:88px}
  .bubble{max-width:calc(100vw - 116px)}
  .room-tabs button img{width:36px;height:36px;flex-basis:36px}
}

/* The desktop device preview must receive the same mobile rules even though
   the actual browser viewport is wide. */
html.mobile-preview .sidebar{
  display:block;
  overflow-y:auto;
  overflow-x:hidden;
  padding:8px 10px 18px;
}
html.mobile-preview .sidebar .panel-title{
  position:sticky;top:0;z-index:2;background:var(--panel);
  display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;
  min-height:48px;padding:4px 0 8px;margin:0 0 6px;
}
html.mobile-preview .sidebar .panel-title>span{display:none}
html.mobile-preview .member{width:100%;grid-template-columns:64px minmax(0,1fr) 12px;gap:9px;min-height:78px;padding:4px 2px}
html.mobile-preview .member img{width:62px;height:62px}
html.mobile-preview .member-description{max-width:none;font-size:11px;white-space:normal;overflow-wrap:anywhere}

html.mobile-preview .modal-overlay,
html.mobile-preview .admin-overlay{
  position:fixed;
  inset:auto;
  left:50%;top:50%;
  transform:translate(-50%,-50%);
  width:var(--preview-w,390px);
  height:var(--preview-h,844px);
  max-width:calc(100vw - 36px);
  max-height:calc(100vh - 36px);
  align-items:stretch;
  justify-content:stretch;
  padding:8px;
  overflow:hidden;
}
html.mobile-preview .profile-modal{
  width:100%;max-width:none;height:100%;max-height:none;overflow-y:auto;
  border-radius:18px;padding:52px 14px 18px;
}
html.mobile-preview .profile-close{position:absolute;right:10px;top:8px;width:40px;height:40px;font-size:30px}
html.mobile-preview .profile-hero{align-items:center;gap:10px}
html.mobile-preview .profile-avatar-circle-large{width:78px;height:78px;min-width:78px}
html.mobile-preview .profile-hero h2{font-size:22px;margin:0}
html.mobile-preview .profile-info{display:grid;gap:9px}
html.mobile-preview .profile-info label{margin:0}
html.mobile-preview .profile-info input{width:100%;min-width:0}
html.mobile-preview .profile-readonly{padding:10px 11px}
html.mobile-preview .profile-info .primary,
html.mobile-preview .profile-info .secondary,
html.mobile-preview .profile-logout{width:100%}

html.mobile-preview .admin{
  width:100%;max-width:none;height:100%;max-height:none;border-radius:18px;
  grid-template-rows:auto auto minmax(0,1fr);
}
html.mobile-preview .admin>header{padding:12px 12px 10px;gap:8px;align-items:flex-start}
html.mobile-preview .admin>header h2{font-size:22px}
html.mobile-preview .admin>header p{font-size:12px;line-height:1.25}
html.mobile-preview .admin>header button{flex:0 0 auto;padding:9px 10px}
html.mobile-preview .admin nav{overflow-x:auto;flex-wrap:nowrap;padding:8px 10px;gap:6px;scrollbar-width:none}
html.mobile-preview .admin nav::-webkit-scrollbar{display:none}
html.mobile-preview .admin nav button{flex:0 0 auto;padding:8px 10px}
html.mobile-preview .admin section{padding:0 10px 12px;min-width:0}
html.mobile-preview .admin-clan-grid{grid-template-columns:1fr;gap:9px}
html.mobile-preview .admin-clan-card{grid-template-columns:76px minmax(0,1fr);gap:9px;padding:10px}
html.mobile-preview .admin-clan-card>img{width:76px;height:76px}
html.mobile-preview .admin-clan-card input{width:100%;min-width:0}
html.mobile-preview .admin-card{max-width:100%;overflow-x:auto}
html.mobile-preview .admin-card table{min-width:680px}
html.mobile-preview .create-row{min-width:0;grid-template-columns:1fr!important}
html.mobile-preview .create-row>*{width:100%;min-width:0}
html.mobile-preview .admin-character-grid{grid-template-columns:1fr!important}

html.mobile-preview .message{grid-template-columns:92px minmax(0,1fr);gap:8px}
html.mobile-preview .message>img{width:88px;height:88px}
html.mobile-preview .bubble{max-width:calc(var(--preview-w,390px) - 116px)}
html.mobile-preview .room-tabs button img{width:36px;height:36px;flex-basis:36px}


/* 2026-08-10 MOBILE PREVIEW C — registration readability, lounge crop, mobile bomb overlay */
@media(max-width:900px){
  /* Move the lounge artwork itself down ~15% so less carpet is visible. */
  .chat-bg.clan-bg{background-position:center 29%}

  /* Registration carousel: readable dark card instead of washed-out cream text. */
  .carousel-character{
    background:rgba(43,33,27,.96)!important;
    border:1px solid rgba(168,121,84,.55)!important;
    border-radius:18px!important;
    padding:10px 10px 12px!important;
    color:#f7ead5!important;
  }
  .carousel-character h3{color:#fff3df!important;text-shadow:none!important}
  .carousel-character code{color:#e8a27d!important;background:transparent!important}
  .carousel-character>p{color:#eadcc9!important;opacity:1!important}
  .carousel-character .power{background:#4a3528!important;color:#fff1dd!important;border:1px solid #6a4a38!important}
  .carousel-character .power b,.carousel-character .power span{color:#fff1dd!important;opacity:1!important}
  .carousel-avatar{height:min(34dvh,285px)}

  /* Password step is stacked and fully contained in the phone width. */
  .mobile-join .join-form{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:10px!important;
    width:100%!important;
    max-width:340px!important;
    padding:12px!important;
    overflow:hidden!important;
  }
  .mobile-join .join-form #chosen,.mobile-join .join-form label,.mobile-join .join-form input,.mobile-join .join-form button{
    width:100%!important;min-width:0!important;max-width:100%!important;
  }

  /* Bomb art belongs to the phone viewport, never to the surrounding desktop page. */
  #app>.screen-effect{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;z-index:95!important;overflow:hidden!important}
  #app>.screen-effect .effect-art{width:145%!important;height:145%!important;object-fit:contain!important}
  #app>.screen-effect .effect-art-echo{width:120%!important;height:120%!important}
  #app>.screen-effect .effect-caption{top:max(14px,env(safe-area-inset-top))!important;max-width:84%!important;text-align:center}
  #app>.screen-effect button{right:12px!important;bottom:max(12px,env(safe-area-inset-bottom))!important}
}

html.mobile-preview .chat-bg.clan-bg{background-position:center 29%}
html.mobile-preview .carousel-character{
  background:rgba(43,33,27,.96)!important;
  border:1px solid rgba(168,121,84,.55)!important;
  border-radius:18px!important;
  padding:10px 10px 12px!important;
  color:#f7ead5!important;
}
html.mobile-preview .carousel-character h3{color:#fff3df!important;text-shadow:none!important}
html.mobile-preview .carousel-character code{color:#e8a27d!important;background:transparent!important}
html.mobile-preview .carousel-character>p{color:#eadcc9!important;opacity:1!important}
html.mobile-preview .carousel-character .power{background:#4a3528!important;color:#fff1dd!important;border:1px solid #6a4a38!important}
html.mobile-preview .carousel-character .power b,
html.mobile-preview .carousel-character .power span{color:#fff1dd!important;opacity:1!important}
html.mobile-preview .carousel-avatar{height:min(285px,34vh)}
html.mobile-preview .mobile-join .join-form{
  display:grid!important;grid-template-columns:1fr!important;gap:10px!important;
  width:100%!important;max-width:340px!important;padding:12px!important;overflow:hidden!important;
}
html.mobile-preview .mobile-join .join-form #chosen,
html.mobile-preview .mobile-join .join-form label,
html.mobile-preview .mobile-join .join-form input,
html.mobile-preview .mobile-join .join-form button{width:100%!important;min-width:0!important;max-width:100%!important}
html.mobile-preview #app>.screen-effect{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;z-index:95!important;overflow:hidden!important}
html.mobile-preview #app>.screen-effect .effect-art{width:145%!important;height:145%!important;object-fit:contain!important}
html.mobile-preview #app>.screen-effect .effect-art-echo{width:120%!important;height:120%!important}
html.mobile-preview #app>.screen-effect .effect-caption{top:14px!important;max-width:84%!important;text-align:center}
html.mobile-preview #app>.screen-effect button{right:12px!important;bottom:12px!important}

/* 2026-08-10 MOBILE PREVIEW D — lower lounge, compact registration, smaller message avatars, admin close at bottom */
.admin-footer{display:none}

@media(max-width:900px){
  /* Move the lounge artwork DOWN by ~30 percentage points from the previous crop. */
  .chat-bg.clan-bg{background-position:center 0%!important}

  /* Registration: keep the portrait and text visually together. */
  .carousel-avatar{height:min(26dvh,220px)!important;margin-bottom:0!important}
  .carousel-character h3{margin:0 0 2px!important}
  .carousel-character code{display:block;margin:0 0 3px!important}
  .carousel-character>p{margin:4px auto!important;line-height:1.22!important}
  .carousel-character .power{margin:5px auto 0!important;padding:8px!important}
  .carousel-count{margin:4px 0 5px!important}

  /* Compact password panel so the chosen character remains visible. */
  .mobile-join .join-form{
    max-width:315px!important;
    gap:5px!important;
    padding:8px 10px!important;
    margin-top:7px!important;
    border-radius:12px!important;
  }
  .mobile-join .join-form label{gap:3px!important;margin:2px 0!important;font-size:13px!important}
  .mobile-join .join-form input{height:38px!important;padding:0 9px!important}
  .mobile-join .join-form button{padding:9px 12px!important}
  .mobile-join .join-form #chosen{gap:1px!important;font-size:12px!important}
  .mobile-join .join-form #regError{margin:0!important;font-size:12px!important}

  /* Writer avatar: 10% smaller than preview C. */
  .message{grid-template-columns:83px minmax(0,1fr)!important;gap:7px!important}
  .message>img{width:79px!important;height:79px!important}
  .bubble{max-width:calc(100vw - 105px)!important}

  /* Clan management: close action lives at the bottom on phones. */
  .admin{grid-template-rows:auto auto minmax(0,1fr) auto!important}
  .admin-close-top{display:none!important}
  .admin-footer{display:block!important;padding:8px 10px max(10px,env(safe-area-inset-bottom));border-top:1px solid var(--border);background:var(--panel)}
  .admin-footer button{width:100%!important;padding:11px!important}
}

html.mobile-preview .chat-bg.clan-bg{background-position:center 0%!important}
html.mobile-preview .carousel-avatar{height:min(220px,26vh)!important;margin-bottom:0!important}
html.mobile-preview .carousel-character h3{margin:0 0 2px!important}
html.mobile-preview .carousel-character code{display:block;margin:0 0 3px!important}
html.mobile-preview .carousel-character>p{margin:4px auto!important;line-height:1.22!important}
html.mobile-preview .carousel-character .power{margin:5px auto 0!important;padding:8px!important}
html.mobile-preview .carousel-count{margin:4px 0 5px!important}
html.mobile-preview .mobile-join .join-form{max-width:315px!important;gap:5px!important;padding:8px 10px!important;margin-top:7px!important;border-radius:12px!important}
html.mobile-preview .mobile-join .join-form label{gap:3px!important;margin:2px 0!important;font-size:13px!important}
html.mobile-preview .mobile-join .join-form input{height:38px!important;padding:0 9px!important}
html.mobile-preview .mobile-join .join-form button{padding:9px 12px!important}
html.mobile-preview .mobile-join .join-form #chosen{gap:1px!important;font-size:12px!important}
html.mobile-preview .mobile-join .join-form #regError{margin:0!important;font-size:12px!important}
html.mobile-preview .message{grid-template-columns:83px minmax(0,1fr)!important;gap:7px!important}
html.mobile-preview .message>img{width:79px!important;height:79px!important}
html.mobile-preview .bubble{max-width:calc(var(--preview-w,390px) - 105px)!important}
html.mobile-preview .admin{grid-template-rows:auto auto minmax(0,1fr) auto!important}
html.mobile-preview .admin-close-top{display:none!important}
html.mobile-preview .admin-footer{display:block!important;padding:8px 10px 10px;border-top:1px solid var(--border);background:var(--panel)}
html.mobile-preview .admin-footer button{width:100%!important;padding:11px!important}

/* 2026-08-10 MOBILE PREVIEW E — four fixed room tabs + tighter registration layout */
@media(max-width:900px){
  /* All four rooms must fit on one phone screen: no horizontal room scrolling. */
  .room-tabs{
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:3px!important;
    overflow:hidden!important;
    padding:3px 4px!important;
    min-height:0!important;
  }
  .room-tabs button{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    justify-content:center!important;
    padding:3px 2px!important;
    gap:2px!important;
    overflow:hidden!important;
  }
  .room-tabs button img{
    width:26px!important;
    height:26px!important;
    flex:0 0 26px!important;
  }
  .room-tabs button span{
    min-width:0!important;
    font-size:11px!important;
    line-height:1.05!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }

  /* Registration: keep portrait, name, description and power close together and above password form. */
  .mobile-join-shell{padding-top:10px!important}
  .character-carousel{margin-top:2px!important;align-items:start!important}
  .carousel-avatar{
    height:min(21dvh,180px)!important;
    margin:0!important;
  }
  .carousel-character{
    padding-top:0!important;
    padding-bottom:0!important;
  }
  .carousel-character h3{margin:-2px 0 1px!important}
  .carousel-character code{margin:0 0 2px!important}
  .carousel-character>p{margin:2px auto 3px!important}
  .carousel-character .power{margin:3px auto 0!important;padding:7px!important}
  .carousel-count{margin:2px 0 3px!important}
  .choose-character{margin-top:0!important}

  /* Password card: centered, smaller, and closer to the character card. */
  .mobile-join .join-form{
    position:relative!important;
    left:auto!important;
    right:auto!important;
    bottom:auto!important;
    width:min(300px,calc(100% - 12px))!important;
    max-width:300px!important;
    margin:4px auto 0!important;
    padding:7px 9px!important;
    gap:4px!important;
    align-self:center!important;
    justify-self:center!important;
  }
  .mobile-join .join-form label{margin:1px 0!important}
  .mobile-join .join-form input{height:34px!important}
  .mobile-join .join-form button{padding:8px 10px!important}
}

html.mobile-preview .room-tabs{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  gap:3px!important;
  overflow:hidden!important;
  padding:3px 4px!important;
  min-height:0!important;
}
html.mobile-preview .room-tabs button{width:100%!important;min-width:0!important;max-width:none!important;justify-content:center!important;padding:3px 2px!important;gap:2px!important;overflow:hidden!important}
html.mobile-preview .room-tabs button img{width:26px!important;height:26px!important;flex:0 0 26px!important}
html.mobile-preview .room-tabs button span{min-width:0!important;font-size:11px!important;line-height:1.05!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
html.mobile-preview .mobile-join-shell{padding-top:10px!important}
html.mobile-preview .character-carousel{margin-top:2px!important;align-items:start!important}
html.mobile-preview .carousel-avatar{height:min(180px,21vh)!important;margin:0!important}
html.mobile-preview .carousel-character{padding-top:0!important;padding-bottom:0!important}
html.mobile-preview .carousel-character h3{margin:-2px 0 1px!important}
html.mobile-preview .carousel-character code{margin:0 0 2px!important}
html.mobile-preview .carousel-character>p{margin:2px auto 3px!important}
html.mobile-preview .carousel-character .power{margin:3px auto 0!important;padding:7px!important}
html.mobile-preview .carousel-count{margin:2px 0 3px!important}
html.mobile-preview .choose-character{margin-top:0!important}
html.mobile-preview .mobile-join .join-form{position:relative!important;left:auto!important;right:auto!important;bottom:auto!important;width:min(300px,calc(100% - 12px))!important;max-width:300px!important;margin:4px auto 0!important;padding:7px 9px!important;gap:4px!important;align-self:center!important;justify-self:center!important}
html.mobile-preview .mobile-join .join-form label{margin:1px 0!important}
html.mobile-preview .mobile-join .join-form input{height:34px!important}
html.mobile-preview .mobile-join .join-form button{padding:8px 10px!important}

/* 2026-08-10 MOBILE PREVIEW F — final mobile polish */
@media(max-width:900px){
  /* Lounge: crop from the top and zoom slightly so the carpet no longer dominates. */
  .chat-bg.clan-bg{
    background-position:center top!important;
    background-size:auto 126%!important;
  }

  /* Message author portraits: another 8% smaller than preview E. */
  .message{grid-template-columns:75px minmax(0,1fr)!important;gap:7px!important}
  .message>img{width:73px!important;height:73px!important}
  .bubble{max-width:calc(100vw - 98px)!important}

  /* Main rose: twice the previous 50px mobile size without inflating the header row. */
  .topbar{overflow:visible!important}
  .brand{overflow:visible!important}
  .brand img{
    width:100px!important;height:100px!important;flex:0 0 100px!important;
    object-fit:contain!important;margin-left:-17px!important;margin-right:-18px!important;
    position:relative!important;z-index:4!important;
  }

  /* Registration CTA centered. */
  .choose-character{
    display:block!important;
    width:min(250px,78%)!important;
    margin:3px auto 0!important;
    justify-self:center!important;
    text-align:center!important;
  }

  /* Custom in-app delete confirmation. */
  .mobile-confirm-overlay{
    position:fixed;inset:0;z-index:140;display:flex;align-items:flex-end;justify-content:center;
    padding:12px 10px max(12px,env(safe-area-inset-bottom));background:rgba(0,0,0,.58);
  }
  .mobile-confirm{
    width:min(100%,390px);padding:18px 16px 14px;border:1px solid #6a4a38;border-radius:22px;
    background:#241b17;color:#f7ead5;box-shadow:0 18px 50px #000a;
  }
  .mobile-confirm h3{margin:0 0 6px;text-align:center;font-family:Georgia,serif;font-size:21px}
  .mobile-confirm p{margin:0 0 15px;text-align:center;color:#d9c7b4;font-size:13px}
  .mobile-confirm>div{display:grid;grid-template-columns:1fr 1fr;gap:9px}
  .mobile-confirm button{min-height:46px;border-radius:12px;font-weight:800}
  .danger-confirm{border:0;background:#a33f36;color:white}

  /* Online count remains compact but explicit. */
  .members-toggle .count{font-size:11px!important;font-weight:900!important;white-space:nowrap}
}

html.mobile-preview .chat-bg.clan-bg{background-position:center top!important;background-size:auto 126%!important}
html.mobile-preview .message{grid-template-columns:75px minmax(0,1fr)!important;gap:7px!important}
html.mobile-preview .message>img{width:73px!important;height:73px!important}
html.mobile-preview .bubble{max-width:calc(var(--preview-w,390px) - 98px)!important}
html.mobile-preview .topbar,html.mobile-preview .brand{overflow:visible!important}
html.mobile-preview .brand img{width:100px!important;height:100px!important;flex:0 0 100px!important;object-fit:contain!important;margin-left:-17px!important;margin-right:-18px!important;position:relative!important;z-index:4!important}
html.mobile-preview .choose-character{display:block!important;width:min(250px,78%)!important;margin:3px auto 0!important;justify-self:center!important;text-align:center!important}
html.mobile-preview .mobile-confirm-overlay{position:absolute!important;inset:0!important;z-index:140!important;display:flex!important;align-items:flex-end!important;justify-content:center!important;padding:12px 10px 12px!important;background:rgba(0,0,0,.58)!important}
html.mobile-preview .mobile-confirm{width:100%!important;max-width:370px!important;padding:18px 16px 14px!important;border:1px solid #6a4a38!important;border-radius:22px!important;background:#241b17!important;color:#f7ead5!important;box-shadow:0 18px 50px #000a!important}
html.mobile-preview .mobile-confirm h3{margin:0 0 6px!important;text-align:center!important;font-family:Georgia,serif!important;font-size:21px!important}
html.mobile-preview .mobile-confirm p{margin:0 0 15px!important;text-align:center!important;color:#d9c7b4!important;font-size:13px!important}
html.mobile-preview .mobile-confirm>div{display:grid!important;grid-template-columns:1fr 1fr!important;gap:9px!important}
html.mobile-preview .mobile-confirm button{min-height:46px!important;border-radius:12px!important;font-weight:800!important}
html.mobile-preview .danger-confirm{border:0!important;background:#a33f36!important;color:white!important}
html.mobile-preview .members-toggle .count{font-size:11px!important;font-weight:900!important;white-space:nowrap!important}
html.mobile-preview .mobile-confirm-overlay{
  position:fixed!important;inset:auto!important;left:50%!important;top:50%!important;
  transform:translate(-50%,-50%)!important;width:var(--preview-w,390px)!important;height:var(--preview-h,844px)!important;
  max-width:calc(100vw - 36px)!important;max-height:calc(100vh - 36px)!important;
}
