/* room */
.room{max-width:1440px;margin:0 auto;padding:14px 16px 24px}
.gamebar{display:grid;grid-template-columns:auto 150px 1fr 150px;align-items:center;gap:14px;height:64px;padding:0 14px;margin-bottom:12px;border:1px solid var(--line);border-radius:var(--radius);background:var(--panel)}
.timer{position:relative;width:48px;height:48px;display:grid;place-items:center}
.timer svg{position:absolute;inset:0;transform:rotate(-90deg)}
.timer circle{fill:none;stroke-width:4}
.timer circle:first-child{stroke:#ffffff14}
#timer-ring{stroke:var(--green);stroke-linecap:round;stroke-dasharray:119.4;stroke-dashoffset:0;transition:stroke-dashoffset .25s linear,stroke .3s}
.timer span{position:relative;font:500 15px var(--mono)}
.timer.warn #timer-ring{stroke:var(--yellow)}
.timer.urgent #timer-ring{stroke:var(--red)}
.timer.urgent span{color:var(--red-2);animation:beat 1s infinite}
@keyframes beat{50%{transform:scale(1.15)}}
.round-info{font-weight:700;font-size:15px;color:var(--soft)}
.word{display:flex;align-items:flex-end;justify-content:center;flex-wrap:wrap;gap:4px 6px;min-width:0;text-align:center}
.word .label{width:100%;font-size:12px;color:var(--muted);font-weight:600;line-height:1}
.word .plain{font-size:24px;font-weight:800;letter-spacing:.02em}
.word .plain.ok{color:var(--green)}
.word .letters{display:flex;flex-wrap:wrap;justify-content:center;gap:5px;font:500 24px var(--mono);line-height:1.1}
.word .letters i{font-style:normal;display:inline-block;min-width:.8em;border-bottom:3px solid var(--soft);text-align:center;text-transform:uppercase}
.word .letters i.open{color:var(--yellow);border-color:var(--yellow)}
.word .letters i.gap{border:0;min-width:.6em}
.word .count{font:500 13px var(--mono);color:var(--muted);margin-left:6px;align-self:flex-start}
.phase-text{text-align:right;font-size:13px;color:var(--muted);font-weight:600}

.layout{display:grid;grid-template-columns:230px minmax(0,1fr) 300px;gap:12px;align-items:start}
.players-panel,.chat-panel,.stage{border:1px solid var(--line);border-radius:var(--radius);background:var(--panel)}
.players-panel{padding:8px}
.players{display:flex;flex-direction:column;gap:4px}
.player{position:relative;display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:12px;transition:background .3s}
.player:nth-child(even){background:#ffffff06}
.player.guessed{background:var(--green-bg)}
.player.drawing{box-shadow:inset 0 0 0 1px var(--yellow)}
.player.away{opacity:.4}
.player.me .p-name{color:#fff}
.p-rank{width:22px;font:500 12px var(--mono);color:var(--muted)}
.p-body{min-width:0;flex:1}
.p-name{display:block;font-size:14px;font-weight:700;color:var(--soft);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.p-score{display:block;font-size:12px;color:var(--muted)}
.player.guessed .p-score{color:var(--green)}
.p-badges{display:flex;gap:2px;font-size:15px}
.kick{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:26px;height:26px;border-radius:8px;border:0;background:#e0325a33;color:var(--red-2);font-size:14px;opacity:0;transition:opacity .15s}
.player:hover .kick,.kick:focus-visible{opacity:1}

.stage{padding:12px;min-width:0}
.canvas-wrap{position:relative;width:100%;aspect-ratio:4/3;border-radius:12px;overflow:hidden;background:#fff;touch-action:none}
#canvas{display:block;width:100%;height:100%;touch-action:none}
.canvas-wrap.can-draw #canvas{cursor:none}
.brush-cursor{position:absolute;left:0;top:0;pointer-events:none;border-radius:50%;border:1.5px solid #000a;box-shadow:0 0 0 1px #fff9;transform:translate(-50%,-50%)}
.overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:safe center;gap:14px;padding:16px;overflow-y:auto;background:#0d0a12f0;text-align:center}
.overlay h3{margin:0;font-size:26px;letter-spacing:-.02em}
.overlay p{margin:0;color:var(--soft)}
.overlay .big-word{font-size:34px;font-weight:800;color:var(--yellow)}
.choices{display:flex;flex-wrap:wrap;justify-content:center;gap:10px}
.choices button{padding:14px 22px;border-radius:14px;border:2px solid var(--line-2);background:#ffffff0d;font-size:19px;font-weight:800;transition:background .15s,border-color .15s,transform .1s}
.choices button:hover{background:var(--red);border-color:var(--red);transform:translateY(-2px)}
.gains{display:flex;flex-direction:column;gap:6px;width:min(340px,100%);max-height:55%;overflow:auto}
.gain{display:flex;align-items:center;gap:10px;padding:6px 10px;border-radius:10px;background:#ffffff08}
.gain .g-name{flex:1;text-align:left;font-weight:700}
.gain .g-pts{font:500 15px var(--mono);color:var(--green)}
.gain .g-pts.zero{color:var(--muted)}
.podium{display:flex;align-items:flex-end;justify-content:center;gap:14px}
.podium .place{display:flex;flex-direction:column;align-items:center;gap:6px;width:110px}
.podium .place .medal{font-size:30px}
.podium .place .pn{font-weight:800;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.podium .place .ps{font:500 13px var(--mono);color:var(--muted)}
.podium .step{width:100%;border-radius:10px 10px 0 0;background:linear-gradient(180deg,#ffffff1f,#ffffff08)}
.podium .p1 .step{height:90px;background:linear-gradient(180deg,#f3c34455,#f3c34411)}
.podium .p2 .step{height:62px}
.podium .p3 .step{height:44px}
.overlay-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.overlay-actions .btn{min-width:160px}

.tools{margin-top:12px;display:flex;flex-direction:column;gap:10px}
.palette{display:grid;grid-template-columns:repeat(13,1fr);gap:4px;max-width:520px}
.swatch{aspect-ratio:1;border-radius:7px;border:2px solid #0000;background:var(--c);box-shadow:inset 0 0 0 1px #0000002a}
.swatch.active{border-color:#fff;transform:scale(1.12)}
.tool-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;justify-content:space-between}
.sizes{display:flex;gap:4px;padding:4px;border:1px solid var(--line-2);border-radius:12px}
.size{width:40px;height:40px;border-radius:9px;border:0;background:transparent;display:grid;place-items:center}
.size i{display:block;border-radius:50%;background:var(--soft)}
.size.active{background:#ffffff1a}
.size.active i{background:#fff}
.tool-btns{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.tool{width:44px;height:44px;border-radius:11px;border:1px solid var(--line-2);background:var(--panel-2);font-size:19px;display:grid;place-items:center;padding:0}
.tool.active{background:var(--red);border-color:var(--red)}
.tool.danger:hover{border-color:var(--red)}
.tool:hover:not(.active){border-color:#ffffff55}
.sep{width:1px;height:28px;background:var(--line-2);margin:0 4px}
.custom-color{position:relative;overflow:hidden;background:conic-gradient(red,yellow,lime,cyan,blue,magenta,red)}
.custom-color input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
.custom-color.active{box-shadow:0 0 0 2px #fff}
.rate{display:flex;align-items:center;justify-content:center;gap:10px;margin-top:12px;color:var(--muted);font-size:14px}
.rate button{display:flex;align-items:center;gap:6px;height:40px;padding:0 14px;border-radius:999px;border:1px solid var(--line-2);background:var(--panel-2);font-size:17px}
.rate button b{font:500 13px var(--mono);color:var(--soft)}
.rate button.mine{border-color:var(--red-2);background:#e0325a22}

/* lobby */
.lobby{display:flex;flex-direction:column;gap:14px}
.invite{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px;border-radius:14px;background:linear-gradient(135deg,#e0325a26,#8a68bd26);border:1px solid var(--line-2)}
.invite>div:first-child{min-width:0}
.invite-label{font-weight:700;margin-bottom:8px}
.invite-link{display:flex;align-items:center;gap:8px;min-width:0}
.invite-link code{min-width:0;padding:8px 10px;border-radius:9px;background:#0b090f;font:13px var(--mono);color:var(--soft);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.invite-code{text-align:center}
.invite-code span{display:block;font-size:12px;color:var(--muted)}
.invite-code strong{font:500 30px var(--mono);letter-spacing:.2em}
.settings{padding:16px;border:1px solid var(--line);border-radius:14px}
.settings-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px;margin-bottom:14px}
.settings-head h2{margin:0;font-size:20px}
.settings-head span{font-size:13px;color:var(--muted)}
.settings-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.settings-grid label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:700;color:var(--soft)}
.settings-grid label.wide{grid-column:1/-1}
.settings select,.custom-box textarea{width:100%;height:44px;padding:0 12px;border:1px solid var(--line-2);border-radius:10px;background:#0b090f;font-size:15px;font-weight:600}
.settings select:disabled{opacity:.7;cursor:default}
.custom-box{margin-top:12px}
.custom-box textarea{height:auto;padding:10px 12px;resize:vertical;font-weight:500;line-height:1.5}
.custom-foot{display:flex;align-items:center;justify-content:space-between;margin-top:8px;font-size:13px;color:var(--muted)}
.lobby-start{text-align:center}
.lobby-hint{margin:10px 0 0;color:var(--muted);font-size:14px}

/* chat */
.chat-panel{display:flex;flex-direction:column;height:calc(100vh - 186px);min-height:420px;max-height:760px}
.chat{flex:1;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:2px;font-size:14px;line-height:1.4;overscroll-behavior:contain}
.msg{padding:5px 9px;border-radius:9px;word-wrap:break-word}
.msg:nth-child(even){background:#ffffff05}
.msg b{font-weight:800;margin-right:5px}
.msg.secret{background:var(--green-bg)!important;color:#bdf0d2}
.msg.k-guess{color:var(--green);font-weight:800}
.msg.k-close{color:var(--yellow);font-weight:700}
.msg.k-join{color:var(--blue)}
.msg.k-leave{color:var(--red-2)}
.msg.k-system,.msg.k-reveal{color:#c9a8f2;font-weight:700}
.msg.k-like{color:var(--green)}
.msg.k-dislike{color:var(--red-2)}
.chat-form{padding:8px;border-top:1px solid var(--line)}
.chat-form input{width:100%;height:44px;padding:0 12px;border:1px solid var(--line-2);border-radius:11px;background:#0b090f;font-size:15px}
.chat-form input:focus{outline:none;border-color:var(--red-2)}


@media(max-width:1180px){
  .layout{grid-template-columns:200px minmax(0,1fr) 260px}
  .gamebar{grid-template-columns:auto 110px 1fr 110px}
}
@media(max-width:960px){
  .room{padding:10px 10px 20px}
  .gamebar{grid-template-columns:auto 1fr auto;height:auto;min-height:60px;padding:8px 12px;gap:10px}
  .phase-text{display:none}
  .round-info{order:3;font-size:13px;text-align:right}
  .word{order:2}
  .layout{grid-template-columns:minmax(0,2fr) minmax(0,3fr);grid-template-areas:"stage stage" "players chat"}
  .stage{grid-area:stage;padding:8px}
  .players-panel{grid-area:players;max-height:360px;overflow-y:auto}
  .chat-panel{grid-area:chat;height:360px;min-height:0}
  .player{padding:6px;gap:8px}
  .p-rank{display:none}
  .avatar{width:32px;height:32px;font-size:18px}
  .p-badges{position:absolute;left:28px;top:2px;font-size:12px;flex-direction:column;gap:0}
}
@media(max-width:640px){
  .word .plain{font-size:20px}
  .word .letters{font-size:19px;gap:3px}
  .palette{grid-template-columns:repeat(13,1fr);gap:3px}
  .size{width:34px;height:34px}
  .tool{width:40px;height:40px;font-size:17px}
  .invite{flex-direction:column;align-items:stretch}
  .invite-code{display:none}
  .settings-grid{grid-template-columns:1fr}
  .overlay h3{font-size:20px}
  .overlay .big-word{font-size:26px}
  .choices button{padding:10px 14px;font-size:16px}
  .overlay{gap:8px;padding:10px}
  .overlay p{font-size:13px}
  .podium{gap:8px}
  .podium .place{width:76px;gap:2px}
  .podium .place .medal{font-size:18px}
  .podium .place .pn{font-size:13px;max-width:76px}
  .podium .p1 .step{height:34px}
  .podium .p2 .step{height:22px}
  .podium .p3 .step{height:12px}
  .overlay-actions .btn{min-width:0;height:38px;font-size:14px}
  .gains{gap:3px}
  .gain{padding:3px 8px}
  .avatar.lg{width:40px;height:40px;font-size:24px}
}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}

.player[data-me]{cursor:pointer}
