/* G8L-211 P1-A top bar (DESIGN 6.3/6.4, user NIKKE reference 10/29): no bar background. Small glass pieces float over the
 * stage, hugging the left/top/right edges, so the eye stays on the lobby animation. Glass comes from .glass-pane
 * (game-glass.css); this file only places and sizes. Replaces compact-bar.css.
 * Measured on the 393x852 reference with safe-area top 59: avatar x 11 / y 60 / 40px, name under it, group bottom y117,
 * zeny chip y66-90, buttons flush right. r4: HP/SP and Lv/JLv+EXP are two more capsules of the same chip as Zeny (user 10/29 21:4x). r5: every capsule is the plain .glass-pane (no dark fill); number inks are darker hues.
 * --top-bar-h (44/48) is pinned by test-glass-pane-browser, so the group height is local. */
#game > #topBar.top-bar {
  --top-bar-group-h: 58px;
  --top-bar-hp: #ff9d94; /* r3: light hues for the dark capsules (same family as the level capsule's light green / gold); contrast measured in REPORT */
  --top-bar-sp: #9fcaff;
  --top-bar-jlv: #ffdf86;
  --top-bar-exp-lv: #9af0ae; /* r3d: the level capsule is dark glass with light labels */
  --top-bar-exp-job: #ffdf86;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex !important;
  align-items: flex-start;
  gap: 5px;
  height: calc(var(--top-bar-group-h) + var(--top-edge));
  margin: 0 !important;
  padding: var(--top-edge) max(0px, env(safe-area-inset-right), calc((100% - 980px) / 2)) 0
    max(11px, env(safe-area-inset-left), calc((100% - 980px) / 2)) !important;
  border: 0 !important;
  border-radius: 0;
  background: none !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  color: #1b2a41;
  font: 600 10px/14px -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  text-shadow: none;
  pointer-events: none; /* the gaps between the pieces pass taps to the page */
}
#topBar > * { pointer-events: auto; }
/* The bar leaves the flow, so the page starts below the pieces. */
@media (max-width: 720px) {
  #game.desktop { padding-top: calc(var(--top-bar-group-h, 58px) + var(--top-edge) + var(--card-gap)); }
}
/* 掛機頁（G8L-211 12/01 使用者紅圈）：按鈕列與 LOG 窗往上貼齊頂列膠囊底緣（膠囊底＝群組高 -1px），不再留卡片間距；只套掛機頁。 */
@media (max-width: 720px) {
  #game.desktop:has(> #hunt.active) { padding-top: calc(var(--top-bar-group-h, 58px) + var(--top-edge) - 1px); }
}
@media (min-width: 721px) {
  #game.desktop { padding-top: calc(var(--top-bar-group-h, 58px) + var(--top-edge) + 10px); }
}
#game { --top-bar-group-h: 58px; }
/* A glass piece: lighter shadow and smaller radius than the bottom bar's full-size pane. */
#topBar .glass-pane { box-shadow: 0 2px 8px rgb(10 20 40 / 25%), inset 0 1px 0 rgb(255 255 255 / 70%); }
#topBar .top-bar-id { position: relative; flex: none; width: 40px; height: 40px; }
#topBar .top-bar-avatar {
  display: grid;
  box-sizing: border-box;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(#8fb3e6, #4d78b8);
  color: #fff;
  font: 700 18px/1 -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}
/* Name under the avatar, inside the avatar's column (the second capsule row starts right of it); the name never widens the piece (ellipsis). */
#topBar .top-bar-who { position: absolute; top: 41px; left: 0; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#topBar .top-bar-name {
  --glass-pane-fill: var(--glass-chip-fill);
  display: block;
  box-sizing: border-box;
  max-width: 43px;
  height: 16px;
  padding: 0 5px;
  overflow: hidden;
  border-radius: 8px;
  color: var(--glass-icon-ink);
  font-size: 10px;
  line-height: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Status label: right under the button group (the capsule rows own the space under the avatar). */
