/* =========================
   Base
========================= */
html,
body{
  min-height: 100%;
  margin: 0;
}

body{
  background-color: #1e1e2f;
  color: white;
  font-family: Arial, sans-serif;
}

.hidden{ display:none !important; }

.hint{
  opacity: 0.8;
  font-size: 12px;
}

/* 画面ごとのスクロール制御 */
body.view-room{
  height: 100vh;
  overflow: hidden;
}

body.view-home,
body.view-character,
body.view-login{
  height: auto;
  overflow-y: auto;
}

/* =========================
   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;
}

.select{
  background: #2c2c3f;
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 6px 8px;
}

.textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(0,0,0,0.25);
  color:#fff;
  resize:vertical;
}

/* =========================
   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: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.topbar{
  display:none !important;
}

.main{
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  min-height: 0;
}

/* ===== Active character badge ===== */
.active-badge{
  display:flex;
  align-items:center;
  gap:6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
}

.active-badge.hidden{ display:none; }

.active-badge-label{
  font-size: 12px;
  opacity: 0.85;
}

.active-badge-name{
  font-weight: 700;
  max-width: 180px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-badge-clear{
  width:auto;
  padding: 2px 8px;
  margin: 0;
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.18);
  color:#fff;
  cursor:pointer;
}
.active-badge-clear:hover{
  background: rgba(0,0,0,0.35);
}

.board-top-hud .active-badge{
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* =========================
   Board
========================= */
.board-wrap{
  position: relative;
  background: rgba(255,255,255,0.04);
  border-radius: 0;
  box-sizing: border-box;
  min-height: 0;
  overflow: hidden;
}

.board-area{
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: #111;
  user-select: none;
  overflow: hidden;
  isolation: isolate;
}

/* 基礎画像: 非ズーム / 600%基準 */
.board-base-layer{
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.board-base-image{
  position: absolute;
  left: 50%;
  top: 50%;
  width: 600%;
  height: 600%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  opacity: 0.28;
  filter: blur(14px);
  pointer-events: none;
}

/* ビューポート */
.board-viewport{
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

/* ワールド本体: 中心基準でズーム */
.board-world{
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}

/* ワールド配下の各レイヤー */
.board-background-layer,
.board-foreground-layer,
.battle-grid-layer,
.shared-battle-ui-layer,
.local-battle-overlay,
.board-piece-layer{
  position: absolute;
  inset: 0;
}

/* 背景画像: ズーム対象 */
.board-background-layer{
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.board-background-image{
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  object-fit: contain;
  pointer-events: none;
}

/* 前景画像 */
.board-foreground-layer{
  z-index: 8;
  pointer-events: none;
}

.board-foreground-item{
  position: absolute;
  pointer-events: auto;
}

.board-foreground-item.locked{
  cursor: default;
}

.board-foreground-item.free{
  cursor: grab;
}

.board-foreground-item.free:active{
  cursor: grabbing;
}

.board-foreground-image{
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* 戦闘グリッド */
.battle-grid-layer{
  z-index: 12;
  pointer-events: none;
}

/* 共有戦闘UI / ローカル戦闘UI */
.shared-battle-ui-layer{
  z-index: 18;
  pointer-events: auto;
}

.local-battle-overlay{
  z-index: 25;
  pointer-events: auto;
}

/* 駒 */
.board-piece-layer{
  z-index: 30;
  pointer-events: none;
}

.token{
  position: absolute;
  z-index: 2;
  border-radius: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  box-shadow: none;
  outline: none;
  cursor: grab;
  background-color: transparent;
  pointer-events: auto;
}

.token:active{
  cursor: grabbing;
}

/* 盤面上に見えるが非ズームのUI */
.board-ui-layer{
  position: absolute;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}

.board-ui-layer > *{
  pointer-events: auto;
}

.board-top-hud{
  position: absolute;
  left: 14px;
  right: 14px;
  top: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(70,70,70,0.22);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0.45;
  transition: opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.board-top-hud:hover,
.board-top-hud:focus-within{
  opacity: 1;
  background: rgba(70,70,70,0.42);
  border-color: rgba(255,255,255,0.22);
}

.board-top-hud-left,
.board-top-hud-right{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
}

.board-top-hud-right{
  justify-content:flex-end;
  flex-wrap:wrap;
}

.board-room-pill{
  width:auto;
  max-width:min(420px, 46vw);
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.16);
  color:#fff;
  box-shadow:none;
}

.board-room-pill:hover{
  background: rgba(255,255,255,0.20);
}

.board-room-pill #roomTitle{
  display:block;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-weight:700;
  font-size:15px;
}

.board-room-pill-caret{
  font-size:11px;
  opacity:0.9;
  flex:0 0 auto;
}

.board-hud-btn{
  width:auto;
  min-width:72px;
  padding:10px 12px;
  border-radius:12px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  color:#fff;
  box-shadow:none;
}

.board-hud-btn:hover{
  background: rgba(255,255,255,0.18);
}

.board-hud-popover{
  position:absolute;
  left:14px;
  top:64px;
  z-index:1210;
  width:min(360px, calc(100vw - 28px));
  padding:12px;
  border-radius:14px;
  background: rgba(18,20,28,0.95);
  border:1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 36px rgba(0,0,0,0.34);
}

.board-hud-popover-title{
  font-size:14px;
  font-weight:700;
  margin-bottom:8px;
  opacity:0.95;
}

.board-hud-members{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:13px;
  line-height:1.5;
  color:#fff;
}

.board-hud-members .hud-members-line{
  padding:8px 10px;
  border-radius:10px;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.08);
}

@media (max-width: 980px){
  .main{
    grid-template-columns: 1fr;
  }

  .board-top-hud{
    left:10px;
    right:10px;
    top:10px;
    flex-wrap:wrap;
  }

  .board-room-pill{
    max-width:calc(100vw - 120px);
  }
}

/* 方向UIは現段階ではワールド上に置く */
.local-battle-arrow-ui{
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.local-battle-arrow-ui .battle-arrow-btn{
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* preview box は非ズームUI側 */
.local-battle-preview-box{
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 210;
}

.token.placeholder{
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
}

.token-label{
  position:absolute;
  left:50%;
  bottom:-18px;
  transform:translateX(-50%);
  font-size:12px;
  padding:2px 6px;
  border-radius:999px;
  background:rgba(0,0,0,0.6);
  border:1px solid rgba(255,255,255,0.2);
  pointer-events:none;
  white-space:nowrap;
}

.token.selected{
  outline: 2px solid rgba(255,255,255,0.85) !important;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.12);
}

.token-menu{
  position:fixed;
  z-index:99999;
  min-width:220px;
  padding:8px;
  border-radius:12px;
  background:rgba(20,20,26,0.98);
  border:1px solid rgba(255,255,255,0.14);
  box-shadow:0 10px 30px rgba(0,0,0,0.45);
}

.token-menu.hidden{ display:none; }

.token-menu .menu-item{
  width:100%;
  text-align:left;
  padding:10px 10px;
  border-radius:10px;
  border:none;
  background:transparent;
  color:#fff;
  cursor:pointer;
}

.token-menu .menu-item:disabled{
  opacity:0.45;
  cursor:not-allowed;
}

.token-menu .menu-item:hover{
  background:rgba(255,255,255,0.08);
}

.token-menu .menu-item.danger{
  color:#ffb4b4;
}

.token-menu .menu-sep{
  height:1px;
  margin:8px 0;
  background:rgba(255,255,255,0.10);
}

/* =========================
   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{
  display:flex;
  gap:6px;
  flex-wrap: wrap;
}

.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);
}

.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: 0;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-line{
  display: none;
}

.chat-message-card{
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: transparent;
  box-shadow: none;
}

.chat-message-card:first-child{
  border-top: 1px solid rgba(255,255,255,0.10);
}

.chat-message-avatar-wrap{
  width: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
}

.chat-message-avatar{
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
}

.chat-message-avatar-fallback{
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.chat-message-main{
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-message-head{
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.chat-message-head-left{
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.chat-message-edit-btn{
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 0;
  margin-left: 8px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.64);
  border-radius: 0;
  padding: 0;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: none;
  white-space: nowrap;
}

.chat-message-body{
  color: #f2f4ff;
  line-height: 1.45;
  white-space: normal;
  word-break: break-word;
}

.chat-message-actor{
  font-size: 15px;
  font-weight: 700;
  color: #f7f8ff;
  line-height: 1.2;
  word-break: break-word;
}

.chat-message-time{
  font-size: 11px;
  color: rgba(255,255,255,0.62);
  line-height: 1.2;
  white-space: nowrap;
}



.chat-message-edit-btn:hover{
  background: transparent;
  color: rgba(255,255,255,0.92);
  text-decoration: underline;
}

.chat-message-body.is-dice{
  color: #59b7ff;
}

.chat-input{
  height: 120px;
  resize: none;
}

/* ===== Palette panel ===== */
.palette-list{
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}

.palette-item{
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
  color: #fff;
  cursor: pointer;
}

.palette-item:hover{
  background: rgba(0,0,0,0.28);
}

.palette-empty{
  opacity: 0.8;
  padding: 8px 0;
}

.quick-menu{
  position: fixed;
  z-index: 99999;
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(20,20,26,0.98);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.quick-menu.hidden{ display:none; }

.quick-menu button{
  width:100%;
  text-align:left;
  padding:10px 10px;
  border-radius:10px;
  border:none;
  background:transparent;
  color:#fff;
  cursor:pointer;
}

.quick-menu button:hover{
  background:rgba(255,255,255,0.08);
}

/* =========================
   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);
}

.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;
}

.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;
}

/* =========================
   Tab Manager
========================= */
.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.85) !important;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.12);
}

.token-import-flash{
  animation: tokenImportFlash 1.8s ease-out;
}

@keyframes tokenImportFlash{
  0%{
    box-shadow: 0 0 0 0 rgba(255,255,255,0.65);
    transform: scale(1.06);
  }
  100%{
    box-shadow: 0 0 0 16px rgba(255,255,255,0);
    transform: scale(1);
  }
}

/* ===== Chat suggestion ===== */
.chat-suggest-box{
  margin-top: 6px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.10);
}

.chat-suggest-head{
  margin-bottom: 6px;
  font-size: 12px;
  opacity: 0.8;
}

.chat-suggest-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.chat-suggest-item{
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: #fff;
  cursor: pointer;
}

.chat-suggest-item:hover,
.chat-suggest-item.active{
  background: rgba(255,255,255,0.10);
}

.chat-suggest-main{
  font-weight: 700;
  display: block;
}

.chat-suggest-sub{
  display: block;
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.82;
}

/* =========================
   Battle / Local Preview UI
========================= */
#battleModeGridOverlay,
#localBattleOverlay{
  position: absolute;
  inset: 0;
}

