/* CHOCO plaza (trial). The room on the left, the conversation log on the right (below on phones). */
:root{--choco:#4a2c23;--choco2:#6d4637;--cream:#fbf5ec;--line:#e2cfbb;--pink:#f59ab9;--ink:#3a2a24;
 --c-white:#fff;--c-pink:#ffd3e2;--c-aqua:#c7ecf3;--c-lemon:#fff2a8;--c-lilac:#e3d4f7}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{background:var(--cream);color:var(--ink);
 font:14px/1.5 "Hiragino Maru Gothic ProN","M PLUS Rounded 1c","Noto Sans JP",Meiryo,sans-serif}
/* The plaza fills the screen under the CHARAT header (fixed, 50px); the CHARAT footer follows below it. */
.plaza-app{display:flex;flex-direction:column;height:calc(100dvh - 50px);margin-top:50px}
button,input{font:inherit;color:inherit}
button{cursor:pointer}
[hidden]{display:none!important}

.plaza-header{flex-shrink:0;display:flex;align-items:center;gap:14px;height:52px;padding:0 16px;background:var(--choco);color:#fbefe3}
.plaza-header h1{margin:0;font-size:17px;letter-spacing:.06em;display:flex;align-items:baseline;gap:8px}
.plaza-header small{padding:1px 7px;border:1px solid #fbefe399;border-radius:999px;font-size:10px;font-weight:400;letter-spacing:0}
.plaza-back{color:inherit;text-decoration:none;font-size:12px;opacity:.85}
.plaza-back:hover{opacity:1;text-decoration:underline}
.plaza-count{margin-left:auto;display:flex;align-items:center;gap:6px;font:12px monospace}
.live-dot{width:8px;height:8px;border-radius:50%;background:#8ee06a;box-shadow:0 0 0 3px #8ee06a33}

.plaza-main{flex:1;min-height:0;display:flex}

/* ---- Room ---- */
#stage{position:relative;flex:1;min-width:0;overflow:hidden;--k:1;--horizon:40%;background:#cfe9f7}
#floor,#bubbles,#scenery{position:absolute;inset:0}

/* Scenery: sky and drifting clouds, a row of sweets shops (scenery.svg, repeats sideways) and the square's
   paving drawn in perspective. Characters stand on the paving from just below the horizon. */
#scenery{pointer-events:none;background:linear-gradient(#b9e0f5,#dcf0fa calc(var(--horizon) * .7),#fdf2ea var(--horizon))}
#clouds{position:absolute;left:0;top:3%;width:200%;height:calc(var(--horizon) * .55);
 background:url(clouds.svg) 0 0/50% 100% repeat-x;animation:clouds 160s linear infinite}
@keyframes clouds{to{transform:translateX(-50%)}}
#town{position:absolute;left:0;right:0;bottom:calc(100% - var(--horizon));height:calc(var(--horizon) * .78);
 background:url(scenery.svg) 50% 100%/auto 100% repeat-x}
#ground{position:absolute;left:0;right:0;top:var(--horizon);bottom:0;overflow:hidden;perspective:520px;perspective-origin:50% 0}
/* A big paved plane leaning back; its far edge vanishes into the horizon. */
#ground::before{content:"";position:absolute;left:-150%;right:-150%;bottom:0;height:1400px;transform-origin:50% 100%;transform:rotateX(74deg);
 background:
  repeating-linear-gradient(90deg,#e8d5bf 0 3px,#fff0 3px 90px),
  repeating-linear-gradient(0deg,#e8d5bf 0 3px,#fff0 3px 90px),
  repeating-conic-gradient(#f4e6d4 0 25%,#f9efe2 0 50%) 0 0/180px 180px}
/* Haze where the paving meets the town. */
#ground::after{content:"";position:absolute;inset:0 0 auto;height:38%;background:linear-gradient(#fdf2eaee,#fdf2ea00)}
#bubbles{pointer-events:none;z-index:3000}
.person{position:absolute;transform:translate(-50%,-100%);display:flex;flex-direction:column;align-items:center;animation:pop-in .35s ease-out}
.person::before{content:"";position:absolute;bottom:-4px;left:50%;width:calc(var(--w) * var(--k) * var(--d) * .62px);height:12px;
 transform:translateX(-50%);border-radius:50%;background:#6d463726;z-index:-1}
.person img{display:block;width:calc(var(--w) * var(--k) * var(--d) * 1px);height:auto;-webkit-user-select:none;user-select:none}
.person .tag{position:absolute;top:calc(100% + 4px);left:50%;transform:translateX(-50%);max-width:120px;padding:1px 8px;border-radius:999px;
 background:#ffffffd9;font-size:11px;line-height:1.5;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.person.mine .tag{background:var(--choco);color:#fff}
.person.gone{opacity:0;transition:opacity .35s}
/* Over the speaker's head. --dx keeps it inside the room at the edges; the tail still points at the head. */
.bubble{position:absolute;width:max-content;max-width:190px;padding:7px 11px;border:2px solid var(--choco);border-radius:14px;background:#fff;
 font-size:13px;line-height:1.45;
 transform:translate(calc(-50% + var(--dx,0px)),calc(-100% - var(--h) * var(--k) * var(--d) * 1px - 14px)) scale(.6);transform-origin:50% 100%;
 opacity:0;transition:opacity .2s,transform .2s}
.bubble.show{opacity:1;transform:translate(calc(-50% + var(--dx,0px)),calc(-100% - var(--h) * var(--k) * var(--d) * 1px - 14px)) scale(1)}
.bubble span{display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}
.bubble::after{content:"";position:absolute;top:100%;left:calc(50% - var(--dx,0px));width:10px;height:10px;margin:-4px 0 0 -6px;
 background:inherit;border:solid var(--choco);border-width:0 2px 2px 0;transform:rotate(45deg)}
#stage-idle{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;
 text-align:center;padding:24px;color:var(--choco2)}
#stage-idle p{margin:0}
#stage-idle-count{font-size:20px;font-weight:700;color:var(--choco)}
body.joined #stage-idle{display:none}

/* ---- Log and forms ---- */
#side{flex-shrink:0;width:360px;display:flex;flex-direction:column;border-left:1px solid var(--line);background:#fffaf4}
#log{flex:1;min-height:0;margin:0;padding:14px 12px;list-style:none;overflow-y:auto;display:flex;flex-direction:column;gap:10px}
#log>li:first-child{margin-top:auto}
.note{align-self:center;max-width:92%;padding:4px 12px;border-radius:999px;background:#f1e4d6;color:var(--choco2);font-size:11px;text-align:center}
.msg{display:flex;align-items:flex-end;gap:8px;animation:pop-in .2s ease-out}
.msg.mine{flex-direction:row-reverse}
.face{flex-shrink:0;width:36px;height:36px;border-radius:50%;object-fit:cover;object-position:50% 4%;background:#fff;border:2px solid var(--line)}
.face.missing{visibility:hidden}
.msg-body{display:flex;flex-direction:column;align-items:flex-start;min-width:0;max-width:calc(100% - 50px)}
.msg.mine .msg-body{align-items:flex-end}
.from{font-size:10px;font-weight:700;color:var(--choco2);margin:0 0 2px 4px}
.text{padding:7px 11px;border:1.5px solid var(--choco);border-radius:14px;font-size:13px;line-height:1.45;overflow-wrap:anywhere}
.msg:not(.mine) .text{border-bottom-left-radius:4px}
.msg.mine .text{border-bottom-right-radius:4px}
.c-white{background:var(--c-white)}.c-pink{background:var(--c-pink)}.c-aqua{background:var(--c-aqua)}.c-lemon{background:var(--c-lemon)}.c-lilac{background:var(--c-lilac)}

.panel{flex-shrink:0;margin:0 10px 10px;padding:10px;border:1px solid var(--line);border-radius:14px;background:#fff;box-shadow:0 2px 10px #4a2c2314}
#need-avatar p{margin:0 0 10px;font-size:12px}
.button{display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 18px;border:0;border-radius:999px;
 text-decoration:none;font-weight:700;font-size:13px}
.button.primary{background:var(--choco);color:#fff}
.button.primary:hover{background:var(--choco2)}
.button:disabled{opacity:.5}
#entry{display:flex;flex-direction:column;gap:8px}
#entry-list{display:flex;gap:6px;overflow-x:auto;padding:2px}
.choice{flex-shrink:0;width:46px;height:56px;padding:3px;border:2px solid var(--line);border-radius:10px;background:#fffaf4}
.choice img{width:100%;height:100%;object-fit:contain;object-position:50% 100%}
.choice[aria-checked="true"]{border-color:var(--choco);background:#fff;box-shadow:0 0 0 2px #4a2c2322}
.entry-main{display:flex;gap:10px;align-items:center}
#entry-avatar{width:64px;height:84px;object-fit:contain;object-position:50% 100%;flex-shrink:0}
.entry-fields{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}
#entry-name,#chat-text{width:100%;height:40px;padding:0 12px;border:1.5px solid var(--line);border-radius:999px;background:#fff}
#entry-name:focus-visible,#chat-text:focus-visible{outline:none;border-color:var(--choco)}
.entry-remake{align-self:flex-start;font-size:11px;color:var(--choco2)}
#chat-form{display:grid;gap:8px}
.chat-tools{display:flex;align-items:center;gap:8px}
.chat-colors{display:flex;gap:2px}
.chat-chip{position:relative;display:grid;place-items:center;width:28px;height:28px;cursor:pointer}
.chat-chip input{position:absolute;opacity:0;width:1px;height:1px;margin:0;pointer-events:none}
.chat-chip span{width:18px;height:18px;border:1.5px solid var(--choco);border-radius:50%}
.chat-chip input:checked+span{box-shadow:0 0 0 2px #fff,0 0 0 3.5px var(--choco)}
.chat-chip input:focus-visible+span{outline:3px solid var(--pink);outline-offset:3px}
#chat-me{margin-left:auto;min-width:0;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:700}
#chat-leave{border:0;background:none;padding:6px 2px;font-size:11px;color:var(--choco2)}
#chat-leave:hover{text-decoration:underline}
.chat-row{display:flex;gap:6px}
#chat-send{flex-shrink:0;width:40px;height:40px;border:0;border-radius:50%;background:var(--choco);color:#fff;font:18px Arial,sans-serif}
#chat-send:hover{background:var(--choco2)}

#status{position:fixed;left:50%;bottom:120px;transform:translate(-50%,10px);max-width:calc(100% - 32px);padding:8px 16px;border-radius:999px;
 background:#3a2a24e6;color:#fff;font-size:12px;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:9999}
#status.show{opacity:1;transform:translate(-50%,0)}

@keyframes pop-in{from{opacity:0;transform:translate(-50%,-100%) scale(.85)}}
.msg{animation-name:msg-in}
@keyframes msg-in{from{opacity:0;transform:translateY(6px)}}
@media(prefers-reduced-motion:reduce){.person,.msg,#clouds{animation:none}.bubble{transition:none}}

/* Phones: the room on top, the log below it, the form at the bottom. */
@media(max-width:760px){
 .plaza-header{height:46px;gap:10px;padding:0 12px}
 .plaza-header h1{font-size:15px}
 .plaza-main{flex-direction:column}
 #stage{flex:0 0 46%}
 #side{flex:1;width:auto;min-height:0;border-left:0;border-top:1px solid var(--line)}
 #log{padding:10px}
 .panel{margin:0 8px calc(8px + env(safe-area-inset-bottom))}
 #entry-name,#chat-text{font-size:16px}
 .bubble{max-width:150px;font-size:12px;padding:5px 9px}
 #status{bottom:110px}
}
