/* ==========================================================================
   quiet.css  --  安靜版介面（2026-11-17，Nene 選定樣稿後上線）
   --------------------------------------------------------------------------
   只管長相與排法，不碰計分、資料、雲端。
   全部規則掛在 body.q 底下：拿掉 <body class="q"> 與這支檔的 <link>，
   頁面就回到 index.css 原本的樣子。

   顏色各管一件事：
     紅 / 綠   只表示漲 / 跌
     金        只給第一名與名人堂
     紫        只給「可以按的東西」
     白 / 灰   文字兩階
   版面狀態由 js/quiet-ui.js 掛在 body 上：
     q-guest / q-admin      身份
     q-live / q-pick / q-done  這個月在比賽中 / 選股期 / 已結束
     q-has-board            排行榜有資料
     q-board-complete       排行榜已經列出每一位參賽者
     q-tab-hall             手機上切到「名人堂」分頁
   ========================================================================== */

body.q {
  --q-bg: #0e1116;
  --q-card: #171b22;
  --q-card-2: #1c212a;
  --q-line: rgba(255, 255, 255, 0.08);
  --q-line-strong: rgba(255, 255, 255, 0.16);
  --q-text: #e8eaed;
  --q-text-2: #9aa3af;
  --q-up: #ff5a60;
  --q-down: #1db57a;
  --q-accent: #9b8cfa;
  --q-accent-solid: #6d5df6;
  --q-gold: #e6b450;
  --q-silver: #c9ced6;
  --q-bronze: #c98a5a;
  --q-tabs-h: 64px;

  /* 把 index.css 的變數接到新色票上，沒被下面個別改寫的元件也會跟著安靜下來 */
  --bg-primary: var(--q-bg);
  --bg-secondary: var(--q-card);
  --bg-card: var(--q-card);
  --bg-card-hover: var(--q-card-2);
  --text-primary: var(--q-text);
  --text-secondary: var(--q-text-2);
  --text-muted: var(--q-text-2);
  --accent-primary: var(--q-accent);
  --accent-secondary: var(--q-accent);
  --accent-gradient: var(--q-accent-solid);
  --gain-color: var(--q-up);
  --gain-bg: rgba(255, 90, 96, 0.12);
  --loss-color: var(--q-down);
  --loss-bg: rgba(29, 181, 122, 0.12);
  --price-up: var(--q-up);
  --price-down: var(--q-down);
  --gold: var(--q-gold);
  --silver: var(--q-silver);
  --bronze: var(--q-bronze);
  --card-border: var(--q-line);
  --card-border-hover: var(--q-line-strong);
  --card-shine: none;
  --shadow-glow: none;

  background: var(--q-bg);
  color: var(--q-text);
  line-height: 1.5;
}

html:has(body.q) {
  background: #0e1116;
}

/* 裝飾層全部收掉：背景光暈、卡片掃光、按鈕掃光、分隔光線 */
body.q::before,
body.q .header::after,
body.q .card::before,
body.q .btn::before,
body.q .leaderboard-item::before,
body.q .card-title::before,
body.q .current-month-badge::before {
  display: none;
}

body.q .app-container {
  max-width: 720px;
  padding: 12px 16px 24px;
  gap: 12px;
  min-height: 0;
}

body.q .card,
body.q .card:hover {
  background: var(--q-card);
  border: 1px solid var(--q-line);
  border-radius: 14px;
  box-shadow: none;
  transform: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 14px;
  animation: none;
}

body.q .card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--q-text);
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: none;
  -webkit-text-fill-color: currentColor;
  gap: 6px;
}

body.q .card-icon {
  display: none;
}

/* --------------------------------------------------------------------------
   頁首：◀ 上月｜N 月賽事｜下月 ▶ ／ 狀態列 ／ 連結與身份
   三個原本的容器（左、中、右）攤平，所有東西直接排在頁首的格線上
   -------------------------------------------------------------------------- */
body.q .header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 6px;
  padding: 4px 0 0;
  animation: none;
}

body.q .header-left,
body.q .header-right,
body.q .header-content {
  display: contents;
}

body.q .logo {
  grid-row: 1;
  grid-column: 1 / -1;
  justify-self: center;
  margin: 0;
}

body.q .logo h1 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--q-text-2);
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
  filter: none;
  animation: none;
  margin: 0;
}

body.q .subtitle {
  display: none;
}

body.q .month-nav-btn {
  grid-row: 2;
  min-height: 44px;
  min-width: 0;
  width: auto;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 12px;
  color: var(--q-text-2);
  font-size: 14px;
  font-weight: 500;
  box-shadow: none;
  transform: none;
  z-index: 1;
}