#battleModeGridOverlay{
  pointer-events: none;
}

#localBattleOverlay{
  pointer-events: auto;
}

.battle-grid-layer{
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.battle-cell,
.battle-origin-marker{
  position: absolute;
  box-sizing: border-box;
}

.battle-cell-range{
  background: rgba(91, 170, 255, 0.12);
  outline: 1px solid rgba(91, 170, 255, 0.35);
}

.battle-cell-base{
  background: rgba(255, 210, 90, 0.18);
  outline: 2px solid rgba(255, 210, 90, 0.55);
}

.battle-cell-base-selected{
  background: rgba(255, 235, 120, 0.34);
  outline: 2px solid rgba(255, 235, 120, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
}

.battle-cell-occupied{
  background: rgba(110, 255, 180, 0.16);
  outline: 2px solid rgba(110, 255, 180, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}

.battle-cell-area{
  background: rgba(255, 110, 110, 0.18);
  outline: 1px solid rgba(255, 110, 110, 0.4);
}

.battle-cell-area-selected{
  background: rgba(255, 90, 90, 0.30);
  outline: 2px solid rgba(255, 120, 120, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
}

.battle-origin-marker{
  outline: 2px solid rgba(120, 255, 170, 0.9);
  box-shadow: inset 0 0 0 2px rgba(120, 255, 170, 0.25);
}

.local-battle-preview-box{
  position: absolute;
  min-width: 240px;
  max-width: 320px;
  max-height: 260px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10, 14, 24, 0.94);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
  z-index: 26;
  overflow: hidden;
  pointer-events: auto;
}

.local-battle-preview-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}

.local-battle-preview-close{
  appearance: none;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 8px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
}

.local-battle-preview-close:hover{
  background: rgba(255,255,255,0.14);
}

.local-battle-preview-hint{
  margin-bottom: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  font-size: 12px;
  line-height: 1.45;
}

.local-battle-preview-body{
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.55;
  max-height: 160px;
  overflow: auto;
}

.local-battle-arrow-ui{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 27;
}

.local-battle-arrow-ui.hidden{
  display: none;
}

.battle-arrow-btn{
  position: absolute;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  margin-top: -17px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(10,14,24,0.90);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}

.battle-arrow-btn:hover{
  background: rgba(255,255,255,0.14);
}

.judge-rect-panel{
  position: fixed;
  width: min(280px, calc(100vw - 24px));
  padding: 12px;
  z-index: 100001;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.judge-rect-title{
  font-size: 14px;
  font-weight: 700;
  opacity: 0.95;
}

.judge-rect-row{
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 8px;
}

.judge-rect-row label{
  font-size: 13px;
  opacity: 0.9;
}

.judge-rect-row input{
  width: 100%;
  min-width: 0;
}

.judge-rect-hint{
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.72;
}

.judge-rect-actions{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.judge-rect-actions .menu-item{
  width: auto;
  min-width: 88px;
}

.local-battle-arrow-ui{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9998 !important;
}

.battle-arrow-btn{
  position: absolute;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  margin-top: -19px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.38);
  background: rgba(10,14,24,0.96);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto !important;
  z-index: 9999 !important;
  box-shadow: 0 10px 24px rgba(0,0,0,0.34);
  touch-action: none;
}

.battle-arrow-btn:hover{
  background: rgba(255,255,255,0.18);
}

.battle-arrow-btn:active{
  transform: scale(0.96);
}

.topbar-actions-left{
  display:flex;
  align-items:center;
  gap:8px;
}

#roomSettingsMenu{
  min-width: 240px;
}

#gmTransferPanel{
  position: fixed;
  z-index: 100000;
  right: 16px;
  top: 16px;
  width: min(320px, calc(100vw - 24px));
}

#gmTransferPanel.hidden{
  display:none !important;
}

