/* =====================================================================================================
   APEX GP v6.4 - UI layer (loaded last)
   1. One compact, content-sized button family: no full-width bars, no italics, text always fits.
   2. Conditions panel has a fixed size, so the weather text can never resize the buttons.
   3. Draggable quick-controls bar (settings / sound / fullscreen).
   4. Lobby: ready badges and the "waiting for others" button state.
   ===================================================================================================== */
:root { --bh: clamp(32px, 7.6vmin, 38px); --sh: clamp(26px, 6.3vmin, 30px); --br: 10px; }

/* ---------- 1. buttons ---------- */
.cta, .ghost, .go {
  width: auto !important; min-width: 0; max-width: 100%; height: var(--bh) !important; padding: 0 18px !important; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px !important; font-weight: 700; font-style: normal !important; letter-spacing: 0.07em !important; line-height: 1; text-transform: uppercase; text-shadow: none;
  white-space: nowrap; border-radius: var(--br) !important; transition: transform .12s, filter .15s, background .15s, border-color .15s;
}
.cta, .go { min-width: 112px; }
.ghost { min-width: 84px; }

/* primary: flat accent fill, a thin highlight, a soft shadow (no heavy glow) */
.cta, .go {
  color: var(--accent-ink, #fff);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, #fff 10%), color-mix(in srgb, var(--accent) 88%, #000 12%));
  border: 1px solid color-mix(in srgb, var(--accent) 60%, #fff 40%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent);
}
.cta:hover, .go:hover { filter: brightness(1.08); }
.cta:active, .go:active, .ghost:active { transform: scale(0.97); }

/* secondary: quiet glass */
.ghost {
  color: #fff; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.ghost:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); filter: none; }

/* button rows: right-aligned, wrap instead of squashing */
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; }
.actions.center { justify-content: center; margin-top: 4px; }
.card .cta, .card .ghost { width: auto !important; margin-top: 0 !important; }
.setup .actions { margin-top: 6px; }
.setup .cta { margin: 0 !important; }
.result-actions { display: flex !important; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.result-actions .cta, .result-actions .ghost { margin: 0 !important; }

/* pause menu: a narrow stacked list, not wide bars */
#pause .card { display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: min(240px, 90vw); min-width: 0; text-align: center; }
#pause .card h2 { margin-bottom: 2px; }
#pause .card .cta, #pause .card .ghost { width: 100% !important; }

/* segmented controls: buttons size to their text and wrap to a second row rather than clip */
.seg:not(.tiles) { display: flex !important; flex-wrap: wrap; gap: 3px; padding: 3px !important; border-radius: var(--br) !important; background: rgba(0,0,0,0.32); border: 1px solid rgba(255,255,255,0.1); }
.seg:not(.tiles) button {
  flex: 1 1 0; min-width: min-content; height: var(--sh) !important; padding: 0 6px !important; border-radius: 7px !important;
  font-size: 11.5px !important; font-weight: 600; letter-spacing: 0.03em !important; white-space: nowrap; text-transform: none;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.seg:not(.tiles) button.on { background: rgba(255,255,255,0.17); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -2px 0 var(--accent); }
.v-setup .pair .seg { display: flex !important; }

/* home mode tiles: text always inside, never clipped by an ellipsis */
html body .mode { padding: 0 10px !important; }
html body .modes .mode span { overflow: visible; text-overflow: clip; font-size: clamp(10px, min(2.3vmin, 1.5vw), 13.5px); letter-spacing: 0.05em; }
html body .mode em { overflow: visible; text-overflow: clip; font-size: clamp(8px, min(1.7vmin, 1.1vw), 10.5px); }
.corner { white-space: nowrap; }
.tab span { white-space: nowrap; }

/* in the settings card the footer sits on its own full row */
#settings .card > .actions { grid-column: 1 / -1; }
#settings .field .hint { margin: 6px 2px 0; }
#settings .field .hint:empty { display: none; }

/* online race menu */
.mp-join { align-items: center; }
html body .mp-join input { height: var(--bh); }
html body .mp-join .cta { width: auto !important; min-width: 96px; margin: 0; }
.mp-top-btns .cta, .mp-top-btns .ghost { height: 34px !important; padding: 0 14px !important; font-size: 11px !important; }
.mp-say .ghost { height: 34px !important; padding: 0 14px !important; font-size: 11px !important; min-width: 0; }

/* ---------- 2. conditions panel: fixed size, so the weather text never changes the button sizes ---------- */
.v-cond .panel { width: min(max(calc(var(--u) * 40), 290px), 94vw); box-sizing: border-box; }
.seg.tiles.t4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg.tiles.t5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg.tiles button { min-width: 0; white-space: nowrap; font-size: clamp(9px, calc(var(--u) * 1.1), 11px); padding: 0 0 5px; }
.cond-hint { height: 3.9em; min-height: 0; overflow: hidden; margin: 8px 2px 8px; font-size: 11.5px; line-height: 1.3; }

/* ---------- 3. quick-controls bar: floats above menus and lobby, draggable by its grip ---------- */
html body .pill { position: fixed; z-index: 36; top: calc(var(--safe-t) + var(--pad)); right: calc(var(--safe-r) + var(--pad)); flex-direction: row; align-items: center; touch-action: none; }
.pill.hidden { display: none !important; }
.pill .grip { width: 16px; height: var(--ctl); display: grid; grid-template-columns: repeat(2, 3px); grid-auto-rows: 3px; gap: 3px; align-content: center; justify-content: center; cursor: grab; touch-action: none; border-radius: 8px; }
.pill .grip i { width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,0.5); }
.pill .grip:hover i { background: rgba(255,255,255,0.85); }
.pill.moving { cursor: grabbing; box-shadow: 0 10px 28px rgba(0,0,0,0.6); border-color: var(--accent); }
.pill.moving .grip { cursor: grabbing; }
.pill #btnFull.on { color: var(--accent); }
/* the old per-view positions of the bar no longer apply */
#menu[data-view="car"] .pill, #menu[data-view="driver"] .pill { top: auto; }

/* ---------- 4. lobby ---------- */
.mp-p { grid-template-columns: 5px 1fr auto !important; align-items: center; }
.mp-p i { grid-row: 1 / 3; }
.mp-p em { grid-row: 1 / 3; grid-column: 3; font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.07); }
.mp-p.rdy em { color: #0e1a12; background: #4ee08a; }
#mpStart { min-width: 132px; }
#mpStart.waiting { color: #fff; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); box-shadow: none; }
@media (max-height: 520px) { .mp-p em { font-size: 9px; padding: 2px 6px; } }

/* the bar now lives outside #menu, so it carries its own icon styling */
.pill svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pill button.off #sndWave { opacity: 0; }
/* keep the side panels clear of the bar in short landscape screens */
@media (max-height: 560px) {
  .v-cond .panel, .v-setup .setup { top: calc(50% + 24px) !important; max-height: calc(100% - 68px) !important; }
}
.v-setup .pair .seg button { padding: 0 4px !important; font-size: 11px !important; letter-spacing: 0.01em !important; }
.v-setup .pair .field:nth-child(3) { grid-column: 1 / -1; }