#topBar .top-bar-status {
  position: absolute;
  top: 45px;
  right: 2px;
  padding: 0 5px;
  border-radius: 8px;
  background: rgb(255 255 255 / 75%);
  color: #14532d;
  font-size: 9px;
  font-weight: 700;
  line-height: 12px;
  white-space: nowrap;
}
#topBar .top-bar-status[hidden] { display: none; }
/* Two rows of capsules beside the avatar: HP/SP + Zeny + gacha tokens, then Lv/JLv + EXP. Every capsule is the same chip
 * (.top-bar-chip: 24px tall; the glass itself is .glass-pane, the same as the side rail, no glass values in this file). */
#topBar .top-bar-chips { display: flex; flex: 0 1 256px; flex-wrap: wrap; align-content: flex-start; align-items: flex-start; gap: 2px 5px; min-width: 0; margin: 6px -5px 0 0; } /* -5px: the capsules may use the 5px gap before the buttons (the last capsule ends flush against the button box, as before) */
#topBar .top-bar-row { display: contents; } /* the capsules flow in one wrapping line, so a capsule that does not fit beside the buttons drops to the next line instead of sliding under them */
#game #topBar .top-bar-chip {
  --glass-pane-fill: var(--glass-chip-fill);
  display: flex;
  flex: none;
  align-items: center;
  box-sizing: border-box;
  gap: 8px;
  min-width: 0;
  height: 24px;
  margin: 0;
  padding: 0 8px !important;
  border-radius: 12px !important;
  color: var(--glass-icon-ink) !important;
  font: 700 11px/1 -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#game #topBar .top-bar-hp { color: var(--top-bar-hp); }
#game #topBar .top-bar-sp { color: var(--top-bar-sp); }
#game #topBar .top-bar-jlv { color: var(--top-bar-jlv); }
#game #topBar .top-bar-chip b { font: inherit; } /* #game b would otherwise set its own size */
#game #topBar .top-bar-zeny { cursor: pointer; }
/* Under 360px the vitals and Zeny capsules no longer share a line beside the three buttons: the capsules take three lines, so the group is one line taller. */
@media (max-width: 359px) {
  #game, #game > #topBar.top-bar { --top-bar-group-h: 84px; }
  /* Zeny stays first; the token capsule takes the free space beside it so the capsules stay on three lines. */
  #topBar .top-bar-vitals { order: 1; }
  #topBar .top-bar-exp { order: 2; }
}
#topBar .top-bar-tokens[hidden] { display: none; }
#game #topBar .top-bar-tokens { padding-left: 4px !important; } /* the 14px picture takes the room the old 10px dot plus 4px of padding used, so the capsule is no wider than before */
#topBar .top-bar-tokens::before { content: ''; flex: none; width: 14px; height: 14px; margin-right: -4px; background: url('/api/gacha/assets/gods/item-icons/gacha-currency.png') center / contain no-repeat; } /* the gacha currency picture (the file the gacha page serves) instead of a word: the row is narrow; a failed load leaves no broken-image box. Smooth scaling on purpose: the 1254px art is shrunk ~90x, where pixelated would alias */
#topBar .top-bar-actions { position: relative; display: flex; flex: none; align-items: center; margin-left: auto; }
#game #topBar .top-bar-icon,
#game #topBar .quick-audio {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px !important;
  height: 44px !important;
  min-width: 0 !important;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--glass-icon-ink) !important;
  box-shadow: none !important;
  cursor: pointer;
}
/* 32px glyph disc inside the 40x44 hit area (the disc is the visible piece, so it carries the glass look).
   The look (border, fill, blur, shadow) is shared with the chat dock icon (chat-dock.css); only the position is the bar's own. */
