/* =========================
   Base
========================= */
html, body { height: 100%; }

body{
  background-color: #1e1e2f;
  color: white;
  font-family: Arial, sans-serif;
  margin: 0;
  overflow: hidden; /* 固定レイアウトなのでスクロールさせない */
}

.hidden{ display:none; }

.hint{
  opacity: 0.8;
  font-size: 12px;
}

/* =========================
   Common UI
========================= */
.home-container, .room-container{
  margin: 0 auto;
}

.card{
  background-color: #2c2c3f;
  padding: 18px;
  border-radius: 10px;
  margin: 12px 0;
}

.row{
  display:flex;
  gap: 10px;
  justify-content:center;
  align-items:center;
  flex-wrap: wrap;
}

input, textarea{
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.22);
  color: white;
  outline: none;
}

input:focus, textarea:focus{
  border-color: rgba(255,255,255,0.35);
}

button{
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background-color: #4CAF50;
  color: white;
}

button:hover{
  background-color: #45a049;
}

.secondary{
  background-color: #666;
}
.secondary:hover{
  background-color: #555;
}

.danger{
  background-color: #b84a4a;
}
.danger:hover{
  background-color: #a84040;
}

.small{
  width: auto;
  padding: 6px 10px;
  margin: 0;
  font-size: 12px;
}

/* =========================
   Home
========================= */
.home-container{
  width: min(900px, 92vw);
  padding: 24px 0;
}

.home-header{
  display:flex;
  justify-content: space-between;
  align-items:center;
  margin-bottom: 16px;
}

.room-list{
  list-style:none;
  padding:0;
  margin: 10px 0 0 0;
}

.room-item{
  display:flex;
  justify-content: space-between;
  align-items:center;
  background: rgba(255,255,255,0.06);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 8px 0;
}

/* =========================
   Fixed 100vh Session Layout
========================= */
.room-container{
  width: 100%;
  max-width: none;
  height: 100vh;
  padding: 10px 12px;
  box-sizing: border-box;
}

.topbar{
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  height: 64px;
}

.topbar-left h2{
  margin: 0;
  font-size: 20px;
}
.topbar-left .hint{
  margin: 4px 0 0 0;
}

.topbar-right{
  display:flex;
  align-items: center;
  gap: 8px;
}

.select{
  background: #2c2c3f;
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 6px 8px;
}

.main{
  height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 10px;
  min-height: 0;
}

/* =========================
   Board
========================= */
.board-wrap{
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 10px;
  box-sizing: border-box;
  min-height: 0;
}

.board-area{
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background-color: #111;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;

  position: relative;
  user-select: none;
  overflow: hidden;
  background-image: none !important; /* JS直指定を避ける（--board-bg運用） */
}

/* 余白をブラーで埋める */
.board-area::before{
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--board-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(18px);
  transform: scale(1.08);
  opacity: 0.85;
}

/* 中央はくっきり全体表示 */
.board-area::after{
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--board-bg);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  filter: none;
}

/* tokens */
.token{
  position: absolute;
  z-index: 2; /* 背景より上 */
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border: 2px solid rgba(255,255,255,0.35);
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
  cursor: grab;
  background-color: rgba(0,0,0,0.2);
}
.token:active{ cursor: grabbing; }

/* =========================
   Right Side Panels
========================= */
.side{
  height: 100%;
  min-height: 0;
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.panel{
  background-color: #2c2c3f;
  border-radius: 10px;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

/* tabs */
.tabs{
  display:flex;
  gap: 6px;
}

.tab{
  width: auto;
  margin: 0;
  padding: 6px 10px;
  background: rgba(255,255,255,0.08);
}
.tab.active{
  outline: 2px solid rgba(255,255,255,0.55);
}

/* chat panel: Grid固定（下見切れ防止・高さ安定） */
.side .panel:first-child{
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}

.chat-log{
  min-height: 0;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
  white-space: pre-wrap;
  text-align:left;
}

.chat-line{
  margin: 0 0 6px 0;
  opacity: 0.95;
}

.chat-input{
  height: 120px;      /* 5行相当：必要ならここだけ調整 */
  resize: none;
}

/* =========================
   Drawer (Assets)
========================= */
.drawer{
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 90vw);
  height: 100vh;
  background: #1e1e2f;
  border-left: 1px solid rgba(255,255,255,0.15);
  padding: 12px;
  box-sizing: border-box;
  z-index: 999;
  overflow:auto;
}

.drawer-head{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.layers{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.layer-title{
  font-weight: bold;
  margin: 6px 0;
}

.dropzone{
  border: 1px dashed rgba(255,255,255,0.35);
  border-radius: 8px;
  padding: 10px;
  text-align:center;
  cursor: default;
  background: rgba(255,255,255,0.04);
}
.dropzone.dragover{
  outline: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.08);
}

.asset-list{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.asset-thumb{
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255,255,255,0.20);
  cursor: pointer;
  position: relative;
}
.asset-thumb.selected{
  outline: 2px solid rgba(255,255,255,0.55);
}

/* thumb delete button */
.asset-del{
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}

/* assets manager */
.asset-manager{
  margin: 10px 0 14px 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
}

.asset-manager-list{
  margin-top: 10px;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.asset-row{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
}

.asset-row-left{
  display:flex;
  align-items:center;
  gap: 10px;
  min-width: 0;
}

.asset-mini{
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255,255,255,0.2);
  flex: 0 0 auto;
}

.asset-name{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  opacity: 0.95;
  font-size: 13px;
}

.asset-badges{
  font-size: 12px;
  opacity: 0.8;
}

.asset-row button{ width: auto; }

/* =========================
   Toast (Undo)
========================= */
.toast{
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 2000;
  background: rgba(0,0,0,0.78);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 10px 12px;
  display:flex;
  align-items:center;
  gap: 10px;
}
.toast button{
  width: auto;
  margin: 0;
  padding: 6px 10px;
}
.tabs{
  display:flex;
  gap:6px;
  flex-wrap: wrap;
}
.tab-manager{
  margin-top: 6px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
}

.tab-manager-list{
  margin-top: 10px;
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.tab-row{
  padding: 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.tab-row-head{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
}

.tab-row input{
  width: 100%;
}

.member-grid{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-chip{
  display:flex;
  align-items:center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
}

.member-chip input{
  width: auto;
}
.token.selected {
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 2px;
}