* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  font-family: 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
  overflow: hidden;
  background: #2f5d2a;
}

/* ---- 参加画面 ---- */
#join-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.18), transparent 40%),
    linear-gradient(160deg, #a8d977 0%, #6cbb5a 55%, #4d9e4a 100%);
  z-index: 100;
}

.join-card {
  background: #fff8e7;
  border: 3px solid #c9a15e;
  border-radius: 26px;
  padding: 32px 38px;
  width: 480px;
  box-shadow: 0 20px 50px rgba(30, 60, 20, 0.4);
  text-align: center;
}

.join-card h1 {
  font-size: 30px;
  color: #4a7a35;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.tagline { color: #8a7a5e; font-size: 13px; margin-bottom: 20px; }

/* ---- Googleログイン ---- */
#login-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: #f2e8cf;
  border-radius: 14px;
}
.google-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: #fff;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  color: #4a3524;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.1s;
}
.google-login-btn:hover { transform: scale(1.03); }
.g-mark {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #4285f4; color: #fff;
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
}
.login-hint { font-size: 10px; color: #a89a7c; }
.login-options { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.login-divider { font-size: 10px; color: #a89a7c; }
#biz-login-form { display: flex; gap: 6px; width: 100%; }
#biz-login-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border: 2px solid #dcc79a;
  border-radius: 10px;
  font-size: 12px;
  font-family: inherit;
  background: #fffdf6;
  outline: none;
}
#biz-login-form input:focus { border-color: #6abf59; }
#biz-login-btn {
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: #6abf59;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
#biz-login-btn:disabled { opacity: 0.6; }
.login-error { font-size: 11px; color: #c0392b; font-weight: 700; }
.login-avatar { width: 34px; height: 34px; border-radius: 50%; border: 2px solid #6abf59; }
.login-info { text-align: left; }
.login-name { font-size: 12px; font-weight: 700; color: #4a3524; }
.biz-badge { font-size: 10px; font-weight: 700; padding: 1px 8px; border-radius: 8px; }
.biz-badge.ok { background: #dcefcd; color: #3f7a2e; }
.biz-badge.ng { background: #f5ddd0; color: #a4643a; }
.login-out { font-size: 11px; color: #a89a7c; }

.section-label {
  display: block;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: #6b5638;
  margin: 4px 0 6px;
}

/* ---- 入る街の表示 ---- */
#street-info { margin-bottom: 14px; }
.street-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: #eaf6df;
  border: 2px solid #b7d89e;
  border-radius: 14px;
  padding: 10px 14px;
}
.street-emoji { font-size: 28px; }
.street-name { font-size: 14px; font-weight: 700; color: #3f6a2e; }
.street-sub { font-size: 11px; color: #7a8a6c; margin-top: 2px; }
.street-type {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 8px;
  vertical-align: 2px;
}
.street-type.company { background: #6abf59; color: #fff; }
.street-type.guest { background: #dcc79a; color: #6b5638; }

/* ---- 参加前のカメラ・マイクテスト ---- */
#media-setup {
  background: #f2e8cf;
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 12px;
}
.media-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #263a1e;
  border-radius: 12px;
  overflow: hidden;
}
#join-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.media-off {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b7c9a8;
  font-size: 13px;
  background: #263a1e;
}
.mic-meter {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  height: 6px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  overflow: hidden;
}
#mic-meter-fill {
  height: 100%;
  width: 0%;
  background: #6abf59;
  border-radius: 3px;
  transition: width 0.08s linear;
}
.media-controls {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.media-toggle {
  width: 38px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: #fffdf6;
  border: 2px solid #dcc79a;
  font-size: 15px;
  cursor: pointer;
}
.media-toggle.off { background: #f6d5d0; border-color: #d97757; }
.media-controls select {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 2px solid #dcc79a;
  border-radius: 10px;
  background: #fffdf6;
  font-size: 11px;
  font-family: inherit;
  color: #4a3524;
  outline: none;
}

/* ---- 参加画面のアバター行 ---- */
.join-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  text-align: left;
}
#join-avatar-preview {
  flex-shrink: 0;
  background: #f2e8cf;
  border: 2px dashed #c9a15e;
  border-radius: 14px;
}
.join-avatar-main { flex: 1; }
#avatar-edit-btn {
  flex-shrink: 0;
  padding: 10px 12px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  background: #fffdf6;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: #6b5638;
  cursor: pointer;
  line-height: 1.5;
}
#avatar-edit-btn:hover { border-color: #6abf59; }

/* ---- 設定パネル ---- */
#settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.settings-card {
  width: min(560px, 94vw);
  max-height: min(680px, 92dvh);
  background: #fff8e7;
  border: 3px solid #c9a15e;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(20, 40, 10, 0.5);
}
.settings-body {
  overflow-y: auto;
  padding: 4px 20px 20px;
  text-align: left;
}
.settings-section { font-size: 14px; color: #4a3524; margin: 14px 0 8px; }
#avatar-name, #town-name-input {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  font-size: 13px;
  font-family: inherit;
  background: #fffdf6;
  outline: none;
}
#avatar-name:focus, #town-name-input:focus { border-color: #6abf59; }
.settings-save {
  width: 100%;
  margin-top: 14px;
  padding: 11px;
  border: none;
  border-radius: 12px;
  background: #6abf59;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.settings-save:hover { filter: brightness(1.08); }
.settings-save.warn { background: #d97757; }
#street-settings { border-top: 2px dashed #e6d5ac; margin-top: 18px; padding-top: 4px; }

#world-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.world-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  border: 2px solid #dcc79a;
  border-radius: 16px;
  background: #fffdf6;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.world-btn:hover { transform: scale(1.03); }
.world-btn.selected { border-color: #6abf59; background: #eaf6df; }
.world-emoji { font-size: 26px; }
.world-label { font-size: 13px; font-weight: 700; color: #4a3524; }
.world-desc { font-size: 10px; color: #a89a7c; line-height: 1.4; }
.world-count { font-size: 10px; font-weight: 700; color: #4a7a35; margin-top: 2px; }

.join-columns {
  display: flex;
  gap: 18px;
  text-align: left;
}
.join-left { flex: 1; }
.join-right {
  width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f2e8cf;
  border: 2px dashed #c9a15e;
  border-radius: 18px;
  padding: 8px;
}
.preview-caption { font-size: 11px; color: #8a7a5e; margin-top: 2px; }

.join-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #6b5638;
  margin: 12px 0 5px;
}

#name-input {
  width: 100%;
  padding: 10px 13px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  font-size: 14px;
  background: #fffdf6;
  outline: none;
  transition: border-color 0.15s;
}
#name-input:focus { border-color: #6abf59; }

#species-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.species-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 4px 1px;
  border: 2px solid #dcc79a;
  border-radius: 10px;
  background: #fffdf6;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.species-btn:hover { transform: scale(1.06); }
.species-btn.selected { border-color: #6abf59; background: #eaf6df; }
.sp-emoji { font-size: 17px; }
.sp-label { font-size: 8.5px; color: #6b5638; font-weight: 700; white-space: nowrap; }

#random-btn {
  margin-left: 8px;
  padding: 2px 10px;
  border: none;
  border-radius: 9px;
  background: #c9a15e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
#random-btn:hover { filter: brightness(1.08); }

#color-palette {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.14); }
.swatch.selected { border-color: #5a4a2e; transform: scale(1.14); }

#join-btn {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border: none;
  border-bottom: 4px solid #4d9440;
  border-radius: 16px;
  background: #6abf59;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 2px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
#join-btn:hover { filter: brightness(1.08); }
#join-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
#join-btn:disabled { opacity: 0.6; cursor: default; }

.hint { margin-top: 14px; font-size: 11px; color: #a89a7c; line-height: 1.7; }

/* ---- メイン ---- */
#app { position: fixed; inset: 0; }
#game { display: block; }

/* ---- ビデオタイル ---- */
#video-strip {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 20;
  max-width: calc(100vw - 340px);
  flex-wrap: wrap;
  justify-content: center;
}

.video-tile {
  position: relative;
  width: 150px;
  height: 112px;
  border-radius: 14px;
  overflow: hidden;
  background: #263a1e;
  box-shadow: 0 6px 18px rgba(20, 40, 10, 0.45);
  border: 3px solid #fff8e7;
}
.video-tile.self { border-color: #6abf59; }
.video-tile.screen {
  width: 240px;
  border-color: #e8a748;
}
.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-tile.screen video { object-fit: contain; background: #1c2417; }
.video-tile.self:not(.screen) video { transform: scaleX(-1); }

.tile-name {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(60, 40, 15, 0.7);
  color: #fff8e7;
  font-size: 11px;
  max-width: 85%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #263a1e;
  color: #b7c9a8;
  font-size: 13px;
}
.video-tile.cam-off:not(.screen) .tile-overlay { display: flex; }

.tile-mic {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 13px;
  display: none;
}
.video-tile.mic-off:not(.screen) .tile-mic { display: block; }

/* ---- サイドバー ---- */
#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 310px;
  background: rgba(255, 248, 231, 0.97);
  border-left: 3px solid #c9a15e;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(30, 50, 15, 0.25);
  z-index: 30;
  transition: transform 0.2s;
}
#sidebar.collapsed { transform: translateX(100%); }

.sidebar-tabs {
  display: flex;
  border-bottom: 2px solid #e6d5ac;
}
.tab-btn {
  flex: 1;
  padding: 13px 0;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: #a89a7c;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab-btn.active { color: #4a7a35; border-bottom-color: #6abf59; }

#chat-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#chat-log, #chat-log-project {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg { display: flex; flex-direction: column; }
.chat-name { font-size: 11px; font-weight: 700; color: #4a7a35; margin-bottom: 2px; }
.chat-msg.mine .chat-name { color: #b5651d; }
.chat-text {
  font-size: 13px;
  color: #4a3524;
  background: #f2e8cf;
  border-radius: 4px 14px 14px 14px;
  padding: 7px 11px;
  word-break: break-word;
  align-self: flex-start;
  max-width: 95%;
}
.chat-msg.mine .chat-text { background: #e5f2d8; }
.chat-msg.group .chat-text { border: 1.5px solid #b7d89e; }

.chat-system {
  font-size: 11px;
  color: #a89a7c;
  text-align: center;
  padding: 2px 0;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 2px solid #e6d5ac;
}
#chat-scope {
  border: 2px solid #dcc79a;
  border-radius: 10px;
  background: #fffdf6;
  font-size: 11px;
  font-family: inherit;
  color: #6b5638;
  padding: 0 2px;
  outline: none;
}
#chat-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  font-size: 13px;
  background: #fffdf6;
  font-family: inherit;
  outline: none;
}
#chat-input:focus { border-color: #6abf59; }
#chat-send {
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: #6abf59;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

#members-tab { padding: 12px; overflow-y: auto; }
#member-list { list-style: none; }
#member-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  font-size: 13px;
  color: #4a3524;
  border-bottom: 1px solid #eee0bd;
}
.member-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

/* ---- グループ ---- */
#groups-tab { padding: 12px; overflow-y: auto; }

.group-create-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
#group-name-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  font-size: 13px;
  background: #fffdf6;
  font-family: inherit;
  outline: none;
}
#group-name-input:focus { border-color: #6abf59; }
#group-create-btn {
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: #6abf59;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.group-empty { font-size: 12px; color: #a89a7c; line-height: 1.7; }

.group-item {
  background: #f2e8cf;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.group-item.mine { border-color: #6abf59; background: #e5f2d8; }
.group-title { font-size: 13px; font-weight: 700; color: #4a3524; }
.group-members { font-size: 11px; color: #8a7a5e; margin: 4px 0 8px; }
.group-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 10px;
  background: #c9a15e;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.group-item.mine .group-btn { background: #d97757; }

/* ---- ツールバー ---- */
#toolbar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(92, 58, 32, 0.92);
  border: 2px solid rgba(255, 248, 231, 0.35);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(20, 40, 10, 0.45);
  z-index: 40;
  backdrop-filter: blur(6px);
}

#toolbar > button, .toolbar-emote > button {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 248, 231, 0.16);
  font-size: 21px;
  cursor: pointer;
  transition: background 0.15s;
}
#toolbar > button:hover, .toolbar-emote > button:hover { background: rgba(255, 248, 231, 0.32); }
#toolbar button.off { background: #d64545; }
#toolbar button.on { background: #4d9440; }

.toolbar-emote { position: relative; }

#emote-popover {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(6, 40px);
  gap: 6px;
  padding: 8px;
  background: rgba(92, 58, 32, 0.95);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(20, 40, 10, 0.4);
}
#emote-popover button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 248, 231, 0.15);
  font-size: 20px;
  cursor: pointer;
}
#emote-popover button:hover { background: rgba(255, 248, 231, 0.32); }

/* ---- 常時表示ウィジェット（予定+タスク） ---- */
#agenda-hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 25;
}
#agenda-toggle {
  position: absolute;
  top: 0;
  left: 0;
  width: 38px;
  height: 38px;
  border: 2px solid #c9a15e;
  border-radius: 12px;
  background: rgba(255, 248, 231, 0.95);
  font-size: 17px;
  cursor: pointer;
  z-index: 2;
  display: none;
}
#agenda-panel {
  width: 250px;
  max-height: 56vh;
  overflow-y: auto;
  background: rgba(255, 248, 231, 0.94);
  border: 2px solid #c9a15e;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px rgba(20, 40, 10, 0.25);
}
#agenda-hud.collapsed #agenda-panel { display: none; }
#agenda-hud.collapsed #agenda-toggle { display: block; }
#agenda-hud:not(.collapsed) #agenda-toggle {
  display: block;
  top: 4px;
  right: 4px;
  left: auto;
  width: 26px;
  height: 26px;
  font-size: 12px;
  border-radius: 8px;
}
.agenda-head {
  font-size: 12px;
  font-weight: 700;
  color: #4a3524;
  margin: 6px 0 4px;
}
.agenda-head:first-child { margin-top: 0; padding-right: 26px; }
#agenda-date { font-size: 10px; color: #a89a7c; font-weight: 700; }
.agenda-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.agenda-row {
  display: flex;
  gap: 7px;
  align-items: baseline;
  background: #fffdf6;
  border-radius: 8px;
  padding: 4px 8px;
}
.agenda-row.overdue { }
.agenda-row.overdue .agenda-time { color: #d64545; }
.agenda-time {
  font-size: 10.5px;
  font-weight: 700;
  color: #4a7a35;
  flex-shrink: 0;
  min-width: 34px;
}
.agenda-title {
  font-size: 11.5px;
  color: #4a3524;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-empty { font-size: 10.5px; color: #a89a7c; padding: 2px 2px 4px; }
#agenda-tasks { max-height: 200px; overflow-y: auto; }
.agenda-type {
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: auto;
}
.agenda-src {
  font-size: 8.5px;
  font-weight: 700;
  color: #b3a482;
  flex-shrink: 0;
  margin-left: auto;
}

/* ---- ミニマップ ---- */
#minimap-wrap {
  position: fixed;
  left: 14px;
  bottom: 14px;
  padding: 5px;
  background: rgba(255, 248, 231, 0.9);
  border: 2px solid #c9a15e;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(20, 40, 10, 0.3);
  z-index: 25;
  line-height: 0;
}
#minimap { border-radius: 8px; }

/* ---- DM ---- */
.dm-btn {
  margin-left: auto;
  padding: 2px 10px;
  border: none;
  border-radius: 8px;
  background: #b79ce0;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.dm-btn:hover { filter: brightness(1.1); }
.chat-msg.dm .chat-name { color: #7c5cbf; }
.chat-msg.dm .chat-text { border: 1.5px solid #cebcec; background: #f3eefb; }
.chat-msg.history { opacity: 0.65; }

/* ---- BizFlo パネル ---- */
#biz-modal {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.biz-card {
  width: min(980px, 92vw);
  height: min(640px, 86vh);
  background: #fff8e7;
  border: 3px solid #c9a15e;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(20, 40, 10, 0.5);
}
.biz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
}
.biz-header h2 { font-size: 18px; color: #4a3524; }
#biz-close {
  border: none;
  background: #f2e8cf;
  width: 32px; height: 32px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  color: #6b5638;
}
.biz-tabs {
  display: flex;
  gap: 6px;
  padding: 0 18px 10px;
  border-bottom: 2px solid #e6d5ac;
}
.biz-tab-btn {
  padding: 8px 22px;
  border: none;
  border-radius: 10px 10px 0 0;
  background: #f2e8cf;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  color: #a89a7c;
  cursor: pointer;
}
.biz-tab-btn.active { background: #6abf59; color: #fff; }
#biz-body {
  flex: 1;
  overflow: auto;
  padding: 14px 18px;
}
.biz-loading, .biz-empty, .biz-error { color: #a89a7c; font-size: 13px; padding: 30px; text-align: center; }
.biz-error { color: #b5651d; }

/* 案件カンバン */
.biz-kanban {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 100%;
}
.kanban-col {
  flex: 0 0 240px;
  background: #f6eed7;
  border-radius: 14px;
  padding: 10px;
}
.kanban-head {
  font-size: 13px;
  font-weight: 700;
  color: #4a3524;
  padding: 4px 8px 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.kanban-count { color: #a89a7c; font-size: 12px; }
.kanban-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}
.kanban-card {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: 0 2px 6px rgba(100, 70, 30, 0.12);
}
.kc-name { font-size: 13px; font-weight: 700; color: #4a3524; }
.kc-customer { font-size: 11px; color: #8a7a5e; margin-top: 2px; }
.kc-progress {
  height: 6px;
  background: #eee2c4;
  border-radius: 3px;
  margin: 7px 0 5px;
  overflow: hidden;
}
.kc-bar { height: 100%; background: #6abf59; border-radius: 3px; }
.kc-meta { display: flex; gap: 10px; font-size: 10.5px; color: #a89a7c; }

/* タスク */
.task-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.task-toggle button {
  padding: 6px 16px;
  border: 2px solid #dcc79a;
  border-radius: 10px;
  background: #fffdf6;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: #a89a7c;
  cursor: pointer;
}
.task-toggle button.active { border-color: #6abf59; background: #eaf6df; color: #4a7a35; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 9px 14px;
  box-shadow: 0 2px 5px rgba(100, 70, 30, 0.1);
}
.task-row.overdue { background: #fdf1ef; }
.task-name { font-size: 13px; font-weight: 700; color: #4a3524; }
.task-project { font-size: 11px; color: #8a7a5e; }
.task-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.task-deadline { font-size: 11.5px; color: #6b5638; }
.task-row.overdue .task-deadline { color: #d64545; font-weight: 700; }
.task-deadline.none { color: #c5b899; }
.task-rate {
  font-size: 11px;
  font-weight: 700;
  color: #4a7a35;
  background: #eaf6df;
  padding: 2px 8px;
  border-radius: 8px;
}

/* 顧客 */
#customer-search {
  width: 100%;
  padding: 9px 14px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  font-size: 13px;
  font-family: inherit;
  background: #fffdf6;
  outline: none;
  margin-bottom: 12px;
}
#customer-search:focus { border-color: #6abf59; }
.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.customer-card {
  background: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 2px 5px rgba(100, 70, 30, 0.1);
}
.cc-name { font-size: 13px; font-weight: 700; color: #4a3524; }
.cc-person { font-size: 11px; color: #8a7a5e; margin-top: 2px; }
.cc-badges { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.cc-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 8px;
  background: #eee2c4;
  color: #6b5638;
}
.cc-badge.prospect { background: #fdeacc; color: #b5651d; }
.cc-badge.tag { background: #e3edf8; color: #4a6fa5; }
.cc-contact { font-size: 11px; color: #8a7a5e; margin-top: 2px; word-break: break-all; }

/* ---- KPI ---- */
.biz-user { font-size: 12px; color: #8a7a5e; margin-left: auto; margin-right: 12px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.kpi-tile {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(100, 70, 30, 0.12);
}
.kpi-tile.warn { }
.kpi-label { font-size: 12px; font-weight: 700; color: #8a7a5e; }
.kpi-value { font-size: 26px; font-weight: 700; color: #4a3524; margin-top: 4px; }
.kpi-unit { font-size: 13px; margin-left: 2px; color: #8a7a5e; }
.kpi-sub { font-size: 11px; color: #8a7a5e; margin-top: 2px; }
.kpi-tile.warn .kpi-sub { color: #d64545; font-weight: 700; }

/* ---- 受発注 ---- */
.orders-head { font-size: 14px; color: #4a3524; margin: 14px 0 8px; }
.orders-head:first-child { margin-top: 0; }
.order-list { display: flex; flex-direction: column; gap: 6px; }
.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 9px 14px;
  box-shadow: 0 2px 5px rgba(100, 70, 30, 0.1);
}
.order-title { font-size: 13px; font-weight: 700; color: #4a3524; }
.order-party { font-size: 11px; color: #8a7a5e; }
.order-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.order-amount { font-size: 13px; font-weight: 700; color: #3f7a2e; }
.order-date { font-size: 11px; color: #8a7a5e; }
.order-status {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 8px;
  background: #eee2c4;
  color: #6b5638;
}

/* ---- サイドバー閉じるボタン（モバイル用） ---- */
#sidebar-close {
  display: none;
  border: none;
  background: none;
  font-size: 15px;
  color: #a89a7c;
  padding: 0 14px;
  cursor: pointer;
}

/* ---- 議事録 ---- */
#minutes-indicator {
  position: fixed;
  top: 138px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: rgba(92, 58, 32, 0.92);
  color: #fff8e7;
  font-size: 12px;
  font-weight: 700;
  border-radius: 14px;
  z-index: 35;
  max-width: 90vw;
}
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e74c3c;
  animation: recblink 1.2s infinite;
}
@keyframes recblink { 50% { opacity: 0.25; } }
#minutes-interim {
  font-weight: 400;
  color: #d9cbb2;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 40vw;
}
#toolbar button.rec { background: #d64545; }

#minutes-tab { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.minutes-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  background: #f2e8cf;
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.minutes-item:hover { background: #eaddc0; }
.minutes-item-title { font-size: 13px; font-weight: 700; color: #4a3524; }
.minutes-item-sub { font-size: 11px; color: #8a7a5e; }
#minutes-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.minutes-view-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
#minutes-back {
  border: none;
  background: #f2e8cf;
  border-radius: 9px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  color: #6b5638;
  cursor: pointer;
}
#minutes-view-title { font-size: 12.5px; font-weight: 700; color: #4a3524; }
#minutes-lines { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.minute-line { display: flex; flex-direction: column; }
.minute-speaker { font-size: 10.5px; font-weight: 700; color: #4a7a35; }
.minute-text {
  font-size: 12.5px;
  color: #4a3524;
  background: #fffdf6;
  border-radius: 4px 10px 10px 10px;
  padding: 6px 10px;
}

/* ---- デコパレット ---- */
#deco-palette {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(92, 58, 32, 0.92);
  border: 2px solid rgba(255, 248, 231, 0.35);
  border-radius: 16px;
  z-index: 40;
  max-width: 94vw;
  overflow-x: auto;
}
.deco-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 46px;
  padding: 5px 4px;
  border: 2px solid transparent;
  border-radius: 11px;
  background: rgba(255, 248, 231, 0.14);
  cursor: pointer;
  color: #fff8e7;
}
.deco-item span { font-size: 17px; }
.deco-item small { font-size: 8.5px; font-weight: 700; }
.deco-item:hover { background: rgba(255, 248, 231, 0.28); }
.deco-item.selected { border-color: #6abf59; background: rgba(106, 191, 89, 0.35); }
.deco-item.deco-close { background: rgba(214, 69, 69, 0.4); }

/* ---- 自動退出 ---- */
#autoexit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 15, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}
.autoexit-card {
  background: #fff8e7;
  border: 3px solid #c9a15e;
  border-radius: 20px;
  padding: 32px 40px;
  text-align: center;
  max-width: 90vw;
}
.autoexit-emoji { font-size: 44px; }
.autoexit-card h2 { color: #4a3524; font-size: 20px; margin: 8px 0 6px; }
.autoexit-card p { color: #8a7a5e; font-size: 13px; margin-bottom: 18px; }
#autoexit-rejoin {
  padding: 12px 32px;
  border: none;
  border-radius: 14px;
  background: #6abf59;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

/* ---- 外部への通知（Webhook管理） ---- */
.auto-exit-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #6b5638;
  margin: 12px 0;
  cursor: pointer;
}
#webhook-list { margin-bottom: 10px; }
.webhook-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffdf6;
  border: 2px solid #eee0bd;
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 6px;
}
.webhook-info { flex: 1; min-width: 0; }
.webhook-url { font-size: 11.5px; color: #4a3524; font-weight: 700; word-break: break-all; }
.webhook-ev { font-size: 10px; color: #a89a7c; margin-top: 2px; }
.webhook-del {
  flex-shrink: 0;
  padding: 5px 12px;
  border: none;
  border-radius: 9px;
  background: #d97757;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.webhook-events {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.webhook-events label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: #6b5638;
  cursor: pointer;
}
.webhook-actions { display: flex; gap: 8px; }
#webhook-test-btn, #webhook-add-btn {
  flex: 1;
  padding: 9px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
#webhook-test-btn { border: 2px solid #dcc79a; background: #fffdf6; color: #6b5638; }
#webhook-add-btn { border: none; background: #6abf59; color: #fff; }
#webhook-url-input {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid #dcc79a;
  border-radius: 12px;
  font-size: 12px;
  font-family: inherit;
  background: #fffdf6;
  outline: none;
}
#webhook-url-input:focus { border-color: #6abf59; }

/* ---- トースト ---- */
#toast {
  position: fixed;
  top: 150px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 10px 20px;
  background: rgba(92, 58, 32, 0.92);
  color: #fff8e7;
  font-size: 13px;
  border: 2px solid rgba(255, 248, 231, 0.3);
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==== スマホ最適化 ==== */
#game { touch-action: none; } /* ピンチ・スクロールをゲーム操作と分離 */

@media (max-width: 767px) {
  /* 参加画面 */
  #join-screen { padding: 10px 0; }
  .join-card {
    width: 94vw;
    padding: 20px 16px;
    border-radius: 18px;
  }
  .join-card h1 { font-size: 24px; }
  .join-columns { flex-direction: column; }
  .join-right { width: 100%; flex-direction: row; gap: 10px; padding: 6px; }
  #avatar-preview { width: 90px; height: 90px; }
  #world-grid { gap: 6px; }
  .world-btn { padding: 8px 4px; }
  .world-desc { display: none; }
  #biz-login-form { flex-direction: column; }
  #biz-login-btn { padding: 10px; }
  .species-btn .sp-label { font-size: 8px; }

  /* ビデオタイル */
  #video-strip {
    max-width: 100vw;
    top: 6px;
    gap: 6px;
    padding: 0 4px;
  }
  .video-tile { width: 96px; height: 72px; border-radius: 10px; border-width: 2px; }
  .video-tile.screen { width: 160px; }
  .tile-name { font-size: 9px; padding: 1px 5px; left: 4px; bottom: 4px; }

  /* サイドバーは全画面オーバーレイ */
  #sidebar {
    width: 100vw;
    border-left: none;
    z-index: 45; /* ツールバーより上 */
  }
  #sidebar-close { display: block; }
  .tab-btn { font-size: 11px; }

  /* ツールバー */
  #toolbar {
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 6px;
    padding: 8px 10px;
    border-radius: 16px;
  }
  #toolbar > button, .toolbar-emote > button {
    width: 42px;
    height: 42px;
    font-size: 19px;
  }
  #emote-popover { grid-template-columns: repeat(6, 36px); }
  #emote-popover button { width: 36px; height: 36px; font-size: 17px; }

  /* ミニマップ */
  #minimap-wrap { left: 8px; bottom: max(8px, env(safe-area-inset-bottom)); padding: 3px; }
  #minimap { width: 104px; height: auto; }

  /* Bizパネルは全画面 */
  #biz-modal { align-items: stretch; }
  .biz-card {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .biz-header { padding: 12px 14px 8px; }
  .biz-header h2 { font-size: 16px; }
  .biz-user { font-size: 10px; }
  .biz-tabs { padding: 0 8px 8px; gap: 4px; overflow-x: auto; }
  .biz-tab-btn { padding: 7px 12px; font-size: 12px; white-space: nowrap; }
  #biz-body { padding: 10px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-tile { padding: 10px 12px; }
  .kpi-value { font-size: 20px; }
  .kanban-col { flex: 0 0 200px; }
  .task-row, .order-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .task-side, .order-side { justify-content: flex-start; }
  .customer-grid { grid-template-columns: 1fr; }
}