/* ローカル表示ボックスは一度無効化 */
.local-battle-preview-box{
  display: none !important;
}

#roomSettingsMenu{
  position: fixed;
  z-index: 100000 !important;
  min-width: 240px;
}

.shared-battle-ui-layer{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index: 18;
}

.shared-battle-ui-cell{
  position:absolute;
  box-sizing:border-box;
  pointer-events:auto;
}

.shared-battle-ui-cell[data-visibility="local"]{
  background: rgba(255, 90, 90, 0.18);
  outline: 2px solid rgba(255, 120, 120, 0.92);
}

.shared-battle-ui-cell[data-visibility="gm"]{
  background: rgba(120, 160, 255, 0.18);
  outline: 2px solid rgba(150, 180, 255, 0.92);
}

.shared-battle-ui-cell[data-visibility="public"]{
  background: rgba(110, 255, 180, 0.16);
  outline: 2px solid rgba(110, 255, 180, 0.72);
}

.shared-battle-ui-base{
  position:absolute;
  box-sizing:border-box;
  pointer-events:auto;
  background: rgba(255, 235, 120, 0.28);
  outline: 2px solid rgba(255, 235, 120, 0.92);
  z-index: 19;
}

#battleUiMenu{
  min-width: 220px;
}

#battleUiMenu .menu-title{
  padding: 8px 12px;
  font-weight: 700;
  opacity: 0.95;
}

#battleUiSettingsPanel{
  position: fixed;
  z-index: 100000;
  right: 16px;
  top: 84px;
  width: min(340px, calc(100vw - 24px));
}

#battleUiSettingsPanel.hidden{
  display:none !important;
}

.side .panel:first-child{
  position: relative;
}

#tabManagePanel{
  position: absolute;
  top: 44px;
  right: 10px;
  left: 10px;
  z-index: 50;
  display: block;
  max-height: 260px;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 24px rgba(0,0,0,0.32);
}

#tabManagePanel.hidden{
  display: none !important;
}

.tab-manage-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  margin-bottom: 8px;
}

.tab-manage-name{
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side .panel:first-child{
  position: relative;
}

#tabManagePanel{
  position: absolute;
  top: 46px;
  left: 10px;
  right: 10px;
  z-index: 30;
  display: block;
  max-height: 280px;
  overflow: auto;
  margin-top: 0;
  padding: 10px;
  border-radius: 12px;
  background: rgba(30,30,47,0.98);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}

#tabManagePanel.hidden{
  display: none !important;
}

.tab-manage-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  margin-bottom: 8px;
}

.tab-manage-name{
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ===== GM battle secret manager ===== */
#battleSecretManager{
  position: fixed;
  z-index: 100001;
  right: 16px;
  top: 92px;
  width: min(520px, calc(100vw - 24px));
  height: min(68vh, 560px);
  min-width: 340px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(19, 20, 31, 0.98);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 16px 40px rgba(0,0,0,0.42);
  resize: both;
}

#battleSecretManager.hidden{
  display: none !important;
}

#battleSecretManager.is-minimized{
  height: auto !important;
  min-height: 0;
  resize: none;
}

#battleSecretManager.is-minimized #battleSecretManagerBody{
  display: none;
}

.battle-secret-manager-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: move;
  user-select: none;
}

.battle-secret-manager-title{
  font-weight: 700;
}

.battle-secret-manager-title-wrap{
  min-width: 0;
  display:flex;
  flex-direction:column;
  gap:4px;
}

.battle-secret-manager-status{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.battle-secret-manager-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink: 0;
}

.battle-secret-manager-body{
  flex:1;
  min-height: 0;
  display:grid;
  grid-template-columns: 180px 1fr;
}

.battle-secret-manager-sidebar{
  min-width: 0;
  border-right: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  display:flex;
  flex-direction:column;
}

.battle-secret-manager-sidehead{
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.78;
}

.battle-secret-manager-tabs{
  flex:1;
  min-height:0;
  overflow:auto;
  padding: 0 8px 8px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.battle-secret-manager-tab{
  width: 100%;
  text-align: left;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  padding: 9px 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.battle-secret-manager-tab.active{
  outline: 2px solid rgba(138,168,255,0.72);
  background: rgba(138,168,255,0.14);
}

.battle-secret-manager-tab-main{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:4px;
}

.battle-secret-manager-tab-name{
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.battle-secret-manager-tab-meta{
  font-size: 12px;
  opacity: 0.72;
}

.battle-secret-manager-unread{
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 130, 130, 0.18);
  color: #ffd0d0;
}

.battle-secret-manager-unread.hidden{
  display:none !important;
}

.battle-secret-manager-main{
  min-width: 0;
  min-height: 0;
  display:flex;
  flex-direction:column;
}

.battle-secret-manager-log{
  flex:1;
  min-height:0;
  overflow:auto;
  padding: 12px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.battle-secret-manager-message{
  max-width: 92%;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  white-space: pre-wrap;
  word-break: break-word;
}

.battle-secret-manager-message[data-secret-kind="player-to-gm"]{
  align-self: flex-start;
  background: rgba(255,255,255,0.05);
}

.battle-secret-manager-message[data-secret-kind="gm-to-player"]{
  align-self: flex-end;
  background: rgba(110,255,180,0.10);
  border-color: rgba(110,255,180,0.18);
}

.battle-secret-manager-message-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 6px;
  font-size: 12px;
  opacity: 0.78;
}

.battle-secret-manager-message-body{
  line-height: 1.5;
}

.battle-secret-manager-inputrow{
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display:flex;
  flex-direction:column;
  gap:8px;
}

.battle-secret-manager-input{
  min-height: 84px;
}

.battle-secret-manager-sendrow{
  display:flex;
  justify-content:flex-end;
}

@media (max-width: 820px){
  #battleSecretManager{
    left: 12px;
    right: 12px;
    width: auto;
    height: min(72vh, 560px);
    min-width: 0;
  }

  .battle-secret-manager-body{
    grid-template-columns: 1fr;
    grid-template-rows: 140px 1fr;
  }

  .battle-secret-manager-sidebar{
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .battle-secret-manager-tabs{
    flex-direction: row;
    overflow: auto;
  }

  .battle-secret-manager-tab{
    min-width: 180px;
  }
}

.battle-secret-notice-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3000;
  min-width: 260px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(120, 180, 255, 0.35);
  background: rgba(12, 16, 34, 0.95);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  color: #eef4ff;
  backdrop-filter: blur(8px);
}

.battle-secret-notice-toast.hidden {
  display: none;
}

.battle-secret-notice-toast-title {
  font-size: 13px;
  font-weight: 700;
  color: #9dc2ff;
  margin-bottom: 6px;
}

.battle-secret-notice-toast-body {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.battle-secret-manager-alert {
  position: relative;
}

.battle-secret-manager-alert::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ff5f7a;
  box-shadow: 0 0 0 3px rgba(255, 95, 122, 0.2);
}

.battle-secret-manager-jump-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cfd8ea;
  margin: 8px 12px 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}

