/* 04-panels.css: dock, panels, queue, and dialogs.
   Each dock button opens its panel in the shared space above the dock; opening one closes the previous panel. */

/* ===================================================================
   FLOATING DOCK
   =================================================================== */
.game-dock {
  position: absolute;
  z-index: 11;
  right: var(--ui-dock-right);
  bottom: var(--ui-dock-bottom);
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 14px;
  background: var(--ui-dock-background);
  box-shadow: 0 4px 0 var(--ui-edge-color), 0 10px 24px #0006;
}
.dock-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: var(--ui-dock-button-width);
  padding: 8px 10px 7px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--ui-dock-button-background);
  color: var(--ui-dock-button-color);
  box-shadow: none;
  transition: transform .12s ease, background-color .12s ease;
}
.dock-button[hidden] { display: none; }
.dock-button:hover { background: var(--ui-dock-button-hover); transform: translateY(-2px); }
.dock-button:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
.dock-button.active {
  border-color: var(--ink);
  background: var(--ui-dock-active-background);
  color: var(--ink);
  transform: translateY(-2px);
}
.dock-icon { font-size: var(--ui-icon-dock-size); line-height: 1; }
.dock-label { font-size: 18px; line-height: 1; letter-spacing: .03em; white-space: nowrap; }

/* ===================================================================
   FLOATING PANEL: HEADER, TABS, AND CONTENT
   =================================================================== */