body.q .month-nav-btn:hover {
  background: var(--q-card);
  color: var(--q-text);
  box-shadow: none;
  transform: none;
}

body.q .month-nav-btn .nav-arrow {
  font-size: 10px;
  color: inherit;
}

body.q .month-nav-btn .nav-month {
  color: inherit;
  font-size: 14px;
}

body.q #prevMonthBtn {
  grid-column: 1 / span 2;
  justify-self: start;
}

body.q #nextMonthBtn {
  grid-column: 4;
  justify-self: end;
}

body.q .current-month-badge {
  grid-row: 2;
  grid-column: 1 / -1;
  justify-self: center;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  animation: none;
  color: var(--q-text);
}

body.q .current-month-badge .current-month-number,
body.q .current-month-badge .current-month-label {
  font-size: 22px;
  font-weight: 700;
  line-height: 44px;
  color: var(--q-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
}

body.q .q-status {
  grid-row: 3;
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 8px;
  min-height: 20px;
  font-size: 13px;
  color: var(--q-text-2);
  font-variant-numeric: tabular-nums;
}

body.q .q-status .q-status-phase {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--q-text);
  font-weight: 600;
}

body.q .q-status .q-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--q-accent);
}

body.q.q-pick .q-status .q-dot {
  background: var(--q-gold);
}

body.q.q-done .q-status .q-dot {
  background: var(--q-text-2);
}

body.q .q-status .q-sep {
  color: var(--q-text-2);
}

/* 歷史月份原本有一條橘色橫幅與「已封存」小標，會壓到頁首的字；這兩件事改寫在狀態列上 */
body.q .historical-view::before,
body.q .current-month-badge.archived::after {
  display: none;
}

body.q .last-updated {
  grid-row: 4;
  grid-column: 1 / -1;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--q-text-2);
  background: none;
  border: 0;
  white-space: normal;
}

body.q .last-updated:empty {
  display: none;
}

body.q .last-updated * {
  color: inherit;
}

body.q .margin-link,
body.q .q-ref-link {
  grid-row: 5;
  position: relative;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  margin: 0;
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--q-accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

body.q .margin-link::after,
body.q .q-ref-link::after {
  display: none;
}

body.q .margin-link {
  grid-column: 1;
}

body.q .q-ref-link {
  grid-column: 2;
}

body.q .margin-link:hover,
body.q .q-ref-link:hover {
  color: #b7abff;
  background: none;
  transform: none;
}

body.q .margin-link .margin-link-icon,
body.q .margin-link .margin-link-text {
  color: inherit;
  font-size: inherit;
}

body.q .horse-icon {
  grid-row: 5;
  grid-column: 3;
  justify-self: center;
  position: static;
  font-size: 18px;
  line-height: 1;
  margin: 0;
  padding: 6px;
  animation: none;
  filter: none;
  opacity: 0.5;
}

body.q .horse-icon.not-current-month {
  opacity: 1;
}

body.q .role-indicator {
  grid-row: 5;
  grid-column: 3 / -1;
  justify-self: end;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--q-text-2);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
}

body.q .role-indicator .role-text-short {
  display: none;
}

body.q .role-indicator .role-text-full {
  display: inline;
}

body.q .role-indicator .btn-logout {
  position: relative;
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 10px;
  color: var(--q-text);
  font-size: 13px;
  box-shadow: none;
}

body.q .role-indicator .btn-logout::after {
  display: none;
}

body.q .role-indicator .btn-logout:hover {
  background: var(--q-card);
}

/* --------------------------------------------------------------------------
   版面順序（手機／平板：單欄，兩個欄位容器攤平後用 order 排）
   -------------------------------------------------------------------------- */
body.q .q-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body.q .q-main,
body.q .q-side {
  display: contents;
}

body.q .q-pick-card {
  order: 10;
}
body.q .leaderboard-card {
  order: 20;
}
body.q .action-buttons {
  order: 30;
}
body.q .settings-card {
  order: 40;
}
body.q .participants-card {
  order: 50;
}
body.q .hall-of-fame-card {
  order: 60;
}

/* 比賽中的月份：選股資訊卡是「下個月的預告」，排在排行榜與按鈕後面 */
body.q.q-live .q-pick-card {
  order: 35;
}

/* 管理員維持原本的工作順序：設定 → 參賽者 → 按鈕 → 排行榜 */
body.q.q-admin .settings-card {
  order: 11;
}
body.q.q-admin .participants-card {
  order: 12;
}
body.q.q-admin .action-buttons {
  order: 13;
}

/* 來賓：日期寫在狀態列，設定卡收起來。
   參賽者表只有在排行榜已經列出每一個人（q-board-complete）時才收起來；
   有人缺價進不了排行榜時表要留著，否則那些人在畫面上就不見了（慧澄 2026-11-17 複核 Q-F01）。 */
