/*
 * 站内提醒：内容与展开状态由 app.js 更新。
 * 通知条占位，展开清单悬浮在条下方；轮播只切换文字。
 */
.notification-region {
  position: relative;
  z-index: 3;
  width: min(680px, calc(100% - 32px));
  min-width: 0;
  margin: 8px auto;
  color: #f5ead6;
  color-scheme: dark;
}

body:not(.dashboard-open) #notificationRegion {
  display: none;
}

.notification-bar,
.notification-panel {
  border: 1px solid rgba(205, 165, 103, .48);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(46, 39, 30, .86), rgba(24, 27, 25, .86));
  box-shadow: 0 3px 12px rgba(8, 12, 10, .14);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.notification-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
}

.notification-position {
  flex: none;
  color: #dfc494;
  font-size: 11px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 条数保留给屏幕朗读，不重复占用通知条的可见空间。 */
.notification-count {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.notification-bell {
  flex: none;
  width: 16px;
  height: 16px;
  margin-right: 2px;
  color: #dfc494;
}

.notification-bell,
.notification-icon-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notification-region button {
  min-width: 0;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #ecdbb9;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

.notification-region button:hover:not(:disabled) {
  color: #fff0cd;
  background: rgba(183, 138, 73, .16);
}

.notification-region button:active:not(:disabled) {
  background: rgba(183, 138, 73, .3);
}

.notification-region :focus-visible {
  outline: 2px solid #ffe0a2;
  outline-offset: 3px;
}

/* 一行显示；长消息省略，点击正文或箭头即可在清单内阅读完整内容。 */
.notification-region .notification-summary {
  flex: 1 1 0;
  display: block;
  height: 32px;
  padding: 0 4px;
  overflow: hidden;
  color: #fbf0da;
  font-size: 13px;
  font-weight: 400;
  line-height: 32px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-region .notification-icon-button {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.notification-icon-button svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

#notificationPause[aria-pressed="false"] .notification-play-icon,
#notificationPause[aria-pressed="true"] .notification-pause-icon {
  display: none;
}

#notificationToggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

#notificationClear {
  color: #e8c4a4;
}

.notification-region button:disabled {
  opacity: .45;
  cursor: default;
}

.notification-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline: 0;
  min-width: 0;
  background: linear-gradient(135deg, rgba(46, 39, 30, .97), rgba(24, 27, 25, .97));
  box-shadow: 0 10px 28px rgba(8, 12, 10, .36);
}

.notification-list {
  max-height: min(360px, 48dvh);
  margin: 0;
  padding: 4px 16px 4px 34px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #93754b rgba(11, 18, 15, .3);
  list-style: decimal;
}

.notification-item {
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid rgba(205, 165, 103, .18);
  overflow-wrap: anywhere;
  word-break: normal;
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item::marker {
  color: #cfb17e;
  font-size: 12px;
}

.notification-item-title {
  display: block;
  color: #f5e1bb;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  white-space: pre-wrap;
}

.notification-item-body {
  margin: 6px 0 0;
  color: #e2d8c6;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.notification-item-time {
  display: block;
  margin-top: 8px;
  color: #bdad91;
  font-size: 11px;
  line-height: 1.6;
  white-space: normal;
}

.notification-empty {
  margin: 0;
  padding: 18px 16px;
  color: #cdbb9b;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.notification-error {
  margin: 8px 0 0;
  padding: 9px 12px;
  border: 1px solid rgba(224, 160, 110, .42);
  border-radius: 8px;
  color: #ffd2ab;
  background: rgba(55, 34, 23, .95);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

/*
 * 共用大厅网格的列宽与行高：提醒占中央第一行，对局占中央第二行。
 * 左右列跨这两行；展开清单沿用通知区的上层位置，不改变网格行高。
 * 不支持共享网格的浏览器仍由通知条占位，清单同样悬浮展开。
 */
@supports (grid-template-rows: subgrid) {
  @media (min-width: 721px) {
    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) {
      --notification-side-space: clamp(24px, 4vw, 72px);
      --notification-edge-space: clamp(28px, 4.5vh, 54px);
      --notification-columns: minmax(260px, 308px) minmax(0, 1fr) minmax(300px, 350px);
      --notification-column-gap: clamp(24px, 3vw, 46px);
      display: grid;
      grid-template-columns: var(--notification-columns);
      grid-template-rows: auto minmax(min-content, 1fr);
      column-gap: var(--notification-column-gap);
      row-gap: 16px;
      width: min(100%, 1500px);
      margin: 0 auto;
      padding-block: var(--notification-edge-space);
      /* 原大厅内容最多宽 1356px，超过时把额外宽度平分到两侧。 */
      padding-inline: max(var(--notification-side-space), calc((min(100vw, 1500px) - 1356px) / 2));
    }

    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) > #notificationRegion {
      grid-column: 2;
      grid-row: 1;
      align-self: start;
      width: auto;
      margin: 0;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView {
      display: grid;
      grid-template-columns: subgrid;
      grid-template-rows: subgrid;
      grid-column: 1 / -1;
      grid-row: 1 / span 2;
      width: auto;
      min-height: 0;
      margin: 0;
      padding: 0;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView .lobby-layout {
      grid-template-columns: subgrid;
      grid-template-rows: subgrid;
      grid-column: 1 / -1;
      grid-row: 1 / -1;
      gap: normal;
      width: auto;
      max-width: none;
      min-height: 0;
      margin: 0;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView .lobby-left-column {
      grid-column: 1;
      grid-row: 1 / -1;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView .home-current-games-section {
      grid-column: 2;
      grid-row: 2;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView .lobby-right-column {
      grid-column: 3;
      grid-row: 1 / -1;
    }
  }

  @media (min-width: 721px) and (max-width: 1200px) {
    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) {
      --notification-side-space: 28px;
      --notification-columns: minmax(250px, 280px) minmax(0, 1fr) minmax(260px, 290px);
      --notification-column-gap: 24px;
    }
  }

  @media (min-width: 721px) and (max-width: 1080px) {
    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) {
      --notification-columns: minmax(260px, 308px) minmax(0, 1fr);
      --notification-column-gap: 30px;
      grid-template-rows: auto auto auto;
      align-content: start;
      row-gap: 30px;
      /* 原双列网格最多宽 850px，加左右各 28px 的页面留白。 */
      width: min(100%, 906px);
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView {
      grid-row: 1 / span 3;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView .lobby-left-column {
      grid-row: 1 / span 2;
    }

    body.dashboard-open #notificationRegion:not(.hidden) ~ #dashboardView .lobby-right-column {
      grid-column: 1 / -1;
      grid-row: 3;
    }
  }

  @media (min-width: 1081px) and (max-height: 820px) {
    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) {
      --notification-edge-space: 24px;
    }
  }

  @media (min-width: 1201px) and (max-height: 820px) {
    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) {
      --notification-columns: minmax(240px, min(308px, 40dvh)) minmax(0, 1fr) minmax(300px, 350px);
    }
  }

  @media (min-width: 1081px) and (max-height: 720px) {
    body.dashboard-open #appView:has(> #notificationRegion:not(.hidden)) {
      --notification-edge-space: 20px;
    }
  }
}

@media (max-width: 720px) {
  body.dashboard-open #notificationRegion {
    width: min(440px, calc(100% - 36px));
    margin: 12px auto 0;
    padding-top: env(safe-area-inset-top);
  }

  .notification-region button,
  .notification-region .notification-icon-button {
    min-height: 36px;
    height: 36px;
  }

  .notification-region .notification-icon-button {
    width: 36px;
  }

  .notification-region .notification-summary {
    line-height: 36px;
  }
}

@media (max-width: 390px) {
  body.dashboard-open #notificationRegion {
    width: calc(100% - 24px);
  }

  .notification-position {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .notification-region,
  .notification-region *,
  .notification-region *::before,
  .notification-region *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
