/* ========================================================
   F1 GRAND PRIX MUSIC QUIZ - BROADCAST GRAPHICS STYLESHEET
   Colors:
   - Ferrari Race Red: #e10600
   - Fastest Lap Purple: #b138dd
   - Sector Green: #00d2be / #00ff7f
   - Timing Gold: #ffd100
   - Carbon Black: #0b0d10 / #14171d
   ======================================================== */

:root {
  --f1-red: #e10600;
  --f1-red-dark: #a00400;
  --f1-purple: #b138dd;
  --f1-purple-glow: rgba(177, 56, 221, 0.4);
  --f1-green: #00d2be;
  --f1-yellow: #ffd100;
  --f1-dark: #0b0d11;
  --f1-card-bg: rgba(19, 23, 30, 0.92);
  --f1-border: rgba(255, 255, 255, 0.12);
  --f1-text: #ffffff;
  --f1-text-muted: #8d98a7;
  --font-race: 'Titillium Web', -apple-system, sans-serif;
  --font-display: 'Orbitron', monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

body {
  font-family: var(--font-race);
  background-color: var(--f1-dark);
  color: var(--f1-text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* 碳纖維與競速網格背景 */
.carbon-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 50% 20%, #1f2530 0%, #0d1015 60%, #06080a 100%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 2px, transparent 2px, transparent 6px);
  z-index: -2;
}

.racing-grid-lines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: -1;
}

.f1-app-container {
  max-width: 1500px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: max(12px, var(--sat)) max(20px, var(--sar)) max(16px, var(--sab)) max(20px, var(--sal));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  box-sizing: border-box;
  overflow-x: clip;
}

/* ========================================================
   F1 頂部轉播抬頭顯示器 (Header Telemetry)
   ======================================================== */
.f1-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #12151c 0%, #1c222c 50%, #12151c 100%);
  border-bottom: 3px solid var(--f1-red);
  padding: 12px 24px;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  margin-bottom: 20px;
}

.f1-logo-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.f1-icon {
  background: var(--f1-red);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 1.4rem;
  padding: 2px 14px;
  border-radius: 4px;
  letter-spacing: -1px;
  box-shadow: 0 0 16px rgba(225, 6, 0, 0.5);
}

.f1-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 1.5px;
  font-weight: 800;
}

.f1-title .highlight {
  color: var(--f1-red);
}

.telemetry-center {
  display: flex;
  gap: 16px;
}

.telemetry-badge {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--f1-border);
  padding: 6px 14px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.telemetry-badge .label {
  font-size: 0.68rem;
  color: var(--f1-text-muted);
  font-weight: 700;
  letter-spacing: 1px;
}

.telemetry-badge .value {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}

.diff-badge .value {
  color: var(--f1-yellow);
}

.driver-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid var(--f1-border);
}

.role-tag {
  background: #2a313d;
  color: #00d2be;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
}

.driver-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
}

.drs-status-light {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 900;
  background: #2a2a2a;
  color: #666;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
  transition: all 0.3s;
}

.drs-status-light.active {
  background: var(--f1-green);
  color: #000;
  box-shadow: 0 0 14px var(--f1-green);
  animation: pulse-drs 1s infinite alternate;
}

