:root{
  --bg:#0b1220;
  --card:#111a2d;
  --card2:#0f1729;
  --text:#e7edf8;
  --muted:#a6b1c7;
  --line:rgba(255,255,255,.10);
  --brand:#6ae4ff;
  --brand2:#8b7bff;
  --ok:#35d07f;
  --warn:#ffd166;
  --danger:#ff5c7a;
  --shadow: 0 18px 60px rgba(0,0,0,.35);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(106,228,255,.18), transparent 60%),
              radial-gradient(1000px 700px at 80% 20%, rgba(139,123,255,.16), transparent 60%),
              var(--bg);
  color:var(--text);
}

a{color:inherit}

.app-shell{min-height:100%; display:flex; flex-direction:column}
.topbar{
  display:flex; gap:16px; align-items:center; justify-content:space-between;
  padding:16px 18px;
  border-bottom:1px solid var(--line);
  backdrop-filter: blur(8px);
  position:sticky; top:0; z-index:10;
  background: rgba(11,18,32,.65);
}
.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:40px; height:40px; border-radius:10px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(106,228,255,.25), rgba(139,123,255,.25));
  border:1px solid rgba(255,255,255,.16);
  font-weight:800;
}
.title{font-weight:800; letter-spacing:.2px}
.subtitle{font-size:12px; color:var(--muted)}

.userbox{display:flex; gap:10px; align-items:end}
.label{font-size:12px; color:var(--muted); margin-bottom:4px}

.grid{
  padding:18px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
  max-width: 1200px;
  width:100%;
  margin:0 auto;
}
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  box-shadow: var(--shadow);
}
.card.subtle{background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));}
.card h2{margin:0 0 10px 0; font-size:16px}
.card h3{margin:0 0 10px 0; font-size:14px; color:var(--text)}
.span2{grid-column: 1 / span 2;}

.form{display:flex; flex-direction:column; gap:10px}
.field{display:flex; flex-direction:column; gap:6px}
.field span{font-size:12px; color:var(--muted)}
.row{display:flex; gap:10px; align-items:center}
.rowhead{display:flex; align-items:center; justify-content:space-between}

.input{
  width:100%;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color:var(--text);
  outline:none;
}
.input:focus{border-color: rgba(106,228,255,.55); box-shadow: 0 0 0 4px rgba(106,228,255,.12)}

.btn{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
}
.btn:hover{background: rgba(255,255,255,.10)}
.btn:active{transform: translateY(1px)}
.btn.primary{
  background: linear-gradient(135deg, rgba(106,228,255,.22), rgba(139,123,255,.22));
  border-color: rgba(255,255,255,.22);
}
.btn.small{padding:7px 10px; border-radius:10px; font-size:12px}

.hint{font-size:12px; color:var(--muted)}
.msg{font-size:12px; color:var(--muted); min-height:16px}
.msg.err{color: var(--danger)}
.msg.ok{color: var(--ok)}

.image-grid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap:10px;
}
.image-card{
  border-radius:14px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  cursor:pointer;
  transition: transform .08s ease;
}
.image-card:hover{transform: translateY(-1px)}
.image-card.selected{outline: 2px solid rgba(106,228,255,.75)}
.image-thumb{height:72px; background-size:cover; background-position:center}
.image-title{padding:8px; font-size:12px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

.progress-list{display:flex; flex-direction:column; gap:10px}
.progress-item{
  display:flex; gap:12px; align-items:center; justify-content:space-between;
  border:1px solid rgba(255,255,255,.12);
  border-radius:14px;
  padding:10px;
  background: rgba(0,0,0,.14);
}
.progress-left{display:flex; gap:12px; align-items:center; min-width:0}
.progress-thumb{width:84px; height:54px; border-radius:12px; background-size:cover; background-position:center; border:1px solid rgba(255,255,255,.12)}
.progress-meta{min-width:0}
.progress-meta .name{font-weight:700; font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.progress-meta .sub{font-size:12px; color:var(--muted)}

.footer{padding:14px 18px; color:var(--muted); font-size:12px; text-align:center}

.tips{margin:8px 0 0 18px; padding:0; color:var(--muted); font-size:13px}
.kbd{border:1px solid rgba(255,255,255,.18); padding:2px 6px; border-radius:8px; background: rgba(0,0,0,.2); color:var(--text); font-size:12px}
.pill{display:inline-block; padding:2px 8px; border-radius:999px; border:1px solid rgba(255,255,255,.18); font-size:12px; background: rgba(0,0,0,.18)}
.pill.ok{border-color: rgba(53,208,127,.35); color: rgba(208,255,230,.95)}

/* Room */
.room-shell{min-height:100%; display:flex; flex-direction:column}
.backlink{color:var(--muted); text-decoration:none; margin-right:12px}
.backlink:hover{color:var(--text)}
.room-actions{display:flex; gap:10px; align-items:center}
.room-main{flex:1; display:grid; grid-template-columns: 1fr 320px; gap:14px; padding:14px; max-width: 1400px; width:100%; margin:0 auto}
.board{padding:12px; display:flex; flex-direction:column; min-height: calc(100vh - 120px)}
.board-top{display:flex; gap:12px; align-items:center; padding:6px 4px 10px 4px; border-bottom:1px solid var(--line)}
.stat{min-width:90px}
.statLabel{font-size:11px; color:var(--muted)}
.statValue{font-weight:800}
.spacer{flex:1}
.tool{display:flex; align-items:center; gap:8px}
.toolLabel{font-size:12px; color:var(--muted)}

.viewport{
  position:relative;
  flex:1;
  margin-top:10px;
  border-radius:16px;
  background: rgba(0,0,0,.22);
  border:1px solid rgba(255,255,255,.10);
  overflow:hidden;
  outline:none;
}
.canvas{position:absolute; inset:0; transform-origin: 0 0;}
.frame{position:absolute; left:50%; top:50%; transform: translate(-50%,-50%);
  width: 520px; height: 340px;
  border-radius: 18px;
  border: 2px dashed rgba(255,255,255,.22);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
  pointer-events:none;
}

.piece{
  position:absolute;
  width: 70px; height: 70px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 14px 32px rgba(0,0,0,.35);
  background-size: 520px 340px;
  background-repeat:no-repeat;
  cursor: grab;
  user-select:none;
  touch-action:none;
}
.piece.dragging{cursor:grabbing; filter: brightness(1.05); box-shadow: 0 18px 42px rgba(0,0,0,.5)}
.piece.locked{opacity:.72; filter:saturate(.8)}
.piece.placed{border-color: rgba(53,208,127,.55); box-shadow: 0 14px 32px rgba(53,208,127,.10), 0 14px 32px rgba(0,0,0,.35)}

.sidebar{display:flex; flex-direction:column; gap:14px}
.chat{height: 300px; overflow:auto; border:1px solid rgba(255,255,255,.10); border-radius:14px; padding:10px; background: rgba(0,0,0,.14)}
.chatItem{margin-bottom:10px}
.chatTop{display:flex; gap:8px; align-items:baseline}
.chatName{font-weight:800; font-size:12px}
.chatTime{font-size:11px; color:var(--muted)}
.chatText{font-size:13px; color:rgba(231,237,248,.92); margin-top:2px; white-space:pre-wrap; word-break:break-word}

@media (max-width: 980px){
  .grid{grid-template-columns: 1fr}
  .span2{grid-column:auto}
  .image-grid{grid-template-columns: repeat(2, minmax(0,1fr))}
  .room-main{grid-template-columns: 1fr;}
  .board{min-height: 520px}
}