.battle-secret-manager-jump-setting input {
  margin: 0;
  accent-color: #6effb4;
}

.battle-secret-manager-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:nowrap;
}

.battle-secret-manager-jump-setting{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:#cfd8ea;
  margin:0;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.04);
  white-space:nowrap;
}

.battle-secret-manager-jump-setting.compact{
  padding:6px 8px;
  font-size:11px;
  line-height:1;
  background:rgba(255,255,255,0.03);
}

.battle-secret-manager-jump-setting input{
  margin:0;
  accent-color:#6effb4;
}

.battle-secret-manager-jump-setting span{
  display:inline-block;
  vertical-align:middle;
}

.check-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.check-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.08);
  font-size:13px;
}

.check-item input{
  width:auto;
  margin:0;
}

.tab-edit-panel{
  margin-top:12px;
  padding:12px;
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
}

.tab-edit-panel.hidden{
  display:none;
}

.tab-edit-title{
  font-size:14px;
  font-weight:700;
  margin-bottom:8px;
  color:#eef4ff;
}

#battleSecretManagerSendBtn.is-sent{
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(110,255,180,0.18);
  border-color: rgba(110,255,180,0.45);
}

.battle-secret-manager-tab.has-unread{
  border-color: rgba(255, 210, 110, 0.34);
  box-shadow: 0 0 0 1px rgba(255, 210, 110, 0.10) inset;
}

.battle-secret-manager-message.just-sent{
  animation: battleSecretSentPulse 1.1s ease;
}

.battle-secret-manager-input.sent-flash,
#battleSecretManagerSendBtn.sent-flash{
  box-shadow: 0 0 0 2px rgba(110,255,180,0.28);
  transition: box-shadow 0.18s ease;
}

@keyframes battleSecretSentPulse{
  0%{
    transform: scale(0.985);
    box-shadow: 0 0 0 0 rgba(110,255,180,0.24);
  }
  45%{
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(110,255,180,0.10);
  }
  100%{
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(110,255,180,0);
  }
}

#tokenResourceHud.hidden{
  display:none !important;
}

.token-resource-hud-name{
  font-size:13px;
  font-weight:700;
  margin-bottom:8px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.token-resource-hud-list{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.token-resource-hud-row{
  display:grid;
  grid-template-columns:44px 1fr;
  gap:8px;
  align-items:center;
  font-size:12px;
}

.token-resource-hud-label{
  font-weight:700;
  opacity:0.9;
}

.token-resource-hud-value{
  font-variant-numeric:tabular-nums;
}

.token-resource-hud-row[data-key="HP"] .token-resource-hud-value{
  color:#ffb4b4;
}

.token-resource-hud-row[data-key="MP"] .token-resource-hud-value{
  color:#b9d4ff;
}

.token-resource-hud-row[data-key="SAN"] .token-resource-hud-value{
  color:#c7ffd1;
}

#tokenResourceHud .token-resource-hud-value-button{
  pointer-events:auto;
}

#tokenResourceHud.hidden{
  display:none !important;
}

.token-resource-hud-name{
  font-size:13px;
  font-weight:700;
  margin-bottom:8px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.token-resource-hud-list{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.token-resource-hud-row{
  display:grid;
  grid-template-columns:44px 1fr;
  gap:8px;
  align-items:center;
  font-size:12px;
}

.token-resource-hud-label{
  font-weight:700;
  opacity:0.9;
}

.token-resource-hud-value{
  font-variant-numeric:tabular-nums;
}

.token-resource-hud-row[data-key="HP"] .token-resource-hud-value{
  color:#ffb4b4;
}

.token-resource-hud-row[data-key="MP"] .token-resource-hud-value{
  color:#b9d4ff;
}

.token-resource-hud-row[data-key="SAN"] .token-resource-hud-value{
  color:#c7ffd1;
}

.chat-actor-bar{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
}

.chat-actor-label{
  font-size:12px;
  font-weight:700;
  opacity:0.9;
}

.chat-actor-select{
  width:100%;
  min-height:36px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(0,0,0,0.22);
  color:#fff;
  padding:6px 10px;
}

.chat-actor-bar{
  position: relative;
  display:flex;
  align-items:center;
  min-height:40px;
  padding:6px 0 2px;
}

.chat-actor-current{
  display:inline-flex;
  align-items:center;
  min-height:36px;
  padding:0 12px;
  border-radius:10px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.10);
  font-weight:700;
  cursor:pointer;
  user-select:none;
}

.chat-actor-current:hover{
  background:rgba(255,255,255,0.08);
}

.token-resource-hud-card{
  padding-bottom:10px;
  margin-bottom:10px;
  border-bottom:1px solid rgba(255,255,255,0.10);
}

.token-resource-hud-card:last-child{
  padding-bottom:0;
  margin-bottom:0;
  border-bottom:none;
}

.token-resource-hud-name-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}

.token-resource-hud-agi{
  font-size:11px;
  font-weight:700;
  opacity:0.8;
  font-variant-numeric:tabular-nums;
}

.token-resource-hud-value-button{
  display:inline-flex;
  align-items:center;
  justify-content:flex-end;
  min-width:72px;
  padding:4px 8px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  color:inherit;
  font:inherit;
  cursor:pointer;
  font-variant-numeric:tabular-nums;
}

.token-resource-hud-value-button:hover{
  background:rgba(255,255,255,0.10);
}

.token-resource-hud-value-button:active{
  transform:translateY(1px);
}

.token-resource-hud-controls{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:4px;
  flex-wrap:wrap;
}

.token-resource-hud-adjust-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:30px;
  padding:0 8px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  color:inherit;
  font:inherit;
  cursor:pointer;
}

.token-resource-hud-adjust-button:hover{
  background:rgba(255,255,255,0.10);
}

.token-resource-hud-adjust-button:active{
  transform:translateY(1px);
}

.token-resource-hud-card.is-current-chat-char{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

.token-resource-hud-toggle{
  width:100%;
  display:block;
  text-align:left;
  padding:0;
  margin:0 0 8px 0;
  border:none;
  background:transparent;
  color:inherit;
  cursor:pointer;
}

.token-resource-hud-toggle:hover .token-resource-hud-name-row{
  background:rgba(255,255,255,0.04);
}

.token-resource-hud-name-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:0;
  padding:4px 6px;
  border-radius:8px;
  transition:background 0.15s ease;
}

.token-resource-hud-name-meta{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink:0;
}

.token-resource-hud-chevron{
  font-size:11px;
  opacity:0.75;
  width:14px;
  text-align:center;
}

.token-resource-hud-resource-block{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.token-resource-hud-adjusts{
  display:flex;
  justify-content:flex-end;
  gap:4px;
  flex-wrap:wrap;
}

.token-resource-hud-adjusts.hidden{
  display:none !important;
}

.token-resource-hud-adjust-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  height:28px;
  padding:0 8px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.06);
  color:#fff;
  font:inherit;
  cursor:pointer;
}