@keyframes pulse-drs {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* ========================================================
   主排版佈局 (Left: Track Card / Right: Timing Tower)
   ======================================================== */
.f1-main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.racing-track-card {
  background: var(--f1-card-bg);
  border: 1px solid var(--f1-border);
  border-radius: 8px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  min-height: 540px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.view-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

/* ========================================================
   視圖 1：登入與加入視圖 (Join Screen)
   ======================================================== */
.welcome-box {
  max-width: 650px;
  margin: 30px auto;
  text-align: center;
}

.f1-headline {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 20px rgba(225, 6, 0, 0.6);
  margin-bottom: 8px;
}

.f1-subline {
  color: var(--f1-text-muted);
  font-size: 1.1rem;
  margin-bottom: 30px;
}

.join-form {
  background: rgba(0, 0, 0, 0.4);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--f1-border);
  text-align: left;
  margin-bottom: 24px;
}

.join-form label {
  display: block;
  font-weight: 700;
  margin-bottom: 10px;
  color: #ddd;
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row input {
  flex: 1;
  background: #171b22;
  border: 1px solid #333d4d;
  color: #fff;
  font-size: 1.1rem;
  padding: 12px 16px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
}

.input-row input:focus {
  border-color: var(--f1-red);
  box-shadow: 0 0 10px rgba(225, 6, 0, 0.4);
}

.f1-btn {
  font-family: var(--font-race);
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  background: var(--f1-red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(225, 6, 0, 0.4);
}

.btn-primary:hover {
  background: #ff1810;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(225, 6, 0, 0.6);
}

.btn-danger {
  background: linear-gradient(135deg, #e10600, #b00400);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.btn-secondary {
  background: #232a35;
  color: #fff;
  border: 1px solid #3c4656;
}

.btn-secondary:hover {
  background: #313a48;
}

.btn-dark {
  background: #191414;
  color: #1ed760;
  border: 1px solid #1ed760;
}

.btn-dark:hover {
  background: #1ed760;
  color: #000;
}

/* VPN 連線說明卡片 */
.vpn-connection-box {
  background: rgba(0, 210, 190, 0.05);
  border: 1px dashed rgba(0, 210, 190, 0.4);
  border-radius: 8px;
  padding: 18px;
  text-align: left;
}

.vpn-title {
  color: var(--f1-green);
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.vpn-connection-box p {
  color: var(--f1-text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.ip-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ip-item {
  background: #13171f;
  padding: 6px 12px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ip-item .ip-url {
  color: var(--f1-yellow);
}

/* ========================================================
   視圖 2：大廳等待室視圖 (Lobby Screen)
   ======================================================== */
.lobby-header {
  border-bottom: 1px solid var(--f1-border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 1px;
}

.hint-text {
  color: var(--f1-text-muted);
  margin-top: 4px;
}

.host-control-panel {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid var(--f1-red);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.director-badge {
  color: var(--f1-red);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.host-indicator {
  background: var(--f1-red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.setting-item {
  background: #161b24;
  padding: 16px;
  border-radius: 6px;
  border: 1px solid var(--f1-border);
}

.setting-label-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 10px;
}

.setting-val-display {
  color: var(--f1-yellow);
  font-family: var(--font-display);
}

.setting-item input[type="range"] {
  width: 100%;
  accent-color: var(--f1-red);
  cursor: pointer;
}

.pool-selector-item {
  grid-column: 1 / -1;
}

.pool-select-input {
  width: 100%;
  margin-top: 6px;
  background: rgba(10, 14, 20, 0.95);
  color: #00d2be;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--f1-border);
  border-radius: 5px;
  padding: 10px 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pool-select-input:focus {
  border-color: #00d2be;
  box-shadow: 0 0 10px rgba(0, 210, 190, 0.4);
}

.host-actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-start {
  margin-left: auto;
  font-size: 1.15rem;
  padding: 14px 32px;
}

.client-lobby-status {
  text-align: center;
  padding: 60px 20px;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--f1-red);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.synced-settings-info {
  margin-top: 14px;
  display: inline-block;
  background: #1b212c;
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 700;
  color: var(--f1-yellow);
}

/* ========================================================
   賽事歷史紀錄保持人與名人堂 (Circuit Records & Hall of Fame)
   ======================================================== */
.lap-record-badge {
  margin-top: 10px;
  background: rgba(255, 209, 0, 0.08);
  border: 1px dashed rgba(255, 209, 0, 0.4);
  padding: 6px 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #ffd100;
  font-family: var(--font-race);
}

.lap-record-badge .record-badge-icon {
  font-size: 1rem;
}

.client-record-notice {
  margin-top: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffd100;
  background: rgba(255, 209, 0, 0.1);
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  border: 1px solid rgba(255, 209, 0, 0.3);
}

.btn-record {
  background: linear-gradient(135deg, #2b2512 0%, #17150f 100%);
  color: #ffd100;
  border: 1px solid rgba(255, 209, 0, 0.5);
  box-shadow: 0 4px 12px rgba(255, 209, 0, 0.15);
}

.btn-record:hover {
  background: linear-gradient(135deg, #3d3419 0%, #221d12 100%);
  border-color: #ffd100;
  box-shadow: 0 0 16px rgba(255, 209, 0, 0.35);
  transform: translateY(-2px);
}

/* 結算新紀錄誕生慶祝橫幅 (New Record Banner) */
.new-record-banner {
  background: linear-gradient(90deg, rgba(255, 128, 0, 0.3) 0%, rgba(255, 209, 0, 0.25) 50%, rgba(225, 6, 0, 0.3) 100%);
  border: 2px solid #ffd100;
  border-radius: 8px;
  padding: 16px 24px;
  margin: 0 auto 24px auto;
  max-width: 720px;
  box-shadow: 0 0 30px rgba(255, 209, 0, 0.4), inset 0 0 15px rgba(255, 209, 0, 0.2);
  animation: bannerFlamePulse 1.5s ease-in-out infinite alternate;
}

@keyframes bannerFlamePulse {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 209, 0, 0.35); }
  100% { transform: scale(1.02); box-shadow: 0 0 35px rgba(255, 209, 0, 0.7); }
}

.record-glory-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.record-flame-icon {
  font-size: 2.2rem;
}

.record-glory-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
  color: #ffd100;
  letter-spacing: 1.5px;
  text-shadow: 0 0 10px rgba(255, 209, 0, 0.6);
}

.record-glory-desc {
  font-size: 0.95rem;
  color: #fff;
  margin-top: 4px;
  font-weight: 700;
}

/* 頒獎台當前圈數紀錄卡片 */
.match-record-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 24, 34, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 18px;
  border-radius: 20px;
  color: #ddd;
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 16px;
}

.match-record-card .match-record-icon {
  font-size: 1.1rem;
}

/* 賽事紀錄名人堂彈窗 (Hall of Fame Modal) */
.f1-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 7, 10, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.f1-modal-dialog {
  background: #11141b;
  border: 1px solid var(--f1-border);
  border-top: 4px solid #ffd100;
  border-radius: 8px;
  width: 100%;
  max-width: 680px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.f1-modal-dialog .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #161a23;
  border-bottom: 1px solid var(--f1-border);
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-trophy {
  font-size: 1.4rem;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--f1-text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: #fff;
}

.f1-modal-dialog .modal-body {
  padding: 20px;
  max-height: 65vh;
  overflow-y: auto;
}

.modal-desc {
  color: var(--f1-text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.records-table-container {
  overflow-x: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.records-table th {
  background: #1a202c;
  color: var(--f1-text-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 1px;
  padding: 10px 14px;
  border-bottom: 2px solid var(--f1-border);
}

.records-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.95rem;
}

.records-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.laps-pill {
  background: #252b38;
  color: #00d2be;
  font-family: var(--font-display);
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.record-driver-col {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fff;
}

.record-crown-icon {
  margin-right: 4px;
}

.score-highlight {
  font-family: var(--font-display);
  font-weight: 900;
  color: #ffd100;
  font-size: 1.05rem;
}

.record-date-col {
  color: var(--f1-text-muted);
  font-size: 0.85rem;
}

.records-empty-hint {
  text-align: center;
  padding: 30px 20px;
  color: var(--f1-text-muted);
  font-style: italic;
  font-size: 0.95rem;
}

.f1-modal-dialog .modal-footer {
  padding: 14px 20px;
  background: #161a23;
  border-top: 1px solid var(--f1-border);
  text-align: right;
}

/* ========================================================
   視圖 3：F1 起跑五盞紅燈起跑儀式 (5 Starting Lights)
   ======================================================== */
.lights-gantry-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.gantry-header {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--f1-text-muted);
  letter-spacing: 3px;
  margin-bottom: 24px;
}

.f1-lights-gantry {
  display: flex;
  gap: 18px;
  background: #121316;
  border: 4px solid #22262d;
  padding: 20px 30px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  margin-bottom: 30px;
}

.light-unit {
  background: #08090a;
  border: 3px solid #333842;
  border-radius: 50%;
  padding: 6px;
}

.light-bulb {
  width: 52px;
  height: 52px;
  background: #2a1111;
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.light-bulb.on {
  background: #ff1100;
  box-shadow: 0 0 35px #ff1100, 0 0 60px rgba(255, 17, 0, 0.8);
}

.lights-message {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.upcoming-lap-info {
  background: #1e2430;
  color: var(--f1-yellow);
  font-weight: 800;
  padding: 6px 18px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* ========================================================
   賽事發動動態加載進度條
   ======================================================== */
.telemetry-loader-box {
  width: 100%;
  max-width: 500px;
  margin-top: 24px;
  background: rgba(14, 18, 26, 0.85);
  border: 1px solid var(--f1-border);
  border-radius: 8px;
  padding: 14px 18px;
}

.loader-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.loader-status-text {
  color: var(--f1-green);
  letter-spacing: 0.5px;
}

.loader-pct-digits {
  color: var(--f1-yellow);
  font-family: var(--font-display);
}

.telemetry-bar-track {
  width: 100%;
  height: 10px;
  background: #090c10;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.telemetry-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #e10600, #ffd100, #00d2be);
  background-size: 200% 100%;
  border-radius: 5px;
  transition: width 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 解除靜音醒目橫幅 */
.unmute-banner {
  background: linear-gradient(90deg, #e10600, #b00400);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  animation: pulse-danger 0.8s infinite alternate;
}

/* ========================================================
   視圖 4：正式競速作答視圖 (Racing Screen)
   ======================================================== */
.timing-bar-container {
  margin-bottom: 24px;
}

.timing-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.time-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--f1-text-muted);
  letter-spacing: 1.5px;
}

.time-countdown {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--f1-green);
}

.f1-progress-track {
  width: 100%;
  height: 14px;
  background: #111419;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.f1-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00d2be, #ffd100);
  border-radius: 7px;
  transition: width 0.25s linear, background 0.3s;
}

.f1-progress-fill.warning {
  background: linear-gradient(90deg, #ffd100, #ff8000);
}

.f1-progress-fill.critical {
  background: linear-gradient(90deg, #ff4400, #e10600);
  box-shadow: 0 0 15px rgba(225, 6, 0, 0.8);
  animation: pulse-danger 0.5s infinite alternate;
}

@keyframes pulse-danger {
  0% { opacity: 0.8; }
  100% { opacity: 1; filter: brightness(1.3); }
}

/* 音訊聲波條 */
.audio-visualizer-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 90px;
  margin: 15px 0 25px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.wave-bar {
  width: 6px;
  height: 20px;
  background: var(--f1-green);
  border-radius: 3px;
  animation: equalize 1.2s ease-in-out infinite alternate;
}

.wave-bar:nth-child(2n) { animation-delay: 0.2s; height: 35px; background: var(--f1-yellow); }
.wave-bar:nth-child(3n) { animation-delay: 0.4s; height: 50px; background: var(--f1-red); }
.wave-bar:nth-child(4n) { animation-delay: 0.1s; height: 28px; background: var(--f1-purple); }

@keyframes equalize {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1.4); }
}

/* Heardle / Fuse.js 作答互動框 */
.quiz-interaction-box {
  margin-top: auto;
}

.quiz-input-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: #ddd;
}

.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.search-input-group {
  display: flex;
  gap: 10px;
}

.search-action-btns {
  display: flex;
  gap: 10px;
}

.search-input-group input {
  flex: 1;
  background: #171c26;
  border: 2px solid #2e3848;
  color: #fff;
  font-size: 1.15rem;
  padding: 14px 18px;
  border-radius: 6px;
  outline: none;
  transition: all 0.2s;
}

.search-input-group input:focus {
  border-color: var(--f1-green);
  box-shadow: 0 0 16px rgba(0, 210, 190, 0.3);
}

.btn-submit {
  background: var(--f1-green);
  color: #000;
  font-weight: 900;
}

.btn-submit:hover {
  background: #00ffea;
  box-shadow: 0 0 16px rgba(0, 210, 190, 0.6);
}

.btn-skip {
  background: #252c38;
  color: #a0acbe;
}

.btn-skip:hover {
  background: #343e4f;
  color: #fff;
}

/* 浮動候選下拉選單 */
.suggestions-dropdown {
  position: absolute;
  bottom: 105%;
  left: 0;
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
  background: #141822;
  border: 2px solid var(--f1-red);
  border-radius: 8px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.8);
  z-index: 100;
}

.suggestion-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(225, 6, 0, 0.2);
}

.suggestion-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.suggestion-artist {
  color: var(--f1-text-muted);
  font-size: 0.85rem;
}

.answer-feedback-banner {
  margin-top: 16px;
  padding: 12px 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

/* ========================================================
   最後 10 秒 10選1 選擇題面板
   ======================================================== */
.multiple-choice-panel {
  margin-top: 14px;
  background: rgba(14, 18, 25, 0.95);
  border: 2px solid var(--f1-yellow);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 0 24px rgba(255, 209, 0, 0.2);
  animation: slide-up 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.choice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.choice-notice-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.choice-pulse-dot {
  width: 10px;
  height: 10px;
  background: var(--f1-yellow);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--f1-yellow);
  animation: pulse-dot 0.8s infinite alternate;
}

@keyframes pulse-dot {
  to { transform: scale(1.4); filter: brightness(1.3); }
}

.choice-notice {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--f1-yellow);
  letter-spacing: 0.5px;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.choice-btn {
  background: linear-gradient(135deg, #19202c 0%, #11151e 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 11px 16px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-race);
  font-size: 0.95rem;
  font-weight: 700;
  width: 100%;
  min-height: 48px;
}

.choice-btn:hover {
  background: linear-gradient(135deg, #253145 0%, #19202c 100%);
  border-color: var(--f1-green);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 210, 190, 0.3);
}

.choice-btn:active {
  transform: translateY(0);
}

.choice-key-tag {
  background: rgba(255, 255, 255, 0.1);
  color: var(--f1-yellow);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}

.choice-btn-text {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  line-height: 1.35;
  flex: 1;
}

.answer-feedback-banner.correct {
  background: rgba(0, 210, 190, 0.2);
  border: 1px solid var(--f1-green);
  color: var(--f1-green);
}

.answer-feedback-banner.wrong {
  background: rgba(225, 6, 0, 0.2);
  border: 1px solid var(--f1-red);
  color: #ff6464;
}

.answer-feedback-banner.skipped {
  background: rgba(255, 209, 0, 0.15);
  border: 1px solid var(--f1-yellow);
  color: var(--f1-yellow);
}

/* ========================================================
   視圖 5：本圈公佈解答 (Lap Result Screen)
   ======================================================== */
.lap-result-card {
  padding: 10px;
}

.result-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.lap-summary-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 2px;
  color: #fff;
}

.song-reveal-container {
  display: flex;
  gap: 24px;
  background: #141822;
  border: 1px solid var(--f1-border);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.album-art-wrapper {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.album-art-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.reveal-difficulty-tag {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--f1-yellow);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
  padding: 3px 0;
  border-radius: 3px;
}

.song-meta-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

.song-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.song-artist {
  font-size: 1.15rem;
  color: var(--f1-text-muted);
  margin-bottom: 14px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.popularity-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #aaa;
}

.pop-bar-bg {
  width: 120px;
  height: 8px;
  background: #252b36;
  border-radius: 4px;
  overflow: hidden;
}

.pop-bar-fill {
  height: 100%;
  background: var(--f1-red);
}

/* 最速圈紫標榮耀 */
.fastest-lap-showcase {
  background: linear-gradient(90deg, rgba(177, 56, 221, 0.25) 0%, rgba(20, 24, 34, 0.8) 100%);
  border-left: 5px solid var(--f1-purple);
  padding: 14px 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  box-shadow: 0 0 20px var(--f1-purple-glow);
}

.purple-clock-icon {
  font-size: 1.8rem;
}

.fastest-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  color: var(--f1-purple);
  font-weight: 900;
}

.fastest-driver {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.next-lap-action {
  text-align: right;
}

.waiting-host-notice {
  color: var(--f1-text-muted);
  font-style: italic;
  font-size: 0.95rem;
}

/* ========================================================
   視圖 6：完賽頒獎台 (Podium Screen)
   ======================================================== */
.podium-screen {
  text-align: center;
  padding: 20px 0;
}

.podium-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 2px;
  color: var(--f1-yellow);
  text-shadow: 0 0 20px rgba(255, 209, 0, 0.4);
}

.podium-subtitle {
  color: var(--f1-text-muted);
  margin-bottom: 40px;
}

/* ========================================================
   F1 官方轉播頒獎台 (圖二風格：三柱高對比肖像卡)
   ======================================================== */
.f1-broadcast-podium-deck {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(10px, 2.5vw, 22px);
  margin: 25px auto 20px;
  max-width: 900px;
  padding: 0 10px;
}

/* 選手卡共通結構 */
.f1-driver-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 8px 8px 6px 6px;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
  user-select: none;
}

.f1-driver-card.vacant {
  opacity: 0.35;
  filter: grayscale(0.65);
}

.f1-driver-card:hover {
  transform: translateY(-6px);
}

/* P1 冠軍卡（中央最高、最搶眼，法拉利紅色系） */
.f1-driver-card.card-p1 {
  width: clamp(170px, 30vw, 245px);
  height: clamp(380px, 52vh, 460px);
  background: linear-gradient(180deg, #d40000 0%, #7d0000 45%, #160202 100%);
  border: 2.5px solid #e10600;
  box-shadow: 0 0 35px rgba(225, 6, 0, 0.75), 0 12px 30px rgba(0, 0, 0, 0.85);
  order: 2;
  z-index: 3;
}

.f1-driver-card.card-p1:hover {
  box-shadow: 0 0 45px rgba(225, 6, 0, 0.95), 0 16px 36px rgba(0, 0, 0, 0.9);
}

/* P2 亞軍卡（左側，賓士湖水綠/銀色系） */
.f1-driver-card.card-p2 {
  width: clamp(140px, 26vw, 215px);
  height: clamp(320px, 45vh, 395px);
  background: linear-gradient(180deg, #00d2be 0%, #005a52 45%, #071718 100%);
  border: 2px solid #00d2be;
  box-shadow: 0 0 25px rgba(0, 210, 190, 0.5), 0 10px 25px rgba(0, 0, 0, 0.8);
  order: 1;
  z-index: 2;
}

/* P3 季軍卡（右側，麥拉倫木瓜橙/古銅系） */
.f1-driver-card.card-p3 {
  width: clamp(140px, 26vw, 215px);
  height: clamp(300px, 42vh, 375px);
  background: linear-gradient(180deg, #ff8700 0%, #8c3f00 45%, #1a0f05 100%);
  border: 2px solid #ff8700;
  box-shadow: 0 0 25px rgba(255, 135, 0, 0.5), 0 10px 25px rgba(0, 0, 0, 0.8);
  order: 3;
  z-index: 1;
}

/* ==========================================================================
   F1 頒獎台車隊色彩主題 (法拉利紅 / 賓士淺藍 / 麥拉倫橘 / 紅牛深藍 / BWT粉 / 無肖像灰色)
   ========================================================================== */
/* 1. 法拉利紅 */
.f1-driver-card.podium-theme-ferrari {
  background: linear-gradient(180deg, #d40000 0%, #7d0000 45%, #160202 100%) !important;
  border-color: #e10600 !important;
  box-shadow: 0 0 35px rgba(225, 6, 0, 0.75), 0 12px 30px rgba(0, 0, 0, 0.85) !important;
}
.f1-driver-card.podium-theme-ferrari:hover {
  box-shadow: 0 0 45px rgba(225, 6, 0, 0.95), 0 16px 36px rgba(0, 0, 0, 0.9) !important;
}
.f1-driver-card.podium-theme-ferrari .card-nameplate {
  background: #e10600 !important;
  color: #ffffff !important;
  border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
}
.f1-driver-card.podium-theme-ferrari .card-pts-badge {
  color: var(--f1-yellow) !important;
  border-color: rgba(255, 209, 0, 0.6) !important;
}

/* 2. 賓士淺藍 */
.f1-driver-card.podium-theme-mercedes {
  background: linear-gradient(180deg, #00d2be 0%, #005a52 45%, #071718 100%) !important;
  border-color: #00d2be !important;
  box-shadow: 0 0 35px rgba(0, 210, 190, 0.7), 0 12px 30px rgba(0, 0, 0, 0.85) !important;
}
.f1-driver-card.podium-theme-mercedes:hover {
  box-shadow: 0 0 45px rgba(0, 210, 190, 0.95), 0 16px 36px rgba(0, 0, 0, 0.9) !important;
}
.f1-driver-card.podium-theme-mercedes .card-nameplate {
  background: #00d2be !important;
  color: #000000 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
}
.f1-driver-card.podium-theme-mercedes .card-pts-badge {
  color: #00d2be !important;
  border-color: rgba(0, 210, 190, 0.6) !important;
}

/* 3. 麥拉倫橘 */
.f1-driver-card.podium-theme-mclaren {
  background: linear-gradient(180deg, #ff8700 0%, #8c3f00 45%, #1a0f05 100%) !important;
  border-color: #ff8000 !important;
  box-shadow: 0 0 35px rgba(255, 128, 0, 0.7), 0 12px 30px rgba(0, 0, 0, 0.85) !important;
}
.f1-driver-card.podium-theme-mclaren:hover {
  box-shadow: 0 0 45px rgba(255, 128, 0, 0.95), 0 16px 36px rgba(0, 0, 0, 0.9) !important;
}
.f1-driver-card.podium-theme-mclaren .card-nameplate {
  background: #ff8000 !important;
  color: #000000 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
}
.f1-driver-card.podium-theme-mclaren .card-pts-badge {
  color: #ff8000 !important;
  border-color: rgba(255, 128, 0, 0.6) !important;
}

/* 4. 紅牛深藍 */
.f1-driver-card.podium-theme-redbull {
  background: linear-gradient(180deg, #1e41ff 0%, #0c1a60 45%, #050b20 100%) !important;
  border-color: #1e41ff !important;
  box-shadow: 0 0 35px rgba(30, 65, 255, 0.75), 0 12px 30px rgba(0, 0, 0, 0.85) !important;
}
.f1-driver-card.podium-theme-redbull:hover {
  box-shadow: 0 0 45px rgba(30, 65, 255, 0.95), 0 16px 36px rgba(0, 0, 0, 0.9) !important;
}
.f1-driver-card.podium-theme-redbull .card-nameplate {
  background: #1e41ff !important;
  color: #ffffff !important;
  border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
}
.f1-driver-card.podium-theme-redbull .card-pts-badge {
  color: #60a5fa !important;
  border-color: rgba(96, 165, 250, 0.6) !important;
}

/* 5. BWT粉 */
.f1-driver-card.podium-theme-bwt {
  background: linear-gradient(180deg, #ff69b4 0%, #991b58 45%, #200512 100%) !important;
  border-color: #ff69b4 !important;
  box-shadow: 0 0 35px rgba(255, 105, 180, 0.85), 0 12px 30px rgba(0, 0, 0, 0.85) !important;
}
.f1-driver-card.podium-theme-bwt:hover {
  box-shadow: 0 0 45px rgba(255, 105, 180, 1), 0 16px 36px rgba(0, 0, 0, 0.9) !important;
}
.f1-driver-card.podium-theme-bwt .card-nameplate {
  background: #ff69b4 !important;
  color: #ffffff !important;
  border-top: 1px solid rgba(255, 255, 255, 0.3) !important;
}
.f1-driver-card.podium-theme-bwt .card-pts-badge {
  color: #ffb6c1 !important;
  border-color: rgba(255, 182, 193, 0.6) !important;
}

/* 6. 沒有肖像統一使用灰色 */
.f1-driver-card.podium-theme-gray {
  background: linear-gradient(180deg, #64748b 0%, #334155 45%, #0f172a 100%) !important;
  border-color: #64748b !important;
  box-shadow: 0 0 25px rgba(100, 116, 139, 0.5), 0 12px 30px rgba(0, 0, 0, 0.85) !important;
}
.f1-driver-card.podium-theme-gray:hover {
  box-shadow: 0 0 35px rgba(148, 163, 184, 0.7), 0 16px 36px rgba(0, 0, 0, 0.9) !important;
}
.f1-driver-card.podium-theme-gray .card-nameplate {
  background: #475569 !important;
  color: #ffffff !important;
  border-top: 1px solid rgba(255, 255, 255, 0.2) !important;
}
.f1-driver-card.podium-theme-gray .card-pts-badge {
  color: #cbd5e1 !important;
  border-color: rgba(203, 213, 225, 0.5) !important;
}

/* 卡片頂部欄位（大號名次與分數） */
.card-top-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 12px;
  z-index: 5;
  pointer-events: none;
}

.card-pos-num {
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 2.8rem;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.9);
}

.card-p1 .card-pos-num {
  font-size: 3.4rem;
}

.card-pts-badge {
  font-family: var(--font-race);
  font-size: 0.95rem;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.card-p1 .card-pts-badge {
  color: var(--f1-yellow);
  border-color: rgba(255, 209, 0, 0.5);
  font-size: 1.05rem;
}

.card-p2 .card-pts-badge {
  color: #00d2be;
  border-color: rgba(0, 210, 190, 0.5);
}

.card-p3 .card-pts-badge {
  color: #ff8700;
  border-color: rgba(255, 135, 0, 0.5);
}

/* 冠軍冠冕浮動標誌 */
.card-crown-float {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  z-index: 10;
  animation: bounce 1.1s infinite alternate;
  filter: drop-shadow(0 0 10px rgba(255, 209, 0, 0.8));
}

/* 肖像照片容器與圖像 (大幅提升明顯度與比例) */
.card-portrait-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 42px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

.card-driver-img {
  width: 95%;
  height: 88%;
  max-height: 380px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.85));
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.f1-driver-card:hover .card-driver-img {
  transform: scale(1.05) translateY(-3px);
}

/* 底部車手名牌 (圖二 F1 broadcast Nameplate) */
.card-nameplate {
  margin-top: auto;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 5;
  font-family: var(--font-race);
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-p1 .card-nameplate {
  background: #e10600;
  color: #ffffff;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.card-p2 .card-nameplate {
  background: #00d2be;
  color: #000000;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.card-p3 .card-nameplate {
  background: #ff8700;
  color: #000000;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.card-flag-icon {
  font-size: 1.1rem;
}

.card-driver-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================================
   圖二風格：P4+ 賽事總排名列表 (Race Classification P4+)
   ======================================================== */
.f1-rest-classification-panel {
  max-width: 860px;
  margin: 15px auto 25px;
  background: #0d1017;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
}

.rest-classification-title {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #141822;
  padding: 10px 16px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: #e0e0e0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rest-title-stripe {
  width: 4px;
  height: 18px;
  background: var(--f1-red);
  border-radius: 2px;
}

.rest-drivers-table {
  display: flex;
  flex-direction: column;
}

.rest-driver-row {
  display: grid;
  grid-template-columns: 50px 1fr 180px 100px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-race);
  font-size: 0.92rem;
  transition: background 0.2s ease;
}

.rest-driver-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.rest-driver-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.rest-pos-col {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  color: #aaa;
}

.rest-red-indicator {
  width: 3px;
  height: 16px;
  background: var(--f1-red);
}

.rest-name-col {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rest-team-col {
  font-size: 0.8rem;
  color: #888;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.rest-score-col {
  text-align: right;
  font-weight: 800;
  color: var(--f1-yellow);
}

/* Baidairay 排行榜專屬大頭照勳章 - 全面特大清晰化並強化法拉利光暈與霸氣外觀 */
.baidairay-avatar-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--f1-red);
  box-shadow: 0 0 14px rgba(225, 6, 0, 0.9), 0 0 4px rgba(255, 255, 255, 0.4);
  vertical-align: middle;
  margin-right: 8px;
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.baidairay-avatar-badge:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(225, 6, 0, 1), 0 0 8px #fff;
  z-index: 10;
}

.baidairay-avatar-badge.inline {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  margin-right: 6px;
  border-width: 2px;
}

/* 1. 名人堂紀錄榜：特大號 68px，面容特寫五官極度清晰、王者氣勢霸氣外溢 */
.record-driver-col .baidairay-avatar-badge {
  width: 68px;
  height: 68px;
  min-width: 68px;
  min-height: 68px;
  border-width: 3px;
  border-color: var(--f1-red);
  box-shadow: 0 0 18px rgba(225, 6, 0, 0.95), 0 0 8px rgba(255, 209, 0, 0.7);
  margin-right: 10px;
}

/* 2. 本圈作答時間榜 (Driver Reaction Times)：特大號 50px，清晰奪目 */
.lap-driver-row .baidairay-avatar-badge {
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  border-width: 2.5px;
  box-shadow: 0 0 14px rgba(225, 6, 0, 0.9);
  margin-right: 8px;
}

/* 3. F1 即時排位塔 (Timing Tower)：特大號 44px，醒目名次焦點 */
.timing-row .baidairay-avatar-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-width: 2px;
  box-shadow: 0 0 12px rgba(225, 6, 0, 0.9);
  margin-right: 8px;
}

/* 星詠み々 排行榜專屬大頭照勳章 - Mercedes-AMG 賓士湖水綠尊榮光暈 */
.hoshimi-avatar-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #00d2be;
  box-shadow: 0 0 14px rgba(0, 210, 190, 0.9), 0 0 4px rgba(255, 255, 255, 0.4);
  vertical-align: middle;
  margin-right: 8px;
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.hoshimi-avatar-badge:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(0, 210, 190, 1), 0 0 8px #fff;
  z-index: 10;
}

.hoshimi-avatar-badge.inline {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  margin-right: 6px;
  border-width: 2px;
}

/* 1. 名人堂紀錄榜：特大號 68px，賓士湖水綠光圈 */
.record-driver-col .hoshimi-avatar-badge {
  width: 68px;
  height: 68px;
  min-width: 68px;
  min-height: 68px;
  border-width: 3px;
  border-color: #00d2be;
  box-shadow: 0 0 18px rgba(0, 210, 190, 0.95), 0 0 8px rgba(255, 255, 255, 0.7);
  margin-right: 10px;
}

/* 2. 本圈作答時間榜：特大號 50px */
.lap-driver-row .hoshimi-avatar-badge {
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  border-width: 2.5px;
  border-color: #00d2be;
  box-shadow: 0 0 14px rgba(0, 210, 190, 0.9);
  margin-right: 8px;
}

/* 3. F1 即時排位塔：特大號 44px */
.timing-row .hoshimi-avatar-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-width: 2px;
  border-color: #00d2be;
  box-shadow: 0 0 12px rgba(0, 210, 190, 0.9);
  margin-right: 8px;
}

.podium-driver-name {
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 4px;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-score {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--f1-yellow);
  margin-bottom: 10px;
}

.crown-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  to { transform: translateY(-8px); }
}

.stand-block {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  border-radius: 6px 6px 0 0;
}

.stand-p1 {
  height: 180px;
  background: linear-gradient(180deg, #ffd100 0%, #b89300 100%);
  color: #000;
  box-shadow: 0 0 30px rgba(255, 209, 0, 0.5);
}

.stand-p2 {
  height: 140px;
  background: linear-gradient(180deg, #d3d9e2 0%, #838a95 100%);
  color: #000;
}

.stand-p3 {
  height: 110px;
  background: linear-gradient(180deg, #cd7f32 0%, #824f1c 100%);
  color: #fff;
}

/* ========================================================
   右側：F1 官方排位塔 (Live Timing Tower)
   ======================================================== */
.f1-timing-tower-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ========================================================
   右側欄位：賽道各圈歷史最高紀錄名人堂 (Hall of Fame Circuit Records)
   ======================================================== */
.sidebar-records-section {
  background: var(--f1-card-bg);
  border: 1px solid var(--f1-border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

/* 在正賽進行中自動隱藏名人堂區塊，全權釋放給即時排位塔與 FLIP 動畫 */
body.view-racing .sidebar-records-section {
  display: none !important;
}

.records-header {
  border-top: 3px solid #ffd700 !important;
  background: linear-gradient(135deg, #181d26 0%, #11141b 100%) !important;
}

.records-header .flag-chequered {
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}

.sidebar-records-body {
  display: flex;
  flex-direction: column;
}

.sidebar-pool-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--f1-border);
}

.sidebar-pool-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--f1-text-muted);
  white-space: nowrap;
}

.sidebar-pool-select {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: #0c0e14;
  border: 1px solid #2a3346;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
}

.sidebar-pool-select:focus {
  border-color: #ffd700;
}

.sidebar-records-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2a3346 #0c0e14;
}

.sidebar-records-list::-webkit-scrollbar {
  width: 5px;
}
.sidebar-records-list::-webkit-scrollbar-track {
  background: #0c0e14;
}
.sidebar-records-list::-webkit-scrollbar-thumb {
  background: #2a3346;
  border-radius: 3px;
}
.sidebar-records-list::-webkit-scrollbar-thumb:hover {
  background: #3d4a61;
}

.sidebar-record-card {
  border-radius: 5px;
  padding: 8px 10px;
  box-sizing: border-box;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-record-card.has-record {
  background: linear-gradient(135deg, rgba(22, 28, 38, 0.95) 0%, rgba(14, 18, 25, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-record-card.has-record:hover {
  transform: translateX(3px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.sidebar-rec-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-lap-pill {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  background: #1c2330;
  border: 1px solid #3d4a61;
  color: #ffeb3b;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.sidebar-lap-pill.empty {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #64748b;
}

.sidebar-rec-driver-info {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  max-width: calc(100% - 60px);
}

.sidebar-rec-crown {
  font-size: 0.82rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.7));
}

.sidebar-rec-driver-info img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-rec-driver-name {
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
}

.sidebar-rec-data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}

.sidebar-rec-score-box {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.sidebar-rec-score {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  color: #ffd700;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.45);
}

.sidebar-rec-score-unit {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 800;
  color: #8892b0;
}

.sidebar-rec-meta-box {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sidebar-rec-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.sidebar-rec-badge.practice {
  background: rgba(0, 210, 190, 0.15);
  color: #00d2be;
  border: 1px solid rgba(0, 210, 190, 0.3);
}

.sidebar-rec-badge.gp {
  background: rgba(225, 6, 0, 0.15);
  color: #ff5252;
  border: 1px solid rgba(225, 6, 0, 0.3);
}

.sidebar-rec-pool-tag {
  background: rgba(255, 255, 255, 0.07);
  color: #94a3b8;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-rec-date {
  color: #556277;
  font-size: 0.65rem;
  font-family: monospace;
  white-space: nowrap;
}

/* 尚無紀錄空白卡片 */
.sidebar-record-card.is-empty {
  background: rgba(18, 22, 30, 0.45);
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.sidebar-rec-empty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.74rem;
  color: #526079;
}

.sidebar-rec-empty-text {
  font-weight: 600;
  color: #4b586e;
}

.sidebar-rec-empty-hint {
  font-size: 0.68rem;
  color: #3b465a;
  letter-spacing: 0.5px;
}

.tower-header {
  background: #11141b;
  border-top: 3px solid var(--f1-red);
  padding: 12px 16px;
  border-radius: 6px 6px 0 0;
}

.tower-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tower-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 1px;
}

.tower-sub {
  font-size: 0.7rem;
  color: var(--f1-text-muted);
  letter-spacing: 1px;
  font-weight: 700;
}

.timing-tower-list {
  background: var(--f1-card-bg);
  border: 1px solid var(--f1-border);
  border-radius: 0 0 6px 6px;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  position: relative;
}

.timing-row {
  display: grid;
  grid-template-columns: 58px 1fr 64px 72px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease, border-color 0.2s ease;
  position: relative;
  will-change: transform;
}

.timing-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* F1 官方轉播即時排位名次與超車升降指示組 (Position & Delta Cluster) */
.pos-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pos-chip {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.9rem;
  color: #fff;
}

.pos-p1 { color: var(--f1-yellow); text-shadow: 0 0 8px rgba(255, 209, 0, 0.5); }
.pos-p2 { color: #d3d9e2; }
.pos-p3 { color: #cd7f32; }

.f1-delta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 3px;
  min-width: 22px;
  height: 17px;
  line-height: 1;
}

.f1-delta-badge.delta-up {
  background: #00d26a;
  color: #000;
  box-shadow: 0 0 8px rgba(0, 210, 106, 0.7);
  animation: f1PulseGain 1.2s ease-in-out infinite alternate;
}

.f1-delta-badge.delta-down {
  background: #e10600;
  color: #fff;
  box-shadow: 0 0 8px rgba(225, 6, 0, 0.7);
  animation: f1PulseLoss 1.2s ease-in-out infinite alternate;
}

.f1-delta-badge.delta-same {
  visibility: hidden;
  width: 0;
  min-width: 0;
  padding: 0;
}

.f1-delta-arrow {
  font-size: 0.58rem;
  margin-top: -1px;
}

@keyframes f1PulseGain {
  from { transform: scale(1); box-shadow: 0 0 6px rgba(0, 210, 106, 0.6); }
  to { transform: scale(1.06); box-shadow: 0 0 12px rgba(0, 210, 106, 0.95); }
}

@keyframes f1PulseLoss {
  from { transform: scale(1); box-shadow: 0 0 6px rgba(225, 6, 0, 0.6); }
  to { transform: scale(1.06); box-shadow: 0 0 12px rgba(225, 6, 0, 0.95); }
}

/* F1 轉播超車向上攀升動畫 (Climb / Overtake) */
.timing-row.f1-row-climb {
  background: linear-gradient(90deg, rgba(0, 210, 106, 0.28) 0%, rgba(20, 24, 34, 0.85) 100%) !important;
  border-left: 4px solid #00d26a !important;
  box-shadow: 0 0 20px rgba(0, 210, 106, 0.5);
}

/* F1 轉播被超車向下滑落動畫 (Drop / Overtaken) */
.timing-row.f1-row-drop {
  background: linear-gradient(90deg, rgba(225, 6, 0, 0.22) 0%, rgba(20, 24, 34, 0.85) 100%) !important;
  border-left: 4px solid #e10600 !important;
  box-shadow: 0 0 18px rgba(225, 6, 0, 0.4);
}

.driver-info-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.driver-info-cell .driver-cell-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.driver-cell-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-badges-inline {
  display: flex;
  gap: 4px;
}

.fastest-lap-badge-mini {
  background: var(--f1-purple);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 800;
  box-shadow: 0 0 8px var(--f1-purple);
}

.drs-badge-mini {
  background: var(--f1-green);
  color: #000;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 900;
  font-family: var(--font-display);
}

.score-cell {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--f1-yellow);
  text-align: right;
}

.interval-cell {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--f1-text-muted);
  text-align: right;
  font-weight: 700;
}

.interval-cell.leader {
  color: var(--f1-green);
}

/* 計分備忘卡片 */
.scoring-legend-card {
  background: rgba(14, 17, 23, 0.8);
  border: 1px solid var(--f1-border);
  border-radius: 6px;
  padding: 14px;
  font-size: 0.85rem;
}

.legend-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--f1-text-muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.scoring-legend-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #bbb;
}

.scoring-legend-card li strong {
  color: #fff;
}

/* ========================================================
   行動裝置與平板全面適配 (Comprehensive Mobile & Tablet RWD)
   ======================================================== */

/* 1. 平板橫向 / 中型螢幕 (Tablet Landscape: 900px ~ 1199px) */
@media (min-width: 900px) and (max-width: 1199px) {
  .f1-main-layout {
    grid-template-columns: 1fr 310px;
    gap: 16px;
  }

  .racing-track-card {
    padding: 22px;
  }

  .f1-lights-gantry {
    gap: 14px;
    padding: 16px 20px;
  }

  .light-bulb {
    width: 44px;
    height: 44px;
  }
}

/* 2. 行動端與直向平板導覽標籤 (Mobile & Tablet Portrait: <= 899px) */
.mobile-nav-tabs {
  display: none;
}

/* 當大廳視圖 (lobbyView)、單人練習賽 (practiceView)、或車手登入頁作用時，強制隱藏行動端導覽標籤，徹底根除手機直向浮動遮蔽 */
body.view-lobby .mobile-nav-tabs,
body.view-practice .mobile-nav-tabs,
body.view-join .mobile-nav-tabs,
body:not(.view-racing):not(.view-game-over) .mobile-nav-tabs,
body:has(#lobbyView:not(.hidden)) .mobile-nav-tabs,
body:has(#joinView:not(.hidden)) .mobile-nav-tabs,
body:has(#practiceView:not(.hidden)) .mobile-nav-tabs,
.f1-app-container:has(#lobbyView:not(.hidden)) .mobile-nav-tabs {
  display: none !important;
}

@media (max-width: 899px) {
  .f1-main-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* 預設在手機端強制完全隱藏導覽切換 Tab，徹底避免任何覆蓋問題 */
  .mobile-nav-tabs,
  #mobileNavTabs,
  .mobile-nav-tabs.hidden {
    display: none !important;
  }

  /* 只有在正賽進行中 (view-racing) 或頒獎台結算 (view-game-over) 且非 hidden 時，才以自然流式呈現切換 Tab */
  body.view-racing .mobile-nav-tabs:not(.hidden),
  body.view-game-over .mobile-nav-tabs:not(.hidden) {
    display: flex !important;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    clear: both;
    margin: 8px 0 12px 0;
    background: rgba(14, 18, 26, 0.95);
    border: 1px solid var(--f1-border);
    border-radius: 8px;
    padding: 6px;
    position: relative !important; /* 確保絕不使用 sticky 或 fixed，100% 自然流式排版，絕不浮動遮擋內容 */
    z-index: 5;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  }

  /* 在大廳視圖下，手機版允許 timing-tower-panel 正常在下方自然排列展示，讓玩家一眼看清在線車手 */
  body:has(#lobbyView:not(.hidden)) .f1-timing-tower-panel.mobile-hidden,
  .f1-app-container:has(#lobbyView:not(.hidden)) .f1-timing-tower-panel.mobile-hidden {
    display: flex !important;
  }

  .mobile-tab-btn {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    color: var(--f1-text-muted);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 800;
    padding: 10px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
  }

  .mobile-tab-btn.active {
    background: linear-gradient(135deg, rgba(225, 6, 0, 0.28) 0%, rgba(160, 4, 0, 0.2) 100%);
    color: #fff;
    border-color: var(--f1-red);
    box-shadow: 0 0 12px rgba(225, 6, 0, 0.4);
  }

  .mobile-rank-chip {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 900;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    letter-spacing: 0.5px;
  }

  /* 行動分頁切換時隱藏非作用中區塊 */
  .racing-track-card.mobile-hidden {
    display: none !important;
  }

  .f1-timing-tower-panel.mobile-hidden {
    display: none !important;
  }
}

/* 3. 平板直向適配 (Tablet Portrait: 681px ~ 899px) */
@media (min-width: 681px) and (max-width: 899px) {
  .racing-track-card {
    padding: 24px;
  }

  .f1-top-bar {
    padding: 12px 18px;
  }

  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* 4. 手機裝置全面適配 (Mobile Devices: <= 680px, 含 iPhone, Samsung, Pixel 等各長寬比) */
@media (max-width: 680px) {
  .f1-app-container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: max(8px, env(safe-area-inset-top, 8px)) max(6px, env(safe-area-inset-right, 6px)) max(12px, env(safe-area-inset-bottom, 12px)) max(6px, env(safe-area-inset-left, 6px));
  }

  /* 頂部轉播抬頭顯示器 2 行壓縮排版 (嚴格防溢出) */
  .f1-top-bar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "logo profile"
      "telemetry telemetry" !important;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    margin-bottom: 10px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden;
  }

  .f1-logo-badge {
    grid-area: logo;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
  }

  .f1-icon {
    font-size: 0.9rem;
    padding: 2px 6px;
    flex-shrink: 0;
  }

  .f1-title {
    font-size: 0.78rem;
    letter-spacing: 0px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .driver-profile-badge {
    grid-area: profile;
    padding: 2px 4px;
    gap: 4px;
    margin-left: auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .driver-profile-badge .role-tag {
    display: none !important;
  }

  .driver-profile-badge .driver-name {
    max-width: 65px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 0.78rem !important;
  }

  .driver-profile-badge .drs-status-light {
    font-size: 0.58rem !important;
    padding: 1px 4px !important;
  }

  .driver-profile-badge .btn-report-issue,
  .driver-profile-badge .btn-admin-panel,
  .driver-profile-badge .btn-logout-driver {
    font-size: 0.65rem !important;
    padding: 2px 4px !important;
    min-width: 0 !important;
    flex-shrink: 0 !important;
  }

  .driver-profile-badge .btn-report-issue,
  .driver-profile-badge .btn-admin-panel,
  .driver-profile-badge .btn-logout-driver {
    font-size: 0.68rem;
    padding: 2px 6px;
    height: 24px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .driver-name {
    font-size: 0.8rem;
    max-width: 70px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .role-tag {
    font-size: 0.62rem;
    padding: 1px 5px;
    flex-shrink: 0;
  }

  .drs-status-light {
    font-size: 0.62rem;
    padding: 1px 5px;
    flex-shrink: 0;
  }

  /* 第二行：Telemetry 指標 full width 均勻三等分 */
  .telemetry-center {
    grid-area: telemetry;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px;
    margin-top: 2px;
    min-width: 0;
  }

  .telemetry-badge {
    padding: 3px 4px;
    border-radius: 4px;
    text-align: center;
    min-width: 0;
    overflow: hidden;
  }

  .telemetry-badge .label {
    font-size: 0.58rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .telemetry-badge .value {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 賽道主卡片內距緊縮 */
  .racing-track-card {
    padding: 16px 12px;
    border-radius: 6px;
    min-height: auto;
  }

  /* 登入視圖 */
  .welcome-box {
    margin: 10px auto;
  }

  .f1-headline {
    font-size: clamp(1.5rem, 6vw, 2rem);
    letter-spacing: 1px;
  }

  .f1-subline {
    font-size: 0.9rem;
    margin-bottom: 20px;
  }

  .join-form {
    padding: 16px 14px;
    margin-bottom: 16px;
  }

  .input-row {
    flex-direction: column;
    gap: 10px;
  }

  .input-row input {
    font-size: 16px; /* 防止 iOS Safari 自動縮放螢幕 */
    padding: 12px 14px;
    height: 48px;
  }

  .input-row button {
    width: 100%;
    height: 48px;
  }

  .vpn-connection-box {
    padding: 14px;
  }

  .ip-item {
    font-size: 0.8rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* 大廳視圖與房主控制 */
  .host-control-panel {
    padding: 16px 12px;
  }

  .director-badge {
    font-size: 0.9rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }

  .setting-item {
    padding: 12px;
  }

  .setting-item input[type="range"] {
    height: 28px;
  }

  .host-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .host-actions-row button,
  .host-actions-row a {
    width: 100%;
    height: 44px;
    font-size: 0.82rem;
    padding: 4px 6px;
    margin-left: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    border-radius: 6px;
  }

  /* 開賽按鈕滿版置頂，賽車紅漸層醒目視覺 */
  .host-actions-row .btn-start {
    grid-column: 1 / -1;
    height: 50px;
    font-size: 1.05rem;
    font-weight: 900;
    order: -1;
    padding: 10px 16px;
    box-shadow: 0 0 16px rgba(225, 6, 0, 0.4);
  }

  /* 隱藏大廳中多餘重複的單人練習賽按鈕（下方有完整專屬練習賽卡片，釋出手機縱向空間） */
  #btnHostStartPractice {
    display: none !important;
  }

  /* 手機版 Cloudflare 邀請卡縮減間距與字體，杜絕溢出遮擋 */
  .cloudflare-connection-box,
  .cloudflare-invite-card {
    padding: 10px 12px;
    margin-bottom: 12px;
  }

  .cf-card-hint {
    display: none;
  }

  .cf-url-row,
  .cf-card-url-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .cf-url-display,
  .cf-card-url {
    width: 100%;
    min-width: 0;
    font-size: 0.78rem;
    padding: 6px 8px;
    text-align: center;
    word-break: break-all;
    box-sizing: border-box;
  }

  .btn-copy-cf {
    width: 100%;
    height: 38px;
    font-size: 0.82rem;
  }

  /* 客戶端大廳等待狀態卡緊湊化與全面防溢出 */
  .client-lobby-status {
    padding: 14px 10px;
    margin: 10px 0;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .client-record-notice,
  .synced-settings-info,
  .personal-best-notice,
  .lap-record-badge {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    display: block !important;
    text-align: center !important;
    font-size: 0.8rem !important;
    padding: 6px 10px !important;
    line-height: 1.4 !important;
  }

  /* 單人練習賽卡片緊湊化與完全防溢出 */
  .practice-invite-card {
    padding: 14px 12px;
    margin: 12px 0;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .practice-invite-header {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex;
    align-items: flex-start;
    gap: 10px;
  }

  .practice-title-group {
    flex: 1;
    min-width: 0 !important;
  }

  .practice-title {
    font-size: 0.95rem !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .practice-sub {
    font-size: 0.75rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.35;
  }

  .practice-config-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .practice-select-group {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  .practice-select-group label {
    font-size: 0.8rem;
    color: var(--f1-text-muted);
  }

  .practice-select-group .f1-select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    font-size: 0.85rem !important;
    padding: 8px 10px !important;
  }

  .practice-time-lock-notice {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
  }

  .btn-import-practice-link {
    font-size: 0.75rem !important;
    padding: 3px 8px !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  #btnStartPractice {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: 46px;
    font-size: 0.95rem;
    font-weight: 800;
  }

  /* F1 起跑五盞紅燈架 (保證 360px~430px 手機不換行) */
  .lights-gantry-container {
    padding: 24px 10px;
  }

  .gantry-header {
    font-size: 1.05rem;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
  }

  .f1-lights-gantry {
    gap: 8px;
    padding: 10px 14px;
    border-width: 3px;
    margin-bottom: 20px;
  }

  .light-unit {
    border-width: 2px;
    padding: 3px;
  }

  .light-bulb {
    width: clamp(24px, 6.2vw, 42px);
    height: clamp(24px, 6.2vw, 42px);
  }

  .lights-message {
    font-size: 1.15rem;
    letter-spacing: 1px;
    text-align: center;
  }

  .upcoming-lap-info {
    font-size: 0.85rem;
    padding: 5px 14px;
  }

  .telemetry-loader-box {
    margin-top: 16px;
    padding: 10px 14px;
  }

  /* 正式作答畫面 */
  .timing-bar-container {
    margin-bottom: 14px;
  }

  .time-label {
    font-size: 0.75rem;
  }

  .time-countdown {
    font-size: 1.45rem;
  }

  .f1-progress-track {
    height: 10px;
  }

  /* 聲波條縮減高度，省下寶貴的垂直手機螢幕空間 */
  .audio-visualizer-wave {
    height: 38px;
    margin: 10px 0 16px;
    gap: 6px;
  }

  .wave-bar {
    width: 4px;
  }

  /* 輸入搜尋與按鈕上下垂直組合 */
  .quiz-input-label {
    font-size: 0.85rem;
    margin-bottom: 6px;
  }

  .search-input-group {
    flex-direction: column;
    gap: 8px;
  }

  .search-input-group input {
    width: 100%;
    font-size: 16px; /* 防止 iOS 焦點自動放大畫面 */
    padding: 12px 14px;
    height: 48px;
  }

  .search-action-btns {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .btn-submit {
    flex: 2;
    height: 46px;
    font-size: 0.95rem;
  }

  .btn-skip {
    flex: 1;
    height: 46px;
    font-size: 0.95rem;
  }

  /* 候選下拉清單觸控最佳化 */
  .suggestions-dropdown {
    max-height: 210px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .suggestion-item {
    padding: 11px 14px;
    min-height: 46px;
  }

  .suggestion-title {
    font-size: 0.92rem;
  }

  .suggestion-artist {
    font-size: 0.78rem;
  }

  /* 後 10 秒 10選1 選擇題：手機端一個接一個直向排列，不併排，文字自動換行不裁切 */
  .multiple-choice-panel {
    margin-top: 10px;
    padding: 12px 10px;
    width: 100%;
  }

  .choice-notice {
    font-size: 0.82rem;
  }

  .choices-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .choice-btn {
    width: 100% !important;
    min-height: 48px !important;
    padding: 10px 14px !important;
    font-size: 0.92rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .choice-key-tag {
    font-size: 0.72rem;
    padding: 3px 6px;
    flex-shrink: 0;
  }

  .choice-btn-text {
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
    line-height: 1.35 !important;
    flex: 1 !important;
    text-align: left;
  }

  /* 本圈解答公布卡片 */
  .lap-result-card {
    padding: 4px;
  }

  .lap-summary-title {
    font-size: 1.15rem;
  }

  .song-reveal-container {
    flex-direction: row;
    gap: 14px;
    padding: 14px;
    align-items: center;
  }

  .album-art-wrapper {
    width: 88px;
    height: 88px;
  }

  .song-title {
    font-size: clamp(1.1rem, 4.5vw, 1.45rem);
    margin-bottom: 4px;
  }

  .song-artist {
    font-size: 0.92rem;
    margin-bottom: 8px;
  }

  .pop-bar-bg {
    width: 80px;
  }

  .fastest-lap-showcase {
    padding: 10px 14px;
    gap: 10px;
    margin-bottom: 16px;
  }

  .purple-clock-icon {
    font-size: 1.4rem;
  }

  .fastest-driver {
    font-size: 1rem;
  }

  .next-lap-action button {
    width: 100%;
    height: 48px;
  }

  /* 頒獎台手機比例縮放 (高度由 280px 縮減至 210px，寬度自適應) */
  .podium-title {
    font-size: 1.7rem;
  }

  .podium-subtitle {
    font-size: 0.85rem;
    margin-bottom: 24px;
  }

  /* 圖二風格：F1 官方轉播頒獎台手機版適配 */
  .f1-broadcast-podium-deck {
    gap: 6px;
    margin: 15px auto 16px;
  }

  .f1-driver-card.card-p1 {
    width: clamp(118px, 34vw, 150px);
    height: 275px;
  }

  .f1-driver-card.card-p2 {
    width: clamp(98px, 29vw, 125px);
    height: 235px;
  }

  .f1-driver-card.card-p3 {
    width: clamp(98px, 29vw, 125px);
    height: 220px;
  }

  .card-pos-num {
    font-size: 1.8rem;
  }

  .card-p1 .card-pos-num {
    font-size: 2.2rem;
  }

  .card-pts-badge {
    font-size: 0.72rem;
    padding: 2px 6px;
  }

  .card-nameplate {
    height: 32px;
    font-size: 0.76rem;
    padding: 0 6px;
  }

  .card-crown-float {
    top: -20px;
    font-size: 1.2rem;
  }

  .rest-driver-row {
    grid-template-columns: 40px 1fr 70px;
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .rest-team-col {
    display: none;
  }

  /* 練習賽抬頭條 (Practice Header Bar) 手機適配 */
  .practice-header-bar {
    padding: 8px 10px !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .practice-header-bar .p-label {
    font-size: 0.58rem !important;
    white-space: nowrap;
  }

  .practice-header-bar .p-value {
    font-size: 0.92rem !important;
    white-space: nowrap;
  }

  /* 練習賽完賽總結 (Practice Game Over Screen) 手機防溢出 */
  .podium-screen {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .practice-scorecard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin: 14px 0 12px 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .p-card-stat {
    padding: 8px 4px !important;
    min-width: 0 !important;
    text-align: center !important;
    box-sizing: border-box !important;
    overflow: hidden;
  }

  .p-card-stat .stat-num {
    font-size: 1.25rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .p-card-stat .stat-lbl {
    font-size: 0.6rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.2 !important;
    margin-top: 4px;
  }

  .practice-lap-history-box {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 12px 10px !important;
  }

  .practice-history-list {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }

  .p-history-row {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 6px 8px !important;
    gap: 6px !important;
    font-size: 0.8rem !important;
  }

  .p-history-lap {
    min-width: 48px !important;
    font-size: 0.78rem !important;
    flex-shrink: 0;
  }

  .p-history-track {
    flex: 1 !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding: 0 4px !important;
  }

  .p-history-time {
    min-width: 40px !important;
    font-size: 0.72rem !important;
    flex-shrink: 0;
  }

  .p-history-pts {
    min-width: 55px !important;
    font-size: 0.8rem !important;
    flex-shrink: 0;
  }

  .game-over-actions {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
    margin-top: 16px !important;
    box-sizing: border-box !important;
  }

  .game-over-actions button,
  .game-over-actions .f1-btn {
    width: 100% !important;
    height: 46px !important;
    margin: 0 !important;
    font-size: 0.92rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* 排位塔手機緊湊視圖 */
  .tower-header {
    padding: 10px 12px;
  }

  .tower-title {
    font-size: 1rem;
  }

  .timing-row {
    grid-template-columns: 50px 1fr 48px 54px;
    padding: 8px 10px;
  }

  .record-driver-col .baidairay-avatar-badge {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }

  .lap-driver-row .baidairay-avatar-badge {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .timing-row .baidairay-avatar-badge {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .record-driver-col .hoshimi-avatar-badge {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }

  .lap-driver-row .hoshimi-avatar-badge {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .timing-row .hoshimi-avatar-badge {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .pos-cluster {
    gap: 3px;
  }

  .pos-chip {
    font-size: 0.82rem;
  }

  .f1-delta-badge {
    font-size: 0.6rem;
    padding: 1px 3px;
    min-width: 18px;
    height: 15px;
  }

  .driver-cell-name {
    font-size: 0.85rem;
  }

  .score-cell {
    font-size: 0.85rem;
  }

  .interval-cell {
    font-size: 0.7rem;
  }
}

/* 行動端導覽條即時名次 Chip 升降動畫 */
@keyframes chipGainAnim {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(0, 210, 106, 0); }
  50% { transform: scale(1.15); box-shadow: 0 0 12px rgba(0, 210, 106, 0.9); background: #00d26a !important; color: #000 !important; }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(0, 210, 106, 0); }
}

@keyframes chipLossAnim {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(225, 6, 0, 0); }
  50% { transform: scale(1.15); box-shadow: 0 0 12px rgba(225, 6, 0, 0.9); background: #e10600 !important; color: #fff !important; }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(225, 6, 0, 0); }
}

.chip-pulse-gain {
  animation: chipGainAnim 0.8s ease-in-out;
}

.chip-pulse-loss {
  animation: chipLossAnim 0.8s ease-in-out;
}

/* 5. 針對極窄手機螢幕 (Extra Small Phones: <= 375px，如 iPhone SE / 小型 Android) */
@media (max-width: 375px) {
  .choices-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .choice-btn {
    min-height: 42px;
    font-size: 0.85rem;
  }

  .f1-lights-gantry {
    gap: 5px;
    padding: 8px 10px;
  }

  .light-bulb {
    width: 25px;
    height: 25px;
  }

  .song-reveal-container {
    flex-direction: column;
    text-align: center;
  }

  .album-art-wrapper {
    margin: 0 auto;
  }
}

/* ========================================================
   賽後特別榮譽 (Post-Race Honors & Awards)
   ======================================================== */
.post-race-awards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 28px 0;
  width: 100%;
}

@media (max-width: 680px) {
  .post-race-awards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 20px 0;
  }
}

.award-card {
  background: rgba(18, 22, 30, 0.95);
  border: 1px solid var(--f1-border);
  border-radius: 8px;
  padding: 16px 20px;
  text-align: left;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}

.award-card:hover {
  transform: translateY(-2px);
}

.award-card.dotd-card {
  border-left: 5px solid var(--f1-red);
}

.award-card.purple-card {
  border-left: 5px solid var(--f1-purple);
  box-shadow: 0 0 16px var(--f1-purple-glow);
}

.award-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.award-badge-icon {
  font-size: 1.3rem;
}

.award-badge-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.dotd-card .award-badge-title {
  color: var(--f1-red);
}

.purple-card .award-badge-title {
  color: var(--f1-purple);
}

.award-winner-name {
  font-size: 1.3rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: 4px;
}

.award-desc {
  font-size: 0.88rem;
  color: var(--f1-text-muted);
  line-height: 1.4;
}

/* ========================================================
   F1 Lap Chart 賽事走勢圖動畫 (Telemetry Chart)
   ======================================================== */
.lap-chart-analytics-box {
  background: rgba(14, 18, 26, 0.95);
  border: 1px solid var(--f1-border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 28px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  width: 100%;
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.analytics-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}

.chart-mode-toggle {
  display: flex;
  gap: 8px;
}

.chart-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--f1-text-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chart-tab-btn.active {
  background: var(--f1-red);
  color: #fff;
  border-color: var(--f1-red);
  box-shadow: 0 0 12px rgba(225, 6, 0, 0.4);
}

.chart-legend-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 14px;
  align-items: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.purple-dot {
  background: var(--f1-purple);
  box-shadow: 0 0 8px var(--f1-purple);
}

.correct-dot {
  background: var(--f1-green);
}

.miss-dot {
  background: #555;
  border: 1px solid #888;
}

.chart-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 360px;
}

@media (max-width: 680px) {
  .lap-chart-analytics-box {
    padding: 14px 10px;
  }
  .chart-canvas-wrapper {
    height: 270px;
  }
  .analytics-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .chart-mode-toggle {
    width: 100%;
  }
  .chart-tab-btn {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 0.72rem;
  }
  .chart-legend-notice {
    gap: 8px;
    font-size: 0.74rem;
  }
}

/* ========================================================
   本圈各選手作答時間與成績表 (Lap Driver Reaction Times)
   ======================================================== */
.lap-drivers-timing-box {
  background: rgba(14, 18, 26, 0.95);
  border: 1px solid var(--f1-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  width: 100%;
}

.timing-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.telemetry-flag {
  font-size: 1.1rem;
}

.timing-box-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}

.timing-box-sub {
  font-size: 0.78rem;
  color: var(--f1-yellow);
  margin-left: auto;
  font-weight: 700;
}

.lap-drivers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lap-driver-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: #141822;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 10px 14px;
  transition: all 0.2s ease;
}

.lap-driver-row.is-me {
  border-color: rgba(0, 210, 190, 0.5);
  background: rgba(0, 210, 190, 0.05);
}

.lap-driver-row.fastest-lap-row {
  border-left: 4px solid var(--f1-purple);
  box-shadow: 0 0 12px var(--f1-purple-glow);
}

.lap-driver-row.correct-row {
  border-left: 4px solid var(--f1-green);
}

.lap-driver-row.wrong-row {
  border-left: 4px solid var(--f1-red);
  opacity: 0.85;
}

.lap-driver-row.timeout-row {
  border-left: 4px solid #555;
  opacity: 0.65;
}

.driver-order-index {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--f1-text-muted);
  text-align: center;
}

.driver-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.driver-meta-cell .driver-cell-name {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-tags-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.driver-status-chip {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
}

.driver-status-chip.fastest {
  background: var(--f1-purple);
  color: #fff;
  box-shadow: 0 0 6px var(--f1-purple);
}

.driver-status-chip.correct {
  background: rgba(0, 210, 190, 0.2);
  color: var(--f1-green);
  border: 1px solid var(--f1-green);
}

.driver-status-chip.wrong {
  background: rgba(225, 6, 0, 0.2);
  color: #ff6464;
  border: 1px solid var(--f1-red);
}

.driver-status-chip.skip {
  background: rgba(255, 170, 0, 0.2);
  color: #ffaa00;
  border: 1px solid rgba(255, 170, 0, 0.4);
}

.driver-wrong-choice {
  font-size: 0.72rem;
  color: #ff9999;
  background: rgba(225, 6, 0, 0.15);
  border: 1px solid rgba(225, 6, 0, 0.4);
  border-radius: 4px;
  padding: 1px 7px;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.wrong-choice-prefix {
  color: #ff6464;
  font-weight: 800;
}

.p-wrong-ans {
  color: #ff6464;
  font-size: 0.8rem;
  margin-left: 6px;
  font-weight: 600;
}

.driver-status-chip.timeout {
  background: rgba(255, 255, 255, 0.1);
  color: #aaa;
}

.method-chip {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.method-chip.input {
  background: rgba(0, 210, 190, 0.15);
  color: var(--f1-green);
}

.method-chip.choice {
  background: rgba(255, 209, 0, 0.15);
  color: var(--f1-yellow);
}

.driver-time-cell {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.time-main {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--f1-green);
}

.time-main.timeout {
  color: #888;
  font-size: 0.85rem;
}

.time-sub {
  font-size: 0.72rem;
  color: var(--f1-text-muted);
}

.driver-pts-cell {
  text-align: right;
  min-width: 80px;
}

.lap-pts {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 900;
}

.lap-pts.positive {
  color: var(--f1-yellow);
}

.lap-pts.zero {
  color: #666;
}

@media (max-width: 680px) {
  .lap-driver-row {
    grid-template-columns: 20px 1fr auto;
    gap: 8px;
    padding: 8px 10px;
  }
  .driver-pts-cell {
    grid-column: 2 / -1;
    display: flex;
    justify-content: flex-end;
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
    padding-top: 4px;
    margin-top: 2px;
  }
  .timing-box-sub {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }
}

/* ========================================================
   F1 SUPER LICENSE 車手認證系統 (Auth Card & Forms)
   ======================================================== */
.driver-auth-card {
  background: linear-gradient(135deg, rgba(20, 24, 32, 0.95), rgba(12, 14, 20, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 24px;
  margin: 20px auto 30px auto;
  max-width: 500px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(225, 6, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.driver-auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--f1-red), var(--f1-yellow), var(--f1-teal));
}

.auth-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.super-license-tag {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--f1-teal);
  font-weight: 800;
  border: 1px solid rgba(0, 210, 190, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 210, 190, 0.06);
}

.auth-tabs {
  display: flex;
  gap: 8px;
}

.auth-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--f1-text-muted);
  font-family: var(--font-display);
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab-btn.active {
  background: rgba(225, 6, 0, 0.2);
  border-color: var(--f1-red);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 12px rgba(225, 6, 0, 0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e0e6ed;
}

.auth-field input {
  background: rgba(10, 12, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 12px 14px;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--f1-teal);
  box-shadow: 0 0 10px rgba(0, 210, 190, 0.3);
  background: rgba(15, 18, 24, 0.95);
}

.btn-auth-submit {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  margin-top: 6px;
}

.auth-msg-banner {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.auth-msg-banner.error {
  background: rgba(225, 6, 0, 0.15);
  border: 1px solid var(--f1-red);
  color: #ff6b6b;
}

.auth-msg-banner.success {
  background: rgba(0, 210, 190, 0.15);
  border: 1px solid var(--f1-teal);
  color: #00d2be;
}

/* 記憶登入狀態卡 */
.saved-session-box {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.saved-session-avatar {
  font-size: 2.2rem;
  background: rgba(225, 6, 0, 0.15);
  padding: 8px;
  border-radius: 50%;
  border: 1px solid rgba(225, 6, 0, 0.3);
}

.saved-session-info {
  flex: 1;
  text-align: left;
}

.saved-welcome-text {
  font-size: 0.78rem;
  color: var(--f1-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.saved-driver-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--f1-yellow);
}

.saved-driver-id {
  font-size: 0.8rem;
  color: var(--f1-teal);
}

.saved-session-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 登出按鈕 */
.btn-logout-driver {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ccc;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.2s;
}

.btn-logout-driver:hover {
  background: rgba(225, 6, 0, 0.2);
  border-color: var(--f1-red);
  color: #fff;
}

/* ========================================================
   個人單人練習賽 (Solo Practice Mode Styles)
   ======================================================== */
.practice-invite-card {
  background: linear-gradient(135deg, rgba(25, 30, 42, 0.9), rgba(15, 18, 26, 0.95));
  border: 1px solid rgba(0, 210, 190, 0.35);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 18px 0;
  box-shadow: 0 4px 20px rgba(0, 210, 190, 0.1);
  text-align: left;
}

.practice-invite-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.practice-badge-icon {
  font-size: 1.8rem;
}

.practice-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--f1-teal);
  letter-spacing: 1px;
}

.practice-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--f1-text-muted);
  margin-top: 2px;
}

.practice-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.practice-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.f1-select {
  background: rgba(10, 12, 16, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}

.f1-select:focus {
  border-color: var(--f1-teal);
}

/* 練習賽抬頭資訊條 */
.practice-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(18, 22, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.practice-lap-badge, .practice-score-badge, .practice-streak-badge {
  display: flex;
  flex-direction: column;
}

.practice-header-bar .p-label {
  font-size: 0.7rem;
  color: var(--f1-text-muted);
  font-family: var(--font-display);
  letter-spacing: 1px;
}

.practice-header-bar .p-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--f1-yellow);
}

/* 房主發起比賽即時橫幅 */
.main-race-alert-banner {
  background: linear-gradient(90deg, rgba(225, 6, 0, 0.9), rgba(180, 0, 0, 0.95));
  border: 2px solid #fff;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 0 20px rgba(225, 6, 0, 0.6);
  animation: pulseAlert 1.2s infinite alternate;
}

@keyframes pulseAlert {
  from { box-shadow: 0 0 10px rgba(225, 6, 0, 0.4); }
  to { box-shadow: 0 0 25px rgba(225, 6, 0, 0.8); }
}

.alert-text {
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
}

/* 練習賽單圈回饋 */
.practice-lap-stat-badge {
  padding: 14px;
  border-radius: 8px;
  margin: 16px 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center;
}

.practice-lap-stat-badge.correct {
  background: rgba(0, 210, 190, 0.15);
  border: 1px solid var(--f1-teal);
  color: #00d2be;
}

.practice-lap-stat-badge.wrong {
  background: rgba(225, 6, 0, 0.15);
  border: 1px solid var(--f1-red);
  color: #ff6b6b;
}

.practice-lap-stat-badge.timeout {
  background: rgba(100, 100, 100, 0.15);
  border: 1px solid #666;
  color: #aaa;
}

/* 練習賽計分卡與歷史回顧清單 */
.practice-scorecard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0 16px 0;
  width: 100%;
  box-sizing: border-box;
}

.p-card-stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 16px 10px;
  min-width: 0;
  box-sizing: border-box;
}

.p-card-stat .stat-num {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--f1-yellow);
}

.p-card-stat .stat-lbl {
  font-size: 0.72rem;
  color: var(--f1-text-muted);
  font-family: var(--font-display);
  letter-spacing: 1px;
  margin-top: 4px;
}

.personal-best-notice {
  background: rgba(255, 209, 0, 0.08);
  border: 1px solid rgba(255, 209, 0, 0.3);
  color: var(--f1-yellow);
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 700;
  margin-bottom: 20px;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
}

.practice-lap-history-box {
  background: rgba(15, 18, 24, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.history-box-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  color: var(--f1-text-muted);
  margin-bottom: 12px;
}

.practice-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.p-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border-left: 3px solid #666;
  font-size: 0.88rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.p-history-row.correct {
  border-left-color: var(--f1-green);
  background: rgba(0, 210, 190, 0.05);
}

.p-history-row.wrong {
  border-left-color: var(--f1-red);
}

.p-history-lap {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--f1-yellow);
  min-width: 65px;
}

.p-history-track {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
}

.p-history-time {
  font-size: 0.82rem;
  color: var(--f1-text-muted);
  min-width: 50px;
  text-align: right;
}

.p-history-pts {
  font-family: var(--font-display);
  font-weight: 900;
  min-width: 70px;
  text-align: right;
  color: #fff;
}

.game-over-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  width: 100%;
  box-sizing: border-box;
  flex-wrap: wrap;
}

/* ========================================================
   名人堂賽事類型標籤與自訂練習圈數樣式
   ======================================================== */
.record-type-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.record-type-chip.gp {
  background: rgba(225, 6, 0, 0.15);
  border: 1px solid var(--f1-red);
  color: #ff6b6b;
}

.record-type-chip.practice {
  background: rgba(0, 210, 190, 0.15);
  border: 1px solid var(--f1-teal);
  color: #00d2be;
}

.f1-custom-laps {
  background: rgba(10, 12, 16, 0.9);
  border: 1px solid var(--f1-teal);
  color: #fff;
  padding: 7px 10px;
  border-radius: 6px;
  width: 90px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 8px rgba(0, 210, 190, 0.2);
}

.f1-custom-laps:focus {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(0, 210, 190, 0.4);
}

.practice-time-lock-notice {
  font-size: 0.8rem;
  color: var(--f1-yellow);
  font-weight: 700;
  background: rgba(255, 209, 0, 0.08);
  border: 1px solid rgba(255, 209, 0, 0.25);
  padding: 4px 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* ========================================================
   Cloudflare 公網專線卡片與樣式 (F1 Broadcast Style)
   ======================================================== */
.cloudflare-connection-box,
.cloudflare-invite-card {
  background: linear-gradient(135deg, rgba(246, 130, 31, 0.12) 0%, rgba(15, 18, 25, 0.95) 100%);
  border: 1px solid rgba(246, 130, 31, 0.4);
  border-left: 5px solid #f6821f;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(246, 130, 31, 0.15);
  backdrop-filter: blur(10px);
}

.cf-badge-row,
.cf-card-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.cf-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f6821f;
  box-shadow: 0 0 10px #f6821f;
  animation: pulse-orange 1.5s infinite;
}

@keyframes pulse-orange {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(246, 130, 31, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(246, 130, 31, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(246, 130, 31, 0); }
}

.cf-box-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #ff9d42;
  letter-spacing: 0.5px;
}

.cf-card-badge {
  background: #f6821f;
  color: #111;
  font-size: 0.75rem;
  font-weight: 900;
  font-family: var(--font-display);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.cf-card-hint {
  font-size: 0.8rem;
  color: var(--f1-text-muted);
}

.cf-url-row,
.cf-card-url-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cf-url-display,
.cf-card-url {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 220px;
}

.btn-copy-cf {
  background: linear-gradient(135deg, #f6821f 0%, #e06500 100%);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(246, 130, 31, 0.3);
}

.btn-copy-cf:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(246, 130, 31, 0.5);
  background: #ff9033;
}

.btn-copy-cf.copied {
  background: #00d2be;
  box-shadow: 0 0 10px rgba(0, 210, 190, 0.5);
}

.cf-magic-link-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cf-magic-link-row select {
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: 4px;
  background: #1a1a24;
  color: #fff;
  border: 1px solid #555;
  outline: none;
  cursor: pointer;
}

.cf-magic-link-row button {
  background: linear-gradient(135deg, #00d2be, #008f82);
  color: #000;
  font-weight: 700;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

/* ========================================================
   防掛機提示與後台管理員監控 (AFK & Admin Dashboard)
   ======================================================== */
.afk-warning-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(225, 6, 0, 0.95) 0%, rgba(140, 0, 0, 0.95) 100%);
  border: 1.5px solid #ffcc00;
  box-shadow: 0 4px 20px rgba(225, 6, 0, 0.7), 0 0 12px rgba(255, 204, 0, 0.5);
  padding: 10px 20px;
  border-radius: 30px;
  color: #fff;
  font-family: var(--font-race);
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 99999;
  animation: afkToastBounce 0.5s ease-out;
  pointer-events: none;
}

@keyframes afkToastBounce {
  0% { transform: translate(-50%, -40px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

.afk-kicked-card {
  max-width: 440px;
  text-align: center;
  padding: 30px 24px;
}

.afk-kicked-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.afk-kicked-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--f1-red);
  margin-bottom: 10px;
}

.afk-kicked-desc {
  color: #ccc;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* 後台管理員按鈕 */
.btn-admin-panel {
  background: linear-gradient(135deg, #2a1b38 0%, #150f1d 100%);
  color: #d670ff;
  border: 1px solid #b339f0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 6px;
  box-shadow: 0 0 10px rgba(179, 57, 240, 0.3);
}

.btn-admin-panel:hover {
  background: linear-gradient(135deg, #442261 0%, #20132e 100%);
  box-shadow: 0 0 14px rgba(179, 57, 240, 0.6);
  transform: translateY(-1px);
}

.btn-admin-lobby {
  background: linear-gradient(135deg, #371d47 0%, #1b0e24 100%);
  color: #e599ff;
  border: 1px solid #b339f0;
  box-shadow: 0 4px 12px rgba(179, 57, 240, 0.25);
}

.btn-admin-lobby:hover {
  background: linear-gradient(135deg, #4c2763 0%, #251230 100%);
  box-shadow: 0 4px 16px rgba(179, 57, 240, 0.5);
  border-color: #d670ff;
}

/* 後台管理員模態視窗 */
.admin-modal-card {
  width: min(94vw, 1100px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #10141d;
  border: 1.5px solid rgba(179, 57, 240, 0.4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.85), 0 0 25px rgba(179, 57, 240, 0.25);
}

.admin-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-modal-title h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  color: #fff;
}

.admin-stats-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-stat-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--font-race);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.stat-indicator-dot.online {
  background: #00d26a;
  box-shadow: 0 0 8px #00d26a;
}

.admin-filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-search-input {
  flex: 1;
  background: #171d28;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
}

.admin-search-input:focus {
  outline: none;
  border-color: #b339f0;
  box-shadow: 0 0 10px rgba(179, 57, 240, 0.4);
}

.admin-table-container {
  overflow-x: auto;
  max-height: 52vh;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: #0d1117;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-race);
  font-size: 0.88rem;
  text-align: left;
}

.admin-table th {
  background: #151b26;
  color: #aaa;
  font-weight: 800;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #e0e0e0;
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.admin-status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.admin-status-pill.online {
  background: rgba(0, 210, 106, 0.15);
  color: #00d26a;
  border: 1px solid rgba(0, 210, 106, 0.4);
}

.admin-status-pill.offline {
  background: rgba(255, 255, 255, 0.06);
  color: #888;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-status-pill.afk {
  background: rgba(255, 209, 0, 0.15);
  color: #ffd100;
  border: 1px solid rgba(255, 209, 0, 0.4);
}

.btn-xs {
  padding: 3px 8px !important;
  font-size: 0.75rem !important;
  min-height: unset !important;
}

/* ========================================================
   問題回報系統樣式 (Audio Issue Reporting & Admin Reports)
   ======================================================== */

/* 1. 頂部導覽列回報按鈕 */
.btn-report-issue {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.5);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-report-issue:hover {
  background: #f59e0b;
  color: #000;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
  transform: translateY(-1px);
}

/* 2. 賽道中、公佈解答中快速回報按鈕 */
.quick-report-container {
  display: flex;
  justify-content: center;
  margin: 12px 0 6px 0;
}

.btn-quick-report {
  background: transparent;
  color: #8c9ba5;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-quick-report:hover {
  color: #f59e0b;
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

/* 3. 問題回報彈窗樣式 */
.report-issue-card {
  max-width: 560px !important;
  border: 1px solid rgba(245, 158, 11, 0.4) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 24px rgba(245, 158, 11, 0.2) !important;
}

.report-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.report-modal-title h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  margin: 0;
}

.report-modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-track-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 14px;
}

.report-track-label {
  font-size: 0.75rem;
  color: #8c9ba5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.report-track-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #00d2be;
  word-break: break-all;
}

.report-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-field-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ccc;
}

.report-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.report-option-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.88rem;
  color: #ddd;
}

.report-option-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(245, 158, 11, 0.5);
}

.report-option-chip.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
}

.report-option-chip input[type="radio"] {
  accent-color: #f59e0b;
  transform: scale(1.15);
}

.report-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #11141a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  min-height: 75px;
}

.report-textarea:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* 4. 後台管理員頁籤導航 (Admin Tabs) */
.admin-tabs-nav {
  display: flex;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  padding: 0 20px;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.admin-tab-btn {
  background: transparent;
  color: #8c9ba5;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  top: 2px;
}

.admin-tab-btn:hover {
  color: #fff;
}

.admin-tab-btn.active {
  color: #fff;
  border-bottom-color: #e10600;
  background: rgba(255, 255, 255, 0.04);
}

.admin-badge-count {
  background: #ff1801;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 12px;
  box-shadow: 0 0 8px rgba(255, 24, 1, 0.6);
}

.admin-tab-content {
  display: block;
}

.admin-tab-content.hidden {
  display: none !important;
}

/* 5. 後台回報篩選按鈕列 */
.admin-filter-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.admin-filter-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ccc;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-filter-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.admin-filter-btn.active {
  background: #00d2be;
  color: #000;
  border-color: #00d2be;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(0, 210, 190, 0.4);
}

/* 6. 後台回報表格元素與操作按鈕 */
.report-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.report-status-badge.pending {
  background: rgba(255, 77, 79, 0.15);
  color: #ff4d4f;
  border: 1px solid rgba(255, 77, 79, 0.4);
}

.report-status-badge.resolved {
  background: rgba(0, 210, 106, 0.15);
  color: #00d26a;
  border: 1px solid rgba(0, 210, 106, 0.4);
}

.report-track-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.report-track-name {
  font-weight: 700;
  color: #fff;
}

.report-track-artist {
  font-size: 0.78rem;
  color: #8c9ba5;
}

.btn-report-action {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin: 2px;
}

.btn-report-resolve {
  background: rgba(0, 210, 106, 0.2);
  color: #00d26a;
  border: 1px solid rgba(0, 210, 106, 0.5);
}

.btn-report-resolve:hover {
  background: #00d26a;
  color: #000;
  box-shadow: 0 0 8px rgba(0, 210, 106, 0.5);
}

.btn-report-reopen {
  background: rgba(255, 209, 0, 0.2);
  color: #ffd100;
  border: 1px solid rgba(255, 209, 0, 0.5);
}

.btn-report-reopen:hover {
  background: #ffd100;
  color: #000;
}

.btn-report-delete {
  background: rgba(255, 24, 1, 0.2);
  color: #ff4d4f;
  border: 1px solid rgba(255, 24, 1, 0.4);
}

.btn-report-delete:hover {
  background: #ff1801;
  color: #fff;
}

.btn-audio-preview {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 210, 190, 0.12);
  color: #00d2be;
  border: 1px solid rgba(0, 210, 190, 0.4);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-audio-preview:hover {
  background: #00d2be;
  color: #000;
}

/* ========================================================
   多題庫管理與零成本外部匯入彈窗樣式 (Import Pool Modal & Multi-Pool UI)
   ======================================================== */
.import-pool-card {
  width: min(94vw, 760px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #10141d;
  border: 1px solid rgba(0, 210, 190, 0.4);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(0, 210, 190, 0.2);
}

.import-instruction-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(0, 210, 190, 0.08);
  border: 1px solid rgba(0, 210, 190, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #d1d5db;
}

.import-instruction-banner .banner-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.import-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.import-form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #d1d5db;
}

.ytm-playlists-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--f1-border);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 12px;
}

.ytm-playlist-item-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: left;
  transition: all 0.2s ease;
}

.ytm-playlist-item-btn:hover,
.ytm-playlist-item-btn.selected {
  background: rgba(225, 6, 0, 0.2);
  border-color: var(--f1-red);
}

.pools-manage-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

#adminPoolsTabContent .pools-manage-container {
  max-height: calc(88vh - 220px);
}

#mergePoolsModal {
  z-index: 10005 !important;
}

.pool-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--f1-border);
  border-radius: 8px;
  transition: background 0.2s ease;
}

.pool-manage-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.pool-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.pool-row-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pool-row-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pool-source-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.pool-source-badge.spotify {
  background: rgba(30, 215, 96, 0.2);
  color: #1ed760;
  border: 1px solid rgba(30, 215, 96, 0.4);
}

.pool-source-badge.ytm {
  background: rgba(255, 0, 0, 0.2);
  color: #ff4d4f;
  border: 1px solid rgba(255, 0, 0, 0.4);
}

.pool-source-badge.apple {
  background: rgba(250, 45, 72, 0.2);
  color: #fa2d48;
  border: 1px solid rgba(250, 45, 72, 0.4);
}

.pool-source-badge.custom {
  background: rgba(0, 210, 190, 0.2);
  color: #00d2be;
  border: 1px solid rgba(0, 210, 190, 0.4);
}

.pool-source-badge.mashup {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.pool-row-meta {
  font-size: 0.78rem;
  color: var(--f1-text-muted);
}

.pool-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pools-manage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.merge-pools-checklist {
  max-height: 220px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.merge-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}

.merge-check-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(56, 189, 248, 0.4);
}

.merge-check-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--f1-green);
}

.merge-check-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: #fff;
  font-weight: 600;
}

.merge-check-count {
  font-size: 0.78rem;
  color: var(--f1-cyan);
  background: rgba(0, 210, 190, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(0, 210, 190, 0.3);
}

.import-loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  margin-top: 14px;
  color: #00d2be;
  font-weight: 700;
  font-size: 0.9rem;
}

.btn-import-practice-link {
  background: none;
  border: none;
  color: #00d2be;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.btn-import-practice-link:hover {
  color: #fff;
}

/* ========================================================
   車手自訂照片管理 (Driver Avatar & Podium Portrait)
   ======================================================== */

/* 1. 全域車手自訂大頭照 (Avatar Badge) */
.driver-custom-avatar-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #64748b;
  box-shadow: 0 0 10px rgba(148, 163, 184, 0.5);
  vertical-align: middle;
  margin-right: 8px;
  display: inline-block;
  flex-shrink: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  background: #151b26;
}

/* ======================================================== */
/* 5 大 F1 車隊專屬主色調與光暈系統 (Ferrari / Mercedes / McLaren / Red Bull / BWT) */
/* ======================================================== */

/* 1. 法拉利紅 (Ferrari Red) */
.driver-custom-avatar-badge.theme-ferrari,
.baidairay-avatar-badge {
  border-color: #e10600 !important;
  box-shadow: 0 0 14px rgba(225, 6, 0, 0.9), 0 0 4px rgba(255, 255, 255, 0.4) !important;
}
.driver-custom-avatar-badge.theme-ferrari:hover,
.baidairay-avatar-badge:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(225, 6, 0, 1), 0 0 8px #fff !important;
}

/* 2. 賓士淺藍 (Mercedes Light Blue / Petronas Cyan) */
.driver-custom-avatar-badge.theme-mercedes,
.hoshimi-avatar-badge {
  border-color: #00d2be !important;
  box-shadow: 0 0 14px rgba(0, 210, 190, 0.9), 0 0 4px rgba(255, 255, 255, 0.4) !important;
}
.driver-custom-avatar-badge.theme-mercedes:hover,
.hoshimi-avatar-badge:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(0, 210, 190, 1), 0 0 8px #fff !important;
}

/* 3. 麥拉倫橘 (McLaren Orange / Papaya) */
.driver-custom-avatar-badge.theme-mclaren {
  border-color: #ff8000 !important;
  box-shadow: 0 0 14px rgba(255, 128, 0, 0.9), 0 0 4px rgba(255, 255, 255, 0.4) !important;
}
.driver-custom-avatar-badge.theme-mclaren:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(255, 128, 0, 1), 0 0 8px #fff !important;
}

/* 4. 紅牛深藍 (Red Bull Dark Blue) */
.driver-custom-avatar-badge.theme-redbull {
  border-color: #1e41ff !important;
  box-shadow: 0 0 14px rgba(30, 65, 255, 0.9), 0 0 4px rgba(255, 255, 255, 0.4) !important;
}
.driver-custom-avatar-badge.theme-redbull:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(30, 65, 255, 1), 0 0 8px #fff !important;
}

/* 5. BWT粉 (Alpine BWT Pink) */
.driver-custom-avatar-badge.theme-bwt {
  border-color: #ff69b4 !important;
  box-shadow: 0 0 14px rgba(255, 105, 180, 0.95), 0 0 4px rgba(255, 255, 255, 0.4) !important;
}
.driver-custom-avatar-badge.theme-bwt:hover {
  transform: scale(1.25);
  box-shadow: 0 0 20px rgba(255, 105, 180, 1), 0 0 8px #fff !important;
}

/* 6. 無肖像統一使用灰色 (Gray Theme - No Portrait) */
.driver-custom-avatar-badge.theme-gray {
  border-color: #64748b !important;
  box-shadow: 0 0 10px rgba(148, 163, 184, 0.5) !important;
}
.driver-custom-avatar-badge.theme-gray:hover {
  transform: scale(1.2);
  box-shadow: 0 0 16px rgba(148, 163, 184, 0.8), 0 0 6px #fff !important;
}

.driver-custom-avatar-badge.inline {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  margin-right: 6px;
  border-width: 2px;
}

/* 名人堂特大號大頭照 */
.record-driver-col .driver-custom-avatar-badge {
  width: 68px;
  height: 68px;
  min-width: 68px;
  min-height: 68px;
  border-width: 3px;
  margin-right: 10px;
}
.record-driver-col .driver-custom-avatar-badge.theme-ferrari {
  box-shadow: 0 0 18px rgba(225, 6, 0, 0.95), 0 0 8px rgba(255, 209, 0, 0.7) !important;
}
.record-driver-col .driver-custom-avatar-badge.theme-mercedes {
  box-shadow: 0 0 18px rgba(0, 210, 190, 0.95), 0 0 8px rgba(255, 209, 0, 0.7) !important;
}
.record-driver-col .driver-custom-avatar-badge.theme-mclaren {
  box-shadow: 0 0 18px rgba(255, 128, 0, 0.95), 0 0 8px rgba(255, 209, 0, 0.7) !important;
}
.record-driver-col .driver-custom-avatar-badge.theme-redbull {
  box-shadow: 0 0 18px rgba(30, 65, 255, 0.95), 0 0 8px rgba(255, 209, 0, 0.7) !important;
}
.record-driver-col .driver-custom-avatar-badge.theme-bwt {
  box-shadow: 0 0 18px rgba(255, 105, 180, 0.95), 0 0 8px rgba(255, 209, 0, 0.7) !important;
}
.record-driver-col .driver-custom-avatar-badge.theme-gray {
  box-shadow: 0 0 14px rgba(148, 163, 184, 0.6) !important;
}

.lap-driver-row .driver-custom-avatar-badge {
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  border-width: 2.5px;
  margin-right: 8px;
}

.timing-row .driver-custom-avatar-badge {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-width: 2px;
  margin-right: 8px;
}

/* 頂部駕駛員徽章大頭照 */
.driver-header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #00d2be;
  box-shadow: 0 0 8px rgba(0, 210, 190, 0.6);
  margin-right: 6px;
  vertical-align: middle;
  background: #151b26;
  display: inline-block;
}

/* 2. 車手列表管理操作按鈕 */
.btn-admin-photo {
  background: rgba(0, 210, 190, 0.15);
  border: 1px solid rgba(0, 210, 190, 0.4);
  color: #00d2be;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-right: 6px;
}

.btn-admin-photo:hover {
  background: #00d2be;
  color: #000;
  box-shadow: 0 0 10px rgba(0, 210, 190, 0.6);
}

/* 3. 後台車手照片管理面板 (Photo Management UI) */
.admin-photo-selector-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #151b26;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.photo-select-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 260px;
}

.photo-select-label .label-tag {
  font-weight: 800;
  color: #fff;
  font-size: 0.95rem;
  white-space: nowrap;
}

.admin-driver-select {
  flex: 1;
  max-width: 320px;
  background: #0e121a;
  border: 1px solid #00d2be;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.photo-selected-status {
  font-size: 0.85rem;
  color: #8c9ba5;
  font-weight: 600;
}

.admin-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .admin-photo-grid {
    grid-template-columns: 1fr;
  }
}

.admin-photo-card {
  background: #11151f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.photo-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.photo-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.photo-card-title .card-icon {
  font-size: 1.4rem;
}

.photo-card-title .title-text {
  font-size: 0.96rem;
  color: #fff;
  font-weight: 800;
  display: block;
}

.photo-card-title .subtitle-text {
  font-size: 0.78rem;
  color: #8c9ba5;
  margin-top: 2px;
}

.photo-spec-tag {
  background: rgba(255, 255, 255, 0.06);
  color: #00d2be;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.photo-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 20px 10px;
  min-height: 220px;
}

.avatar-ring-wrapper {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid #00d2be;
  box-shadow: 0 0 20px rgba(0, 210, 190, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  background: #151b26;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-preview-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portrait-stage-wrapper {
  width: 140px;
  height: 210px;
  border-radius: 8px;
  border: 2px solid #e10600;
  box-shadow: 0 0 24px rgba(225, 6, 0, 0.6), inset 0 0 16px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #2a1215 0%, #0d0e14 90%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-preview-portrait {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.photo-info-text {
  font-size: 0.82rem;
  color: #8c9ba5;
  text-align: center;
}

.photo-upload-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 題目來源題庫標記 (Question Song Pool Origin Badge) */
.question-pool-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #94a3b8;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  margin: 0 auto 12px auto;
  width: fit-content;
  max-width: 95%;
  flex-wrap: wrap;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.5px;
}
.question-pool-badge .pool-name-text {
  color: #38bdf8;
  font-weight: 700;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.song-pool-origin-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.82rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 600;
  flex-wrap: wrap;
  max-width: 100%;
}

/* 跨題庫多來源標籤組件 (Multi-Pool Source Chips) */
.source-pool-chips-container {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.source-pool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #e2e8f0;
  line-height: 1.35;
  transition: all 0.2s ease;
}
.source-pool-chip:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.6);
}
.source-pool-chip.my-pool-chip {
  background: rgba(234, 179, 8, 0.16) !important;
  border-color: rgba(234, 179, 8, 0.65) !important;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.22);
}
.source-pool-chip.my-pool-chip .source-pool-name {
  color: #fde047 !important;
  font-weight: 700;
}
.source-pool-name {
  color: #38bdf8;
  font-weight: 600;
}
.source-pool-owner-chip {
  background: rgba(0, 0, 0, 0.45);
  color: #cbd5e1;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.74rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.source-pool-chip.my-pool-chip .source-pool-owner-chip {
  background: rgba(234, 179, 8, 0.3) !important;
  color: #fef08a !important;
  border-color: rgba(234, 179, 8, 0.6) !important;
  font-weight: 800;
}

/* ========================================================
   全面手機端視窗防裁切與絕對響應式適配 (Universal Mobile Overflow Fix)
   ======================================================== */
@media (max-width: 768px) {
  html, body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    position: relative;
  }

  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  .f1-app-container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    padding-left: max(8px, env(safe-area-inset-left, 8px)) !important;
    padding-right: max(8px, env(safe-area-inset-right, 8px)) !important;
  }

  .f1-main-layout {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .racing-track-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 12px 8px !important;
    overflow-x: hidden !important;
  }

  .view-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* 練習賽抬頭資訊條 (Practice Header) */
  .practice-header-bar {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 6px 8px !important;
    margin-bottom: 10px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .practice-lap-badge,
  .practice-score-badge,
  .practice-streak-badge {
    min-width: 0 !important;
    flex: 1 1 0% !important;
    text-align: center !important;
  }

  .practice-header-bar .p-label {
    font-size: 0.58rem !important;
    white-space: nowrap !important;
  }

  .practice-header-bar .p-value {
    font-size: 0.95rem !important;
    white-space: nowrap !important;
  }

  /* 練習賽結算畫面 (Practice Completed) */
  .podium-screen {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .podium-title {
    font-size: 1.35rem !important;
    word-break: break-word !important;
    letter-spacing: 0.5px !important;
  }

  .podium-subtitle {
    font-size: 0.8rem !important;
  }

  .practice-scorecard-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 12px 0 10px 0 !important;
  }

  .p-card-stat {
    min-width: 0 !important;
    padding: 8px 4px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .p-card-stat .stat-num {
    font-size: 1.1rem !important;
    word-break: break-all !important;
  }

  .p-card-stat .stat-lbl {
    font-size: 0.62rem !important;
    white-space: normal !important;
    line-height: 1.2 !important;
  }

  .personal-best-notice {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    padding: 6px 8px !important;
    font-size: 0.78rem !important;
    margin-bottom: 12px !important;
    display: block !important;
    text-align: center !important;
  }

  /* 練習賽圈數回顧清單 (Lap-by-Lap Recap) */
  .practice-lap-history-box {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px 6px !important;
    margin-bottom: 14px !important;
  }

  .history-box-title {
    font-size: 0.82rem !important;
    margin-bottom: 8px !important;
  }

  .practice-history-list {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }

  .p-history-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 6px 6px !important;
    gap: 4px !important;
    font-size: 0.75rem !important;
  }

  .p-history-lap {
    flex-shrink: 0 !important;
    min-width: 38px !important;
    font-size: 0.72rem !important;
  }

  .p-history-track {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    padding: 0 4px !important;
    font-size: 0.75rem !important;
  }

  .p-history-time {
    flex-shrink: 0 !important;
    font-size: 0.7rem !important;
    min-width: 32px !important;
    text-align: right !important;
  }

  .p-history-pts {
    flex-shrink: 0 !important;
    font-size: 0.72rem !important;
    min-width: 48px !important;
    text-align: right !important;
  }

  .game-over-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .game-over-actions button {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.9rem !important;
  }

  /* 大廳客戶端等待與練習賽邀請卡 (Lobby & Solo Practice) */
  .client-lobby-status {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px 4px !important;
  }

  .synced-settings-info,
  .client-record-notice,
  .lap-record-badge {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    font-size: 0.78rem !important;
    padding: 6px 10px !important;
    display: block !important;
    text-align: center !important;
  }

  #btnOpenHallOfFameClient {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.85rem !important;
    padding: 8px 12px !important;
  }

  .practice-invite-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 12px 10px !important;
    margin: 12px 0 !important;
  }

  .practice-invite-header {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    gap: 8px !important;
  }

  .practice-title-group {
    flex: 1 1 0% !important;
    min-width: 0 !important;
  }

  .practice-title {
    font-size: 0.92rem !important;
    word-break: break-word !important;
  }

  .practice-sub {
    font-size: 0.72rem !important;
    word-break: break-word !important;
  }

  .practice-config-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .practice-select-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .practice-select-group label {
    font-size: 0.82rem !important;
  }

  .practice-select-group .f1-select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    font-size: 0.85rem !important;
  }

  .practice-time-lock-notice {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 0.75rem !important;
    padding: 5px 8px !important;
    gap: 4px !important;
  }

  #btnStartPractice {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.92rem !important;
    padding: 10px !important;
  }

  /* Cloudflare 邀請卡 (Cloudflare Box & Invite Card) */
  .cloudflare-connection-box,
  .cloudflare-invite-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px 10px !important;
  }

  .cf-card-url-row,
  .cf-url-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .cf-card-url,
  .cf-url-display {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    word-break: break-all !important;
    white-space: normal !important;
    font-size: 0.76rem !important;
  }

  .btn-copy-cf {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.82rem !important;
  }

  .cf-magic-link-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .cf-magic-link-row select,
  .cf-magic-link-row button {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 側邊欄名人堂手機版極致排版優化 */
  .sidebar-records-section {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin-top: 8px !important;
  }

  .sidebar-pool-filter-row {
    padding: 8px 10px !important;
  }

  .sidebar-pool-select {
    font-size: 0.78rem !important;
    padding: 5px 8px !important;
  }

  .sidebar-records-list {
    max-height: 290px !important;
    padding: 8px !important;
    gap: 6px !important;
  }

  .sidebar-record-card {
    padding: 7px 9px !important;
  }

  .sidebar-rec-driver-name {
    max-width: 120px !important;
    font-size: 0.82rem !important;
  }

  .sidebar-rec-score {
    font-size: 0.98rem !important;
  }

  .sidebar-rec-pool-tag {
    max-width: 70px !important;
  }
}

/* ========================================================
   車隊無線電即時聊天室 (Team Radio Chat System)
   ======================================================== */
.sidebar-chat-section {
  background: var(--f1-card-bg);
  border: 1px solid var(--f1-border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-header {
  border-top: 3px solid #00f0ff !important;
  background: linear-gradient(135deg, #121e28 0%, #0d151c 100%) !important;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}

.chat-header:hover {
  background: linear-gradient(135deg, #172735 0%, #101b24 100%) !important;
}

.chat-header .flag-chequered {
  filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.7));
}

.chat-unread-badge {
  background: #e10600;
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  box-shadow: 0 0 8px rgba(225, 6, 0, 0.7);
  animation: pulseBadge 1.4s infinite;
}

@keyframes pulseBadge {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-chat-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 0.72rem;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-chat-toggle:hover {
  background: rgba(0, 240, 255, 0.2);
  color: #00f0ff;
  border-color: #00f0ff;
}

.toggle-icon {
  display: inline-block;
  transition: transform 0.25s ease;
}

/* 折疊狀態樣式 */
.sidebar-chat-section.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.sidebar-chat-section.collapsed .sidebar-chat-body {
  display: none !important;
}

.sidebar-chat-body {
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 20, 0.95);
}

.chat-messages-container {
  height: 200px;
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-messages-container::-webkit-scrollbar {
  width: 5px;
}
.chat-messages-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}

.chat-empty-hint {
  color: #64748b;
  font-size: 0.76rem;
  text-align: center;
  margin: auto 0;
  padding: 20px 10px;
  line-height: 1.4;
}

/* 訊息卡片 */
.chat-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: fadeInMsg 0.18s ease-out;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--f1-border);
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}

.chat-msg-sender {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.76rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.chat-msg-sender.is-host {
  color: #ffd700;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}

.chat-msg-sender.is-self {
  color: #00f0ff;
}

.chat-msg-time {
  font-size: 0.65rem;
  color: #64748b;
  flex-shrink: 0;
}

.chat-msg-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px 8px 8px 8px;
  padding: 5px 9px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #f1f5f9;
  word-break: break-word;
}

.chat-msg-row.is-self .chat-msg-bubble {
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.28);
  color: #ffffff;
}

.chat-msg-row.is-host .chat-msg-bubble {
  border-color: rgba(255, 215, 0, 0.25);
}

/* 輸入框 */
.chat-input-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.8);
  border-top: 1px solid var(--f1-border);
}

.chat-input {
  flex: 1;
  height: 32px !important;
  font-size: 0.8rem !important;
  padding: 4px 10px !important;
  background: rgba(0, 0, 0, 0.45) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 4px !important;
  color: #fff !important;
}

.chat-input:focus {
  border-color: #00f0ff !important;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.3) !important;
}

.chat-send-btn {
  height: 32px !important;
  padding: 0 12px !important;
  font-size: 0.78rem !important;
  border-radius: 4px !important;
  white-space: nowrap !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 手機版導航欄 Badge */
.mobile-chat-badge {
  background: #e10600;
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 10px;
  box-shadow: 0 0 6px rgba(225, 6, 0, 0.8);
  margin-left: 4px;
}

/* 手機版分頁隱藏控制 */
@media (max-width: 899px) {
  .sidebar-chat-section.mobile-chat-hidden {
    display: none !important;
  }

  /* 在非 chat 標籤頁時隱藏聊天室，在 chat 標籤時獨佔展示並高度自適應 */
  body.mobile-tab-chat .f1-timing-tower-panel {
    display: flex !important;
  }
  body.mobile-tab-chat .sidebar-records-section,
  body.mobile-tab-chat .sidebar-standings-section,
  body.mobile-tab-chat .scoring-legend-card {
    display: none !important;
  }
  body.mobile-tab-chat .sidebar-chat-section {
    display: flex !important;
    width: 100% !important;
  }
  body.mobile-tab-chat .chat-messages-container {
    height: calc(75vh - 220px) !important;
    max-height: 500px !important;
  }
}





/* 退出比賽按鈕 (選手隨時自由返回大廳) */
.btn-leave-race {
  background: rgba(225, 6, 0, 0.15);
  border: 1px solid rgba(225, 6, 0, 0.4);
  color: #ff5555;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-leave-race:hover {
  background: rgba(225, 6, 0, 0.4);
  color: #fff;
  border-color: #ff0000;
  transform: translateY(-1px);
}

/* ========================================================
   浮動可拖曳 Team Radio 播放器 & 整合型車隊聊天泡泡
   - 支援觸控與滑鼠拖曳
   - 支援一鍵最小化為 44px 圓形膠囊泡泡，隨時縮回繼續答題
   - 內建整合 Team Radio 即時聊天室，不用離開作答頁面即可暢聊
   ======================================================== */
.yt-floating-widget {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 310px;
  height: 400px;
  z-index: 99999;
  border-radius: 12px;
  background: rgba(11, 14, 20, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 210, 190, 0.45);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9), 0 0 15px rgba(0, 210, 190, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              height 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              border-radius 0.25s ease,
              box-shadow 0.25s ease;
}

/* 拖曳把手與標題控制列 */
.yt-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, #121721 0%, #1a2230 100%);
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: grab;
  touch-action: none;
  min-height: 32px;
}
.yt-widget-header:active {
  cursor: grabbing;
}
.yt-header-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display, sans-serif);
  font-size: 0.75rem;
  font-weight: 800;
  color: #00d2be;
  letter-spacing: 0.5px;
  pointer-events: none;
}
.yt-drag-handle {
  color: #777;
  font-size: 0.9rem;
  line-height: 1;
}
.yt-radio-icon {
  font-size: 0.9rem;
}
.yt-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.yt-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ddd;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.yt-action-btn:hover {
  background: rgba(0, 210, 190, 0.25);
  border-color: #00d2be;
  color: #fff;
}
.yt-action-btn.btn-audio-action {
  color: #00d2be;
  font-size: 0.68rem;
}
.yt-action-btn.btn-minimize {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 1rem;
  font-weight: 900;
  color: #ff5555;
}
.yt-action-btn.btn-minimize:hover {
  background: rgba(225, 6, 0, 0.3);
  border-color: #ff0000;
  color: #fff;
}

/* 浮動視窗主體 */
.yt-widget-body {
  position: relative;
  flex: 1;
  width: 100%;
  height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #090c12;
}

/* 頂部音訊廣播狀態條 */
.yt-audio-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: rgba(0, 210, 190, 0.07);
  border-bottom: 1px solid rgba(0, 210, 190, 0.15);
  font-size: 0.72rem;
  font-weight: 600;
  color: #aaa;
  cursor: pointer;
}
.yt-strip-status {
  color: #00d2be;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.btn-strip-unmute {
  background: rgba(0, 210, 190, 0.2);
  border: 1px solid rgba(0, 210, 190, 0.5);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.65rem;
  cursor: pointer;
  font-weight: 700;
}
.btn-strip-unmute:hover {
  background: #00d2be;
  color: #000;
}

/* 隱藏但持續正常播放的 YouTube IFrame */
.yt-iframe-box {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  pointer-events: none;
  overflow: hidden;
}

/* 整合在浮動泡泡內的聊天室 */
.yt-chat-integrated {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100% - 30px);
}
.yt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.yt-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.yt-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.yt-chat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #0c1017;
}
.yt-chat-input {
  flex: 1;
  font-size: 0.78rem;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}
.yt-chat-send {
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

/* 音訊跳動波紋效果 */
.yt-audio-indicator {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.yt-audio-indicator .audio-bar {
  width: 2.5px;
  height: 100%;
  background: #00d2be;
  border-radius: 1px;
  animation: audioWave 1.2s infinite ease-in-out;
}
.yt-audio-indicator .audio-bar:nth-child(1) { animation-delay: 0.1s; height: 40%; }
.yt-audio-indicator .audio-bar:nth-child(2) { animation-delay: 0.3s; height: 80%; }
.yt-audio-indicator .audio-bar:nth-child(3) { animation-delay: 0.2s; height: 100%; }
.yt-audio-indicator .audio-bar:nth-child(4) { animation-delay: 0.4s; height: 60%; }

@keyframes audioWave {
  0%, 100% { transform: scaleY(0.3); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* 最小化膠囊模式 (Mini Pill Mode) */
.yt-pill-badge {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}
.yt-floating-widget.minimized {
  width: 46px !important;
  height: 46px !important;
  border-radius: 50% !important;
  border: 2px solid #00d2be !important;
  background: #0f131a !important;
  box-shadow: 0 0 16px rgba(0, 210, 190, 0.75), 0 4px 14px rgba(0, 0, 0, 0.95) !important;
  cursor: pointer;
}
.yt-floating-widget.minimized .yt-widget-header,
.yt-floating-widget.minimized .yt-widget-body {
  display: none !important;
}
.yt-floating-widget.minimized .yt-pill-badge {
  display: flex !important;
}
.yt-pill-badge .pill-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.yt-pill-badge .pill-live-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  background: #00d2be;
  border-radius: 50%;
  box-shadow: 0 0 6px #00d2be;
  animation: pillDotBlink 1.5s infinite;
}
@keyframes pillDotBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.yt-pill-badge .pill-chat-badge {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: #e10600;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  border-radius: 8px;
  padding: 1px 5px;
  line-height: 1;
  border: 1px solid #fff;
}

/* 手機直屏特殊適配 */
@media (max-width: 768px) {
  .yt-floating-widget {
    width: calc(100vw - 32px);
    max-width: 330px;
    height: 350px;
    max-height: 52vh;
  }
}

/* ========================================================
   行動端正賽排名變化 HUD 動態通知 (Mobile Rank HUD Toast)
   - 懸浮於頂部安全區
   - 點擊穿透 (pointer-events: none)，絕對不干擾作答操作
   - 綠色超車攀升 / 紅色名次下滑 / 金色領跑全場 F1 轉播科技視覺
   ======================================================== */
.mobile-rank-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: 24px;
  background: rgba(12, 16, 24, 0.95);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 210, 106, 0.65);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85), 0 0 16px rgba(0, 210, 106, 0.45);
  pointer-events: none !important; /* 核心：絕對點擊穿透，玩家點擊任何按鈕皆零阻礙 */
  user-select: none;
  font-family: var(--font-display, sans-serif);
  animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.35s ease, transform 0.35s ease;
  white-space: nowrap;
}

.mobile-rank-toast.hidden {
  display: none !important;
}

.mobile-rank-toast.toast-leave {
  opacity: 0;
  transform: translateX(-50%) translateY(-16px);
}

/* 排名上升 / 超車 (Gain / Overtake) */
.mobile-rank-toast.toast-gain {
  border-color: #00d26a;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85), 0 0 18px rgba(0, 210, 106, 0.55);
}
.mobile-rank-toast.toast-gain .toast-icon {
  color: #00d26a;
}
.mobile-rank-toast.toast-gain .toast-rank-pill {
  background: #00d26a;
  color: #000;
}
.mobile-rank-toast.toast-gain .toast-title {
  color: #00d26a;
}

/* 排名下滑 / 被超車 (Loss / Overtaken) */
.mobile-rank-toast.toast-loss {
  border-color: #e10600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85), 0 0 18px rgba(225, 6, 0, 0.55);
}
.mobile-rank-toast.toast-loss .toast-icon {
  color: #e10600;
}
.mobile-rank-toast.toast-loss .toast-rank-pill {
  background: #e10600;
  color: #fff;
}
.mobile-rank-toast.toast-loss .toast-title {
  color: #ff5555;
}

/* 領跑全場 / 登頂 P1 (Leader) */
.mobile-rank-toast.toast-leader {
  border-color: #ffd700;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.85), 0 0 22px rgba(255, 215, 0, 0.65);
}
.mobile-rank-toast.toast-leader .toast-icon {
  color: #ffd700;
}
.mobile-rank-toast.toast-leader .toast-rank-pill {
  background: #ffd700;
  color: #000;
}
.mobile-rank-toast.toast-leader .toast-title {
  color: #ffd700;
}

.toast-badge-cluster {
  display: flex;
  align-items: center;
  gap: 5px;
}
.toast-icon {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}
.toast-rank-pill {
  font-size: 0.76rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 12px;
  line-height: 1.1;
  letter-spacing: 0.5px;
}
.toast-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.toast-title {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1px;
}
.toast-desc {
  font-size: 0.75rem;
  font-weight: 700;
  color: #e5e5e5;
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-22px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* ========================================================
   下次正賽定時倒數 HUD 看板 (15 分鐘定時排程)
   ======================================================== */
.telemetry-badge.schedule-badge {
  border-color: rgba(0, 210, 190, 0.4);
  background: rgba(0, 210, 190, 0.06);
  min-width: 105px;
}
.telemetry-badge.schedule-badge .label {
  color: #00d2be;
  font-size: 0.62rem;
  letter-spacing: 0.8px;
}
.telemetry-badge.schedule-badge .schedule-time {
  font-family: 'Consolas', 'Courier New', monospace;
  font-weight: 900;
  color: #00d2be;
  font-size: 0.95rem;
  letter-spacing: 1px;
}
.telemetry-badge.schedule-badge .schedule-time.urgent {
  color: #ff334b !important;
  animation: urgentBlink 0.6s infinite alternate;
}
.telemetry-badge.schedule-badge .schedule-time.is-racing {
  color: #00e676 !important;
  font-size: 0.78rem !important;
  font-family: var(--font-display, sans-serif) !important;
  letter-spacing: 0.5px !important;
  animation: racingPulse 1.2s infinite alternate;
}
@keyframes urgentBlink {
  0% { opacity: 1; filter: drop-shadow(0 0 4px #ff1801); }
  100% { opacity: 0.4; }
}
@keyframes racingPulse {
  0% { opacity: 1; filter: drop-shadow(0 0 6px rgba(0, 230, 118, 0.8)); }
  100% { opacity: 0.65; }
}

/* 大廳專屬下次正賽倒數看板 (Lobby Schedule Card) */
.lobby-schedule-card {
  margin: 14px 0 20px;
  background: linear-gradient(135deg, rgba(16, 24, 39, 0.95) 0%, rgba(10, 16, 28, 0.98) 100%);
  border: 1px solid rgba(0, 210, 190, 0.35);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(0, 210, 190, 0.08);
}
.schedule-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.schedule-icon {
  font-size: 1.4rem;
}
.schedule-title-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.schedule-sub {
  font-size: 0.65rem;
  font-weight: 800;
  color: #8892b0;
  letter-spacing: 1.2px;
}
.schedule-main {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
}
.schedule-status-pill {
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(0, 210, 190, 0.18);
  color: #00d2be;
  border: 1px solid rgba(0, 210, 190, 0.4);
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.8px;
}
.schedule-status-pill.racing {
  background: rgba(0, 230, 118, 0.2);
  color: #00e676;
  border-color: #00e676;
  animation: racingPulse 1.2s infinite alternate;
}
.schedule-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.schedule-timer-display {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 1.9rem;
  font-weight: 900;
  color: #00d2be;
  letter-spacing: 2px;
  line-height: 1;
}
.schedule-timer-display.urgent {
  color: #ff334b;
  animation: urgentBlink 0.6s infinite alternate;
}
.schedule-timer-display.racing {
  font-size: 1.3rem;
  color: #00e676;
  font-family: var(--font-display, sans-serif);
}
.schedule-meta-text {
  font-size: 0.78rem;
  color: #94a3b8;
  max-width: 320px;
}

/* ========================================================
   手機端 Team Radio 浮動泡泡防遮擋與流暢交互優化
   ======================================================== */
@media (max-width: 768px) {
  /* 浮動泡泡預設改為停靠在頂部右上安全區，嚴禁覆蓋下方選項 6~10 */
  .yt-floating-widget.minimized {
    width: 42px !important;
    height: 42px !important;
    position: fixed !important;
    top: 65px !important;
    right: 12px !important;
    bottom: auto !important;
    left: auto !important;
    z-index: 99999 !important;
    box-shadow: 0 0 12px rgba(0, 210, 190, 0.8), 0 3px 10px rgba(0,0,0,0.8) !important;
  }

  /* 展開模式手機寬度自適應與安全邊距 */
  .yt-floating-widget:not(.minimized) {
    width: calc(100vw - 24px) !important;
    max-width: 340px !important;
    height: 380px !important;
    max-height: 55vh !important;
    top: 60px !important;
    right: 12px !important;
    bottom: auto !important;
    left: auto !important;
  }
}