.menu-overlay {
  position: absolute;
  /* Above the entire game HUD. */
  z-index: 10;
  right: var(--ui-dock-right);
  bottom: calc(var(--ui-dock-bottom) + var(--ui-dock-height) + 10px);
  /* Grow with content up to the space between the top edge and dock. */
  max-height: calc(100% - var(--ui-float-panel-top) - var(--ui-dock-bottom) - var(--ui-dock-height) - 10px);
  width: min(var(--ui-float-panel-width), calc(100% - 2 * var(--ui-dock-right)));
  display: flex;
  flex-direction: column;
  border: var(--ui-menu-border);
  border-radius: 14px;
  background: var(--ui-menu-background);
  box-shadow: var(--ui-menu-shadow);
  overflow: hidden;
  animation: float-panel-in .14s ease-out;
}
@keyframes float-panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.float-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 12px 10px 16px;
  background: var(--ui-menu-tabs-background);
  color: var(--paper);
}
.float-panel-icon { font-size: var(--ui-icon-panel-size); line-height: 1; }
.float-panel-header h2 { flex: 1; margin: 0; font: 18px var(--ui-heading-font); letter-spacing: .04em; }
.float-panel-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid #4a5664;
  border-radius: 50%;
  background: transparent;
  color: var(--paper);
  font-size: 18px;
  line-height: 1;
}
.float-panel-close:hover { background: #ffffff1f; }
/* Classes such as .small define display and would otherwise override hidden. */
.menu-content [hidden] { display: none !important; }
.menu-content { flex: 1 1 auto; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: var(--ui-menu-content-padding); }
.menu-content .panel,
.menu-content .sidebar {
  display: block;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
/* The panel header already names the section; hide duplicate headings. */
.menu-content .panel > .eyebrow,
.menu-content .panel > h1 { display: none; }
.menu-content h2 { margin: 18px 0 8px; font-size: 18px; }
.menu-content .types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.menu-content .type-card { min-width: 0; }
.menu-content .actions { flex-wrap: wrap; }
.menu-content .shop-items { grid-template-columns: var(--ui-menu-shop-columns); }
.menu-content :is(input, select, button) { max-width: 100%; min-width: 0; }
.menu-content .shop-item { grid-template-columns: 72px minmax(0, 1fr); }
.menu-content #settingsActions .header-actions { display: grid; gap: 12px; color: var(--ink); }
.menu-content #settingsActions .account-badge { justify-self: start; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--mint); font-size: 18px; }
.menu-content #settingsActions #signOut { margin: 0; background: var(--ui-secondary-background); color: var(--ui-leave-color); }
.menu-content #settingsActions .language { display: grid; gap: 6px; font-size: 18px; }

/* Readable text and controls inside panels. */
.menu-content :is(.panel-help, .muted, .shop-section-help, .shop-item p) {
  margin: 4px 0 10px;
  color: var(--ui-panel-help-color);
  font: 18px/1.45 var(--ui-body-font);
  text-transform: none;
}
.menu-content .menu-section {
  margin-bottom: 14px;
  padding: 14px;
  border: 2px solid var(--ui-card-border-color);
  border-radius: 12px;
  background: var(--ui-card-background);
}
.menu-content .menu-section[hidden] { display: none; }
.menu-content .menu-section h3 { margin: 0 0 2px; font-size: 18px; }
.menu-content label { font-size: 18px; }
.menu-content :is(input, select) { border-radius: 8px; }
.menu-content button {
  border-radius: 8px;
  transition: transform .1s ease, filter .1s ease;
}
.menu-content button:not(:disabled):hover { filter: brightness(1.06); transform: translateY(-1px); }
.menu-content button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.menu-content .primary { box-shadow: 0 3px 0 var(--ink); }
.menu-content .field-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 12px; }
.menu-content .field-row > label { display: grid; flex: 1 1 180px; gap: 6px; }
.menu-content .field-row > label[hidden] { display: none; }
.menu-content #createRoom { width: 100%; padding: 12px; font-size: 18px; }
.menu-content .join-box { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 8px 0 0; }
.menu-content .join-box label { display: grid; flex: 1 1 140px; gap: 6px; }
.menu-content .join-box button { flex: 1 1 100%; }
.menu-content #roomBrowserScreen { margin: 0; }
.menu-content #roomBrowserScreen h3 { margin: 0 0 6px; font-size: 18px; }
.menu-content #roomBrowserScreen h3 ~ h3 { margin-top: 18px; }
.menu-content .room-browser-entry {
  flex-wrap: wrap;
  margin: 6px 0;
  padding: 8px 10px;
  border: 2px solid #e6dcc3;
  border-radius: 10px;
  background: var(--paper);
}
.menu-content .room-browser-name { display: flex; align-items: center; gap: 8px; }
.menu-content .room-browser-name small { color: var(--ui-panel-help-color); font-size: 18px; }
.menu-content .room-browser-entry .small { margin: 0; }
.menu-content #roomBrowserScreen .actions { margin-top: 12px; }
.menu-content .wallet { border-radius: 12px; }
.menu-content .wallet-amount b { font-size: 18px; }
.menu-content #leaveBattleButton { width: 100%; }

/* ===================================================================
   AUTOMATIC MATCH QUEUE
   =================================================================== */
/* Stage mode buttons are configured in the Stage creator and styled in queue-mode-button.css.
   This section controls the queue panel and searching card. */
.menu-content .queue-section { border-color: var(--ink); background: var(--ui-notice-background); }
.queue-section .error:empty { display: none; }
.queue-searching { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 12px; border: 2px dashed var(--ink); border-radius: 12px; background: #fffdf5; }
.queue-searching[hidden] { display: none; }
.queue-searching-text { display: grid; flex: 1; gap: 3px; min-width: 0; }
.queue-searching-text b { font-size: 18px; }
.queue-searching-text small { color: var(--ui-panel-help-color); font: 18px var(--ui-body-font); }
.menu-content .queue-searching button { flex-shrink: 0; padding: 8px 12px; }
.queue-spinner {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 3px solid #0002;
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: queue-spin .8s linear infinite;
}
@keyframes queue-spin { to { transform: rotate(360deg); } }
/* Floating queue reminder stays visible when the panel closes. */
.queue-pill {
  position: absolute;
  z-index: 9;
  top: 1.5%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 999px;
  background: var(--ui-dock-background);
  color: var(--ui-dock-button-color);
  font-size: 18px;
  transform: translateX(-50%);
  box-shadow: 0 3px 0 var(--ui-edge-color);
}
.queue-pill[hidden] { display: none; }
.queue-pill .queue-spinner { width: 14px; height: 14px; border-color: #fff3; border-top-color: var(--mint); }
.queue-pill button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #ffffff1f;
  color: inherit;
  font-size: 18px;
  box-shadow: none;
}
/* Brief top-screen notice for queue, administration, and muted chat. */
.queue-notice {
  position: absolute;
  z-index: 11;
  top: 7%;
  left: 50%;
  max-width: min(92%, 420px);
  padding: 8px 14px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 12px;
  background: var(--ui-notice-background);
  color: var(--ink);
  font: 18px/1.35 var(--ui-body-font);
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 3px 0 var(--ui-edge-color);
}
.queue-notice[hidden] { display: none; }

/* ===================================================================
   MATCH FOUND DIALOG
   =================================================================== */
/* Confirmation dialog shared by all automatic queue stages. */
.ready-check {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: #0b0f14a6;
}
.ready-check[hidden] { display: none; }
/* On top of everything (popover="manual", showOnTop in 01-core.js): the whole screen behind the
   window, and none of the browser's own popover look. Without popovers, still above the page. */
.ready-check[popover] { position: fixed; inset: 0; z-index: 10001; width: auto; height: auto; max-width: none; max-height: none;
  margin: 0; border: 0; color: inherit; overflow: auto; }
.ready-check-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(100%, 380px);
  padding: 22px 20px 20px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--ui-notice-background);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 6px 0 var(--ink);
  animation: ready-check-pop .25s ease-out;
}
@keyframes ready-check-pop { from { transform: scale(.85); opacity: 0; } }
.ready-check-icon { font-size: var(--ui-icon-ready-check-size); line-height: 1; }
.ready-check-card h2 { margin: 0; font: 18px var(--ui-heading-font); }
.ready-check-card p { margin: 0; font: 18px/1.4 var(--ui-body-font); }
.ready-check-timer { width: 100%; height: 10px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: #fff; }
.ready-check-timer span { display: block; height: 100%; background: var(--orange); transform-origin: left; }
.ready-check-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ready-check-slots span { width: 16px; height: 16px; border: 2px solid var(--ink); border-radius: 50%; background: #fff; }
.ready-check-slots span.on { background: var(--mint); }
.ready-check-card .ready-check-status { color: var(--ui-panel-help-color); font-size: 18px; }
.ready-check-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.ready-check-actions[hidden] { display: none; }
.ready-check-actions button { flex: 1 1 140px; padding: 12px 16px; font-size: 18px; }
#readyCheckAccept { background: var(--mint); }

/* ===================================================================
   CONFIRMATION DIALOG
   =================================================================== */
/* Use the floating panels' header, border, and colors. */
.confirm-dialog {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--ui-dialog-backdrop);
}
.confirm-dialog[hidden] { display: none; }
.confirm-dialog-card {
  width: min(100%, var(--ui-dialog-width));
  overflow: hidden;
  border: var(--ui-menu-border);
  border-radius: var(--ui-dialog-radius);
  background: var(--ui-menu-background);
  box-shadow: var(--ui-menu-shadow);
  animation: float-panel-in .14s ease-out;
}
.confirm-dialog-body { display: grid; gap: 16px; padding: 18px 16px 16px; }
.confirm-dialog-message { margin: 0; color: var(--ui-dialog-message-color); font: var(--ui-dialog-message-size)/1.45 var(--ui-body-font); }
.confirm-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.confirm-dialog-actions button {
  flex: 1 1 120px;
  padding: 11px 16px;
  border-radius: 8px;
  color: var(--ink);
  transition: transform .1s ease, filter .1s ease;
}
.confirm-dialog-actions button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.confirm-dialog-actions button:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.confirm-dialog-cancel { background: var(--ui-dialog-cancel-background); }
.confirm-dialog-confirm { background: var(--ui-dialog-confirm-background); box-shadow: 0 3px 0 var(--ink); }
.confirm-dialog.danger .confirm-dialog-confirm { background: var(--ui-dialog-danger-background); color: var(--ui-dialog-danger-color); }
.confirm-dialog button { cursor: pointer; }

/* ===================================================================
   ROOM AND RANKING PANELS
   =================================================================== */
/* Reuse the other panels' card appearance. */
.menu-content .sidebar > section {
  margin: 0 0 12px;
  padding: 14px;
  border: 2px solid var(--ui-card-border-color);
  border-radius: 12px;
  background: var(--ui-card-background);
  box-shadow: none;
}
.menu-content .room-card strong { display: block; margin: 4px 0 2px; font-size: 26px; letter-spacing: .12em; }
.menu-content .battle-map-picker { display: grid; gap: 6px; margin-top: 12px; font-size: 18px; }
.menu-content .sidebar > .leave { width: 100%; margin: 0 0 8px; }
/* On light backgrounds, highlight the local player's ranking row in dark green. */
.menu-content .kill-rank-list li { color: var(--ink); }
.menu-content .kill-rank-list .my-kill-rank { color: #2f7a22; font-weight: 700; }

/* ===================================================================
   CURSORS AND SPECIAL STATES
   Battle crosshair, hidden battle controls, frozen matches, and administrator mode.
   =================================================================== */
/* Default cursor in the hall and waiting room. */
body, canvas {
  cursor: default;
}

/* Crosshair in the battle arena. */
body.state-battle canvas {
  cursor: crosshair; /* Optional image cursor: url('../../assets/crosshair.png') 16 16, crosshair. */
}

/* Menus, buttons, chat, and in-game controls retain the pointer cursor. */
body.state-battle button,
body.state-battle input,
body.state-battle select,
body.state-battle .menu-overlay,
body.state-battle .chat-card,
body.state-battle .hud-toggle,
body.state-battle .dock-button {
  cursor: pointer !important;
}

body.state-battle input[type="text"] {
  cursor: text !important;
}

/* Battles and Settings remain accessible during combat. */
/* Buttons created in the editor (hud-custom-buttons.js) appear where the layout shows them, battles included. */
body.state-battle #gameDock .dock-button:not([data-menu-tab="arena"]):not(#menuToggle):not(#fullscreenToggle):not(.dock-custom-button),
body.state-battle #arenaMenu > :not(#battleExit):not(#arenaKillRanking),
body.state-battle #roomBrowserScreen,
body.state-battle .sidebar {
  display: none !important;
}

/* Match frozen notice: editor > Live matches > Enter match. */
.frozen-banner {
  position: absolute;
  z-index: 11;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92%, 440px);
  padding: 8px 16px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 12px;
  background: var(--ui-frozen-background);
  color: var(--ink);
  font: 700 18px/1.35 var(--ui-body-font);
  text-align: center;
  box-shadow: 0 3px 0 var(--ui-edge-color);
  pointer-events: none;
}
.frozen-banner[hidden] { display: none; }
/* ADMIN MODE bar visible to the administrator inside a match. */
.admin-play-bar {
  position: absolute;
  z-index: 11;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: min(94%, 620px);
  padding: 8px 12px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 12px;
  background: var(--ui-admin-bar-background);
  color: var(--ink);
  font: 700 18px/1.35 var(--ui-body-font);
  box-shadow: 0 3px 0 var(--ui-edge-color);
}
.admin-play-bar[hidden] { display: none; }
.admin-play-bar button { min-height: 32px; padding: 4px 12px; }
/* Administrator sessions have no player account; hide account menus. */
body.admin-play #gameDock,
body.admin-play #lobbyControls { display: none; }

.admin-watch-controls {
  position: absolute;
  z-index: 12;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  width: min(94%, 850px);
  padding: 8px 12px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 10px;
  background: #182029ed;
  color: #fffdf5;
  font: 700 18px/1.35 var(--ui-body-font);
  box-shadow: 0 3px 0 var(--ui-edge-color);
}
.admin-watch-controls[hidden] { display: none; }
.admin-watch-controls.is-collapsed { top: 52px; left: 12px; width: max-content; max-width: calc(100% - 24px); padding: 4px; transform: none; }
.admin-watch-controls.is-collapsed > :not(#adminWatchToggle) { display: none; }
.admin-watch-controls label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.admin-watch-controls select, .admin-watch-controls button { min-height: 30px; padding: 3px 8px; font: inherit; }
.admin-watch-legend { flex-basis: 100%; text-align: center; font-weight: 400; }
body.admin-watch #frozenBanner { top: 100px; }
body.admin-watch #gameDock,
body.admin-watch #chatToggle,
body.admin-watch #chatCard,
body.admin-watch #mobileControls,
body.admin-watch #abilityHud { display: none !important; }

/* ===================================================================
   SKILL LABORATORY (index.html#skill-lab=ID)
   Show the arena, skill bar, and dummies; keep the damage meter in the corner.
   =================================================================== */
body.skill-lab { overflow: hidden; background: #101419; }
body.skill-lab .shell:has(#gameScreen:not([hidden])) { padding: 0; }
body.skill-lab #gameDock,
body.skill-lab #lobbyControls,
body.skill-lab #chatToggle,
body.skill-lab #chatCard,
body.skill-lab #practiceControls,
body.skill-lab #tournamentStatusBadge,
body.skill-lab #globalTournamentNotice,
body.skill-lab #queuePill,
body.skill-lab #queueNotice,
body.skill-lab #partyHud,
body.skill-lab #spectatorFollow,
body.skill-lab #matchClock,
body.skill-lab #pingIndicator,
body.skill-lab #privateMessageToast,
body.skill-lab .sidebar { display: none !important; }
.skill-lab-meter {
  position: absolute;
  z-index: 6;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 14px;
  padding: 5px 10px;
  border: 2px solid var(--ui-edge-color);
  border-radius: 8px;
  background: #182029e0;
  color: #fffdf5;
  font: 700 16px/1.2 var(--ui-body-font);
  pointer-events: none;
}
.skill-lab-meter[hidden] { display: none; }
.skill-lab-meter b { color: #ffd23f; }

/* ===================================================================
   CHANGE PASSWORD (MENU > SETTINGS)
   =================================================================== */
.menu-content .password-form { display: grid; gap: 8px; margin-top: 14px; }
.menu-content .password-form label { display: grid; gap: 4px; }
.menu-content .password-form .error { min-height: 0; }

/* ===================================================================
   EFFECTS VOLUME (MENU > SETTINGS)
   =================================================================== */
.menu-content .sound-settings { display: grid; gap: 16px; margin-top: 14px; }
.menu-content .sound-settings label { display: grid; gap: 6px; }
.menu-content .sound-settings input[type="range"] { width: 100%; padding: 0; accent-color: var(--orange); }
.menu-content .game-display-settings { display: grid; gap: 10px; }
/* Settings in tabs: General, Sound, Display, Names, Account. */
.menu-content .settings-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 0; }
#settingsMenu .settings-tabs button { min-width: 0; padding: 7px 1px; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
@media (max-width: 560px) { #settingsMenu .settings-tabs button { font-size: min(15px, 3.4vw); } }
.menu-content [data-settings-page][hidden] { display: none; }
.menu-content .name-art-settings { display: grid; gap: 10px; }
.menu-content .name-art-settings > label { display: grid; gap: 6px; }
.menu-content .name-art-settings select { width: 100%; }
.menu-content .game-display-settings > label { display: grid; gap: 6px; }
.menu-content .game-display-settings select,
.menu-content .game-display-settings input[type="number"] { width: 100%; }
.menu-content .game-custom-aspect { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: end; }
.menu-content .game-custom-aspect label { display: grid; gap: 6px; }
.menu-content .game-custom-aspect > span { padding-bottom: 10px; font-weight: 700; }
.menu-content .game-render-resolution { font-weight: 700; }

/* ===================================================================
   ROOM NAME: EDITABLE BY THE HOST IN THE WAITING ROOM
   =================================================================== */
.menu-content .room-name { margin: 4px 0 0; font: 700 18px/1.3 var(--ui-game-font); overflow-wrap: anywhere; }
.menu-content .room-name-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 10px 0 4px; }
.menu-content .room-name-form label { display: grid; flex: 1 1 160px; gap: 4px; }
.menu-content .room-name-form .small { margin: 0; }

/* Full screen uses an icon in the dock; its name remains available on hover and to screen readers. */
.dock-button.dock-icon-only .dock-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Narrow game windows use icon-only dock controls and lift chat above the dock or skill bar.
   fitGameHud measures the required space in --chat-lift. */
#gameScreen .world-wrap.compact-dock .dock-label { display: none; }
#gameScreen .world-wrap.chat-above-dock .chat-card { bottom: var(--chat-lift, calc(var(--ui-dock-bottom) + var(--ui-dock-height) + 10px)); }
/* Lift the skill bar when the dock overlaps it, including with icon-only controls. */
#gameScreen .world-wrap.skills-above-dock .ability-hud { bottom: var(--skills-lift); }