.token-resource-hud-adjust-button:hover{
  background:rgba(255,255,255,0.12);
}

.token-resource-hud-adjust-button:active{
  transform:translateY(1px);
}

#tokenResourceHud .token-resource-hud-toggle,
#tokenResourceHud .token-resource-hud-value-button,
#tokenResourceHud .token-resource-hud-adjust-button{
  pointer-events:auto;
}

.token-resource-hud-toggle{
  width:100%;
  display:block;
  text-align:left;
  padding:0;
  margin:0 0 8px 0;
  border:none;
  background:transparent;
  color:inherit;
  cursor:pointer;
  pointer-events:auto;
}

.token-resource-hud-name-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:0;
  padding:10px 12px;
  border-radius:10px;
  background:rgba(255,255,255,0.08);
  border:1px solid rgba(255,255,255,0.10);
  transition:background 0.15s ease, border-color 0.15s ease;
}

.token-resource-hud-toggle:hover .token-resource-hud-name-row{
  background:rgba(255,255,255,0.12);
  border-color:rgba(255,255,255,0.18);
}

.token-resource-hud-toggle:focus-visible .token-resource-hud-name-row{
  outline:2px solid rgba(255,255,255,0.28);
  outline-offset:2px;
}

.token-resource-hud-name-meta{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink:0;
}

.token-resource-hud-chevron{
  font-size:11px;
  opacity:0.75;
  width:14px;
  text-align:center;
}

#tokenResourceHud .token-resource-hud-adjust-button{
  pointer-events:auto;
  touch-action:manipulation;
}
.room-char-edit-panel{
  background:#23233a;
  border:1px solid rgba(255,255,255,0.14);
  border-radius:16px;
  padding:18px;
  box-sizing:border-box;
  box-shadow:0 18px 44px rgba(0,0,0,0.42);
  color:#fff;
}

.room-char-edit-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}

.room-char-edit-title{
  font-size:18px;
  font-weight:700;
  color:#eef4ff;
  margin-bottom:4px;
}

.room-char-edit-block{
  margin-top:14px;
  padding:14px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.04);
}

.room-char-edit-section-title{
  font-size:14px;
  font-weight:700;
  color:#eef4ff;
  margin-bottom:10px;
}

.room-char-edit-grid{
  display:grid;
  gap:12px;
}

.room-char-edit-grid-basic{
  grid-template-columns:1fr 1fr;
}

.room-char-edit-grid-status{
  grid-template-columns:repeat(3, minmax(0, 1fr));
}

.room-char-edit-field{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}

.room-char-edit-field > span{
  font-size:12px;
  color:#cfd8ea;
}

.room-char-edit-name-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.room-char-edit-name-row > input{
  flex:1;
  min-width:0;
}

.room-char-edit-image-button{
  width:44px;
  height:44px;
  min-width:44px;
  border-radius:999px;
  border:1px dashed rgba(255,255,255,0.28);
  background:rgba(255,255,255,0.04);
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  cursor:pointer;
}

.room-char-edit-image-button:hover{
  background:rgba(255,255,255,0.08);
  border-color:rgba(255,255,255,0.42);
}

.room-char-edit-image-button:disabled{
  opacity:0.6;
  cursor:default;
}

.room-char-edit-image-button.has-image{
  border-style:solid;
}

.room-char-edit-image-button img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.room-char-edit-image-button-empty{
  width:16px;
  height:16px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.32);
  background:transparent;
}

.room-char-image-picker-overlay{
  position:fixed;
  inset:0;
  z-index:100120;
}

.room-char-image-picker-overlay.hidden{
  display:none;
}

.room-char-image-picker-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.54);
}

.room-char-image-picker-panel{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  width:min(920px, calc(100vw - 32px));
  max-height:min(82vh, 760px);
  overflow:auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.14);
  background:#23233a;
  box-shadow:0 22px 60px rgba(0,0,0,0.48);
  padding:18px;
  color:#fff;
}

.room-char-image-picker-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}

.room-char-image-picker-title{
  font-size:18px;
  font-weight:700;
  color:#eef4ff;
}

.room-char-image-picker-meta{
  margin-top:4px;
  font-size:12px;
  color:#cfd8ea;
}

.room-char-image-dropzone{
  border:1px dashed rgba(255,255,255,0.24);
  border-radius:16px;
  padding:22px 16px;
  text-align:center;
  background:rgba(255,255,255,0.03);
  color:#dbe6ff;
  margin-bottom:14px;
}

.room-char-image-dropzone.dragover{
  background:rgba(138,168,255,0.14);
  border-color:rgba(138,168,255,0.62);
}

.room-char-image-picker-current{
  margin-bottom:14px;
}

.room-char-image-picker-current-card{
  display:flex;
  align-items:center;
  gap:14px;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.04);
}

.room-char-image-picker-current-label{
  font-size:12px;
  color:#cfd8ea;
  min-width:72px;
}

.room-char-image-picker-current-preview{
  width:72px;
  height:72px;
  border-radius:14px;
  background:rgba(255,255,255,0.04);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex:0 0 auto;
}

.room-char-image-picker-current-preview img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.room-char-image-picker-current-empty{
  font-size:12px;
  color:#cfd8ea;
}

.room-char-image-picker-current-name{
  min-width:0;
  word-break:break-word;
}

.room-char-image-picker-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
  gap:12px;
}

.room-char-image-picker-item{
  border:1px solid rgba(255,255,255,0.08);
  border-radius:14px;
  background:rgba(255,255,255,0.04);
  padding:10px;
  text-align:left;
  color:#fff;
  cursor:pointer;
}

.room-char-image-picker-item.selected{
  outline:2px solid rgba(138,168,255,0.72);
  background:rgba(138,168,255,0.12);
}

.room-char-image-picker-item-thumb{
  width:100%;
  aspect-ratio:1 / 1;
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  margin-bottom:8px;
}

.room-char-image-picker-item-thumb img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.room-char-image-picker-item-name{
  font-size:12px;
  line-height:1.4;
  word-break:break-word;
}

.room-char-image-picker-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:14px;
}

.token-image{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
  pointer-events:none;
  user-select:none;
}

.room-char-edit-field-wide{
  grid-column:1 / -1;
}

.room-char-edit-resource-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.room-char-edit-resource-row{
  display:grid;
  grid-template-columns:120px 1fr 1fr;
  gap:10px;
  align-items:end;
  padding:10px;
  border-radius:12px;
  background:rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.08);
}

.room-char-edit-resource-label{
  font-size:16px;
  font-weight:700;
  color:#eef4ff;
}

.room-char-edit-skill-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:12px;
}

.room-char-edit-skill-tab{
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.10);
}

.room-char-edit-skill-tab.active{
  background:rgba(255,255,255,0.16);
  box-shadow:0 0 0 1px rgba(255,255,255,0.18) inset;
}

.room-char-edit-skill-box{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.room-char-edit-skill-row{
  display:grid;
  grid-template-columns:minmax(0, 1.4fr) 160px auto;
  gap:10px;
  align-items:end;
  padding:10px;
  border-radius:12px;
  background:rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.08);
}

