.has-site-menu .site-header { z-index: 110; }
/* メニューを開いている間は、後ろのページをスクロールさせない（html・bodyの両方で止める） */
html.menu-is-open,
body.menu-is-open { overflow: hidden; overscroll-behavior: none; }
/* html と body の両方を overflow: hidden にすると、body がスクロール枠になって上に固定したヘッダーが画面の外へ出てしまうため、
   スクロール止めは html 側だけで行い、body は普段どおりに戻す（メニューを開いてもヘッダーを出したままにする） */
html.menu-is-open > body.menu-is-open { overflow: visible; }

.site-menu-created {
  position: sticky;
  top: 0;
  z-index: 110;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line, #303858);
  color: var(--text, #f3f4ff);
  background: rgba(7, 8, 21, 0.96);
}
.site-menu-created .brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-family: var(--font-serif, "Noto Serif JP", "Yu Mincho", serif);
  font-weight: 800;
  text-decoration: none;
}
.site-menu-created .header-actions { display: flex; align-items: center; }
.site-menu-created .brand-mark { color: var(--accent, #9eabff); }
/* ゲーム名の右に付くバージョン表記（例：－Cβ－）。ゲーム名と同じ大きさ・色。site-menu.js が付ける */
.game-version-label { margin-left: .5em; white-space: nowrap; }

.auth-page.has-site-menu { display: block; padding: 0; }
.auth-page.has-site-menu .auth-shell { margin: 30px auto; padding-inline: 18px; }

.has-site-menu .header-actions > :not(.menu-toggle-button) { display: none !important; }
.has-site-menu .header-actions > .user-name {
  display: inline-flex !important;
  max-width: min(260px, 36vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-page.has-site-menu .header-actions > .layout-switcher,
.chat-page.has-site-menu .header-actions > #screenshot-mode-button {
  display: inline-flex !important;
}

.menu-toggle-button {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  z-index: 102;
}

.menu-toggle-button:hover,
.menu-toggle-button:focus-visible { border-color: var(--accent); }

.menu-unread-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-sizing: border-box;
  background: #ff315c;
  box-shadow: 0 0 0 1px rgba(255, 49, 92, .35), 0 0 5px rgba(255, 49, 92, .72);
}
.menu-unread-dot.is-personal { border-color: #f4fff8; background: #159b57; box-shadow: 0 0 0 1px rgba(21, 155, 87, .42), 0 0 5px rgba(21, 155, 87, .58); }
.menu-unread-dot[hidden] { display: none !important; }
.menu-toggle-indicators { position: absolute; top: 0; right: -2px; z-index: 2; display: flex; align-items: center; gap: 2px; }
.menu-toggle-indicators[hidden] { display: none !important; }
.menu-news-link { display: flex; min-height: inherit; align-items: center; justify-content: flex-start; gap: 8px; }
.menu-news-indicators { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: flex-start; gap: 5px; margin-left: 0; white-space: nowrap; }
.menu-personal-notice-tag { display: inline-flex; align-items: center; min-height: 18px; padding: 2px 6px; border: 1px solid #158d50; border-radius: 999px; background: #137e49; color: #f2fff7; font-size: .58rem; font-weight: 700; line-height: 1; white-space: nowrap; }
.menu-personal-notice-tag[hidden] { display: none !important; }
.menu-contact-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; }
.menu-contact-label small { color: var(--muted); font-size: .64rem; font-weight: 400; white-space: nowrap; }

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  position: absolute;
  left: 50%;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: translateX(-50%);
  transition: transform 0.24s ease, top 0.24s ease, opacity 0.18s ease;
}

.menu-icon { top: 50%; }
.menu-icon::before,
.menu-icon::after { content: ""; }
.menu-icon::before { top: -7px; }
.menu-icon::after { top: 7px; }
.menu-is-open .menu-icon { background: transparent; }
.menu-is-open .menu-icon::before { top: 0; transform: translateX(-50%) rotate(45deg); }
.menu-is-open .menu-icon::after { top: 0; transform: translateX(-50%) rotate(-45deg); }

.menu-backdrop {
  position: fixed;
  top: var(--site-menu-header-height, 54px);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 90;
  border: 0;
  background: rgba(2, 3, 12, 0.58);
  touch-action: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

.header-menu-panel {
  position: fixed;
  top: var(--site-menu-header-height, 54px);
  right: 0;
  z-index: 100;
  width: min(360px, 88vw);
  height: calc(100dvh - var(--site-menu-header-height, 54px));
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 24px 20px;
  border-left: 1px solid var(--line);
  background: rgba(8, 10, 27, 0.98);
  box-shadow: -20px 0 48px rgba(0, 0, 0, 0.35);
  font-family: var(--font-serif, "Noto Serif JP", "Yu Mincho", serif);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(174, 188, 255, 0.45) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
  transform: translateX(104%);
  visibility: hidden;
  transition: transform 0.24s ease, visibility 0s linear 0.24s;
}

.menu-is-open .menu-backdrop { opacity: 1; pointer-events: auto; }
.menu-is-open .header-menu-panel {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.24s ease, visibility 0s;
}

.menu-user-name {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
}

.menu-section {
  display: grid;
  gap: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line, #303858);
}
.menu-section:last-child { border-bottom: 0; }
.menu-section[hidden] { display: none !important; }
.menu-section-title {
  margin: 12px 14px 5px;
  color: var(--muted, #a9aec9);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

/* 古いメニューJSがキャッシュに残った場合も、通常メニューの見出しは表示しない。 */
#site-menu-normal > .menu-section-title { display: none !important; }

.site-login-required-toast {
  position: fixed;
  right: clamp(14px, 3vw, 32px);
  bottom: clamp(14px, 3vw, 30px);
  z-index: 180;
  max-width: min(360px, calc(100vw - 28px));
  padding: 13px 18px;
  border: 1px solid var(--line, rgba(174, 188, 255, 0.3));
  border-radius: 12px;
  color: var(--text, #eef0ff);
  background: var(--panel-solid, rgba(20, 24, 47, 0.98));
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  font: 800 0.9rem/1.5 var(--font-sans, system-ui, sans-serif);
  opacity: 0;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.5s ease, opacity 0.5s ease;
  pointer-events: none;
}
.site-login-required-toast.is-visible { opacity: 1; transform: translateX(0); }

.menu-link {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.menu-link:hover,
.menu-link:focus-visible { color: var(--accent); }
.menu-action { border-radius: 0; }

@media (max-width: 640px) {
  .menu-toggle-button { width: 42px; height: 42px; flex-basis: 42px; }
  .header-menu-panel { width: min(330px, 92vw); padding-inline: 18px; }
  .auth-page.has-site-menu .auth-shell { margin-block: 18px; }
  .menu-news-link { align-items: center; }
  .menu-news-indicators { flex-wrap: nowrap; max-width: none; }
  .menu-contact-label { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-icon,
  .menu-icon::before,
  .menu-icon::after,
  .menu-backdrop,
  .header-menu-panel,
  .site-login-required-toast { transition-duration: 0.01ms; }
}

/* メニューの文字サイズ（全ページ共通）：PCは約5px、スマホは約2px大きくする */
.header-menu-panel .menu-link { font-size: 19px; }
.header-menu-panel .menu-section-title { font-size: 15px; }
.header-menu-panel .menu-user-name { font-size: 16px; }
.header-menu-panel .menu-contact-label small { font-size: 13px; }
.header-menu-panel .menu-personal-notice-tag { font-size: 11px; }
@media (max-width: 640px) {
  .header-menu-panel .menu-link { font-size: 18px; }
  .header-menu-panel .menu-section-title { font-size: 13px; }
  .header-menu-panel .menu-user-name { font-size: 15px; }
  .header-menu-panel .menu-contact-label small { font-size: 12px; }
  .header-menu-panel .menu-personal-notice-tag { font-size: 11px; }
}