#topBar .top-bar-icon::before,
#topBar .quick-audio::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 4px;
}
#topBar .top-bar-icon::before,
#topBar .quick-audio::before,
.chat-dock-icon,
.odin-fs-bar > button > i {
  width: 32px;
  height: 32px;
  border: 1px solid rgb(255 255 255 / 50%);
  border-radius: 50%;
  background: var(--glass-icon-fill);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
}
#topBar .top-bar-icon > svg,
#topBar .quick-audio > svg { position: relative; width: 18px; height: 18px; }
#topBar .quick-audio[data-audio-state='muted']::before { background: rgb(96 30 38 / 72%); }
#topBar .quick-audio[data-audio-state='muted'] { color: #ffd9d9 !important; }
#topBar .top-bar-dot {
  position: absolute;
  top: 6px;
  right: 5px;
  min-width: 10px;
  height: 10px;
  border-radius: 5px;
  background: #d23b47;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  line-height: 10px;
  text-align: center;
}
#topBar .top-bar-dot:not([hidden]) { display: block; }
/* 更多 = the system menu (P1-B, RO Escape window): 登出, the server lamp and the existing 系統 page. Phone: flush left/right
 * (max(4px, inset)), every tap target 44px, scrolls inside the screen instead of overflowing. */
#topBar .top-bar-menu {
  --menu-edge-l: max(4px, env(safe-area-inset-left));
  --menu-edge-r: max(4px, env(safe-area-inset-right));
  position: absolute;
  top: 100%;
  left: var(--menu-edge-l);
  right: var(--menu-edge-r);
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-height: calc(100dvh - var(--top-bar-group-h) - var(--top-edge) - 4px - max(8px, env(safe-area-inset-bottom)));
  margin-top: 4px;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 16px;
}
/* Desktop width 568 (G8L-211 Odin G4, W-PREVIEW-CROP): the settings pages keep two columns above 650px (styles.css .audio-settings), each
 * 90 + 100 + 44 + 2 x 8 gaps = 250, 10 between them = 510, the width of the damage number preview frame. Around that: 24 settings padding
 * + 2 window border + 12 menu padding + 2 menu border = 550, + 17 for a classic scrollbar = 567. At 440 the right 96px were cut off. */
@media (min-width: 721px) {
  #topBar .top-bar-menu { left: auto; right: max(var(--menu-edge-r), calc((100% - 980px) / 2)); width: min(568px, calc(100% - 8px)); }
}
#topBar .top-bar-menu > * { min-width: 0; }
#topBar .top-bar-menu #worldLamp { flex: 1 1 auto; }
#topBar .top-bar-menu #system { flex: 1 0 100%; display: grid; gap: 6px; color: #1b2a41; }
#topBar .top-bar-menu :is(button, select, [role='tab']) { min-height: 44px; }
#topBar .top-bar-menu :is(input[type='range'], .audio-check) { min-height: 44px; }
#topBar .top-bar-menu[hidden] { display: none; }
#game #topBar #worldLamp {
  display: inline-flex;
  align-items: center;
  height: 30px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 15px;
  background: rgb(255 255 255 / 55%);
  color: #263954;
  font: 700 12px/1 'Microsoft JhengHei', sans-serif;
  text-shadow: none;
}
#topBar #worldLamp::before { content: ''; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #c9a227; }
#topBar #worldLamp.online::before { background: #2fb45a; }
#game #topBar #logout {
  margin: 0 !important;
  padding: 0 14px !important;
  border: 0 !important;
  border-radius: 22px !important;
  background: linear-gradient(#6f9ad6, #3f69a8) !important;
  color: #fff !important;
  font: 700 12px/1 'Microsoft JhengHei', sans-serif;
  box-shadow: none !important;
}
@media (min-width: 721px) {
  #topBar .top-bar-name { font-size: 11px; }
  #game #topBar .top-bar-chip { font-size: 12px; }
  #game > #topBar.top-bar { gap: 8px; }
}

/* G8L-211 P1-F: the avatar is the 角色 button (RO BasicInfo "info" -> WinStats / SkillList). Same 40px disc as before; the 44px tap area
 * extends past it with a pseudo element, so nothing in the bar moves. */