.room-char-edit-skill-addbar{
  display:flex;
  justify-content:flex-end;
  margin-top:4px;
}

.room-char-edit-actions{
  margin-top:16px;
}

@media (max-width: 900px){
  .room-char-edit-grid-basic,
  .room-char-edit-grid-status,
  .room-char-edit-resource-row,
  .room-char-edit-skill-row{
    grid-template-columns:1fr;
  }

  .room-char-edit-resource-label{
    margin-bottom:2px;
  }
}

.token-memo-tooltip{
  position: fixed;
  z-index: 100002;
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(18,18,26,0.96);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 28px rgba(0,0,0,0.38);
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  pointer-events: none;
  transform: translateZ(0);
  text-align: left;
}

.token-memo-tooltip.hidden{
  display: none !important;
}

.token-memo-tooltip.hidden{
  display:none !important;
}

.token-memo-tooltip{
  position: fixed;
  z-index: 100002;
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(18,18,26,0.96);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 28px rgba(0,0,0,0.38);
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  pointer-events: none;
  transform: translateZ(0);
}

.token-memo-tooltip.hidden{
  display: none !important;
}

.token-memo-tooltip{
  position: fixed;
  z-index: 100002;
  max-width: min(360px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(18,18,26,0.96);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 10px 28px rgba(0,0,0,0.38);
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  pointer-events: none;
  transform: translateZ(0);
}

.token-memo-tooltip.hidden{
  display: none !important;
}

.token-resource-hud-name-wrap{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.token-resource-hud-owner{
  font-size:11px;
  opacity:0.72;
  line-height:1.2;
}

.token-resource-hud-card.is-current-chat-char{
  box-shadow:0 0 0 1px rgba(255,255,255,0.22) inset;
}

.battle-menu-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:12px;
  padding: 4px 2px 8px;
  cursor: move;
  user-select: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.battle-menu-title{
  font-size:16px;
  font-weight:700;
}

.battle-menu-body{
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height: 0;
}

.battle-menu-section{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.04);
}

.battle-menu-section-title{
  font-size:13px;
  font-weight:700;
  opacity:0.92;
}

.battle-menu-select{
  width:100%;
  box-sizing:border-box;
}

.battle-menu-skill-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  max-height:180px;
  overflow:auto;
}

.battle-menu-skill-item{
  width:100%;
  text-align:left;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  color:#fff;
}

.battle-menu-skill-item.active{
  outline:2px solid rgba(110,255,180,0.65);
  background:rgba(110,255,180,0.12);
}

.battle-menu-skill-item-sub{
  display:block;
  margin-top:4px;
  font-size:12px;
  opacity:0.75;
}

.battle-menu-current-card{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.05);
}

.battle-menu-current-main{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  flex-wrap:wrap;
}

.battle-menu-current-name{
  font-weight:700;
}

.battle-menu-status-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  border:1px solid rgba(255,255,255,0.14);
  background:rgba(255,255,255,0.06);
}

.battle-menu-status-badge[data-mode="local"]{
  background:rgba(255,90,90,0.14);
}

.battle-menu-status-badge[data-mode="gm"]{
  background:rgba(120,160,255,0.16);
}

.battle-menu-status-badge[data-mode="public"]{
  background:rgba(110,255,180,0.12);
}

.battle-menu-button-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.battle-menu-empty{
  font-size:12px;
  opacity:0.75;
}

@media (max-width: 900px){
  #battleMenuPanel{
    left:12px !important;
    right:12px !important;
    width:auto;
  }
}

#battleMenuPanel{
  position: fixed;
  z-index: 100020;
  right: auto;
  width: 420px;
  min-width: 320px;
  max-width: min(520px, calc(100vw - 16px));
  height: min(72vh, 720px);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(20,22,40,0.96);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  color: #fff;
  resize: both;
}

#battleMenuPanel.hidden{
  display:none !important;
}

.battle-menu-panel{
  position: fixed;
}

.battle-menu-current-card{
  overflow: hidden;
}

.battle-menu-button-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

@media (max-width: 900px){
  #battleMenuPanel{
    width: min(420px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
  }
}

/* =========================
   Battle Menu Window visibility fix
========================= */
#battleMenuPanel{
  background: #202338 !important;
  color: #f4f7ff !important;
  border: 1px solid rgba(255,255,255,0.16) !important;
  box-shadow: 0 18px 40px rgba(0,0,0,0.48) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: hidden !important;
}

#battleMenuPanel.hidden{
  display:none !important;
}

#battleMenuPanel .battle-menu-head{
  background: #2a2f49 !important;
  color: #ffffff !important;
  padding: 10px 12px !important;
  margin: -12px -12px 12px -12px !important;
  border-bottom: 1px solid rgba(255,255,255,0.10) !important;
}

#battleMenuPanel .battle-menu-title{
  color: #ffffff !important;
  font-weight: 700 !important;
  text-shadow: 0 1px 0 rgba(0,0,0,0.22);
}

#battleMenuPanel .battle-menu-body{
  background: transparent !important;
  color: #f4f7ff !important;
}

#battleMenuPanel .battle-menu-section{
  background: #2b314d !important;
  border: 1px solid rgba(255,255,255,0.10) !important;
  border-radius: 12px !important;
  padding: 10px !important;
}

#battleMenuPanel .battle-menu-section-title{
  color: #ffffff !important;
  font-weight: 700 !important;
}

#battleMenuPanel .battle-menu-current-card{
  background: #262c45 !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 12px !important;
}

#battleMenuPanel .battle-menu-current-name,
#battleMenuPanel .battle-menu-empty,
#battleMenuPanel .hint,
#battleMenuPanel label,
#battleMenuPanel span,
#battleMenuPanel div{
  color: #f4f7ff;
}

#battleMenuPanel .battle-menu-select,
#battleMenuPanel select{
  background: #1b2033 !important;
  color: #ffffff !important;
  border: 1px solid rgba(255,255,255,0.16) !important;
}

#battleMenuPanel .battle-menu-skill-list{
  background: rgba(0,0,0,0.10) !important;
  border-radius: 10px !important;
  padding: 4px !important;
}

#battleMenuPanel .battle-menu-skill-item{
  background: #47b34f !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: none !important;
}

#battleMenuPanel .battle-menu-skill-item:hover{
  background: #409f47 !important;
}

#battleMenuPanel .battle-menu-skill-item.active{
  background: #2d8fff !important;
  color: #ffffff !important;
  outline: 2px solid rgba(255,255,255,0.28) !important;
}

#battleMenuPanel .battle-menu-skill-item-sub{
  color: rgba(255,255,255,0.92) !important;
  opacity: 1 !important;
}

#battleMenuPanel .battle-menu-status-badge{
  background: #1d2338 !important;
  color: #ffffff !important;
  border: 1px solid rgba(255,255,255,0.16) !important;
}

#battleMenuPanel .battle-menu-status-badge[data-mode="local"]{
  background: #5b2430 !important;
}

#battleMenuPanel .battle-menu-status-badge[data-mode="gm"]{
  background: #243b67 !important;
}