body.q.q-guest .settings-card,
body.q.q-guest.q-board-complete .participants-card {
  display: none;
}

/* 排行榜沒列齊時的一行說明 */
body.q .q-board-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--q-line);
  border-radius: 10px;
  color: var(--q-text-2);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
body.q .q-board-note[hidden] {
  display: none;
}

/* 選股參考只留頁首那一顆 */
body.q .settings-card .stock-ref-link {
  display: none;
}

/* 原本用來把排行榜墊到畫面中間的空白不需要了；改成在整頁底部留出分頁列的高度，頁尾才不會被蓋住 */
body.q #bottomSpacer {
  min-height: 0 !important;
  height: 0;
}

@media (max-width: 1023px) {
  body.q .app-container {
    padding-bottom: calc(var(--q-tabs-h) + 28px + env(safe-area-inset-bottom, 0px));
  }

  body.q .toast-container {
    bottom: calc(var(--q-tabs-h) + 16px + env(safe-area-inset-bottom, 0px));
  }
}

body.q .footer {
  padding: 4px 0 0;
  margin: 0;
  border: 0;
  background: none;
  text-align: center;
  font-size: 12px;
  color: var(--q-text-2);
}

body.q .footer p {
  margin: 0;
  color: inherit;
  font-size: inherit;
}

/* --------------------------------------------------------------------------
   排行榜
   -------------------------------------------------------------------------- */
body.q .leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.q .leaderboard .leaderboard-item,
body.q .leaderboard .leaderboard-item:hover {
  display: grid;
  grid-template-columns: 34px auto minmax(0, 1fr) 64px auto;
  grid-template-areas:
    "rank name name spark gain"
    "rank code sname spark gain"
    "rank price price spark gain"
    "bar bar bar bar bar";
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  padding: 10px 12px;
  margin: 0;
  background: var(--q-card-2);
  border: 1px solid var(--q-line);
  border-radius: 12px;
  box-shadow: none;
  transform: none;
  animation: none;
  opacity: 1;
  overflow: visible;
}

body.q .leaderboard .leaderboard-item.rank-1 {
  border-color: rgba(230, 180, 80, 0.55);
}

body.q .leaderboard .leaderboard-item.guest-participant {
  opacity: 1;
}

body.q .leaderboard .leaderboard-item .participant-block {
  display: contents;
}

body.q .leaderboard .leaderboard-item .rank-badge {
  grid-area: rank;
  width: 32px;
  height: 32px;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: transparent;
  border: 1px solid var(--q-line-strong);
  box-shadow: none;
  color: var(--q-text-2);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  animation: none;
  -webkit-text-fill-color: currentColor;
}

body.q .leaderboard .leaderboard-item.rank-1 .rank-badge,
body.q .leaderboard .leaderboard-item.rank-2 .rank-badge,
body.q .leaderboard .leaderboard-item.rank-3 .rank-badge {
  border: 0;
  background: transparent;
  font-size: 24px;
}