#topBar button.top-bar-avatar { padding: 0; cursor: pointer; }
#topBar .top-bar-avatar::after { content: ''; position: absolute; inset: -2px; }
#topBar .top-bar-avatar[aria-expanded='true'] { outline: 2px solid #fff; }
/* The 角色 overlay: a sheet under the bar with the same geometry as the 更多 menu (flush left/right at max(4px, inset), every control 44px,
 * scrolls inside the screen). It holds the existing #character / #skills DOM, nothing is copied; only one sheet is open at a time. */
#topBar .top-bar-sheet {
  --sheet-edge-l: max(4px, env(safe-area-inset-left));
  --sheet-edge-r: max(4px, env(safe-area-inset-right));
  position: absolute;
  top: 100%;
  left: var(--sheet-edge-l);
  right: var(--sheet-edge-r);
  box-sizing: border-box;
  display: grid;
  gap: 6px;
  max-height: calc(100dvh - var(--top-bar-group-h) - var(--top-edge) - 4px - max(8px, env(safe-area-inset-bottom)));
  margin-top: 4px;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 16px;
  color: #1b2a41;
  font: 13px/1.4 'Microsoft JhengHei', sans-serif;
}
@media (min-width: 721px) {
  #topBar .top-bar-sheet { left: max(var(--sheet-edge-l), calc((100% - 980px) / 2)); right: auto; width: min(560px, calc(100% - 8px)); }
}
#topBar .top-bar-sheet[hidden] { display: none; }
#topBar .top-bar-sheet > * { min-width: 0; }
#topBar .top-bar-sheet .ro-subtabs > button { flex: 1 1 0; min-height: 44px; }
#game #topBar .top-bar-sheet :is(#resetStats, #resetSkills) { min-height: 44px !important; }
/* The 28px + keeps its look; its tap area grows to 44px around it (rows are 44px tall so neighbours never overlap). */
#game #topBar .top-bar-sheet .base-stats > [data-stat-row] { min-height: 44px; }
#game #topBar .top-bar-sheet .ro-status-increase { position: relative !important; }
#game #topBar .top-bar-sheet .ro-status-increase::after { content: ''; position: absolute; inset: -9px; }
/* header.brand carries a blanket glass rule for its buttons (game-glass.css, "#game .brand button"), which also lands on the sub page tabs; the shared active look wins again here. */
#game #topBar .top-bar-sheet .ro-subtabs > button.active,
#game #topBar .top-bar-sheet .ro-subtabs > button[aria-selected='true'] {
  border-color: rgb(255 255 255 / 75%) !important;
  background: var(--glass-blue) !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgb(10 20 40 / 35%);
}

/* r3d (user 10/30, mock4): the level capsule is dark glass (the shared .glass-pane with a darker --glass-pane-fill, never a glass of its own) with white
 * numbers and a light green Lv / light gold Job label. Folded: "Lv 99  Job 50" and a thin bar under each (how full the EXP is); unfolded (tap, aria-expanded):
 * the percentages join the labels and the bars grow with them. */
#game #topBar .top-bar-exp {
  align-items: flex-start;
  gap: 10px;
  padding: 3px 9px 0 !important;
  border-color: rgb(255 255 255 / 35%);
  color: #fff !important;
  font-size: 11px;
  cursor: pointer;
}
#game #topBar .top-bar-exp > span { display: grid; gap: 2px; align-content: start; min-width: 0; }
#game #topBar .top-bar-exp .top-bar-seg { display: flex; gap: 4px; line-height: 14px; }
#game #topBar .top-bar-exp .top-bar-lv { color: var(--top-bar-exp-lv); }
#game #topBar .top-bar-exp .top-bar-jlv { color: var(--top-bar-exp-job); }
#game #topBar .top-bar-exp .top-bar-pct { color: #fff; }
#game #topBar .top-bar-exp[aria-expanded='false'] .top-bar-pct { display: none; }
#game #topBar .top-bar-exp .top-bar-bar { display: block; height: 3px; overflow: hidden; border-radius: 2px; background: rgb(255 255 255 / 28%); }
#game #topBar .top-bar-exp .top-bar-bar > u { display: block; width: 0; height: 100%; border-radius: inherit; background: currentColor; text-decoration: none; }