#battleMenuPanel .battle-menu-status-badge[data-mode="public"]{
  background: #1f5a41 !important;
}

#battleMenuPanel button.secondary{
  background: #666 !important;
  color: #fff !important;
}

#battleMenuPanel button.small:not(.secondary):not(.danger){
  background: #4CAF50 !important;
  color: #fff !important;
}

#battleMenuPanel .battle-menu-top-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:12px;
}

#battleMenuPanel .battle-menu-current-summary{
  font-size:12px;
  line-height:1.5;
  color:#eaf1ff;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.08);
}

#battleMenuPanel .battle-menu-skill-item{
  text-align:left;
}

#battleMenuPanel .battle-menu-skill-item-sub{
  display:block;
  margin-top:4px;
}

#battleMenuPanel #battleMenuAttackClearBtn{
  background:#a94444 !important;
  color:#fff !important;
}

#battleMenuPanel #battleMenuAttackClearBtn:hover{
  background:#963c3c !important;
}

.room-char-edit-name-row{
  display:flex;
  align-items:center;
  gap:10px;
}

.room-char-edit-name-row > input{
  flex:1;
  min-width:0;
}

.room-char-edit-image-button{
  width:44px;
  height:44px;
  min-width:44px;
  border-radius:999px;
  border:1px dashed rgba(255,255,255,0.28);
  background:rgba(255,255,255,0.04);
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  cursor:pointer;
}

.room-char-edit-image-button:hover{
  background:rgba(255,255,255,0.08);
  border-color:rgba(255,255,255,0.42);
}

.room-char-edit-image-button:disabled{
  opacity:0.6;
  cursor:default;
}

.room-char-edit-image-button.has-image{
  border-style:solid;
}

.room-char-edit-image-button img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.room-char-edit-image-button-empty{
  width:16px;
  height:16px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.32);
  background:transparent;
}

.room-char-image-picker-overlay{
  position:fixed;
  inset:0;
  z-index:100120;
}

.room-char-image-picker-overlay.hidden{
  display:none !important;
}

.room-char-image-picker-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.54);
}

.room-char-image-picker-panel{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  width:min(920px, calc(100vw - 32px));
  max-height:min(82vh, 760px);
  overflow:auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.14);
  background:#23233a;
  box-shadow:0 22px 60px rgba(0,0,0,0.48);
  padding:18px;
  color:#fff;
}

.room-char-image-picker-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}

.room-char-image-picker-title{
  font-size:18px;
  font-weight:700;
  color:#eef4ff;
}

.room-char-image-picker-meta{
  margin-top:4px;
  font-size:12px;
  color:#cfd8ea;
}

.room-char-image-dropzone{
  border:1px dashed rgba(255,255,255,0.24);
  border-radius:16px;
  padding:22px 16px;
  text-align:center;
  background:rgba(255,255,255,0.03);
  color:#dbe6ff;
  margin-bottom:14px;
}

.room-char-image-dropzone.dragover{
  background:rgba(138,168,255,0.14);
  border-color:rgba(138,168,255,0.62);
}

.room-char-image-picker-current{
  margin-bottom:14px;
}

.room-char-image-picker-current-card{
  display:flex;
  align-items:center;
  gap:14px;
  padding:12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.04);
}

.room-char-image-picker-current-label{
  font-size:12px;
  color:#cfd8ea;
  min-width:72px;
}

.room-char-image-picker-current-preview{
  width:72px;
  height:72px;
  border-radius:14px;
  background:rgba(255,255,255,0.04);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex:0 0 auto;
}

.room-char-image-picker-current-preview img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.room-char-image-picker-current-empty{
  font-size:12px;
  color:#cfd8ea;
}

.room-char-image-picker-current-name{
  min-width:0;
  word-break:break-word;
}

.room-char-image-picker-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
  gap:12px;
}

.room-char-image-picker-item{
  border:1px solid rgba(255,255,255,0.08);
  border-radius:14px;
  background:rgba(255,255,255,0.04);
  padding:10px;
  text-align:left;
  color:#fff;
  cursor:pointer;
}

.room-char-image-picker-item.selected{
  outline:2px solid rgba(138,168,255,0.72);
  background:rgba(138,168,255,0.12);
}

.room-char-image-picker-item-thumb{
  width:100%;
  aspect-ratio:1 / 1;
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  margin-bottom:8px;
}

.room-char-image-picker-item-thumb img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.room-char-image-picker-item-name{
  font-size:12px;
  line-height:1.4;
  word-break:break-word;
}

.room-char-image-picker-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:14px;
}

.token-image{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
  pointer-events:none;
  user-select:none;
}

.token-has-character-image{
  background:transparent !important;
  border:none !important;
  box-shadow:none !important;
  border-radius:0 !important;
}

.token-has-character-image .token-image{
  object-fit:contain;
  filter:drop-shadow(0 2px 6px rgba(0,0,0,0.28));
}

.token-resource-hud-name-row.has-portrait{
  align-items:center;
  min-height:76px;
}

.token-resource-hud-portrait-wrap{
  display:flex;
  align-items:center;
  min-width:0;
  flex:1 1 auto;
}

.token-resource-hud-portrait{
  width:64px;
  height:64px;
  border-radius:14px;
  overflow:hidden;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.12);
  box-shadow:0 4px 12px rgba(0,0,0,0.22);
  flex:0 0 auto;
}

.token-resource-hud-portrait img{
  width:100%;
  height:100%;
  object-fit:contain;
  display:block;
}

.token-resource-hud-name-wrap{
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
  flex:1 1 auto;
}

.token-resource-hud-title{
  font-weight:700;
  color:#fff;
  word-break:break-word;
}

.token-resource-hud-owner{
  font-size:11px;
  color:rgba(255,255,255,0.68);
  word-break:break-word;
}

.chat-message-body.is-dice.is-success{
  color:#59b7ff;
}

.chat-message-body.is-dice.is-failure{
  color:#ff6b6b;
}

.chat-message-body.is-secret-mask{
  color:rgba(255,255,255,0.70);
  font-style:italic;
}

.chat-dice-single,
.chat-dice-group-head,
.chat-dice-group-line,
.chat-dice-mask{
  line-height:1.7;
}