body.q .leaderboard .leaderboard-item .participant-name {
  grid-area: name;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  color: var(--q-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.q .leaderboard .leaderboard-item .stock-code-badge {
  grid-area: code;
  justify-self: start;
  padding: 0 6px;
  margin: 0;
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 6px;
  box-shadow: none;
  color: var(--q-text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

body.q .leaderboard .leaderboard-item .stock-name-label {
  grid-area: sname;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  color: var(--q-text-2);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.q .leaderboard .leaderboard-item .price-range {
  grid-area: price;
  font-size: 13px;
  line-height: 18px;
  color: var(--q-text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.q .leaderboard .leaderboard-item .price-range .price-arrow {
  margin: 0 4px;
  color: inherit;
}

body.q .leaderboard .leaderboard-item .sparkline-cell {
  grid-area: spark;
  width: 64px;
  height: 26px;
  margin: 0;
  display: block;
}

body.q .leaderboard .leaderboard-item .sparkline-cell svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

body.q .sparkline-up {
  color: var(--q-up);
  stroke: var(--q-up);
}

body.q .sparkline-down {
  color: var(--q-down);
  stroke: var(--q-down);
}

body.q .leaderboard .leaderboard-item .gain-display {
  grid-area: gain;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  min-width: 0;
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

body.q .leaderboard .leaderboard-item .gain-percent {
  font-size: 19px;
  font-weight: 700;
  line-height: 26px;
  white-space: nowrap;
  text-shadow: none;
  background: none;
}

body.q .leaderboard .leaderboard-item .price-change {
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  white-space: nowrap;
  opacity: 1;
}

body.q .positive,
body.q .gain-percent.positive,
body.q .price-change.positive {
  color: var(--q-up);
  -webkit-text-fill-color: currentColor;
}

body.q .negative,
body.q .gain-percent.negative,
body.q .price-change.negative {
  color: var(--q-down);
  -webkit-text-fill-color: currentColor;
}

body.q .leaderboard .leaderboard-item .gain-bar-track {
  grid-area: bar;
  position: static;
  width: 100%;
  height: 3px;
  margin: 6px 0 0;
  border-radius: 2px;
  background: var(--q-line);
  overflow: hidden;
}

body.q .leaderboard .leaderboard-item .gain-bar {
  height: 3px;
  border-radius: 2px;
  box-shadow: none;
  animation: none;
}

body.q .gain-bar.positive {
  background: var(--q-up);
}

body.q .gain-bar.negative {
  background: var(--q-down);
}

/* 標題右邊一句話，說明每列那條小線是什麼 */
body.q .leaderboard-card .card-title {
  display: flex;
  align-items: baseline;
}

body.q .leaderboard-card .card-title::after {
  content: "小圖＝近 30 日走勢";
  display: inline;
  position: static;
  width: auto;
  height: auto;
  margin-left: auto;
  background: none;
  font-size: 12px;
  font-weight: 400;
  color: var(--q-text-2);
}

/* 小手機（≤480px）：排行榜不套外框，橫向空間留給每一列 */
@media (max-width: 480px) {
  body.q .leaderboard-card,
  body.q .leaderboard-card:hover {
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  body.q .leaderboard-card .card-title {
    margin: 0 2px 8px;
    font-size: 13px;
    color: var(--q-text-2);
  }

  body.q .leaderboard .leaderboard-item,
  body.q .leaderboard .leaderboard-item:hover {
    grid-template-columns: 30px auto minmax(0, 1fr) 56px auto;
    column-gap: 6px;
    background: var(--q-card);
  }

  body.q .leaderboard .leaderboard-item .rank-badge {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  body.q .leaderboard .leaderboard-item.rank-1 .rank-badge,
  body.q .leaderboard .leaderboard-item.rank-2 .rank-badge,
  body.q .leaderboard .leaderboard-item.rank-3 .rank-badge {
    font-size: 22px;
  }

  body.q .leaderboard .leaderboard-item .sparkline-cell {
    width: 56px;
  }

  body.q .leaderboard .leaderboard-item .gain-percent {
    font-size: 18px;
  }
}

/* 排行榜上的小徽章：後悔藥、友誼參賽、自動續賽、空、除息 */
body.q .short-badge,
body.q .direction-label,
body.q .direction-toggle {
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 6px;
  box-shadow: none;
  color: var(--q-text);
}

body.q .short-badge {
  padding: 0 5px;
  font-size: 11px;
  line-height: 16px;
}

/* --------------------------------------------------------------------------
   按鈕
   -------------------------------------------------------------------------- */
body.q .btn,
body.q .btn:hover {
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 12px;
  box-shadow: none;
  transform: none;
  color: var(--q-text);
  font-size: 14px;
  font-weight: 500;
  text-shadow: none;
  letter-spacing: 0;
  animation: none;
  filter: none;
}

body.q .btn:hover {
  background: var(--q-card-2);
}

body.q .btn:focus-visible,
body.q .q-tab:focus-visible,
body.q .month-nav-btn:focus-visible {
  outline: 2px solid var(--q-accent);
  outline-offset: 2px;
}

body.q .btn .btn-icon {
  filter: grayscale(1);
  opacity: 0.85;
  font-size: 14px;
}

body.q .btn.btn-primary,
body.q .btn.btn-blind-pick-cta,
body.q .q-btn-primary {
  background: var(--q-accent-solid);
  border-color: var(--q-accent-solid);
  color: #ffffff;
  font-weight: 700;
}

body.q .btn.btn-primary:hover,
body.q .btn.btn-blind-pick-cta:hover,
body.q .q-btn-primary:hover {
  background: #7c6df8;
  border-color: #7c6df8;
}

body.q .btn.btn-danger {
  border-color: rgba(255, 90, 96, 0.5);
  color: var(--q-up);
}

body.q .btn:disabled,
body.q .btn[disabled] {
  opacity: 0.45;
}

body.q .action-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding: 0;
}

body.q .action-buttons .btn {
  flex: 1 1 140px;
  max-width: none;
  width: auto;
}

body.q .action-buttons .fetch-btn-wrapper {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin: 0;
  min-width: 0;
}

body.q .action-buttons .fetch-btn-wrapper .btn {
  flex: 0 0 auto;
  width: 100%;
}

body.q .action-buttons .fetch-btn-wrapper > .fetch-timestamp,
body.q .action-buttons .fetch-btn-wrapper > .fetch-timestamp.fresh,
body.q .action-buttons .fetch-btn-wrapper > .fetch-timestamp.stale {
  width: auto;
  min-width: 0;
  display: block;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  color: var(--q-text-2);
  white-space: normal;
}

/* 盤中自動刷新的小圓點：改用互動色，綠色只留給「跌」 */
body.q .fetch-btn-wrapper.auto-refresh-active::before {
  background: var(--q-accent);
  box-shadow: none;
}

/* 來賓的按鈕列：名人堂／比賽規則／自動續賽搬到分頁，排名自動算，所以這裡只留當下要按的那一顆 */
body.q.q-guest #hallOfFameBtn,
body.q.q-guest #rulesBtn,
body.q.q-guest #calculateBtn {
  display: none;
}

body.q.q-guest.q-live #blindPickMenuBtn,
body.q.q-guest.q-done #blindPickMenuBtn,
body.q.q-guest.q-live #autoRenewBtn,
body.q.q-guest.q-done #autoRenewBtn,
body.q.q-guest.q-pick .fetch-btn-wrapper {
  display: none;
}

/* 來賓、比賽中：左邊更新時間、右邊一顆「抓最新價」 */
body.q.q-guest.q-live .action-buttons .fetch-btn-wrapper,
body.q.q-guest.q-done .action-buttons .fetch-btn-wrapper {
  flex: 1 1 100%;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.q.q-guest.q-live .action-buttons .fetch-btn-wrapper .btn,
body.q.q-guest.q-done .action-buttons .fetch-btn-wrapper .btn {
  width: auto;
  flex: 0 0 auto;
}

body.q.q-guest.q-live .action-buttons .fetch-btn-wrapper > .fetch-timestamp,
body.q.q-guest.q-done .action-buttons .fetch-btn-wrapper > .fetch-timestamp {
  flex: 1 1 auto;
  text-align: left;
}

/* 來賓、選股期：主按鈕整排，自動續賽在下面一排 */
body.q.q-guest.q-pick .action-buttons .btn {
  flex: 1 1 100%;
}

body.q.q-guest.q-pick #blindPickMenuBtn {
  min-height: 56px;
  font-size: 17px;
  border-radius: 14px;
}

body.q.q-guest.q-pick #autoRenewBtn {
  min-height: 48px;
  font-size: 15px;
  border-radius: 14px;
}

body.q.q-guest.q-pick #autoRenewBtn::after {
  content: "：忘記選就沿用上個月那一檔";
  font-weight: 400;
  margin-left: -6px;
}

/* --------------------------------------------------------------------------
   選股期資訊卡（早鳥線、截止日；比賽中的月份則預告下個月）
   -------------------------------------------------------------------------- */
body.q .q-pick-card {
  padding: 4px 14px;
}

body.q .q-pick-card .q-pick-head {
  padding: 10px 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--q-text);
}

/* 一列＝標題（左）＋剩幾天（右），說明文字在下面佔整列寬 */
body.q .q-pick-card .q-pick-row {
  padding: 12px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title left"
    "note note";
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  border-bottom: 1px solid var(--q-line);
}

body.q .q-pick-card .q-pick-row:last-of-type {
  border-bottom: 0;
}

body.q .q-pick-card .q-pick-main {
  display: contents;
}

body.q .q-pick-card .q-pick-title {
  grid-area: title;
}

body.q .q-pick-card .q-pick-note {
  grid-area: note;
}

body.q .q-pick-card .q-pick-left {
  grid-area: left;
}

body.q .q-pick-card .q-pick-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--q-text);
  font-variant-numeric: tabular-nums;
}

body.q .q-pick-card .q-pick-note {
  font-size: 13px;
  color: var(--q-text-2);
}

body.q .q-pick-card .q-pick-left {
  font-size: 20px;
  font-weight: 700;
  color: var(--q-text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

body.q .q-pick-card .q-pick-left.q-gold {
  color: var(--q-gold);
}

body.q .q-pick-card .q-pick-left.q-past {
  font-size: 15px;
  font-weight: 500;
  color: var(--q-text-2);
}

body.q .q-pick-card .q-pick-go {
  width: 100%;
  min-height: 48px;
  margin: 2px 0 10px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  border: 1px solid var(--q-accent-solid);
}

/* --------------------------------------------------------------------------
   參賽者表（選股期給大家看「誰選好了」；管理員的編輯表）
   -------------------------------------------------------------------------- */
body.q .participants-header,
body.q .participants-header-mobile {
  color: var(--q-text-2);
  border-color: var(--q-line);
  background: none;
}

body.q .participant-row,
body.q .participant-row:hover {
  background: var(--q-card-2);
  border: 1px solid var(--q-line);
  border-radius: 12px;
  box-shadow: none;
  transform: none;
  animation: none;
}

body.q .participant-number {
  background: transparent;
  border: 1px solid var(--q-line-strong);
  box-shadow: none;
  color: var(--q-text-2);
}

body.q .participant-input,
body.q .participant-select,
body.q .date-input,
body.q select,
body.q input[type="text"],
body.q input[type="password"],
body.q input[type="number"],
body.q input[type="date"] {
  background: var(--q-bg);
  border: 1px solid var(--q-line-strong);
  border-radius: 10px;
  box-shadow: none;
  color: var(--q-text);
}

body.q .participant-input:focus,
body.q .participant-select:focus,
body.q select:focus,
body.q input:focus {
  outline: 2px solid var(--q-accent);
  outline-offset: 1px;
  border-color: var(--q-accent);
  box-shadow: none;
}

body.q .participant-input.stock-code {
  color: var(--q-text);
  border-style: solid;
  font-family: inherit;
  letter-spacing: 0;
}

body.q .participant-input.stock-name-display {
  background: transparent;
  border-color: transparent;
  color: var(--q-text-2);
}

body.q .date-inputs label,
body.q .input-group label {
  color: var(--q-text-2);
}

body.q .date-note {
  color: var(--q-text-2);
}

/* 來賓、選股期：這張表只是讓大家看「誰選好了」，價格兩格還沒有東西，先收起來 */
body.q.q-guest.q-pick .participants-card .card-title::after {
  content: "標的開賽前隱藏";
  display: inline;
  position: static;
  width: auto;
  height: auto;
  margin-left: auto;
  background: none;
  font-size: 12px;
  font-weight: 400;
  color: var(--q-text-2);
}

body.q.q-guest.q-pick .participants-card .card-title {
  display: flex;
  align-items: baseline;
}

body.q.q-guest.q-pick .participants-header,
body.q.q-guest.q-pick .participants-header-mobile,
body.q.q-guest.q-pick .participants-grid .participant-row > .price-input,
body.q.q-guest.q-pick .participants-grid .participant-row .price-with-badge {
  display: none;
}

body.q .btn-add-participant,
body.q .btn-remove {
  background: transparent;
  border: 1px dashed var(--q-line-strong);
  box-shadow: none;
  color: var(--q-text-2);
}

/* --------------------------------------------------------------------------
   名人堂
   -------------------------------------------------------------------------- */
body.q .hall-of-fame-card,
body.q .hall-of-fame-card:hover {
  background: var(--q-card);
  border: 1px solid var(--q-line);
  box-shadow: none;
}

body.q .title-badge {
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 999px;
  box-shadow: none;
  color: var(--q-text-2);
  font-size: 12px;
  font-weight: 500;
  padding: 1px 8px;
  margin-left: 6px;
}

body.q .scoring-rules {
  display: block;
  justify-content: flex-start;
  margin: 0 0 6px;
  padding: 0;
  background: none;
  border: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--q-text-2);
  text-align: left;
}

body.q .scoring-rules * {
  color: inherit;
  white-space: normal;
}

body.q .hall-year-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}

body.q .hall-year-tab {
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 10px;
  box-shadow: none;
  color: var(--q-text-2);
  font-size: 13px;
  font-weight: 500;
}

body.q .hall-year-tab.active {
  background: rgba(155, 140, 250, 0.12);
  border-color: transparent;
  color: var(--q-accent);
  font-weight: 600;
}

body.q .hall-year-note {
  font-size: 12px;
  color: var(--q-text-2);
  margin: 0 0 8px;
}

body.q .hall-of-fame {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.q .hall-card,
body.q .hall-card:hover {
  background: var(--q-card-2);
  border: 1px solid var(--q-line);
  border-radius: 12px;
  box-shadow: none;
  transform: none;
  animation: none;
  padding: 10px 12px;
  margin: 0;
}

body.q .hall-card.champion {
  border-color: rgba(230, 180, 80, 0.55);
}

body.q .hall-card .hall-rank {
  color: var(--q-text-2);
  background: none;
  text-shadow: none;
  -webkit-text-fill-color: currentColor;
  font-size: 18px;
  font-weight: 700;
}

body.q .hall-card .hall-name {
  color: var(--q-text);
  font-size: 15px;
  font-weight: 600;
}

body.q .hall-card .streak-badge {
  background: transparent;
  border: 1px solid var(--q-gold);
  border-radius: 6px;
  box-shadow: none;
  color: var(--q-gold);
  font-size: 12px;
  font-weight: 500;
  padding: 0 6px;
  animation: none;
}

body.q .hall-card .medal {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--q-text-2);
  padding: 0;
  font-size: 13px;
}

body.q .hall-card .hall-medals {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
}

body.q .hall-card .medal {
  white-space: nowrap;
}

body.q .hall-card .hall-stats {
  color: var(--q-text-2);
  font-size: 13px;
}

body.q .hall-card .hall-points .points-value {
  color: var(--q-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

body.q .hall-card.champion .hall-points .points-value {
  color: var(--q-gold);
}

body.q .hall-card .hall-points .points-label {
  color: var(--q-text-2);
  font-size: 12px;
}

body.q .hall-detail summary {
  color: var(--q-accent);
  font-size: 13px;
  min-height: 32px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

body.q .hall-detail-grid {
  background: var(--q-bg);
  border: 1px solid var(--q-line);
  border-radius: 10px;
  color: var(--q-text-2);
}

body.q .hall-detail-grid b {
  color: var(--q-text);
}

body.q .hall-detail-note {
  color: var(--q-text-2);
}

body.q .projection-divider {
  margin: 8px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--q-line);
  background: none;
  color: var(--q-text-2);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

body.q .projection-divider::before,
body.q .projection-divider::after {
  display: none;
}

body.q .projection-divider span {
  background: none;
  padding: 0;
  color: inherit;
}

body.q .hall-card.projection {
  border-style: solid;
  opacity: 1;
}

body.q .empty-hall {
  color: var(--q-text-2);
}

/* --------------------------------------------------------------------------
   分頁：手機／平板釘在畫面底部；桌機排在頁首下方
   -------------------------------------------------------------------------- */
body.q .q-tabs {
  display: none;
}

body.q.q-ready .q-tabs.q-tabs-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--q-bg);
  border-top: 1px solid var(--q-line);
}

body.q .q-tab {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 4px;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--q-text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

body.q .q-tab svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

body.q .q-tab.is-active {
  background: rgba(155, 140, 250, 0.12);
  color: var(--q-accent);
  font-weight: 600;
}

body.q .q-tab:hover {
  color: var(--q-text);
}

body.q .q-tab.is-active:hover {
  color: var(--q-accent);
}

/* 手機／平板切到「名人堂」分頁：只留名人堂 */
@media (max-width: 1023px) {
  body.q.q-guest:not(.q-tab-hall) .hall-of-fame-card {
    display: none;
  }

  body.q.q-tab-hall .q-pick-card,
  body.q.q-tab-hall .leaderboard-card,
  body.q.q-tab-hall .action-buttons,
  body.q.q-tab-hall .settings-card,
  body.q.q-tab-hall .participants-card {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   視窗（登入、盲選、自動續賽、規則、倒數…）
   -------------------------------------------------------------------------- */
body.q .login-content,
body.q .countdown-content,
body.q .confirm-content,
body.q .progress-content,
body.q .margin-modal-content,
body.q .cute-popup-content {
  background: var(--q-card);
  border: 1px solid var(--q-line-strong);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  color: var(--q-text);
  animation: none;
}

body.q .login-modal,
body.q .countdown-modal,
body.q .confirm-modal,
body.q .progress-modal,
body.q .margin-modal {
  background: rgba(8, 10, 14, 0.78);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.q .login-title,
body.q .countdown-title,
body.q .confirm-title,
body.q .progress-title,
body.q .margin-modal-title {
  color: var(--q-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
}

body.q .login-subtitle,
body.q .countdown-message,
body.q .countdown-label,
body.q .login-btn-desc,
body.q .progress-text,
body.q .progress-details {
  color: var(--q-text-2);
}

body.q .login-btn,
body.q .login-btn:hover {
  background: var(--q-accent-solid);
  border: 1px solid var(--q-accent-solid);
  border-radius: 14px;
  box-shadow: none;
  transform: none;
  animation: none;
  color: #ffffff;
}

body.q .login-btn .login-btn-text {
  color: #ffffff;
}

body.q .login-btn .login-btn-desc {
  color: rgba(255, 255, 255, 0.86);
}

body.q .login-divider,
body.q .login-divider span {
  color: var(--q-text-2);
  background: var(--q-card);
}

/* 規則視窗的小標：用白字，金色留給第一名 */
body.q .rules-content h3,
body.q .rules-content h4 {
  color: var(--q-text);
}

/* 手機點進輸入框時，字小於 16px 會讓 iPhone 自動放大畫面 */
body.q .admin-password-input {
  font-size: 16px;
}

body.q .admin-btn-small,
body.q .countdown-close-btn,
body.q .margin-modal-close {
  background: transparent;
  border: 1px solid var(--q-line-strong);
  border-radius: 10px;
  box-shadow: none;
  color: var(--q-text);
}

body.q .countdown-close-btn {
  background: var(--q-accent-solid);
  border-color: var(--q-accent-solid);
  color: #ffffff;
  min-height: 44px;
}

body.q .countdown-days {
  color: var(--q-gold);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
}

body.q .progress-bar-container {
  background: var(--q-bg);
  border: 1px solid var(--q-line);
}

body.q .progress-bar {
  background: var(--q-accent-solid);
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   桌機（≥1024px）：兩欄。左邊這個月，右邊下個月選股與名人堂；分頁排在頁首下方
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  body.q .app-container {
    max-width: 1160px;
    padding: 20px 24px 40px;
    gap: 16px;
  }

  body.q .header {
    grid-template-columns: auto auto auto minmax(0, 1fr) auto auto auto;
    column-gap: 12px;
    row-gap: 10px;
  }

  body.q .logo {
    grid-row: 1;
    grid-column: 1;
    justify-self: start;
  }

  body.q .logo h1 {
    font-size: 15px;
    font-weight: 600;
  }

  body.q #prevMonthBtn {
    grid-row: 1;
    grid-column: 2;
  }

  body.q .current-month-badge {
    grid-row: 1;
    grid-column: 3;
    justify-self: start;
    padding: 0 4px;
  }

  body.q #nextMonthBtn {
    grid-row: 1;
    grid-column: 4;
    justify-self: start;
  }

  body.q .month-nav-btn {
    min-height: 40px;
  }

  body.q .margin-link {
    grid-row: 1;
    grid-column: 5;
  }

  body.q .q-ref-link {
    grid-row: 1;
    grid-column: 6;
  }

  body.q .role-indicator {
    grid-row: 1;
    grid-column: 7;
  }

  body.q .horse-icon {
    grid-row: 1;
    grid-column: 4;
    justify-self: end;
  }

  body.q .q-status {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding: 10px 16px;
    background: var(--q-card);
    border: 1px solid var(--q-line);
    border-radius: 12px;
    font-size: 14px;
  }

  body.q .last-updated {
    grid-row: 3;
    text-align: left;
    padding: 0 4px;
  }

  body.q.q-ready .q-tabs.q-tabs-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }

  body.q.q-ready .q-tabs.q-tabs-bottom {
    display: none;
  }

  body.q .q-tabs-top .q-tab {
    min-height: 40px;
    flex-direction: row;
    gap: 6px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 14px;
  }

  body.q .q-tabs-top .q-tab svg {
    width: 16px;
    height: 16px;
  }

  body.q .q-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: start;
  }

  body.q .q-main,
  body.q .q-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
  }

  body.q #bottomSpacer {
    height: 0;
  }

  body.q .card,
  body.q .card:hover {
    padding: 16px;
  }

  /* 排行榜一列排完 */
  body.q .leaderboard .leaderboard-item,
  body.q .leaderboard .leaderboard-item:hover {
    grid-template-columns: 34px minmax(88px, 1.1fr) auto minmax(56px, 0.8fr) auto 96px minmax(92px, auto);
    grid-template-areas:
      "rank name code sname price spark gain"
      "bar bar bar bar bar bar bar";
    column-gap: 12px;
    padding: 10px 14px;
  }

  body.q .leaderboard .leaderboard-item .sparkline-cell {
    width: 96px;
    height: 28px;
  }

  body.q .leaderboard .leaderboard-item .price-range {
    font-size: 14px;
    text-align: right;
  }

  body.q .leaderboard .leaderboard-item .stock-name-label {
    font-size: 14px;
  }

  body.q .leaderboard .leaderboard-item .gain-percent {
    font-size: 18px;
    line-height: 24px;
  }

  /* 參賽者表：左欄比原本窄，欄寬收緊，股票名稱那一欄才不會被擠到看不見 */
  body.q .participants-grid .participant-row,
  body.q .participants-header {
    grid-template-columns: 32px minmax(90px, 1.1fr) 132px minmax(72px, 1fr) 96px 96px 20px;
    gap: 10px;
  }

  body.q .participants-header span {
    white-space: nowrap;
  }
}

/* 窄桌機／橫放平板（1024–1199px）：右欄收窄一點，排行榜一列才排得下 */
@media (min-width: 1024px) and (max-width: 1199px) {
  body.q .q-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
  }

  body.q .leaderboard .leaderboard-item,
  body.q .leaderboard .leaderboard-item:hover {
    grid-template-columns: 34px minmax(72px, 1.1fr) auto minmax(44px, 0.8fr) auto 72px minmax(86px, auto);
    column-gap: 10px;
  }

  body.q .leaderboard .leaderboard-item .sparkline-cell {
    width: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.q *,
  body.q *::before,
  body.q *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