.chat-dice-group{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.chat-dice-group-list{
  display:flex;
  flex-direction:column;
  gap:2px;
}

.chat-dice-group-line{
  display:flex;
  gap:6px;
  align-items:flex-start;
}

.chat-dice-group-index{
  flex:0 0 auto;
  min-width:1.5em;
  color:rgba(255,255,255,0.72);
}

.chat-dice-group-text{
  min-width:0;
  word-break:break-word;
}

.chat-dice-mask{
  color:rgba(255,255,255,0.70);
  font-style:italic;
}

.chat-dice-single,
.chat-dice-group-head,
.chat-dice-group-line,
.chat-dice-mask{
  line-height:1.7;
}

.chat-dice-group{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.chat-dice-group-list{
  display:flex;
  flex-direction:column;
  gap:2px;
}

.chat-dice-group-line{
  display:flex;
  gap:6px;
  align-items:flex-start;
}

#battleModeGridOverlay,
#localBattleOverlay,
.shared-battle-ui-layer{
  z-index: 12;
}

.token{
  z-index: 20;
}

#battleModeGridOverlay,
#localBattleOverlay,
.shared-battle-ui-layer{
  z-index: 12;
}

.token{
  z-index: 20;
}

/* ===== board background image layers (clean) ===== */

#battleModeGridOverlay,
#localBattleOverlay,
.shared-battle-ui-layer{
  z-index:12 !important;
}

.token{
  z-index:20 !important;
}

#tokenResourceHud{
  position: absolute;
  left: 12px;
  top: 76px;
  z-index: 40;
  min-width: 180px;
  max-width: 240px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10,12,18,0.82);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.asset-kind-badge{
  position:absolute;
  left:6px;
  bottom:6px;
  padding:2px 6px;
  border-radius:999px;
  font-size:11px;
  line-height:1;
  background:rgba(0,0,0,0.72);
  color:#fff;
  border:1px solid rgba(255,255,255,0.16);
  pointer-events:none;
}

.board-foreground-menu{
  position: fixed;
  z-index: 260;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 132px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(26, 26, 46, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
}

.board-foreground-menu.hidden{
  display: none;
}

.battle-grid-layer-inner{
  position:absolute;
  pointer-events:none;
}

.board-foreground-item{
  transform-origin:center center;
}

.board-foreground-item.free{
  outline: 2px solid rgba(255,255,255,0.95);
  outline-offset: 0;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.22),
    0 0 14px rgba(255,255,255,0.35);
}

.board-foreground-item.locked{
  outline: none;
  box-shadow: none;
}

.board-foreground-menu{
  position: fixed;
  z-index: 260;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
  max-width: min(240px, calc(100vw - 20px));
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 10px;
  border-radius: 12px;
  background: rgba(26, 26, 46, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
}

.board-foreground-menu.hidden{
  display: none;
}

.board-foreground-editor{
  position: fixed;
  z-index: 1202;
  width: min(320px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow: auto;
  padding: 12px;
  border-radius: 14px;
  background: rgba(18, 22, 34, 0.96);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.board-foreground-editor.hidden{
  display: none;
}

.board-foreground-editor-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}

.board-foreground-editor-title{
  font-weight:700;
}

.board-foreground-editor-label{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:13px;
}

.board-foreground-editor-label input,
.board-foreground-editor-label textarea{
  width:100%;
  box-sizing:border-box;
}

.board-foreground-editor-actions{
  display:flex;
  gap:8px;
  justify-content:flex-end;
}

.board-foreground-editor input[type="number"]{
  width:100%;
  box-sizing:border-box;
}

.asset-shelf-window{
  position:absolute;
  right:14px;
  top:64px;
  z-index:1300;
  width:min(520px, calc(100vw - 28px));
  max-height:min(72vh, 760px);
  display:flex;
  flex-direction:column;
  border-radius:18px;
  background:rgba(16,18,26,0.94);
  border:1px solid rgba(255,255,255,0.12);
  box-shadow:0 18px 48px rgba(0,0,0,0.38);
  overflow:hidden;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
}

.asset-shelf-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px 12px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}

.asset-shelf-title{
  font-size:16px;
  font-weight:700;
  color:#fff;
}

.asset-shelf-sub{
  margin-top:4px;
  font-size:12px;
  color:rgba(255,255,255,0.72);
}

.asset-shelf-head-actions{
  display:flex;
  align-items:center;
  gap:8px;
}

.board-hud-btn.smallish{
  min-width:auto;
  padding:8px 12px;
}

.asset-shelf-body{
  padding:14px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.asset-shelf-empty{
  padding:18px;
  border-radius:12px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
  color:rgba(255,255,255,0.72);
}

.asset-shelf-item{
  display:grid;
  grid-template-columns:84px 1fr auto;
  gap:12px;
  align-items:center;
  padding:10px;
  border-radius:14px;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.08);
}

.asset-shelf-thumb{
  width:84px;
  height:84px;
  border-radius:12px;
  background:rgba(255,255,255,0.05) center center / contain no-repeat;
  border:1px solid rgba(255,255,255,0.08);
}

.asset-shelf-meta{
  min-width:0;
}

.asset-shelf-name{
  font-size:14px;
  font-weight:700;
  color:#fff;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.asset-shelf-kind{
  margin-top:4px;
  font-size:12px;
  color:rgba(255,255,255,0.66);
}

.asset-shelf-actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:8px;
}

.asset-shelf-pill{
  width:auto;
  min-width:auto;
  padding:8px 10px;
  border-radius:999px;
  background:rgba(255,255,255,0.08);
  border:1px solid rgba(255,255,255,0.10);
  color:#fff;
  box-shadow:none;
}

.asset-shelf-pill:hover{
  background:rgba(255,255,255,0.16);
}

.asset-register-modal{
  position:absolute;
  inset:0;
  z-index:1400;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.42);
}

.asset-register-panel{
  width:min(980px, calc(100vw - 32px));
  max-height:min(82vh, 860px);
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:18px;
  border-radius:20px;
  background:rgba(16,18,26,0.96);
  border:1px solid rgba(255,255,255,0.12);
  box-shadow:0 24px 64px rgba(0,0,0,0.44);
  overflow:hidden;
}

.asset-register-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.asset-register-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.asset-register-tab{
  width:auto;
  min-width:auto;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.05);
  color:#fff;
  box-shadow:none;
}

.asset-register-tab.active{
  background:rgba(255,255,255,0.16);
  border-color:rgba(255,255,255,0.18);
}

.asset-register-dropzone{
  min-height:160px;
  padding:18px;
  border-radius:16px;
  border:2px dashed rgba(255,255,255,0.16);
  background:rgba(255,255,255,0.03);
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  color:rgba(255,255,255,0.72);
}

.asset-register-dropzone.dragover{
  background:rgba(255,255,255,0.08);
  border-color:rgba(255,255,255,0.28);
}

.asset-register-draft-list{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
  gap:12px;
  overflow:auto;
}

.asset-register-draft{
  padding:8px;
  border-radius:14px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
  cursor:pointer;
}

.asset-register-draft.selected{
  outline:2px solid rgba(255,255,255,0.34);
  background:rgba(255,255,255,0.10);
}

.asset-register-draft-thumb{
  width:100%;
  aspect-ratio:1/1;
  border-radius:12px;
  background:rgba(255,255,255,0.05) center center / contain no-repeat;
  border:1px solid rgba(255,255,255,0.08);
}

.asset-register-draft-name{
  margin-top:8px;
  font-size:12px;
  color:#fff;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.asset-register-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
}

@media (max-width: 980px){
  .asset-shelf-window{
    left:10px;
    right:10px;
    top:112px;
    width:auto;
  }

  .asset-shelf-item{
    grid-template-columns:1fr;
  }

  .asset-shelf-actions{
    justify-content:flex-start;
  }
}

.asset-register-dropzone{
  cursor: pointer;
}

.text-asset-panel{
  width:min(760px, calc(100vw - 32px));
}

.text-asset-fields{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.text-asset-field{
  display:flex;
  flex-direction:column;
  gap:6px;
}